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

Support chunk-wise processing in containsMz #341

Merged
merged 5 commits into from
Nov 21, 2024
Merged

Support chunk-wise processing in containsMz #341

merged 5 commits into from
Nov 21, 2024

Conversation

jorainer
Copy link
Member

Refactor containsMz() to support chunk-wise processing.

@jorainer jorainer requested a review from philouail November 20, 2024 09:36
Copy link
Collaborator

@philouail philouail left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any changes to suggest but I'm a bit confused by the different functions.
See my comment

if (length(object)) {
cond_fun <- match.fun(match.arg(which))
if (all(is.na(mz)))
return(rep(NA, length(object)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused, when do you use this function containsMz() exactly ? I saw the definition in the documentation but i've never had to use it before I think, so i'm not sure of the context where its usefull.

About this line of code above: Why would the variable mz be full of NA ?

Also the .has_mz_each() is not used here ? i'm a bit confused by the difference between .has_mz_each() and .peaks_contains_mz(), don't they both compare the mz() of a Spectra object to a numeric vector made of m/z values ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in fact both do. I need to replace/remove also the .has_mz_each() function, but that will involve some bigger changes.

The .has_mz_each() and .has_mz() are old functions that simply run the code on all m/z values, without the possibility of chunk-wise processing or similar. This PR removes/replaces the .has_mz() function. I will then later also remove the other one. The difference between the two was: .has_mz() checks for presence of the same provided mz values in the m/z values of all spectra, while .has_mz_each() allowed to specify an individual (single!) mz value to check in a spectrum. Example: .has_mz(sps, mz = c(123.3, 234.12)) would check if any of the spectra have either an m/z value of 123.3 or 234.12. .has_mz_each(sps, mz = c(1, 2, 3, 4, 5)) checks if the first spectrum contains a 1, the second a 2 and so on - with the requirement length(sps) == length(mz).

@jorainer jorainer merged commit 0deee7b into main Nov 21, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants