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
Bug in filterMz #184
Comments
Note that this came up while looking into a |
Following up here - an empty spectra is not valid anymore! > sp <- im[[1]]
> empty_sp <- filterMz(sp, mz = c(1005, 1006))
Warning message:
In trimMz_Spectrum(object, mzlim = mz, msLevel. = msLevel., ...) :
No data points between 1005 and 1006 for spectrum with acquisition
number 1. Returning empty spectrum.
> empty_sp
Object of class "Spectrum1"
Retention time: 4:30
MSn level: 1
Total ion count:
Polarity: 0
> validObject(empty_sp)
Error in if (length(mz(object)) != peaksCount(object)) msg <- validMsg(msg, :
argument is of length zero |
This above is now fixed in d1c7e07 Another issue is that setMethod("filterMz", "Spectrum",
function(object, mz, msLevel., ...) {
return(trimMz_Spectrum(object, mzlim = mz,
msLevel. = msLevel., ...))
}) didn't check that @sgibb @jotsetung - should we add a call to |
Note also that > peaksCount(empty_sp)
integer(0) but > peaksCount(new("Spectrum1"))
[1] 0 This is not very consistent. Should we change that an empty spectrum has a peaks count of 0? @sgibb @jotsetung |
Regarding the Regarding |
Could you clarify? |
Whenever .validSpectrum <- function(object) {
msg <- validMsg(NULL, NULL)
if (any(is.na(intensity(object))))
msg <- validMsg(msg, "'NA' intensities found.")
if (any(is.na(mz(object))))
msg <- validMsg(msg, "'NA' M/Z found.")
if (any(intensity(object) < 0))
msg <- validMsg(msg, "Negative intensities found.")
if (any(mz(object)<0))
msg <- validMsg(msg, "Negative M/Z found.")
if (length(object@mz) != length(object@intensity))
msg <- validMsg(msg, "Unequal number of MZ and intensity values.")
if (length(mz(object)) != peaksCount(object))
msg <- validMsg(msg, "Peaks count does not match up with number of MZ values.")
if (any(diff(mz(object)) < 0))
msg <- validMsg(msg, "MZ values are out of order.")
if (is.null(msg)) TRUE
else stop(msg)
} which can be also added to the ...
mz = numeric(),
intensity = numeric()),
validity = .validSpectrum
}) and which is called directly whenever a faster validation is required (i.e. Benchmarking for this: sp1 <- new("Spectrum1")
microbenchmark(validObject(sp1), .validSpectrum(sp1))
Unit: microseconds
expr min lq mean median uq max neval
validObject(sp1) 510.942 558.6075 594.44723 568.1550 584.061 975.295 100
.validSpectrum(sp1) 25.774 29.3020 33.62809 31.8005 33.299 93.858 100
cld
b
a
|
Done in 1381fcc |
@jotsetung - is your |
actually, |
Ah yes, I was not paying attention. So may be there could be a |
If, in the validity = function(object) validSpectrum(object) we should end up with the validity defined in |
Yes. I think it's even enough to just say |
I have it ready, testing right now. You can take over if you want. Just name it |
No prob, let's use your implementation. |
Done |
So I'll not implement it as you already did. |
o Accessing slots directly. o Using is.unsorted instead of any(diff(mz) < 0) o related to issue #184.
Small modification: mz <- abs(rnorm(5000, sd = 4))
int <- abs(rnorm(5000, sd = 3, mean = 1000))
sp1 <- new("Spectrum1", mz = mz, intensity = int)
microbenchmark(any(diff(sp1@mz) < 0), is.unsorted(sp1@mz))
Unit: microseconds
expr min lq mean median uq max neval
any(diff(sp1@mz) < 0) 79.970 95.7015 157.13452 173.8415 182.5305 746.460 100
is.unsorted(sp1@mz) 17.496 18.0430 19.66587 18.7865 20.4275 51.865 100
cld
b
a |
On disk works
But note that this will lead to only empty spectra and that, at this stage, nothing has happened, as the filtering is recorded but not applied.
But in memory fails
I haven't done any additional, more extensive testing so far.
The text was updated successfully, but these errors were encountered: