-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Thanks Mar @mar-garcia for this contribution! I'll merge and fix the missing NAMESPACE entry. |
@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!!