lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

removing non-proteotypic peptide #585

Open ibphuangchen opened 1 year ago

ibphuangchen commented 1 year ago

Hi @lgatto ,

I felt that the code used to remove non-proteotypic peptide might not work as expected:

keep <- tapply(x[, accession], x[, spectrumID], function(xx) length(unique(xx))) == 1
x <- x[keep, ]
n3 <- nrow(x)

I found this out when I was debugging my issues. length(keep) might not be the same with nrow(x). Probably what you mean is:

keep <- tapply(x[, accession], x[, spectrumID], function(xx) length(unique(xx))) == 1
x <- x[x[,spectrumID] %in% names(keep)[keep],]
n3 <- nrow(x)

Is that right?