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
Show file tree
Hide file tree
Changes from 5 commits
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
29 changes: 26 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.null(testID) || is.character(testID),
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 @@ -136,13 +137,19 @@ resetSearch <- function(pkgNamespaces) {
#' rows are reordered to match the order of this input (and thus match the order
#' of the assays data frame).}
#'
#' \item{\code{results}}{A data frame that contains the test results,
#' filtered to only include the row(s) corresponding to the input featureID(s).
#' If multiple featureIDs are requested, the rows are reordered to match the
#' order of this input. The column order is unchanged.}
#'
#' @seealso \code{\link{addPlots}}, \code{\link{plotStudy}}
#'
#' @export
getPlottingData <- function(study, modelID, featureID, libraries = NULL) {
getPlottingData <- function(study, modelID, featureID, testID = NULL, libraries = NULL) {
stopifnot(
is.character(modelID),
is.character(featureID),
is.null(testID) || is.character(testID),
is.null(libraries) || is.character(libraries)
)
# Deduplicate the featureIDs
Expand Down Expand Up @@ -186,10 +193,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)
}
9 changes: 8 additions & 1 deletion man/getPlottingData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/plotStudy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.