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

filterMatches, ScoreThresholdParam #87

Merged
merged 3 commits into from Sep 5, 2022
Merged

filterMatches, ScoreThresholdParam #87

merged 3 commits into from Sep 5, 2022

Conversation

andreavicini
Copy link
Collaborator

filterMatches, ScoreThresholdParam to perform filtering the matches based on a threshold for the "score" variable. Also filtering based on "score_rt" is possible with filterScoreRt = TRUE (not sure if that's the best way or, for example, we could also use a parameter scorename with the name of the score the filtering will use and default value "score"?)

Merge branch 'master' into andrea

# Conflicts:
#	R/Matched.R
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.

Very nice Andrea! I have however one request: maybe better to use a slot/parameter column instead of filterScoreRt that allows to specify the column in @matches which should be used for the filtering. That would be more flexible and would allow us in future also to use this param even if we add additional (different) score columns.

@@ -148,6 +156,10 @@
#' - `whichQuery` returns an `integer` with the indices of the elements in
#' *query* that match at least one element in *target*.
#'
#' @param above for `ScoreThresholdParam` : `logical(1)` specifying whether
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be good to describe whether above (or below) means > or >=.

R/Matched.R Outdated
@@ -156,6 +168,12 @@
#' `decreasing = FALSE`.
#'
#' @param drop for `[`: ignored.
#'
#' @param filterScoreRt for `ScoreThresholdParam` : `logical(1)` specifying
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to replace this parameter with a parameter column = "score" which allows to define the column in the matches data.frame that should be used for the filtering. That would allow us also to use this param later for other columns (scores) we might add.

R/Matched.R Outdated
slots = c(
threshold = "numeric",
above = "logical",
filterScoreRt = "logical"),
Copy link
Member

Choose a reason for hiding this comment

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

as described above, I would replace this slot with column that has as default "score".

R/Matched.R Outdated
#' @export
setMethod("filterMatches", c("Matched", "ScoreThresholdParam"),
function (object, param, ...) {
scorename <- ifelse(param@filterScoreRt, "score_rt", "score")
Copy link
Member

Choose a reason for hiding this comment

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

After changing to column you would need to check if the @matches has a column called column and throw an error otherwise.

@andreavicini
Copy link
Collaborator Author

I agree with you and I should have updated accordingly. I was not sure if the user would know the name of the "score variables" available in a object. Maybe we could return such names with a simple function (assuming they are the names in object@matches excluding query_idx and target_idx)? or maybe they could also read directly from colnames(object) (but that includes also variables that are not in object@matches).

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.

Great Andrea! I will merge and push to BioC.

@jorainer jorainer merged commit ed91207 into master Sep 5, 2022
@jorainer
Copy link
Member

jorainer commented Sep 5, 2022

@andreavicini , regarding your question with the function to return score column names - I think that's a great idea! Question is just how to name that function - should it be matchedVariables or scoreVariables? Happy to discuss.

@andreavicini
Copy link
Collaborator Author

andreavicini commented Sep 6, 2022

@jorainer, I'm fine with both or could also be matchesVariables. Do you think there would be use cases when object@matches contain a column that is not a score?

@jorainer
Copy link
Member

jorainer commented Sep 6, 2022

Hm, yes, I think we do also add other information into the @matches, such as the adduct (if I'm not wrong). So, from matchedVariables I would expect to get all variables that are present in the matchedData data frame (same as for spectraVariables and spectraData). So, I would be maybe a little in favour of scoreVariables, but can also be convinced for other choices.

@andreavicini
Copy link
Collaborator Author

Yes, you are right about the adduct columns (don't know why I didn't think of that 😅). But now I'm thinking: if we want a function that returns only score columns in @matches how do we extract those? Maybe we cannot assume that they are always called "score" and "score_rt" or can we? Or maybe we can just have matchesValues return all column names in @matches (except query_idx and target_idx) and write in the documentation that the user should use score variables for filterMatches, ScoreThresholdParam?

@andreavicini
Copy link
Collaborator Author

Unrelated question: do you think it would ever be helpful to filter based on character variables in @matches such as adducts?

@jorainer
Copy link
Member

jorainer commented Sep 8, 2022

For the former, we could have a simple grep that searches for column names in matches that contain "score" and return these with the scoreVariables.

For the second question, yes, I think it would be helpful to filter also based on e.g. "adduct" or other character columns.

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.

None yet

2 participants