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

Error in addFragments when calling multiple Spectra objects #18

Open
guideflandre opened this issue Jan 9, 2025 · 1 comment
Open

Comments

@guideflandre
Copy link
Contributor

guideflandre commented Jan 9, 2025

In addFragments, an error is thrown when the length of x, the Spectra object, is higher than 1:

addFragments <- function (x, tolerance = 0, ppm = 20, ...) {
    stopifnot(requireNamespace("Spectra"))
    stopifnot(inherits(x, "Spectra"), length(x) == 1)

This in itself is not a problem, but when combining with plotSpectra these different cases occur:

## Code works and plot is given with default parameters for `calculateFragments`
plotSpectra(sc[1:4], labels = addFragments)

## throws an error in addFragments, argument x is missing with no default
plotSpectra(sc[1:4], labels = addFragments(type = c("a"))) 

## thus needs to call the spectra object explicitly with the custom parameters but..
## this throws an error in `addFragments` as length(x) != 1 (see above)
plotSpectra(sc[1:4], labels = addFragments(sc[1:4], type = c("a"))) 

In short, plotSpectra coupled to addFragments only works with its default parameters. If these parameters are changed, this can only be done on 1 spectrum at a time and not multiple.

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

1 participant