# Data analysis for Desorption Electrospray Ionization

Desorption Electrospray Ionization (DESI) is known for on-site mass spectrum analysis. For example, you could use DESI-MS to get the distribution of certain ions on the surface or cross section of sample. Without chromatograph or related separation process, the mass spectrum is actually the average intensities of all the mass during the sampling time. Recently I am thinking how to process such data via xcms.

Supposing we have data from 1 min sampling and we want to get the mass spectrum. For mass spectrum, 1 min usually means more than 100 full scan. The basic idea to process such data is directly binning the mass and average the intensity. However, I found group.mzClust function and MSW method are designed for this purpose.

library(msdata)
mzdatapath <- system.file("fticr", package = "msdata")
mzdatafiles <- list.files(mzdatapath, recursive = TRUE, full.names = TRUE)

xs <- xcmsSet(method="MSW", files=mzdatafiles, scales=c(1,7),
SNR.method='data.mean' , winSize.noise=500,
peakThr=80000,  amp.Th=0.005)
xsg <- group.mzClust(xs)
xsg <- fillPeaks.MSW(xsg)
r <- groupval(xsg,'medret','into')
z <- as.data.frame(groups(xsg))
file <- cbind(z\$mz,r)

You could save the data as csv file. Then you could perform further analysis such as peak picking or PCA analysis. If your data could be organized for spatial analysis or imaging, all the data has been ready and you could draw them by one for loop or just use animation package for a gif. I used this trick for my last group meeting as PhD students.

PS: the new design of xcms 3 is much more friendly to process such data via XCMSnExp object and the parameters design is very friendly to users.