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

Issue with readChromatogram when type = "xic" #47

Closed
Arthfael opened this issue Feb 1, 2022 · 14 comments
Closed

Issue with readChromatogram when type = "xic" #47

Arthfael opened this issue Feb 1, 2022 · 14 comments

Comments

@Arthfael
Copy link

Arthfael commented Feb 1, 2022

I have been using this package for ~1 year now, specifically the readChromatogram function for extracting "tic" and "base peak". It works nicely and has been very useful. However, I have just for the first time tried to extract an "xic" for some masses of interest, and here is what I get:

XICs <- lapply(Raws, function(raw) { readChromatogram(raw, masses, tols) })
Error in .rawrrSystem2Source(rawfile, input = mass, rawrrArgs = sprintf("xic %f %s",  : 
  **Rcode file to parse does not exist. 'C:\Users\MyUserName\AppData\Local/R/cache/R/rawrr/rawrrassembly/rawrr.exe' failed for an unknown reason.
Please check the debug files:
	C:\Users\MyUserName\AppData\Local\Temp\2\RtmpeQSRv0\file62986016698d.stderr
	C:\Users\MyUserName\AppData\Local\Temp\2\RtmpeQSRv0\file629849cf6634.stdout
and the System Requirements
Called from: .rawrrSystem2Source(rawfile, input = mass, rawrrArgs = sprintf("xic %f %s", 
    tol, shQuote(filter)))**

This is on a Windows 2019 Server machine, using R version 4.1.0 (2021-05-18) in RStudio 1.4.1717.
File "C:/Users/MyUserName/AppData/Local/R/cache/R/rawrr/rawrrassembly/rawrr.exe" does exist, but maybe this is an issue with slashes in Windows, since the error uses inconsistently backwards (Windows) and forward (Linux) slashes? In which case, including normalizePath(..., winslash = "/") would probably be enough to fix it?

@tobiasko
Copy link
Collaborator

Hi @Arthfael

That is indeed a bit strange! Could you please upload your sessionInfo? Do you get the same error when reading from a single file (outside of the lapply function)? Are other reading functions of the package also affected (readIndex)?

Best,
Tobi

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@tobiasko
Copy link
Collaborator

Hi @Arthfael

since release 3.13 rawrr is a Bioconductor package, see

https://bioconductor.org/packages/release/bioc/html/rawrr.html

I would recommend to use the latest BioC release 3.14 to install rawrr with the help of the BiocManager:

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("rawrr")

I am honestly not sure what you get when installing from GitHub directly using devtools::. Version 0.2.1 is stone age. Please don't use it.

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@tobiasko
Copy link
Collaborator

Did you follow this

https://bioconductor.org/packages/release/bioc/install/rawrr/INSTALL

or specifically did you install the RawFileReader DLLs and rawrr exe on your system:

> installRawFileReaderDLLs()
Do you accept the Thermo License agreement 'X:/Rlibs/rawrr/rawrrassembly/RawFileReaderLicense.txt'? [Y/n]: Y
trying URL 'https://github.com/thermofisherlsms/ThermoRawFileParser/raw/master/packages/ThermoFisher.CommonCore.RawFileReader.4.0.26/lib//ThermoFisher.CommonCore.Data.dll'
Content type 'application/octet-stream' length 360448 bytes (352 KB)
downloaded 352 KB

trying URL 'https://github.com/thermofisherlsms/ThermoRawFileParser/raw/master/packages/ThermoFisher.CommonCore.RawFileReader.4.0.26/lib//ThermoFisher.CommonCore.MassPrecisionEstimator.dll'
Content type 'application/octet-stream' length 11264 bytes (11 KB)
downloaded 11 KB

trying URL 'https://github.com/thermofisherlsms/ThermoRawFileParser/raw/master/packages/ThermoFisher.CommonCore.RawFileReader.4.0.26/lib//ThermoFisher.CommonCore.RawFileReader.dll'
Content type 'application/octet-stream' length 620544 bytes (606 KB)
downloaded 606 KB

                  ThermoFisher.CommonCore.Data.dll ThermoFisher.CommonCore.MassPrecisionEstimator.dll 
                                                 0                                                  0 
         ThermoFisher.CommonCore.RawFileReader.dll 
                                                 0 
> installRawrrExe()
trying URL 'http://fgcz-ms.uzh.ch/~cpanse/rawrr/rawrr.1.1.12.exe'
Content type 'application/x-msdos-program' length 26624 bytes (26 KB)
downloaded 26 KB

MD5 6d5f6d19512eaba73e92d2bfb474e6f2 C:\Users\tobiasko.FGCZ-NET\AppData\Local/R/cache/R/rawrr/rawrrassembly/rawrr.exe
[1] 0
> 

@tobiasko
Copy link
Collaborator

The problem is:

Bioc was not willing to host the binary rawrr.x.exe as part of the package. So it is downloaded on demand after the package installation through BiocManager. Same-same for the RawFileReader dlls. They are fetched from a Thermo GitHub Repo. I know this is kind of annoying, but it was the only option.

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@Arthfael
Copy link
Author

Arthfael commented Feb 16, 2022 via email

@tobiasko
Copy link
Collaborator

That is all pretty wired. I meanwhile installed rawrr 1.2.0 using BiocManager on a very similar system (Windows Server 2021):

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2012 R2 x64 (build 9600)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] rawrr_1.2.0         BiocManager_1.30.16

loaded via a namespace (and not attached):
 [1] magrittr_2.0.2    tidyselect_1.1.1  R6_2.5.1          rlang_1.0.1       fastmap_1.1.0     fansi_1.0.2      
 [7] dplyr_1.0.8       tools_4.1.0       DT_0.20           utf8_1.2.2        cli_3.2.0         DBI_1.1.2        
[13] htmltools_0.5.2   ellipsis_0.3.2    yaml_2.2.2        assertthat_0.2.1  digest_0.6.29     tibble_3.1.6     
[19] lifecycle_1.0.1   crayon_1.5.0      purrr_0.3.4       htmlwidgets_1.5.4 vctrs_0.3.8       glue_1.6.1       
[25] compiler_4.1.0    pillar_1.7.0      generics_0.1.2    pkgconfig_2.0.3  

What do you get when reading from the sample data that comes with the package?

> rawfile <- sampleFilePath()
> Idx <- readIndex(rawfile)
> str(Idx)
'data.frame':	573 obs. of  8 variables:
 $ scan          : int  1 2 3 4 5 6 7 8 9 10 ...
 $ scanType      : chr  "FTMS + c NSI Full ms [350.0000-1800.0000]" "FTMS + c NSI Full ms2 487.2567@hcd28.00 [140.0000-1015.0000]" "FTMS + c NSI Full ms2 644.8226@hcd28.00 [140.0000-1335.0000]" "FTMS + c NSI Full ms2 683.8279@hcd28.00 [140.0000-1415.0000]" ...
 $ rtinseconds   : num  0.097 0.35 0.419 0.489 0.558 0.627 0.696 0.766 0.835 0.904 ...
 $ precursorMass : num  1075 487 645 684 547 ...
 $ MSOrder       : chr  "Ms" "Ms2" "Ms2" "Ms2" ...
 $ charge        : int  0 2 2 2 2 2 2 2 2 2 ...
 $ masterScan    : int  NA NA NA NA NA NA NA NA NA NA ...
 $ dependencyType: logi  NA NA NA NA NA NA ...

My path to the sample data is:

> rawfile
[1] "X:/Rlibs/rawrr/extdata/sample.raw"

The rawrr assembly path (the path were the dll are placed) is

> rawrrAssemblyPath()
[1] "C:\\Users\\tobiasko.FGCZ-NET\\AppData\\Local/R/cache/R/rawrr/rawrrassembly"

as you can see, also here I am getting this strange mixture of \\ and / in a single path. But that is obviously not a problem, since readIndex works.

The exe and the dlls should be at the assembly path location together with the EULA text:

> list.files(rawrrAssemblyPath())
[1] "eula.txt"                                           "rawrr.exe"                                         
[3] "ThermoFisher.CommonCore.Data.dll"                   "ThermoFisher.CommonCore.MassPrecisionEstimator.dll"
[5] "ThermoFisher.CommonCore.RawFileReader.dll"         
> 

Could you just execute the same commands and upload the returns?

@Arthfael
Copy link
Author

Arthfael commented Feb 17, 2022 via email

@tobiasko
Copy link
Collaborator

Puh! Yip, we need to check more carefully if the parameters are valid (length = 1) and raise an error right away. That could be avoided very easily by a stopifnot() statement at the start of readChromatogram.

@tobiasko
Copy link
Collaborator

@cpanse

We need to check this here:

readChromatogram <- function(rawfile,
                             mass = NULL,
                             tol = 10,
                             filter = "ms",
                             type = 'xic'){
    
    .isAssemblyWorking()
    .checkRawFile(rawfile)
    
    stopifnot(type %in% c('xic', 'bpc', 'tic'))

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