Open sneumann opened 6 years ago
Is there some general format in which the data should be exported? some test files? descriptions? Implementing should then be simple and straightforward.
Hi, Information on http://www.metaboanalyst.ca/MetaboAnalyst/faces/docs/Format.xhtml
It would also be great if @xia-lab can give feedback whether the existing not-exported MetaboAnalyst export linked above works or needs any fixes.
Yours Steffen
I blame Android for the brevity and typos
Hi, thank you for opening this issue. I will do some testing if it still works well with our MetaboAnalystR package and let you know. I’ll also prepare some examples on a workflow using XCMS then our package.
Cheers, Jasmine
Hi,
The xcms:::.write.metaboanalyst() works perfectly with our R package, creating the correct data table in the right format. From our end I've created an example workflow that I will add as a vignette/use-case in our package.
Thanks! Jasmine
Great! Can you just point here to the vignette once you've added it? I'll then check the export function again, eventually add unit tests (if not already implemented) and add documentation etc.
Here it is! Let me know if you have any thoughts. https://github.com/xia-lab/MetaboAnalystR/blob/master/vignettes/XCMS_to_MetaboAnalystR.Rmd
Thanks for the link! I'll have a look at it next week as I'm on a workshop this week.
Looks nice. I'll implement a method for the newer XCMSnExp
object and export that. Would be nice if you could then also switch to the xcms xcms functions/user interface in your Rmd (I'll make a pull request on that).
Just had a look at the exported file. The supported file format is thus:
"Sample","ko15","ko16","ko18"
"Label","KO","KO","KO"
"279/2788","17140626.9682501",NA,"16919266.8898065"
"286.2/3255",NA,"1264118.63831818","732016.229999997"
"300.2/3387","4700903.21950002","5313736.07442857","5169558.19975"
"301/2788","3051847.80832143","1964443.59906668","2774885.34432354"
Is that correct? Is there any way that feature definitions could be added too, e.g. the rt range and mz range of the features/rows?
And how does MetaboAnalyst handle missing values? As shown above they are exported as NA
. Is that OK for MetaboAnalystR
?
Yes that file format is correct, and NA is fine for missing values. Also, we currently don't make use of feature definitions so all we need is the m/z and peak intensities. We will for sure switch over once you have that ready. As well, I had an email from a user that tried our example vignette and wanted to know if it was possible to edit the decimal points for the m/z or retention time?
Thanks for the information. Regarding the decimal point: so the user wants to use either a "."
or a ","
as decimal point?
Could you check if the new exportMetaboAnalyst
function works (is allows to specify also the character to be used as decimal point)?
I made a pull request at your MetaboAnalystR
repo that features the vignette to use the new user interface and the exportMetaboAnalyst
function.
For the decimal point it was the number of digits following the decimal, not "." or ",". And I will check the new function/your pull request now and get back to you ASAP!
I see. No problem about that. I'll be however on holidays the next two weeks - so it will take some time...
I've now added a digits
parameter that allows to specify the number of significant digits (passed directly to R's format
function).
Great! Everything looks good on our end, thank you.
It would be great to have the possibility to replace rownames
with mz/rt
values. This is how I currently do it:
### Convert XCMSnExp to xcmsSet ###
xset_conv <- as(xdata, "xcmsSet")
sampclass(xset_conv) <- gsub("^.*\\.", "", sampclass(xset_conv))
### Build the MetaboAnalyst Matrix ###
metaboanalyst_dat <- groupval(xset_conv, "medret", "into")
rownames(metaboanalyst_dat) <- groupnames(xset_conv, mzdec = 6, rtdec = 6)
metaboanalyst_dat <- rbind(group = as.character(phenoData(xset_conv)$class), metaboanalyst_dat)
colnames(metaboanalyst_dat) <- xset_conv@phenoData$sample_name
### Export ###
write.csv(metaboanalyst_dat, file='MetaboAnalyst_Matrix.csv')
@etrh I could add a parameter to exportMetaboAnalyst
that allows to use groupnames
instead of the feature IDs as rownames - would that be OK?
XCMS has for quite some time a hidden export to MetaboAnalyst https://github.com/sneumann/xcms/blob/d66fd8f9dc7aa5c49cb66be20a1bbdda6999eea3/R/functions-xcmsSet.R#L563 I had feedback by people from @xia-lab @jsychong that this actually works, so it would be great to have that better exposed. The current version is designed for
xcmsSet
, and the exposed version should handle bothxcmsSet
and the new interface. If the Xia lab have some code examples, they could contribute that to the documentation/manpage/examples. PR appreciated :-) Yours, Steffen