Metabolomics Society Forum

Software => R => XCMS => Topic started by: K4A on October 07, 2015, 05:31:58 AM

Title: Alignment of matrices with obiwarp
Post by: K4A on October 07, 2015, 05:31:58 AM
Dear all,

I usually perform the feature extraction from HRMS data with software from the vendor and want to use the XCMS package in R now to align the features from different measurements.
As i already have all of the required information available in matrices (one matrix per sample measurement with the mass, retention time and intensity), i would like to know if i can perform the alignment now directly on the matrices without using the typical input formats for XCMS (NetCDF, mzData,...).

Best regards,
Sascha
Title: Re: Alignment of matrices with obiwarp
Post by: sneumann on October 07, 2015, 11:55:10 AM
Hi,

it is possible to create an xcmsSet from a peak list,
as shown by the following minimalistic example.
But this will not allow to use Obiwarp, since Obiwarp
goes back to the raw data files, which in turn would have
to be netCDF, mzML etc.

Code: [Select]
library(xcms)

intensity <- matrix(1:32, ncol=4)
mz <- rep(1:8, ncol(intensity))
rt <- rep(8:1, ncol(intensity))

xs <- new("xcmsSet")

peaks(xs) <- cbind(mz=mz, mzmin=mz, mzmax=mz,
                  rt=mz, rtmin=mz, rtmax=mz,
                  into=as.vector(intensity), intf=as.vector(intensity),
                  maxo=as.vector(intensity), maxf=as.vector(intensity),
                  sample=rep(seq(1,ncol(intensity)), each=nrow(intensity))
                  )
sampnames(xs) <- 1:4

xsg <- group(xs)
xsg

If you need Obiwarp, you will need to write a new constructor
for the xcmsSource class that reads a peaklist into an xcmsRaw,
see also this thread: viewtopic.php?f=8&t=310 (http://www.metabolomics-forum.com/viewtopic.php?f=8&t=310)

and the code in https://github.com/sneumann/xcms/blob/m ... msSource.R (https://github.com/sneumann/xcms/blob/master/R/xcmsSource.R)
and the use in https://github.com/sneumann/xcms/blob/m ... /xcmsRaw.R (https://github.com/sneumann/xcms/blob/master/R/xcmsRaw.R)


Yours,
Steffen
Title: Re: Alignment of matrices with obiwarp
Post by: K4A on October 10, 2015, 04:28:06 AM
Hi Steffen,

thanks a lot for your fast reply to my question.
Unfortunately, i think i am not capable of performing the required modifications right now as i only created rather basic code in R so far.
Depending on the amount of time i have to spend I will either try to make myself more familiar with the code of XCMS and a more advanced type of programming or i will stick to my current alignment algorithm from OpenMS.

Best regards,
Sascha