Open 13479776 opened 1 year ago
A single function that you could use is featureChromatograms
, but that will extract you a chromatogram for every feature in every sample.
if you want to get the chromatogram with the highest signal for each feature, you would need to loop over the features (not sure if the code below works, did not try, but it's to give you an idea how it could be done):
## Get the feature definitions
fdef <- featureDefinitions(xdata)
cpks <- chromPeaks(xdata)
## Get the index (within the chromPeak matrix) of the peak with the highest intensity (using
## "maxo" for that, but could also use "into" instead.
idx <- vapply(fdef$peakidx, function(x) {
i <- which.max(cpks[x, "maxo"])
x[i]
}, integer(1))
## Extracting the chromatograms. Need to subset to the respective sample and then
## use the chromatogram call with the m/z and retention time range of the selected
## chromatographic peak
chrs <- lapply(idx, function(i) {
pk <- cpks[i, , drop = FALSE]
tmp <- filterFile(xdata, pk[1, "sample"])
## maybe expand the rt width a bit
pk[, "rtmin"] <- pk[, "rtmin"] - 2
pk[, "rtmax"] <- pk[, "rtmax"] + 2
chromatogram(tmp, mz = pk[, c("mzmin", "mzmax")], rt = pk[, c("rtmin", "rtmax")])
})
chrs
should then be a list
of individual MChromatogram
objects, each representing the EIC of the peak with the highest intensity for a feature in that sample.
Dear Sir or madam,
I would like to require if it possible to get the feature chromatograms of different samples based on the intensity . Is it to use the chromatograms function for this task? For example, if a feature peak is strongest in a particular sample, obtain the chromatogram of that feature peak in this sample.
Thanks
best wish, hees