Mercurial > repos > davidvanzessen > shm_csr
comparison shm_csr.r @ 7:ad9be244b104 draft
Uploaded
author | davidvanzessen |
---|---|
date | Mon, 07 Nov 2016 03:04:07 -0500 |
parents | 012a738edf5a |
children | 3968d04b5724 |
comparison
equal
deleted
inserted
replaced
6:2ddb9a21f635 | 7:ad9be244b104 |
---|---|
117 | 117 |
118 regions = c("FR1", "CDR1", "FR2", "CDR2", "FR3") | 118 regions = c("FR1", "CDR1", "FR2", "CDR2", "FR3") |
119 if(empty.region.filter == "FR1") { | 119 if(empty.region.filter == "FR1") { |
120 regions = c("CDR1", "FR2", "CDR2", "FR3") | 120 regions = c("CDR1", "FR2", "CDR2", "FR3") |
121 } else if (empty.region.filter == "CDR1") { | 121 } else if (empty.region.filter == "CDR1") { |
122 regions = c("FR2", "CDR2", "FR3", "CDR3") | 122 regions = c("FR2", "CDR2", "FR3") |
123 } else if (empty.region.filter == "FR2") { | 123 } else if (empty.region.filter == "FR2") { |
124 regions = c("CDR2", "FR3", "CDR3") | 124 regions = c("CDR2", "FR3") |
125 } | 125 } |
126 | 126 |
127 sum_by_row = function(x, columns) { sum(as.numeric(x[columns]), na.rm=T) } | 127 sum_by_row = function(x, columns) { sum(as.numeric(x[columns]), na.rm=T) } |
128 | 128 |
129 print("aggregating data into new columns") | 129 print("aggregating data into new columns") |
227 matrx[9,x] = round(f(tmp$nonSilentMutationsCDR, na.rm=T), digits=1) | 227 matrx[9,x] = round(f(tmp$nonSilentMutationsCDR, na.rm=T), digits=1) |
228 matrx[9,y] = round(f(tmp$silentMutationsCDR, na.rm=T), digits=1) | 228 matrx[9,y] = round(f(tmp$silentMutationsCDR, na.rm=T), digits=1) |
229 matrx[9,z] = round(matrx[9,x] / matrx[9,y], digits=1) | 229 matrx[9,z] = round(matrx[9,x] / matrx[9,y], digits=1) |
230 | 230 |
231 if(fname == "sum"){ | 231 if(fname == "sum"){ |
232 matrx[10,x] = round(f(rowSums(tmp[,c("FR2.IMGT.Nb.of.nucleotides", "FR3.IMGT.Nb.of.nucleotides")], na.rm=T)), digits=1) | 232 |
233 regions.fr = regions[grepl("FR", regions)] | |
234 regions.fr = paste(regions.fr, ".IMGT.Nb.of.nucleotides", sep="") | |
235 regions.cdr = regions[grepl("CDR", regions)] | |
236 regions.cdr = paste(regions.cdr, ".IMGT.Nb.of.nucleotides", sep="") | |
237 | |
238 if(length(regions.fr) > 1){ #in case there is only on FR region (rowSums needs >1 column) | |
239 matrx[10,x] = round(f(rowSums(tmp[,regions.fr], na.rm=T)), digits=1) | |
240 } else { | |
241 matrx[10,x] = round(f(tmp[,regions.fr], na.rm=T), digits=1) | |
242 } | |
233 matrx[10,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1) | 243 matrx[10,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1) |
234 matrx[10,z] = round(matrx[10,x] / matrx[10,y] * 100, digits=1) | 244 matrx[10,z] = round(matrx[10,x] / matrx[10,y] * 100, digits=1) |
235 | 245 |
236 matrx[11,x] = round(f(rowSums(tmp[,c("CDR1.IMGT.Nb.of.nucleotides", "CDR2.IMGT.Nb.of.nucleotides")], na.rm=T)), digits=1) | 246 if(length(regions.cdr) > 1){ #in case there is only on CDR region |
247 matrx[11,x] = round(f(rowSums(tmp[,regions.cdr], na.rm=T)), digits=1) | |
248 } else { | |
249 matrx[11,x] = round(f(tmp[,regions.cdr], na.rm=T), digits=1) | |
250 } | |
237 matrx[11,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1) | 251 matrx[11,y] = round(f(tmp$VRegionNucleotides, na.rm=T), digits=1) |
238 matrx[11,z] = round(matrx[11,x] / matrx[11,y] * 100, digits=1) | 252 matrx[11,z] = round(matrx[11,x] / matrx[11,y] * 100, digits=1) |
239 } | 253 } |
240 } | 254 } |
241 | 255 |