lgatto / MSnbase

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

removing non-proteotypic peptide #585

Open ibphuangchen opened 2 years ago

ibphuangchen commented 2 years 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?