computational-metabolomics / mspurity-galaxy

Galaxy tools for msPurity package: includes precursor ion purity calculations and spectral matching
GNU General Public License v3.0
2 stars 6 forks source link

AverageFragSpectra in Galaxy error #52

Closed yguitton closed 1 year ago

yguitton commented 1 year ago

Hi @Tomnl , Hi @RJMW

I have an error in Galaxy with Average Frag Spectra step

'Error: 'mean' is not an exported object from 'namespace:stats' Execution halted'

any idea?

My history is here https://workflow4metabolomics.usegalaxy.fr/u/yguitton44/h/average-mean-singlemzmlms2snoop

I was doing some testing as it seems that the 'Sum intensities across (averaged) scans?' option set to NO is apparently not doing the job as intensities in spectra seems to be higher than expected

Best Yann

Tomnl commented 1 year ago

Hi Yann,

Thanks for spotting this. The error is related to where I call the mean from in the msPurity package https://github.com/computational-metabolomics/msPurity/blob/master/R/averaging.R#L132 I need to update so that it is from "stats" not base.

Regarding the intensities being greater than expected. Have you got any examples? I checked a few in my own datasets and they seem do being doing the median correctly. And I checked one example in yours and it seemed to be doing as expected

e.g. XCMS grouped feature (grpid) 70

Averaged spectra for one of the fragment peaks Mz: 55.93463898 intensity: 4065.879883

This XCMS feature has 5 fragmentation scans associated with it. The individual fragmentation scans have the following intensities for the 55.93 peak: 3779.976, 5244.639, 4591.896, 4065.880 & 3518.550

The median of these intensities is 4065.88.

But you might have found some occurences where this is not happening! So if you provide the "grpid" of a the problematic features I can look in more detail.

For reference this is how I checked the XCMS grouped feature 70.

library(msPurity)
load("Galaxy27-[msPurity.averageFragSpectra_(intra)_on_data_16__RData].rdata")

matching_peak = lapply(pa@grped_ms2$`70`, function(scanpeaks){
  return(scanpeaks[scanpeaks[,1] > 55.9 & scanpeaks[,1] < 55.95,][2]  )
})
median(unlist(matching_peak))
yguitton commented 1 year ago

Hi @Tomnl

Sorry, I have check and the error is on my side, I was not exporting correctly the MS/MS spectra from Xcalibur and that explains most of the difference observed.

Best