changeset 108:6add3e66f4fa draft

Uploaded
author davidvanzessen
date Wed, 13 Jul 2016 09:04:15 -0400
parents 01c9993865af
children 0096cd454380
files aa_histogram.r mutation_analysis.py wrapper.sh
diffstat 3 files changed, 10 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/aa_histogram.r	Wed Jul 13 08:04:13 2016 -0400
+++ b/aa_histogram.r	Wed Jul 13 09:04:15 2016 -0400
@@ -26,7 +26,9 @@
 	if(nrow(mutations.by.id.gene) == 0){
 		next
 	}
-
+	
+	print(paste("nrow", gene, nrow(absent.aa.by.id.gene)))
+	
 	mutations.at.position = colSums(mutations.by.id.gene[,-c(1,2)])
 	aa.at.position = colSums(absent.aa.by.id.gene[,-c(1,2,3,4)])
 
@@ -45,7 +47,12 @@
 	m = m + expand_limits(y=c(-0.1,1)) + xlab("AA position") + ylab("Frequency") + ggtitle(paste(gene, "AA mutation frequency"))
 
 	print("---------------- write/print ----------------")
-
+	
+	dat.sums = data.frame(index=1:length(mutations.at.position), mutations.at.position=mutations.at.position, aa.at.position=aa.at.position)	
+	
+	write.table(dat.sums, paste(outdir, "/aa_histogram_sum_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
+	write.table(mutations.by.id.gene, paste(outdir, "/aa_histogram_count_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
+	write.table(absent.aa.by.id.gene, paste(outdir, "/aa_histogram_absent_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
 	write.table(dat_dt, paste(outdir, "/aa_histogram_", gene, ".txt", sep=""), sep="\t",quote=F,row.names=F,col.names=T)
 	png(filename=paste(outdir, "/aa_histogram_", gene, ".png", sep=""), width=1280, height=720)
 	print(m)
--- a/mutation_analysis.py	Wed Jul 13 08:04:13 2016 -0400
+++ b/mutation_analysis.py	Wed Jul 13 09:04:15 2016 -0400
@@ -146,35 +146,6 @@
 			absentAAbyID[c] -= 1
 		o.write(ID + "\t" + str(cdr1Length) + "\t" + str(cdr2Length) + "\t" + genedic[ID] + "\t" + "\t".join([str(x) for x in absentAAbyID]) + "\n")
 
-
-
-aa_mutations_file = outfile[:outfile.rindex("/")] + "/aa_mutations.txt"
-with open(aa_mutations_file, 'w') as o:
-	o.write("row.name\t" + "\t".join([str(x) for x in range(1, AALength-1)]) + "\n")
-	o.write("mutations.at.position\t" + "\t".join([str(x) for x in AA_mutation[1:]]) + "\n")
-	o.write("AA.at.position\t" + "\t".join([str(x) for x in absentAA]) + "\n")
-
-
-aa_mutations_file_ca = outfile[:outfile.rindex("/")] + "/aa_mutations_ca.txt"
-with open(aa_mutations_file_ca, 'w') as o:
-	o.write("row.name\t" + "\t".join([str(x) for x in range(1, AALength-1)]) + "\n")
-	o.write("mutations.at.position\t" + "\t".join([str(x) for x in AA_mutation_dic["ca"][1:]]) + "\n")
-	o.write("AA.at.position\t" + "\t".join([str(x) for x in absentAA]) + "\n")
-
-
-aa_mutations_file_cg = outfile[:outfile.rindex("/")] + "/aa_mutations_cg.txt"
-with open(aa_mutations_file_cg, 'w') as o:
-	o.write("row.name\t" + "\t".join([str(x) for x in range(1, AALength-1)]) + "\n")
-	o.write("mutations.at.position\t" + "\t".join([str(x) for x in AA_mutation_dic["cg"][1:]]) + "\n")
-	o.write("AA.at.position\t" + "\t".join([str(x) for x in absentAA]) + "\n")
-
-
-aa_mutations_file_cm = outfile[:outfile.rindex("/")] + "/aa_mutations_cm.txt"
-with open(aa_mutations_file_cm, 'w') as o:
-	o.write("row.name\t" + "\t".join([str(x) for x in range(1, AALength-1)]) + "\n")
-	o.write("mutations.at.position\t" + "\t".join([str(x) for x in AA_mutation_dic["cg"][1:]]) + "\n")
-	o.write("AA.at.position\t" + "\t".join([str(x) for x in absentAA]) + "\n")
-
 if linecount == 0:
 	print "No data, exiting"
 	with open(outfile, 'w') as o:
--- a/wrapper.sh	Wed Jul 13 08:04:13 2016 -0400
+++ b/wrapper.sh	Wed Jul 13 09:04:15 2016 -0400
@@ -148,9 +148,9 @@
 echo "---------------- aa_histogram.r ----------------"
 echo "---------------- aa_histogram.r ----------------<br />" >> $log
 
-cp $outdir/aa_mutations.txt $outdir/aa_mutations_count.txt
 Rscript $dir/aa_histogram.r $outdir/aa_id_mutations.txt $outdir/absent_aa_id.txt "ca,cg,cm" $outdir/ 2>&1
 mv $outdir/aa_histogram_.png $outdir/aa_histogram.png
+mv $outdir/aa_histogram_.txt $outdir/aa_histogram.txt
 
 genes=(ca ca1 ca2 cg cg1 cg2 cg3 cg4 cm)