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

An error message #619

Closed ghost closed 2 years ago

ghost commented 2 years ago

I coped and pasted codes fromhttps://bioconductor.org/packages/devel/bioc/vignettes/xcms/inst/doc/xcms.html. I changed files to mine. I executed the following code,

plot(bpis, col = group_colors[raw_data$sample_group])

I got the following error

Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ

I knew my files. There are 601 scans in some files, 602 scans in others. I wonder if different scans created such a problem.

jorainer commented 2 years ago

Indeed, there can be files and combinations of files that can result in unexpected behaviour like this.

I would suggest the following

rts <- split(rtime(raw_data), fromFile(raw_data))
lapply(rts, range)

you could then select a (rounded maybe) retention time range that is within all files and filter the raw_data accordingly.

bpis <- chromatogram(filterRt(raw_data, c(1, 2000)), aggregationFun = "max")

You would obviously exchange the values 1 and 2000 above with the values that match your files (i.e. the minimum and maximum retention time to which you would filter your data set).

ghost commented 2 years ago

Thank you! It worked.