-
Notifications
You must be signed in to change notification settings - Fork 16
/
generics.R
76 lines (56 loc) · 2.38 KB
/
generics.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
72
73
74
75
76
#' @title Gets contingency table
#' @description Creates a cross table using two columns from the metadata
#' @param object \code{Seurat} object
#' @param true Column name in \code{meta.data} slot that corresponds to the true known classes
#' @param pred Column name in \code{meta.data} slot that corresponds to the predicted classes
#' if they have been assigned independently from the \code{scPredict()} function
#' @param output Return counts, fraction, or proportions? Default: counts
#' @param digits If proportions are returned, number of digits to round numbers
#' @return A contingency table
#' @export
#' @author Jose Alquicira Hernandez
#'
setGeneric("crossTab", def = function(object, true = NULL, pred = NULL, output = c("counts", "fraction", "prop"), digits = 2) {
standardGeneric("crossTab")
})
#' @title Get scPred object
#' @description Accessor function to retrieve scPred models from Seurat objects
#' @param object Seurat object
#' @return scPred object
#' @export
setGeneric("get_scpred", def = function(object) {
standardGeneric("get_scpred")
})
#' @title Get classification models
#' @description Accessor function to retrieve classification models from Seurat
#' and scPred objects
#' @param object \code{Seurat} or scPred object
#' @return A list of \code{train} objects
setGeneric("get_classifiers", def = function(object) {
standardGeneric("get_classifiers")
})
#' @title Plot training probabilities
#' @description Plots all training probabilities for each cell type
#' @param object Seurat or scPred object
#' @param size Point size for each cell
#' @export
#' @return Plot with the probability distribution for each cell type
setGeneric("plot_probabilities", def = function(object, size = 0.8) {
standardGeneric("plot_probabilities")
})
#' @title Get training probabilities
#' @description Gets training probabilities for each cell type
#' @param object Seurat or scPred object
#' @export
#' @return A data frame with all cell-type probabilities associated to each cell
setGeneric("get_probabilities", def = function(object) {
standardGeneric("get_probabilities")
})
#' @title Get metadata from scPred object
#' @description Accessor function to retrieve metadata from scPred object
#' @return A dataframe including the cell barcodes and prediction variable
#' (cell type labels)
#' @export
setGeneric("get_metadata", def = function(object) {
standardGeneric("get_metadata")
})