sneumann / xcms

This is the git repository matching the Bioconductor package xcms: LC/MS and GC/MS Data Analysis
Other
177 stars 81 forks source link

Setter for filepath in XcmsExperiment #748

Closed jmorim closed 1 week ago

jmorim commented 1 month ago

Is there a way to set the file paths in an XcmsExperiment object? I do peak picking and grouping on an HPC and the stats locally, but sometimes I get an error because the data filepath gets saved as the path on the cluster. Something like fileNames(xcms.experiment) <- rep('/path', n.samples)

jmorim commented 1 month ago

The hacky way i worked around it was for xcmsSet objects:

test.xcmsSet@xcmsSet@filepaths = paste0('./_mzML/', list.files('_mzML/'))[6:20]

and for XcmsExperiment objects

attr(test.XcmsExperiment, 'sampleData')$spectraOrigin = paste0('./_mzML/', list.files('_mzML')[6:20])
jorainer commented 4 weeks ago

oh yes, that's indeed something needed... am just pinging also @philouail because she's also working on something related.

jorainer commented 4 weeks ago

With Spectra version 1.15.2 we have now a dataStorageBasePath() function that allows to get or set the path of the base directory containing the data files.

so, you could first load your MsExperiment/XcmsExperiment object.

## List the *common* base path of the data storage files
dataStorageBasePath(spectra(xmse))

## You can update/change the path with
dataStorageBasePath(xmse@spectra) <- "new path"

You would need to install Spectra from the current devel branch (BiocManager::install("RforMassSpectrometry/Spectra")), also, it needs the most recent MsCoreUtils version (from Bioconductor release 3.19).

let me know if something is not working.