Vitek-Lab / MSstats

R package - MSstats
74 stars 46 forks source link

Failure of MaxQtoMSstatsFormat when fewMeasurements = "remove" and there are no rows to remove #41

Closed bpolacco closed 3 years ago

bpolacco commented 4 years ago

One more thing I found while investigating #40, here's a bug I found which only occurs when fewMeasurements = "remove" and there are no rows that should be removed. This was a side effect of #40 , all what would have been NA were replaced with low numbers, so there were no missing values. See line 419 below

    x <- x[-which(x$Feature %in% remove_feature_name$Feature), ]

When the which() statement returns an empty vector, you get x[-c(),] which selects no rows instead of the intended all rows except those inside c(). Recoding this with a boolean index instead of the -which() would fix this rare-to-occur bug.

    x <- x[!(x$Feature %in% remove_feature_name$Feature), ]
mstaniak commented 3 years ago

please let us know if the problem persists after an update, closing the issue for now