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

findIsotopes throws "Error in mint[ipeak, , drop = FALSE] : subscript out of bounds #57

Open jmorim opened 4 years ago

jmorim commented 4 years ago

Happens when I tried processing a single data file. The other annotation functions work except this one. CAMERA version 1.44.0. Debugging shows ipeak is a list from 1947:1963, when the mint matrix only has length 1843.

jmorim commented 4 years ago

Seems to be an issue with https://github.com/sneumann/CAMERA/blob/0ff0ebf7a9de2adb18e51ccf6fc278b391a40906/R/xsAnnotate.R#L609-L627

A single file doesn't trigger the else condition, is if(nrow(groups(object@xcmsSet)) > 0) supposed to be if(length(object@xcmsSet@filepaths) > 1)? It seems the point is to tell whether or not the dataset is a single file.

sneumann commented 4 years ago

The nrow(groups(object@xcmsSet)) > 0 checks if group() had been called before. Best thing to get this right would be unit tests for all combinations of 1) one 2) multiple files a) grouped b) not grouped (where 1a probably does not exist). Yours, Steffen

jmorim commented 4 years ago

I don't understand why 1a wouldn't exist since grouping in xcms groups within samples according to the docs. I'm also stuck on why groupval(object@xcmsSet) returns a shorter list than the number of peaks in all pspectra, length(unlist(object@pspectra)) for a single file, but not multiple.

For now I'm changing https://github.com/sneumann/CAMERA/blob/0ff0ebf7a9de2adb18e51ccf6fc278b391a40906/R/xsAnnotate.R#L610 to if(nrow(groups(object@xcmsSet)) > 0 && length(object@sample) > 1){...