R package:xcms(四):Chromatographic peak detection色谱峰检测

1导入数据

library(xcms)
library(RColorBrewer)
library(ggplot2)
library(ggrepel)
library(stringr)

2多组数据

myfiles <- list.files(pattern = "^neg")
myfiles
name<- str_sub(basename(myfiles),11,-6)
name
pd <- data.frame(sample_name = sub(name, pattern = ".mzML",
                                   replacement = "", fixed = TRUE),
                 sample_group = c(rep("FA", 6), rep("HFD", 6)),
                 stringsAsFactors = FALSE)
pd
data_raw <- readMSData(files = myfiles, pdata = new("NAnnotatedDataFrame", pd),mode = "onDisk")

3 色谱峰检测

3.1

3.2 检测features

xchr <- findChromPeaks(data_raw, param = CentWaveParam(snthresh = 5))
dda_data.png

此时dda_data多了msFeatureData属性,检测到的色谱峰信息储存在
dda_data@msFeatureData[["chromPeaks"]]

dda_data@msFeatureData[["chromPeaks"]]%>% head()

或者

mz = 117.0194
mzr = mz + c(-0.01,0.01)
chromPeaks(xchr,mz = mzr)
#              mz    mzmin    mzmax      rt   rtmin   rtmax       into       intb       maxo  sn sample
#CP00387 117.0196 117.0166 117.0202 225.976 201.758 251.732 201143.331 199248.458 11735.4843 153      1
#CP00946 117.0190 117.0185 117.0202 651.321 631.142 684.479 328866.455 321557.847 16002.3513  44      1
#CP01897 117.0198 117.0179 117.0210 235.163 194.475 267.051  20846.146  17670.137   760.9054   7      2
data <- chromPeaks(xchr) |> data.frame()
i = 946#琥珀酸
mz = c(data$mzmin[i],data$mzmax[i])
rt = c(data$rtmin[i],data$rtmax[i])
mzr <- mz + c(-0.01, 0.01)
rtr <- rt + c(-20, 20)

提取两组琥珀酸色谱图

chr_raw <- chromatogram(data_raw, mz = mzr, rt = rtr)
group_colors <- paste0(brewer.pal(3, "Set1")[1:2], "60")
names(group_colors) <- c("FA", "HFD")
plot(chr_raw, col = group_colors[chr_raw$sample_group])
Extracted ion chromatogram
data_raw |> 
  filterRt(rtr)|>
  filterMz(mzr)|> 
  plot(type = "XIC")
XIC
xchr <- findChromPeaks(chr_raw, param = CentWaveParam(snthresh = 2))
sample_colors <- group_colors[xchr$sample_group]
bg <- sample_colors[chromPeaks(xchr)[, "column"]]
plot(xchr, col = sample_colors, peakBg = bg)
Rplot06.png

设置参数

cwp <- CentWaveParam(snthresh = 5)
xdata <- findChromPeaks(data_raw, param = cwp)

设置参数
使用centWave算法对centroid模式的高分辨LC-MS进行色谱峰检测。centWave算法最适用于高分辨率 centroid模式 的LC/{TOF、OrbiTrap、FTICR}-MS数据。在第一阶段,该方法确定了感兴趣区域(ROI),这些区域代表了LC/MS连续扫描时小于ppm m/z偏差的质量轨迹。 详细地说,从单个m/z开始,如果在下一次扫描(频谱)中发现的m/z,其与平均m/z的差异小于用户定义的m/z的ppm,则合并为一个ROI。 考虑到新加入的m/z值,ROI的平均m/z值也随之更新。

合并分裂峰

mpp <- MergeNeighboringPeaksParam(expandRt = 4)
xdata_pp <- refineChromPeaks(xdata, mpp)

参数

expandRt
numeric(1) defining by how many seconds the retention time window is expanded on both sides to check for overlapping peaks.

expandMz
numeric(1) constant value by which the m/z range of each chromatographic peak is expanded (on both sides!) to check for overlapping peaks.

ppm

numeric(1) defining a m/z relative value (in parts per million) by which the m/z range of each chromatographic peak is expanded to check for overlapping peaks.

minProp
numeric(1) between 0 and 1 representing the proporion of intensity to be required for peaks to be joined. See description for more details. The default (minProp = 0.75) means that peaks are only joined if the signal half way between then is larger 75% of the smallest of the two peak's "maxo" (maximal intensity at peak apex).

object
XCMSnExp object with identified chromatographic peaks.

param
MergeNeighboringPeaksParam object defining the settings for the method.

msLevel
integer defining for which MS level(s) the chromatographic peaks should be merged.

BPPARAM
parameter object to set up parallel processing. Uses the default parallel processing setup returned by bpparam(). See bpparam() for details and examples.

chr_ex <- chromatogram(xdata_pp, mz = mzr, rt = rtr)
chromPeaks(chr_ex)
sample_colors <- group_colors[chr_ex$sample_group]
plot(chr_ex, col = group_colors[chr_raw$sample_group], lwd = 2,
     peakBg = sample_colors[chromPeaks(chr_ex)[, "sample"]])
Rplot09.png
plot(chr_ex, col = sample_colors, peakType = "rectangle",
     peakCol = sample_colors[chromPeaks(chr_ex)[, "sample"]],
     peakBg = NA)
Rplot08.png
## Extract a list of per-sample peak intensities (in log2 scale)
ints <- split(log2(chromPeaks(xdata_pp)[, "into"]),
              f = chromPeaks(xdata_pp)[, "sample"])
boxplot(ints, varwidth = TRUE, col = sample_colors,
        ylab = expression(log[2]~intensity), main = "Peak intensities")
grid(nx = NA, ny = NULL)
Boxplot

参考资料:

https://bioconductor.org/packages/release/bioc/html/xcms.html
LCMS data preprocessing and analysis with xcms (bioconductor.org)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

相关阅读更多精彩内容

友情链接更多精彩内容