Mercurial > repos > davidvanzessen > plotting_merged
comparison RScript.r @ 51:8f5ab5290c88 draft
Uploaded
| author | davidvanzessen |
|---|---|
| date | Tue, 10 Dec 2013 07:21:31 -0500 |
| parents | 3da85f1a7f42 |
| children | 907e2a756f85 |
comparison
equal
deleted
inserted
replaced
| 50:e6209052aaf4 | 51:8f5ab5290c88 |
|---|---|
| 36 | 36 |
| 37 #test$VDJCDR3 = do.call(paste, c(test[c("Top.V.Gene", "Top.D.Gene", "Top.J.Gene","CDR3.Seq.DNA")], sep = ":")) | 37 #test$VDJCDR3 = do.call(paste, c(test[c("Top.V.Gene", "Top.D.Gene", "Top.J.Gene","CDR3.Seq.DNA")], sep = ":")) |
| 38 test$VDJCDR3 = do.call(paste, c(test[unlist(strsplit(clonalType, ","))], sep = ":")) | 38 test$VDJCDR3 = do.call(paste, c(test[unlist(strsplit(clonalType, ","))], sep = ":")) |
| 39 | 39 |
| 40 PROD = test[test$VDJ.Frame != "In-frame with stop codon" & test$VDJ.Frame != "Out-of-frame" & test$CDR3.Found.How != "NOT_FOUND" , ] | 40 PROD = test[test$VDJ.Frame != "In-frame with stop codon" & test$VDJ.Frame != "Out-of-frame" & test$CDR3.Found.How != "NOT_FOUND" , ] |
| 41 if("Functionality" %in% colnames(test)) { | |
| 42 PROD = test[test$Functionality == "productive" | test$Functionality == "productive (see comment)", ] | |
| 43 } | |
| 41 | 44 |
| 42 NONPROD = test[test$VDJ.Frame == "In-frame with stop codon" | test$VDJ.Frame == "Out-of-frame" | test$CDR3.Found.How == "NOT_FOUND" , ] | 45 NONPROD = test[test$VDJ.Frame == "In-frame with stop codon" | test$VDJ.Frame == "Out-of-frame" | test$CDR3.Found.How == "NOT_FOUND" , ] |
| 43 | 46 |
| 44 #PRODF = PROD[ -1] | 47 #PRODF = PROD[ -1] |
| 45 | 48 |
| 88 PRODFJ = merge(PRODFJ, Jchain, by.x='Top.J.Gene', by.y='v.name', all.x=TRUE) | 91 PRODFJ = merge(PRODFJ, Jchain, by.x='Top.J.Gene', by.y='v.name', all.x=TRUE) |
| 89 close(tcJ) | 92 close(tcJ) |
| 90 | 93 |
| 91 setwd(outDir) | 94 setwd(outDir) |
| 92 | 95 |
| 93 write.table(PRODF, "allUnique.tsv", sep="\t",quote=F,row.names=T,col.names=T) | 96 write.table(PRODF, "allUnique.tsv", sep="\t",quote=F,row.names=F,col.names=T) |
| 94 | 97 |
| 95 pV = ggplot(PRODFV) | 98 pV = ggplot(PRODFV) |
| 96 pV = pV + geom_bar( aes( x=factor(reorder(Top.V.Gene, chr.orderV)), y=relFreq, fill=Sample), stat='identity', position="dodge") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) | 99 pV = pV + geom_bar( aes( x=factor(reorder(Top.V.Gene, chr.orderV)), y=relFreq, fill=Sample), stat='identity', position="dodge") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) |
| 97 pV = pV + xlab("Summary of V gene") + ylab("Frequency") + ggtitle("Relative frequency of V gene usage") | 100 pV = pV + xlab("Summary of V gene") + ylab("Frequency") + ggtitle("Relative frequency of V gene usage") |
| 98 | 101 |
| 231 if("Replicate" %in% colnames(test)) | 234 if("Replicate" %in% colnames(test)) |
| 232 { | 235 { |
| 233 clonalityFrame = PROD | 236 clonalityFrame = PROD |
| 234 clonalityFrame$ReplicateConcat = do.call(paste, c(clonalityFrame[c("VDJCDR3", "Sample", "Replicate")], sep = ":")) | 237 clonalityFrame$ReplicateConcat = do.call(paste, c(clonalityFrame[c("VDJCDR3", "Sample", "Replicate")], sep = ":")) |
| 235 clonalityFrame = clonalityFrame[!duplicated(clonalityFrame$ReplicateConcat), ] | 238 clonalityFrame = clonalityFrame[!duplicated(clonalityFrame$ReplicateConcat), ] |
| 236 write.table(clonalityFrame, "clonalityComplete.tsv", sep="\t",quote=F,row.names=T,col.names=T) | 239 write.table(clonalityFrame, "clonalityComplete.tsv", sep="\t",quote=F,row.names=F,col.names=T) |
| 237 | 240 |
| 238 ClonalitySampleReplicatePrint <- function(dat){ | 241 ClonalitySampleReplicatePrint <- function(dat){ |
| 239 write.table(dat, paste("clonality_", unique(dat$Sample) , "_", unique(dat$Replicate), ".tsv", sep=""), sep="\t",quote=F,row.names=T,col.names=T) | 242 write.table(dat, paste("clonality_", unique(dat$Sample) , "_", unique(dat$Replicate), ".tsv", sep=""), sep="\t",quote=F,row.names=F,col.names=T) |
| 240 } | 243 } |
| 241 | 244 |
| 242 clonalityFrameSplit = split(clonalityFrame, f=clonalityFrame[,c("Sample", "Replicate")]) | 245 clonalityFrameSplit = split(clonalityFrame, f=clonalityFrame[,c("Sample", "Replicate")]) |
| 243 lapply(clonalityFrameSplit, FUN=ClonalitySampleReplicatePrint) | 246 lapply(clonalityFrameSplit, FUN=ClonalitySampleReplicatePrint) |
| 244 | 247 |
| 245 ClonalitySamplePrint <- function(dat){ | 248 ClonalitySamplePrint <- function(dat){ |
| 246 write.table(dat, paste("clonality_", unique(dat$Sample) , ".tsv", sep=""), sep="\t",quote=F,row.names=T,col.names=T) | 249 write.table(dat, paste("clonality_", unique(dat$Sample) , ".tsv", sep=""), sep="\t",quote=F,row.names=F,col.names=T) |
| 247 } | 250 } |
| 248 | 251 |
| 249 clonalityFrameSplit = split(clonalityFrame, f=clonalityFrame[,"Sample"]) | 252 clonalityFrameSplit = split(clonalityFrame, f=clonalityFrame[,"Sample"]) |
| 250 lapply(clonalityFrameSplit, FUN=ClonalitySamplePrint) | 253 lapply(clonalityFrameSplit, FUN=ClonalitySamplePrint) |
| 251 | 254 |
