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

plotStudy and getPlottingData functions accept parameter testID. #4

Merged
merged 7 commits into from
Aug 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#' @seealso \code{\link{addPlots}}, \code{\link{getPlottingData}}
#'
#' @export
plotStudy <- function(study, modelID, featureID, plotID, libraries = NULL) {
plotStudy <- function(study, modelID, featureID, plotID, testID = NULL, libraries = NULL) {
stopifnot(
is.character(modelID),
is.character(featureID),
is.character(plotID),
# is.character(testID),
curadomr marked this conversation as resolved.
Show resolved Hide resolved
is.null(libraries) || is.character(libraries)
)

Expand Down Expand Up @@ -49,7 +50,7 @@ plotStudy <- function(study, modelID, featureID, plotID, libraries = NULL) {
)
}

plottingData <- getPlottingData(study, modelID, featureID,
plottingData <- getPlottingData(study, modelID, featureID, testID = testID,
libraries = libraries)

# Setup for the plot and ensure everything is properly reset after the
Expand Down Expand Up @@ -139,10 +140,11 @@ resetSearch <- function(pkgNamespaces) {
#' @seealso \code{\link{addPlots}}, \code{\link{plotStudy}}
#'
#' @export
getPlottingData <- function(study, modelID, featureID, libraries = NULL) {
getPlottingData <- function(study, modelID, featureID, testID, libraries = NULL) {
curadomr marked this conversation as resolved.
Show resolved Hide resolved
stopifnot(
is.character(modelID),
is.character(featureID),
# is.character(testID),
curadomr marked this conversation as resolved.
Show resolved Hide resolved
is.null(libraries) || is.character(libraries)
)
# Deduplicate the featureIDs
Expand Down Expand Up @@ -186,10 +188,26 @@ getPlottingData <- function(study, modelID, featureID, libraries = NULL) {
row.names(featuresPlotting) <- NULL # reset row numbers after filtering
}

if (!isEmpty(testID)) {
results <- getResults(study, modelID = modelID, testID = testID, quiet = TRUE,
libraries = libraries)
if (isEmpty(results)) {
stop(sprintf("The test result (testID) \"%s\" is not available for modelID \"%s\" ", testID, modelID))
}
featureIDAvailable_results <- featureID %in% results[,1]
if (any(!featureIDAvailable_results)) {
stop(sprintf("The feature \"%s\" is not available for testID \"%s\"",
featureID[!featureIDAvailable][1], testID))
}
resultsPlotting <- results[match(featureID, results[,1], nomatch = 0), , drop = FALSE]
}

plottingData <- list(
assays = assaysPlotting,
samples = samplesPlotting,
features = featuresPlotting
)
if (!isEmpty(testID)) plottingData <- c(plottingData, list(results = resultsPlotting))

return(plottingData)
}