Mercurial > repos > davidvanzessen > mutation_analysis
changeset 68:3636d5aaa127 draft
Uploaded
author | davidvanzessen |
---|---|
date | Wed, 20 Apr 2016 10:16:25 -0400 |
parents | 67a9ddf6a8f5 |
children | 7acdcd5c52ef |
files | merge_and_filter.r mutation_analysis.r |
diffstat | 2 files changed, 18 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/merge_and_filter.r Wed Apr 20 05:32:45 2016 -0400 +++ b/merge_and_filter.r Wed Apr 20 10:16:25 2016 -0400 @@ -59,7 +59,7 @@ unmatched=summ[NULL,c("Sequence.ID", "chunk_hit_percentage", "nt_hit_percentage", "start_locations", "best_match")] -if(!all(higher_than)){ #check for not all because that would mean the unmatched set is empty +if(!all(higher_than)){ #check for 'not all' because that would mean the unmatched set is empty unmatched = summ[!higher_than,] unmatched = unmatched[,c("Sequence.ID", "chunk_hit_percentage", "nt_hit_percentage", "start_locations", "best_match")] unmatched$best_match = paste("unmatched,", unmatched$best_match)
--- 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)