diff mutation_analysis.r @ 68:3636d5aaa127 draft

Uploaded
author davidvanzessen
date Wed, 20 Apr 2016 10:16:25 -0400
parents 7290a88ea202
children 9165bec41c02
line wrap: on
line diff
--- a/mutation_analysis.r	Wed Apr 20 05:32:45 2016 -0400
+++ b/mutation_analysis.r	Wed Apr 20 10:16:25 2016 -0400
@@ -172,18 +172,24 @@
 
 
 calculate_result = function(i, gene, dat, matrx, f, fname, name){
-  tmp = dat[grepl(paste(".*", gene, ".*", sep=""), dat$best_match),]
-  
-  j = i - 1
-  x = (j * 3) + 1
-  y = (j * 3) + 2
-  z = (j * 3) + 3
-     
-  if(nrow(tmp) > 0){
+	tmp = dat[grepl(paste(".*", gene, ".*", sep=""), dat$best_match),]
+
+	j = i - 1
+	x = (j * 3) + 1
+	y = (j * 3) + 2
+	z = (j * 3) + 3
+	 
+	if(nrow(tmp) > 0){
 	  
-	  matrx[1,x] = round(f(tmp$VRegionMutations, na.rm=T), digits=1)
-	  matrx[1,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1)
-	  matrx[1,z] = round(matrx[1,x] / matrx[1,y] * 100, digits=1)
+	  if(fname == "sum"){
+		matrx[1,x] = round(f(tmp$VRegionMutations, na.rm=T), digits=1)
+		matrx[1,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1)
+		matrx[1,z] = round(f(matrx[1,x] / matrx[1,y]) * 100, digits=1)
+	  } else {
+		matrx[1,x] = round(f(tmp$VRegionMutations, na.rm=T), digits=1)
+		matrx[1,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1)
+		matrx[1,z] = round(f(tmp$VRegionMutations / tmp$VRegionNucleotides) * 100, digits=1)
+	  }
 	  
 	  matrx[2,x] = round(f(tmp$transitionMutations, na.rm=T), digits=1)
 	  matrx[2,y] = round(f(tmp$VRegionMutations, na.rm=T), digits=1)