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

add entropy functions #309

Merged
merged 5 commits into from
Jan 30, 2024
Merged

add entropy functions #309

merged 5 commits into from
Jan 30, 2024

Conversation

mar-garcia
Copy link
Contributor

@jorainer, I've tried to follow your suggestions...
Not sure if I've understood everything 100%, but let's try to star with what I've done here :)
Let me know if I should proceed in another way, change anything, etc..
Thanks!!

Copy link
Member

@jorainer jorainer left a comment

Choose a reason for hiding this comment

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

Thanks Mar for the PR!

I have some change requests and I would also ask you to add yourself as a contributor to the DESCRIPTION (similar to https://github.com/rformassspectrometry/MsCoreUtils/blob/main/DESCRIPTION), to also increase the version in DESCRIPTION to 1.13.4 and to also add an entry to the NEWS file mentioning that you added the entropy method.

R/Spectra.R Outdated
#'
#' @importFrom MsCoreUtils entropy
setMethod("entropy", "Spectra", function(object, normalized = TRUE) {
if (length(object))
Copy link
Member

Choose a reason for hiding this comment

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

for normalize == TRUE we would need to call nentropy, for normalized = FALSE entropy - I would suggest to add something like:

if (normalized) entropy_fun <- nentropy
else entropy_fun <- entropy
unlist(.peaksapply(
    object, FUN = function(pks, ...) entropy_fun(pks[, "intensity"])), 
    use.names = FALSE
))

ah, and please remove the na.rm = TRUE since the entropy function does not support that.

R/Spectra.R Outdated

#' @rdname Spectra
#'
#' @importFrom MsCoreUtils entropy
Copy link
Member

Choose a reason for hiding this comment

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

here import both, entropy and nentropy

@jorainer jorainer self-requested a review January 30, 2024 09:01
@jorainer
Copy link
Member

Thanks Mar @mar-garcia for this contribution! I'll merge and fix the missing NAMESPACE entry.

@jorainer jorainer merged commit 8eaa18c into rformassspectrometry:main Jan 30, 2024
0 of 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.

2 participants