Mercurial > repos > tomnl > track_rt_raw
comparison create_msp.R @ 27:682f25e2341a draft default tip
planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit 1800a3818988f21ef129e500818c9a087fce5875
| author | tomnl |
|---|---|
| date | Wed, 18 Jul 2018 06:11:13 -0400 |
| parents | 485c92d69777 |
| children |
comparison
equal
deleted
inserted
replaced
| 26:95a4c22e0d64 | 27:682f25e2341a |
|---|---|
| 19 | 19 |
| 20 puritydf <- pa@puritydf | 20 puritydf <- pa@puritydf |
| 21 | 21 |
| 22 | 22 |
| 23 | 23 |
| 24 | 24 #grped_df$fileid <- sapply(grped_df$filename, function(x) which(basename(pa@fileList)==x)) |
| 25 | 25 #puritydf$fileid <- sapply(puritydf$filename, function(x) which(basename(pa@fileList)==x)) |
| 26 grped_df$fileid <- sapply(grped_df$filename, function(x) which(basename(pa@fileList)==x)) | 26 |
| 27 | 27 |
| 28 puritydf$fileid <- sapply(puritydf$filename, function(x) which(basename(pa@fileList)==x)) | 28 |
| 29 | 29 |
| 30 selfrag <- as.numeric(unique(grped_df$grpid)) | 30 selfrag <- as.numeric(unique(grped_df$grpid)) |
| 31 | 31 |
| 32 of <- file(description = "outfile.msp", open = "w+a") | 32 of <- file(description = "outfile.msp", open = "w+a") |
| 33 | 33 |
| 64 | 64 |
| 65 idj <- paste(i,jj,sep=".") | 65 idj <- paste(i,jj,sep=".") |
| 66 | 66 |
| 67 specj <- spec[[jj]] | 67 specj <- spec[[jj]] |
| 68 | 68 |
| 69 | |
| 70 | |
| 69 grpdj <- grpd[jj,] | 71 grpdj <- grpd[jj,] |
| 70 | 72 if ('sample' %in% colnames(grpd)){ |
| 71 name = paste(i, grpdj$sample, grpdj$pid, sep='-') | 73 fileid = grpdj$sample |
| 74 }else{ | |
| 75 fileid = grpdj$fileid | |
| 76 } | |
| 77 name = paste(i, fileid, grpdj$pid, sep='-') | |
| 72 | 78 |
| 73 write.msp(name,grpdj$precurMtchMZ,"",specj,of) | 79 write.msp(name,grpdj$precurMtchMZ,"",specj,of) |
| 74 } | 80 } |
| 75 | 81 |
| 76 }else{ | 82 }else{ |
| 80 if (opt$mode=="max"){ | 86 if (opt$mode=="max"){ |
| 81 | 87 |
| 82 idx <- which(prec_int==max(prec_int)) | 88 idx <- which(prec_int==max(prec_int)) |
| 83 | 89 |
| 84 grpd <- grpd[idx,] | 90 grpd <- grpd[idx,] |
| 85 name = paste(i, grpd$sample, grpd$pid, sep='-') | 91 if ('sample' %in% colnames(grpd)){ |
| 92 fileid = grpd$sample | |
| 93 }else{ | |
| 94 fileid = grpd$fileid | |
| 95 } | |
| 96 | |
| 97 name = paste(i, fileid, grpd$pid, sep='-') | |
| 86 write.msp(name,grpd$precurMtchMZ,"",specj[[idx]], of) | 98 write.msp(name,grpd$precurMtchMZ,"",specj[[idx]], of) |
| 87 } | 99 } |
| 88 | 100 |
| 89 if (opt$mode=="average"){ | 101 if (opt$mode=="average"){ |
| 90 | 102 |
| 173 } | 185 } |
| 174 }else{ | 186 }else{ |
| 175 spec <- spec[[1]] | 187 spec <- spec[[1]] |
| 176 | 188 |
| 177 grpd <- grped_df[j,] | 189 grpd <- grped_df[j,] |
| 178 name = paste(i, grpd$sample, grpd$pid, sep='-') | 190 if ('sample' %in% colnames(grpd)){ |
| 191 fileid = grpd$sample | |
| 192 }else{ | |
| 193 fileid = grpd$fileid | |
| 194 } | |
| 195 name = paste(i, fileid, grpd$pid, sep='-') | |
| 179 write.msp(name,grpd$precurMtchMZ,"",spec,of) | 196 write.msp(name,grpd$precurMtchMZ,"",spec,of) |
| 180 } | 197 } |
| 181 } | 198 } |
| 182 | 199 |
| 183 | 200 |
