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

refining precursorMz #336

Open
cbroeckl opened this issue Oct 24, 2024 · 2 comments
Open

refining precursorMz #336

cbroeckl opened this issue Oct 24, 2024 · 2 comments

Comments

@cbroeckl
Copy link

cbroeckl commented Oct 24, 2024

I am processing Waters DDA data with the Spectra package. I want to refine the precursor mass, since in the waters data i have, the precursor mass mass not been lockmass corrected. I am able to map the uncorrected precursorMz to the feature mz values, and want to replace, in the Spectra object, the uncorrected precursorMz values with the 'corrected' accurate mass feature values, so i can use all the great filtering and write tools you have created for Spectra objects. However, i am getting an error when i try to replace the precusorMz values in the Spectra object of the raw data. A (trivial) reproducible example:

sciex_file <- dir(system.file("sciex", package = "msdata"),
                  full.names = TRUE)
sciex <- Spectra(sciex_file, backend = MsBackendMzR())
sciex

sciex_im <- setBackend(sciex, MsBackendMemory())
sciex_im

raw.prec <- precursorMz(sciex)
new.prec <- sample(50:1200, length(raw.prec), replace = TRUE)

precursorMz(sciex) <- raw.prec
precursorMz(sciex_im) <- raw.prec

this 'sciex' data contains no precursorMz value at all, but in either case, i generate the same error message on my Waters data:
Error: unable to find an inherited method for function ‘precursorMz<-’ for signature ‘object = "Spectra"’
this function is apparently being called from the ProtGenerics package, which does not support the Spectra object format. I noticed in the help section ?Spectra::precursorMz,Spectra-method that there is no setter method for this spectrum header. Any chance i could request one to be added? I did see in the help that this could be done by first moving to a data.frame and then returning to a Spectra object, but that seems pretty inefficient.

the same issue holds for

> Spectra::precursorIntensity(object) <- newValues 
Error: 'precursorIntensity<-' is not an exported object from 'namespace:Spectra'

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/Denver
tzcode source: internal

attached base packages:
[1] stats4 stats graphics grDevices utils datasets methods base

other attached packages:
[1] Spectra_1.14.1 ProtGenerics_1.36.0 S4Vectors_0.42.0 BiocGenerics_0.50.0 xcms_4.2.2 BiocParallel_1.38.0

loaded via a namespace (and not attached):
[1] DBI_1.2.3 rlang_1.1.4 magrittr_2.0.3 clue_0.3-65 MassSpecWavelet_1.70.0
[6] matrixStats_1.3.0 compiler_4.4.1 vctrs_0.6.5 reshape2_1.4.4 stringr_1.5.1
[11] pkgconfig_2.0.3 MetaboCoreUtils_1.12.0 crayon_1.5.3 XVector_0.44.0 utf8_1.2.4
[16] UCSC.utils_1.0.0 preprocessCore_1.66.0 purrr_1.0.2 MultiAssayExperiment_1.30.2 zlibbioc_1.50.0
[21] GenomeInfoDb_1.40.1 jsonlite_1.8.8 progress_1.2.3 DelayedArray_0.30.1 parallel_4.4.1
[26] prettyunits_1.2.0 cluster_2.1.6 R6_2.5.1 stringi_1.8.4 RColorBrewer_1.1-3
[31] limma_3.60.3 pkgload_1.3.4 GenomicRanges_1.56.1 Rcpp_1.0.12 SummarizedExperiment_1.34.0
[36] iterators_1.0.14 snow_0.4-4 IRanges_2.38.0 Matrix_1.7-0 igraph_2.0.3
[41] tidyselect_1.2.1 rstudioapi_0.16.0 abind_1.4-5 doParallel_1.0.17 codetools_0.2-20
[46] affy_1.82.0 lattice_0.22-6 tibble_3.2.1 plyr_1.8.9 Biobase_2.64.0
[51] pillar_1.9.0 affyio_1.74.0 BiocManager_1.30.23 MatrixGenerics_1.16.0 foreach_1.5.2
[56] MSnbase_2.30.1 MALDIquant_1.22.2 ncdf4_1.22 generics_0.1.3 hms_1.1.3
[61] ggplot2_3.5.1 munsell_0.5.1 scales_1.3.0 MsExperiment_1.6.0 glue_1.7.0
[66] MsFeatures_1.12.0 lazyeval_0.2.2 tools_4.4.1 mzID_1.42.0 QFeatures_1.14.1
[71] vsn_3.72.0 mzR_2.38.0 fs_1.6.4 XML_3.99-0.16.1 grid_4.4.1
[76] impute_1.78.0 tidyr_1.3.1 MsCoreUtils_1.16.0 colorspace_2.1-0 GenomeInfoDbData_1.2.12
[81] PSMatch_1.8.0 cli_3.6.2 fansi_1.0.6 S4Arrays_1.4.1 dplyr_1.1.4
[86] AnnotationFilter_1.28.0 pcaMethods_1.96.0 gtable_0.3.5 digest_0.6.35 SparseArray_1.4.8
[91] lifecycle_1.0.4 httr_1.4.7 statmod_1.5.0 MASS_7.3-60.2

@jorainer
Copy link
Member

Thanks Corey for the suggestion! I've added the precursorMz<- method now - will become part of the Spectra package in the upcoming Bioconductor release 3.20 (should happen in a couple of weeks). In the meantime, you could use object$precursorMz <- newValues as a workaround.

Maybe you are already aware, but we have now also in Spectra a function to estimate the precursor m/z - that can be used exactly for the issue you mention with Waters data. The function is estimatePrecursorMz.

jorainer added a commit that referenced this issue Oct 25, 2024
feat: add precursorMz<- replacement method (issue #336)
@cbroeckl
Copy link
Author

cbroeckl commented Oct 25, 2024

Thanks! I did NOT know you had the estimatePrecursorMz function. thanks for pointing it out! i have a hard time keeping up with your progress!!

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