Mercurial > repos > lecorguille > xcms_retcor
comparison lib.r @ 15:950b97b679c6 draft
planemo upload for repository https://github.com/workflow4metabolomics/xcms commit f0d42bca2f34c58c04b55e5990058d479c0ae639
author | lecorguille |
---|---|
date | Mon, 11 Feb 2019 06:06:50 -0500 |
parents | e95f0dcdea3b |
children | 0dcc9d0902cf |
comparison
equal
deleted
inserted
replaced
14:e95f0dcdea3b | 15:950b97b679c6 |
---|---|
142 return (dataMatrix) | 142 return (dataMatrix) |
143 } | 143 } |
144 | 144 |
145 #@author G. Le Corguille | 145 #@author G. Le Corguille |
146 # Draw the plotChromPeakDensity 3 per page in a pdf file | 146 # Draw the plotChromPeakDensity 3 per page in a pdf file |
147 getPlotChromPeakDensity <- function(xdata, mzdigit=4) { | 147 getPlotChromPeakDensity <- function(xdata, param = NULL, mzdigit=4) { |
148 pdf(file="plotChromPeakDensity.pdf", width=16, height=12) | 148 pdf(file="plotChromPeakDensity.pdf", width=16, height=12) |
149 | 149 |
150 par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5)) | 150 par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5)) |
151 | 151 |
152 group_colors <- brewer.pal(3, "Set1")[1:length(unique(xdata$sample_group))] | 152 group_colors <- brewer.pal(3, "Set1")[1:length(unique(xdata$sample_group))] |
154 | 154 |
155 xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax)) | 155 xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax)) |
156 for (i in 1:nrow(featureDefinitions(xdata))) { | 156 for (i in 1:nrow(featureDefinitions(xdata))) { |
157 mzmin = featureDefinitions(xdata)[i,]$mzmin | 157 mzmin = featureDefinitions(xdata)[i,]$mzmin |
158 mzmax = featureDefinitions(xdata)[i,]$mzmax | 158 mzmax = featureDefinitions(xdata)[i,]$mzmax |
159 plotChromPeakDensity(xdata, mz=c(mzmin,mzmax), col=group_colors, pch=16, xlim=xlim, main=paste(round(mzmin,mzdigit),round(mzmax,mzdigit))) | 159 plotChromPeakDensity(xdata, param = param, mz=c(mzmin,mzmax), col=group_colors, pch=16, xlim=xlim, main=paste(round(mzmin,mzdigit),round(mzmax,mzdigit))) |
160 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) | 160 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) |
161 } | 161 } |
162 | 162 |
163 dev.off() | 163 dev.off() |
164 } | 164 } |
187 #@author G. Le Corguille | 187 #@author G. Le Corguille |
188 # value: intensity values to be used into, maxo or intb | 188 # value: intensity values to be used into, maxo or intb |
189 getPeaklistW4M <- function(xdata, intval="into", convertRTMinute=F, numDigitsMZ=4, numDigitsRT=0, naTOzero=T, variableMetadataOutput, dataMatrixOutput, sampleNamesList) { | 189 getPeaklistW4M <- function(xdata, intval="into", convertRTMinute=F, numDigitsMZ=4, numDigitsRT=0, naTOzero=T, variableMetadataOutput, dataMatrixOutput, sampleNamesList) { |
190 dataMatrix <- featureValues(xdata, method="medret", value=intval) | 190 dataMatrix <- featureValues(xdata, method="medret", value=intval) |
191 colnames(dataMatrix) <- make.names(tools::file_path_sans_ext(colnames(dataMatrix))) | 191 colnames(dataMatrix) <- make.names(tools::file_path_sans_ext(colnames(dataMatrix))) |
192 dataMatrix = cbind(name=groupnamesW4M(xdata), dataMatrix) | 192 dataMatrix = cbind(name=groupnames(xdata), dataMatrix) |
193 variableMetadata <- featureDefinitions(xdata) | 193 variableMetadata <- featureDefinitions(xdata) |
194 colnames(variableMetadata)[1] = "mz"; colnames(variableMetadata)[4] = "rt" | 194 colnames(variableMetadata)[1] = "mz"; colnames(variableMetadata)[4] = "rt" |
195 variableMetadata = data.frame(name=groupnamesW4M(xdata), variableMetadata) | 195 variableMetadata = data.frame(name=groupnames(xdata), variableMetadata) |
196 | 196 |
197 variableMetadata <- RTSecondToMinute(variableMetadata, convertRTMinute) | 197 variableMetadata <- RTSecondToMinute(variableMetadata, convertRTMinute) |
198 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT=numDigitsRT, numDigitsMZ=numDigitsMZ) | 198 variableMetadata <- formatIonIdentifiers(variableMetadata, numDigitsRT=numDigitsRT, numDigitsMZ=numDigitsMZ) |
199 dataMatrix <- naTOzeroDataMatrix(dataMatrix, naTOzero) | 199 dataMatrix <- naTOzeroDataMatrix(dataMatrix, naTOzero) |
200 | 200 |