### R代码从vignette源的cosmiq。Rnw ' ################################################### ### 代码块1号:style-Sweave ################################################### BiocStyle:乳胶 () ################################################### ### 代码块2号:cosmiq。Rnw: 43-57 (eval = FALSE ) ################################################### ## 库(cosmiq) # # cdfpath < - file.path (find.package(“faahKO”),“提供”)# # # # my.input.files < - dir (c(粘贴(cdfpath,“WT”,9月 ='/'), ## 粘贴(cdfpath“柯”,9 = ' / ')),full.names = TRUE ) ## ## # cosmiq运行包装器函数# # # # # x < = my.input cosmiq(文件。, mzbin=0.25,信噪比。Th = 0,线性= TRUE ) ## # ## ## # 图结果# #图像(t (x eicmatrix美元),主要=“mz和RT地图”)# #头(x xs@peaks美元 ) ################################################### ### 代码块3号:cosmiq。Rnw: 78 - 79 ################################################### 选项(宽度= 80 ) ################################################### ### 代码块数量4:cosmiq。Rnw: 87 - 97 ################################################### 库(cosmiq) cdfpath < - file.path (find.package(“faahKO”),“提供”)my.input.files < - dir (c(粘贴(cdfpath,“WT”,9 = ' / '),粘贴(cdfpath,“柯”,9 = ' / ')),full.names = TRUE) # # # todo创建xcmsSet对象x < -新xs@filepaths < - my.input.files(“xcmsSet”) ################################################### ### 代码块5号:cosmiq。Rnw: 103 - 106 ################################################### 类< - as.data.frame (c(代表(“柯”,6),代表(WT, 6))) rownames(类)< - basename (my.input.files) xs@phenoData <类 ################################################### ### 代码块6号:cosmiq。Rnw: 111 - 112 ################################################### 属性(xs ) ################################################### ### 代码块7号:cosmiq。Rnw: 127 - 135 ################################################### x < - combine_spectra (x = x, mzbin = 0.25,线性= TRUE,连续= FALSE)情节(x mz美元,美元强度、类型=“l”,主要=结合光谱,xlab = m / Z, ylab = '离子强度 ') ################################################### ### 代码块8号:cosmiq。Rnw: 151 - 170 ################################################### xy < - peakdetection (x = x美元mz, y = x美元强度、尺度= 1:10,SNR.Th = 1.0,信噪比。区域=20,mintr=0.5) id。peakcenter < xy[4]过滤器。Mz <- 400 < x$ Mz & x$ Mz < 450 plot(x$ Mz[过滤器。mz), x $强度[过滤器。mz], main='相关质量的检测',type='l', xlab='m/Z', ylab='离子强度')点(x$mz[id。peakcenter), x $强度[id。peakcenter],坳= '红',类型= ' h ') ################################################### ### 代码块9号:cosmiq。Rnw:188-199 ################################################### # create dummy object xs@peaks <- matrix(c(rep(1, length(my.input.files) * 6), 1:length(my.input.files)), ncol=7) colnames(xs@peaks) <- c("mz", "mzmin", "mzmax", "rt", "rtmin", "rtmax", "sample") xs <- xcms::retcor(xs, method="obiwarp", profStep=1, distFunc="cor", center=1) ################################################### ### code chunk number 10: cosmiq.Rnw:217-257 ################################################### eicmat <- eicmatrix(xs=xs, xy=xy, center=1) # # process a reduced mz range for a better package build performance (eicmat.mz.range <- range(which(475 < xy[,1] & xy[,1] < 485))) eicmat.filter <- eicmat[eicmat.mz.range[1]:eicmat.mz.range[2],] xy.filter <- xy[eicmat.mz.range[1]:eicmat.mz.range[2],] # # determine the new range and plot the mz versus RT map (rt.range <- range(as.double(colnames(eicmat.filter)))) (mz.range<-range(as.double(row.names(eicmat.filter)))) image(log(t(eicmat.filter))/log(2), main='overlay of 12 samples using faahKO', col=rev(gray(1:20/20)), xlab='rt [in seconds]', ylab='m/z', axes=FALSE) axis(1, seq(0,1, length=6), round(seq(rt.range[1], rt.range[2], length=6))) axis(2, seq(0,1, length=4), round(seq(mz.range[1], mz.range[2], length=4), 2)) # # determine the chromatographic peaks rxy <- retention_time(xs=xs, RTscales=c(1:10, seq(12,32, by=2)), xy=xy.filter, eicmatrix=eicmat.filter, RTSNR.Th=120, RTSNR.area=20) rxy.rt <- (rxy[,4] - rt.range[1]) / diff(rt.range) rxy.mz <- (rxy[,1] - mz.range[1]) / diff(mz.range) points(rxy.rt, rxy.mz, pch="X", lwd=2, col="red") ################################################### ### code chunk number 11: cosmiq.Rnw:274-275 ################################################### xs <- create_datamatrix(xs=xs, rxy=rxy) ################################################### ### code chunk number 12: cosmiq.Rnw:284-289 ################################################### peaktable <- xcms::peakTable(xs) idx <- order(rowSums(peaktable[,8:19]), decreasing=TRUE) head(peaktable[idx,]) ################################################### ### code chunk number 13: sessioninfo ################################################### toLatex(sessionInfo())