Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for XIC plot of timsTof data #734

Open
NorStorz opened this issue Mar 26, 2024 · 3 comments
Open

Error for XIC plot of timsTof data #734

NorStorz opened this issue Mar 26, 2024 · 3 comments

Comments

@NorStorz
Copy link
Contributor

Hi,
i run into the following error when i try to call plot(mse, type = "XIC") on timfTOF data with MsBackendTimsTof:

Error in rep(rtime(z), lns) : invalid 'times' argument

This example should be reproducible:

library(xcms)
library(MsExperiment)
library(opentimsr)
library(MsBackendTimsTof)
 
so_folder <- tempdir()
so_file <- download_bruker_proprietary_code(so_folder, method = "wget")
setup_bruker_so(so_file)
 
link <- "[https://www.biosino.org/download/node/data/public/OED788908"](https://www.biosino.org/download/node/data/public/OED788908%22)
download.file(link ,destfile="dat.tar.gz")
untar("dat.tar.gz")
 
fls <- "12_serial_diluted_urine_neg/1X/04_1X_nist_urine_neg_6_p1-a1_1_7154.d"
 
mse <- readMsExperiment(fls, source = MsBackendTimsTof())
 
plot(mse, type = "XIC")

From the traceback i could find out that the error occurs inside the function .xmse_plot_xic
I tested it with the following code:

msLevel = 1L
z <- mse[1]
lst <- as(filterMsLevel(spectra(z), msLevel = msLevel), "list")
lns <- lengths(lst) / 2
lst <- do.call(rbind, lst)
df <- data.frame(rt = rep(rtime(z), lns), lst)

The problem seems to be that rtime(z) and 'lns' differ in length. This is probably caused by the MS1 filtering of the Spectra:

> length(rtime(z))
[1] 1839591
> length(spectra(z))
[1] 1839591
> length(lns)
[1] 1260153
> length(as(filterMsLevel(spectra(z), msLevel = 1L), "list"))
[1] 1260153

This is my session info:

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS
 
Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0
 
locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
 
time zone: Etc/UTC
tzcode source: system (glibc)
 
attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     
 
other attached packages:
[1] devtools_2.4.5         usethis_2.2.2          viridis_0.6.5         
[4] viridisLite_0.4.2      opentimsr_1.0.13       MsExperiment_1.4.0    
[7] xcms_4.0.2             MSnbase_2.28.1         mzR_2.36.0            
[10] Rcpp_1.0.12            Biobase_2.62.0         MsBackendTimsTof_0.1.5
[13] Spectra_1.12.0         ProtGenerics_1.34.0    BiocParallel_1.36.0   
[16] S4Vectors_0.40.2       BiocGenerics_0.48.1   
...
@jorainer
Copy link
Collaborator

jorainer commented Mar 26, 2024

Hm, strange error. Can you please run table(msLevel(mse)) - I would assume you have MS1 and MS2 spectra in your data set?

If we call rtime on the full object (MsExperiment/XcmsExperiment) and as(..., "list") only on the data set filtered for one MS level than we have indeed a bug... PR with a fix would be highly welcome :)

Also, have you tried to run plot without type = "XIC"? I think, for MsExperiment the plot is always the type XIC.

@NorStorz
Copy link
Contributor Author

Hi,
Yes i have MS1 and MS2 spectra in my data set. table(msLevel(spectra(mse))) returns:

      1       2 
1260153  579438  

And plot(mse) also leads to the error.
And it seems to be a problem for all LC-MS/MS data. I tried some data from the msdata package, which also caused the error:

library("msdata")
FilePaths <- msdata::proteomics(full.names=TRUE)
mse_test <- readMsExperiment(FilePaths[4])
plot(mse_test)

I will look into this and create a PR.

@jorainer
Copy link
Collaborator

jorainer commented Apr 3, 2024

Great! Thanks @NorStorz - let me know if you need some help or if something is unclear.

jorainer added a commit that referenced this issue Jun 7, 2024
- Add the fix merged with PR #741 into the devel branch also to the release
  branch.
- The fix addresses the error generated when `plot,MsExperiment` is called on a
  `MsExperiment` with MS1 and MS2 spectra (issue #734).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants