rickhelmus / patRoon

Workflow solutions for mass-spectrometry based non-target analysis.
https://rickhelmus.github.io/patRoon/
GNU General Public License v3.0
58 stars 17 forks source link

MS2Quant: "Error in if (fingerprints != "") { : the condition has length > 1" #92

Closed drewszabo closed 7 months ago

drewszabo commented 7 months ago

Hey Rick,

I am trying to use MS2Quant in patRoon, but I keep getting the same error after trying a number of tests. I am using the code below where compoundsSIR is the object that contains the SIRIUS fingerprints. Both the compounds and fGroups are rather large (4000+ features) but I even tried to test the first 25 and 100 features using fGroups[,1:100] with the same result. I also checked the compoundsSIR@fingerprints and these are all populated correctly (no empty slots).

I am using areas in the calibrants data.frame, with only the required variables (name, SMILES, area, conc, rt). I have around 20 calibrant compounds but the same issue occurs if filter for only 3 compounds (atrazine, caffeine, carbamazepine).

I cannot provide a useful replication with patRoonData because there does not seem to be calibration data here. I can try to provide a small example if you need?

> compoundsConc <- predictRespFactors(
+   compoundsSIR,
+   fGroups,
+   calibrants = calibrants,
+   eluent = eluent,
+   organicModifier = "MeCN",
+   pHAq = 2.7,
+   concUnit = "ugL",
+   calibConcUnit = "ugL")
NOTE: using MS2Quant column 'area' for 'intensity'
Predicting response factors from fingerprints with MS2Quant for 100 candidates...
Error in if (fingerprints != "") { : the condition has length > 1
rickhelmus commented 7 months ago

Hi Drew,

I suspect it's due to this change in MS2Quant:

https://github.com/kruvelab/MS2Quant/commit/eb2bc0e1c191986fd9ff06daec6943eea6b63d39#diff-1914f62e1613797775065e47b0f506b7c62d4bc06fbb20ffd41707361d433209L1080 (there is a similar change a bit below)

With patRoon the fingerprints variable is a data.frame and comparing this with an empty string will result in an error with recent R versions (I believe since 4.3). I'm not sure why this line was changed. Perhaps it could be changed to

if ((is.character(fingerprints) && fingerprints != "") || (is.data.frame(fingerprints) && nrow(fingerprints) > 0)
   ...

In this case we avoid for empty strings if fingeprints is a string and empty dataframes if fingerprints is a dataframe.

Thanks, Rick

drewszabo commented 7 months ago

That was it! Thank you for the help. Ill push the edit to the MS2Quant repo as soon as possible to restore the patRoon functionality :)