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

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

Open
jmorim opened this issue Jun 13, 2020 · 3 comments

Comments

@jmorim
Copy link
Contributor

jmorim commented Jun 13, 2020

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
Copy link
Contributor Author

jmorim commented Jun 13, 2020

Seems to be an issue with

CAMERA/R/xsAnnotate.R

Lines 609 to 627 in 0ff0ebf

# get mz,rt and intensity values from peaktable
if(nrow(groups(object@xcmsSet)) > 0){
##multiple sample or grouped single sample
if(is.na(object@sample[1])){
index <- 1:length(object@xcmsSet@filepaths);
}else{
index <- object@sample;
}
cat("Generating peak matrix!\n");
mint <- groupval(object@xcmsSet,value=intval)[,index,drop=FALSE];
imz <- object@groupInfo[, "mz", drop=FALSE];
irt <- object@groupInfo[, "rt", drop=FALSE];
}else{
##one sample case
cat("Generating peak matrix!\n");
imz <- object@groupInfo[, "mz", drop=FALSE];
irt <- object@groupInfo[, "rt", drop=FALSE];
mint <- object@groupInfo[, intval, drop=FALSE];
}

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
Copy link
Owner

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
Copy link
Contributor Author

jmorim commented Jul 7, 2020

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

if(nrow(groups(object@xcmsSet)) > 0){

to
if(nrow(groups(object@xcmsSet)) > 0 && length(object@sample) > 1){...

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