forked from satijalab/seurat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvenience.R
71 lines (62 loc) · 1.97 KB
/
convenience.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#' @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, ...) {
name <- as.character(x = sys.calls()[[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)
return(do.call(what = 'DimPlot', args = args))
}