1、xcms会自动给这些数据命名为groupA/day1, group A/day 2, 等等。 (所以这里你要根据你的数据组来把它们存入不同的文件夹)。如果这里描述的不清楚的话,我会在后面的例子里进一步说明。下面将会以一个详细的例子来分布解说xcms是如何处理LC-MS数据的。2.数据分析2.1文件读取cdfpath -system.file(cdf, package = faahKO)system.file 作用是寻找包里面文件的路径和全名。这里指的是在叫faahKO的包中找到文件类型为cdf的文件的全名。list.files(cdfpath,recursive = TRUE)1 KO/ko1
2、5.CDF KO/ko16.CDFKO/ko18.CDFKO/ko19.CDFKO/ko21.CDF6 KO/ko22.CDFWT/wt15.CDFWT/wt16.CDFWT/wt18.CDFWT/wt19.CDF11 WT/wt21.CDFWT/wt22.CDFlist.files 是读取该路径下的文件夹或文件名,并以字符型向量存储。当然,这两条代码对我们都不重要,它们只是单纯的为了从这个包里面读取数据。2.2过滤及谱峰检测(filtration and peak identification)Library(xcms)每次使用这个包之前先要加载。cdffiles - list.files(
3、cdfpath, recursive = TRUE, full.names = TRUE)读取cdf文件,这里如果你要读取你自己的文件,你只要把cdfpath换成你的文件夹所在的位置就行,比如你的数据在文件 D:/data,那你把这里的代码换成cdffiles - list.files(D:/data, recursive = TRUE, full.names = TRUE) 就行(当然还有更方便的方法,不过这个就够用了)。Recursive=TURE 的话,它会递归读取到你文件夹里,如果是False的话就只会读取到文件夹。Full.names=TURE的话,你会得到一个包含路径的文件名,Fa
4、lse的话只会得到文件名。C:/Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/ko15.CDF2 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/ko16.CDF3 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/ko18.CDF4 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/ko19.CDF5 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/
5、ko21.CDF/Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/KO/ko22.CDF7 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt15.CDF8 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt16.CDF9 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt18.CDF10 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt19.C
6、DF/Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt21.CDF12 /Softwares/R 3.0.1/R-3.0.1/library/faahKO/cdf/WT/wt22.CDFxset - xcmsSet(cdffiles)这条语句主要作用是谱峰鉴定(peak identification),其结果存储在了一个xcmsset类型的数据(不用管这个类型是啥意思)。250:38 300:103 350:226 400:338 450:431 500:529 550:674 600:84743 300:128 350:275 400:39
7、4 450:500 500:637 550:835 600:102725 300:93 350:227 400:337 450:411 500:498 550:640 600:75819 300:67 350:169 400:258 450:301 500:373 550:488 600:58024 300:60 350:166 400:254 450:315 500:391 550:501 600:58231 300:71 350:183 400:280 450:338 500:422 550:532 600:60441 300:105 350:212 400:319 450:416 500
8、:533 550:684 600:83827 300:107 350:232 400:347 450:440 500:549 550:712 600:90587 350:200 400:293 450:351 500:426 550:548 600:66122 300:65 350:161 400:243 450:293 500:358 550:483 600:56128 300:69 350:157 400:229 450:282 500:364 550:493 600:59230 300:81 350:188 400:356 500:473 550:618 600:765每一行就是一个文件
9、,并且谱峰鉴定结果用成对的数据形式来给出。分号前面的数字表示正在处理的质荷比(m/z),后面的数字表示到该质荷比时已经找出的峰数目(peaknumber)这个语句看似简单,里面包含的参数却很多:xcmsSet(files = NULL, snames = NULL, sclass = NULL, phenoData = NULL, profmethod = bin, profparam = list(), polarity = NULL, lockMassFreq=FALSE, mslevel=NULL, nSlaves=0, progressCallback=NULL, scanrange
10、= NULL, .)多数情况下,我们用这些默认值就够了。但对于特定的分析仪器或者数据,我们也需要优化一些参数。Findpeaks利用两种不同的算法来进行峰值检测(peak detection)。其中默认法是ndPeaks.matchedFilter,另一种方法是ndPeaks.centWave。2.2.1ndPeaks.matchedFilter该法有几个参数需要考虑:峰宽(peak width)可用标准方差(sigma) 或者半峰全宽(fwhm)来表示,默认值是FWHM=30 s。根据色谱类型,我们应当选择合适的峰宽。步长(step)默认值是2,step=2.存储,有四种方法, bin,bi
11、nlin,binlinbase,intlin,其中bin是默认方法。四种方法的具体意思自己看文献吧,最后一个不推荐用,第三个具体怎么设置,我也没咋看懂。2.2.2ndPeaks.centWave该法更适合于高分辨率的仪器下的centroid mode的数据, 比如LC/TOF,OrbiTrap,FTICR-MS。binning在这里是不必要的。这里面有两个参数需要考虑:ppm,其选择和仪器精度有关峰宽范围(peak width range):比如HPLC里用peakwidth=c(20,50) ,UPLC里是peakwidth=c(5,12), 单位是秒。说了这个多了,举例子吧(英语说明里这部
12、分一笔带过,而且help里的例子也不适合batchfiles,如何设置这些参数的确让人有些摸不着头脑):- xcmsSet(cdffiles, method=matchedFilter,fwhm=60, step=3, profmethod=binlin )xsetAnxcmsSet object with 12 samplesTimerange: 2507.6-4139.9 seconds (41.8-69 minutes)Massrange: 200.1-597.0233 m/zPeaks:2549 (about 212 per sample)PeakGroups: 0Sampleclas
13、ses: KO, WTPro: method = binlin step = 3Memoryusage: 0.497 MB最后结果如上,我用了matchedFilter方法,fwhm是60s,步长是3,存储方法是 binlin-xcmsSet(cdffiles, method=centWave, ppm=5, peakwidth=c(10,20) ) 2502.9-4476.4 seconds (41.7-74.6 minutes) 200.1-600 m/z52907 (about 4409 per sample) method = binstep = 0.1 4.68 MB最后结果如上,我
14、用了centWave方法,ppm=5,峰宽范围是10-20s。2.3样本间峰匹配 (peak match across samples)xset- group(xset)Group有三种方法density,mzClust和nearest。每种方法下都有一系列不同的参数。density是默认方法。nearest需要额外安装RANN的包 才能实现。Density:Group peaks together across samples using overlapping m/z bins andcalculation of smoothed peak distributions in chromat
15、ographic time。mzClust:Runs high resolution alignment onsingle spectra samples stored in a given xcmsSet.Nearest:Group peaks together across samples by creating a master peaklist and assigning corresponding peaks from all samples.具体的方法和参数自己可以用help。比如想查density方法,就用help(group.density)来查看。举个例子:Xset-grou
16、p(xset, mzppm = 10, mzabs= 0, minsamp = 1, minfrac=0)这里我用了mzCluster,它对应的各个参数跟在后面。2.4保留时间校正 (retention time correction)样本间峰匹配分组后,xcms便通过这些分组来确定和校正每次运行之间保留时间的漂移。峰对其后xcms再进行一次分组,以提高分组的精确性。并非所有的分组都适合用来做保留时间的校正,比如有很多缺失峰的组和来自于同一样品,但却有多条峰的组。xset2 - retcor(xset,family = symmetric, plottype = mdevden)这里面又是一大
17、堆参数Rector也有三种方法loess,obiwarp,peakgroups, 其中loess是默认方法。Loess& peakgroups:Use smoothed deviations to alignretention times.这两个方法竟然完全一样,参数也一样。Obiwarp:Calculate retention time deviationsfor each sample. It is based on the code at. However, this function is ableto align multiple samples, by a center-star
18、strategy.每个方法后面又是跟了很多参数。具体还是通过help来查看。比如想看loess,就用help(retcor.loess)保留时间校正后,xcms又进行了一次分组,方法同上,不再细讲。- group(xset2,bw = 10)2.5Filling in Missing Peak Data即使再次精确分组,还会存在有些组有缺失峰。xset3 -fillPeaks(xset2)这里有两种方法,chrom和MSW,其中chrom是默认法。chrom法:Integrateareas of missing peaks它有一个参数nSlaves:number of slaves/cores to be used for parallel peaklling. MPI is used if installed,otherwise the snow package is employed for multicore support.MSW法:Integrateareas of missing peaks in FTICR-MS data