convenience.R
#' @include generics.R
#' @include visualization.R
#'
NULL
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Functions
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#' @param ... Extra parameters passed to \code{DimHeatmap}
#'
#' @rdname DimHeatmap
#' @export
#'
PCHeatmap <- function(object, ...) {
args <- list('object' = object)
args <- c(args, list(...))
args$reduction <- "pca"
return(do.call(what = 'DimHeatmap', args = args))
}
#' @rdname DimPlot
#' @export
#'
PCAPlot <- function(object, ...) {
return(SpecificDimPlot(object = object, ...))
}
#' @rdname DimPlot
#' @export
#'
TSNEPlot <- function(object, ...) {
return(SpecificDimPlot(object = object, ...))
}
#' @rdname DimPlot
#' @export
#'
UMAPPlot <- function(object, ...) {
return(SpecificDimPlot(object = object, ...))
}
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Methods for Seurat-defined generics
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Methods for R-defined generics
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Internal
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# @rdname DimPlot
#
SpecificDimPlot <- function(object, ...) {
funs <- sys.calls()
name <- as.character(x = funs[[length(x = funs) - 1]])[1]
name <- tolower(x = gsub(pattern = 'Plot', replacement = '', x = name))
args <- list('object' = object)
args <- c(args, list(...))
reduc <- grep(
pattern = name,
x = names(x = object),
value = TRUE,
ignore.case = TRUE
)
reduc <- grep(pattern = DefaultAssay(object = object), x = reduc, value = TRUE)
args$reduction <- ifelse(test = length(x = reduc) == 1, yes = reduc, no = name)
tryCatch(
expr = return(do.call(what = 'DimPlot', args = args)),
error = function(e) {
stop(e)
}
)
}