-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add filterSpectra function (issue #41) #42
Conversation
- Add a `filterSpectra` method that allows to filter the `Spectra` within an `MsExperiment` updating eventually present relationships (links) between samples and spectra.
#' If @spectra got filtered eventually present *links* between them and samples | ||
#' will no longer be valid and need to be updated/fixed. This function | ||
#' consolidates these links using a spectra variable `"._SPECTRA_IDX"` in | ||
#' `@spectra` that needs to represent/contain the index of the spectra |
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.
So this ._SPECTRA_IDX
variable already existed before this update ?
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.
Ah, no. but very good question! I specifically add this variable before I call the filter function on the Spectra
object. That's the only way (at least that I found) how I can now to which spectra the data was filtered. So, the workflow is:
- add the spectra variable
._SPECTRA_IDX
to theSpectra
containing the index 1:length spectra (I chose this name for the spectra variable to not overwrite any potentially existing spectra variable with the same name - unlikely that somebody will call a spectra variable with this name - at least I assume) - filter the
Spectra
object - after filtering I need to update/consolidate the link (mapping) between samples and
Spectra
(which is stored in the@sampleDataLinks[["spectra"]]
- it contains a two column matrix, the first with the index of the sample, the second with the index of the spectrum assigned to this sample). I can use the._SPECTRA_IDX
variable for that, because this got also subset (along with theSpectra
object). So, I need to only keep rows in the above mapping matrix with the spectrum index (second column) present in._SPECTRA_IDX
. - after that I remove the
._SPECTRA_IDX
spectra variable again, because it's not needed anymore.
let me know if something is still unclear.
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 me this looks great, I think it's a really nice method to have ! thanks
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.
General/design questions:
- why not using the actual Spectra filtering functions such as
filterRt()
... on anMsExperiment
object, rather that having a generalfilterSpectra()
method? - why not (also) offer
filterSpectra()
forSpectra
objects?
NEWS.md
Outdated
## MsExperiment 1.5.3 | ||
|
||
- Add `filterSpectra` method to allow filtering of `Spectra` within an | ||
`MsExperiment` while keeping eventually present relationships between samples |
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.
... while keeping possibly present relationships between samples ...
R/MsExperiment.R
Outdated
#' - `filterSpectra`: subsets the `Spectra` within an `MsExperiment` using a | ||
#' provided filter function (parameter `filter`). Parameters for the filter | ||
#' function can be passed with parameter `...`. Any of the filter functions | ||
#' of a [Spectra()] object can be passed with parameter `filter`. Eventually |
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.
Possibly, not eventually.
R/MsExperiment.R
Outdated
#' @rdname MsExperiment | ||
#' | ||
#' @export | ||
setGeneric("filterSpectra", def = function(object, filter, ...) |
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.
Why not in ProtGenerics? See general discussion point.
Thanks for the review @lgatto ! Regarding the discussion points:
Totally agree - we should add it there.
We had a discussion on that in issue #30 - I thought the conclusion from that was that we do not want to have these general filter functions for Also, this function would avoid having actual implementations of e.g. We could even have other implementations of So, summarizing:
happy to discuss further |
Thank you!
|
A, yes,
work on |
Yes, fine by me - thank you. Please just change the eventually to possibly in the man page. |
- Import `filterSpectra` from `ProtGenerics`. - Address Laurent's review comments.
R/MsExperiment-functions.R
Outdated
#' | ||
#' @description | ||
#' | ||
#' If @spectra got filtered eventually present *links* between them and samples |
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.
I missed this one: eventually -> possibly.
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.
replaced now all "eventually" with "possibly". thanks!
filterSpectra
method that allows to filter theSpectra
within anMsExperiment
updating eventually present relationships (links) between samples and spectra.