sneumann / CAMERA

This is the git repository matching the Bioconductor package CAMERA: Collection of annotation related methods for mass spectrometry data
11 stars 22 forks source link

Possible bug in `findIsotopesWithValidation` #56

Open breidan opened 4 years ago

breidan commented 4 years ago

Running findIsotopesWithValidation on a xsAnnotate object it throws the error: Fehler in if (!isotopeProportionFits) { : Fehlender Wert, wo TRUE/FALSE nötig ist (sorry German locale :-)) I believe the reason is that object@xcmsSet@peaks contains NAs in the sn column. This leads to snValues of NA which subsequently in function findIsotopesForPS causes isotopeProportionFits to be assigned a NA instead of a TRUE/FALSE. A solution could be to set na.rm=TRUE for the median which calculates snValues for the different groups. Just like it is done for the calculation of intValues.

Cheers

sneumann commented 4 years ago

Hi, thanks for reporting. I might vaguely recall that NA indeed causes issues, maybe there should've been a proper error message to run fillPeaks. Yours, Steffen

breidan commented 4 years ago

Hi Steffen, because I had applied fillPeaks to my xcmsSet I investigated a bit further and am certain now that it is a bug.

findIsotopesWithValidation assigns intValues with a median(...,na.rm=TRUE) from groupval(object@xcmsSet). Then it assigns snValues with a median(...) with the default na.rm=FALSE from object@xcmsSet@peaks. Downstream the division of intValues/snValues defines the value of isotopeProportionFits.

I am investigating FTMS data which inherently might have empty scan regions where fillPeaks even with the most relaxed settings will not find peaks. That will generate NAs in the sn column of xcmsSet@peaks but remove all NAs in groupval(object@xcmsSet).

So I am between a rock and a hard place now: run fillPeaks, introduce NAs in the sn column and findIsotopesWithValidation will fail. Or don't run fillPeaks, no NAs in sn but groupval(object@xcmsSet) with only NAs in some groups. That will return an NA in intValues and also make findIsotopesWithValidation fail.

Setting median(..., na.rm = TRUE) for the assignment of snValues will resolve this for all cases where there is at least one sn value in a group. And it certainly works for my data.

EDIT: I just realized that I had set object@sample to a certain single sample index. If set to the default NA findIsotopesWithValidation will run through with my data set if I DO NOT run fillPeaks over my data.