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

Updating plots.R for multi_mapping #12

Merged
merged 6 commits into from Sep 23, 2022

Conversation

curadomr
Copy link
Contributor

  • if one single mapping is provided, it should be called 'defaults'
  • if > 1 mapping object is provided, it should be named after a model name (as provided in addModels()). For such cases, when having modelID as a vector of models in plotStudy call (or getPlottingData), modelID[1] is picked as the name for the mapping object.

- if one single mapping is provided, it should be called 'defaults'
- if > 1 mapping object is provided, it should be named after a model name (as provided in addModels()). For such cases, by having modelID as a vector of models modelID[1] is picked as the name for the mapping object.
@jdblischak jdblischak self-requested a review September 16, 2022 14:11
R/plots.R Outdated
@@ -207,20 +207,31 @@ resetSearch <- function(pkgNamespaces) {
getMappingPlottingData <- function(study = study, modelID = modelID, featureID = featureID, testID = testID, libraries = NULL) {
mapping <- getMapping(study, libraries = libraries)

# stop if mapping object contains only one element and is not called "defaults"
Copy link
Contributor

Choose a reason for hiding this comment

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

Conclusion from our Slack discussion: let's switch to consistently using modelID = "default", and not make it a hard requirement that a single mapping table be named "default" (this is recommended, but it's hard to predict future use cases)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correcting message from 1st commit below, first bullet point:

  • study obj accepts multiple mappings. For one single element, it may be called whatever user wants it to be named (but in description of addMapping, it recommends being 'default'). Other mapping list elements must be named after modelIDs.

- accepts one single element, whatever it may be named (but in description of addMapping, it recommends being 'default')
- It only accepts one mapping list element NOT named after modelIDs (e.g., 'default')
- modelID[1] passed through plotStudy is the reference for multimapping calls. If a modelID[1] is available among mapping list element names, this mapping element will be used in the call. If not, but a 'default' mapping is available, this is used instead. If not and no 'default' is available, return().
- checkResults and checkEnrichment were modified from 'defaults' to 'default'. testCheck was updated to include checking on those error messages.
if ("defaults" %in% names(results)) {
stop("The results cannot be shared using the modelID \"defaults\"")
if ("default" %in% names(results)) {
stop("The results cannot be shared using the modelID \"default\"")
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this!

expect_error_xl(
addResults(study, results = resultsDefault),
'The results cannot be shared using the modelID \"default\"'
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Great test!

R/plots.R Outdated
mapping_name <- modelID[1]
} else {
return()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

For the above code, is there a reason you can't do something like the following?

mapping <- getMapping(study, modelID = modelID, libraries = libraries)

In other words, can we offload the logic of testing for valid modelIDs and the presence of a "default" option to getMapping()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I got the point correctly, this statement below:

mapping_name <- names(mapping)[!names(mapping) %in% modelID]

gets whatever mapping name that is not in modelID. Mapping name "default" is recommended only in the documentation of addMapping, but user can call it whatever (s)he wants. Still, I am requesting the mapping list element to be named. Is that the issue, i.e., whether user can't simply provide a mapping with no name?

@jdblischak
Copy link
Contributor

Also, don't forget to replace "defaults" with "default" for your mapping object tests:

names(mapping) <- "defaults"

names(tempMapping) <- "defaults"

- requires mapping list elements to be named either as 'default' or a model name. This is checked in validate.R, and enforced by getElements()
- Textual adaptations in addMapping()
Copy link
Contributor

@jdblischak jdblischak left a comment

Choose a reason for hiding this comment

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

Great work @curadomr!

@jdblischak jdblischak merged commit 93b394e into abbvie-external:main Sep 23, 2022
@jdblischak
Copy link
Contributor

Added NEWS bullet in ca0f35e to summarize the final behavior of this PR:

  • Update mapping data to behave in the same way as the features, samples, etc.
    Each element of the list must be named after a modelID or "default" to be shared
    across multiple modelIDs

jdblischak added a commit that referenced this pull request Nov 11, 2022
@curadomr curadomr deleted the multimodel_multimapping branch June 12, 2023 07:29
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