Browse code

update docs

zhewa authored on 21/05/2020 09:04:10
Showing 37 changed files

... ...
@@ -1,16 +1,18 @@
1 1
 # Generated by roxygen2: do not edit by hand
2 2
 
3
-export("clusters<-")
3
+export("celdaClusters<-")
4
+export("celdaModules<-")
4 5
 export("decontXcounts<-")
5
-export("modules<-")
6 6
 export("sampleLabel<-")
7 7
 export(appendCeldaList)
8 8
 export(availableModels)
9 9
 export(bestLogLikelihood)
10 10
 export(celda)
11
+export(celdaClusters)
11 12
 export(celdaGridSearch)
12 13
 export(celdaHeatmap)
13 14
 export(celdaModel)
15
+export(celdaModules)
14 16
 export(celdaPerplexity)
15 17
 export(celdaProbabilityMap)
16 18
 export(celdaTsne)
... ...
@@ -20,7 +22,6 @@ export(celda_CG)
20 22
 export(celda_G)
21 23
 export(celdatosce)
22 24
 export(clusterProbability)
23
-export(clusters)
24 25
 export(compareCountMatrix)
25 26
 export(countChecksum)
26 27
 export(decontX)
... ...
@@ -37,7 +38,6 @@ export(logLikelihood)
37 38
 export(logLikelihoodHistory)
38 39
 export(matrixNames)
39 40
 export(moduleHeatmap)
40
-export(modules)
41 41
 export(normalizeCounts)
42 42
 export(params)
43 43
 export(perplexity)
... ...
@@ -50,9 +50,6 @@ export(plotDimReduceFeature)
50 50
 export(plotDimReduceGrid)
51 51
 export(plotDimReduceModule)
52 52
 export(plotGridSearchPerplexity)
53
-export(plotGridSearchPerplexitycelda_C)
54
-export(plotGridSearchPerplexitycelda_CG)
55
-export(plotGridSearchPerplexitycelda_G)
56 53
 export(plotHeatmap)
57 54
 export(plotMarkerDendro)
58 55
 export(plotMarkerHeatmap)
... ...
@@ -70,14 +67,16 @@ export(simulateCells)
70 67
 export(simulateContamination)
71 68
 export(subsetCeldaList)
72 69
 export(topRank)
73
-exportMethods("clusters<-")
70
+exportMethods("celdaClusters<-")
71
+exportMethods("celdaModules<-")
74 72
 exportMethods("decontXcounts<-")
75
-exportMethods("modules<-")
76 73
 exportMethods("sampleLabel<-")
77 74
 exportMethods(bestLogLikelihood)
75
+exportMethods(celdaClusters)
78 76
 exportMethods(celdaGridSearch)
79 77
 exportMethods(celdaHeatmap)
80 78
 exportMethods(celdaModel)
79
+exportMethods(celdaModules)
81 80
 exportMethods(celdaPerplexity)
82 81
 exportMethods(celdaProbabilityMap)
83 82
 exportMethods(celdaTsne)
... ...
@@ -87,19 +86,30 @@ exportMethods(celda_CG)
87 86
 exportMethods(celda_G)
88 87
 exportMethods(celdatosce)
89 88
 exportMethods(clusterProbability)
90
-exportMethods(clusters)
91 89
 exportMethods(countChecksum)
92 90
 exportMethods(decontX)
93 91
 exportMethods(decontXcounts)
92
+exportMethods(differentialExpression)
94 93
 exportMethods(factorizeMatrix)
95 94
 exportMethods(featureModuleLookup)
95
+exportMethods(findMarkersTree)
96
+exportMethods(geneSetEnrich)
96 97
 exportMethods(logLikelihood)
97 98
 exportMethods(logLikelihoodHistory)
98 99
 exportMethods(matrixNames)
99
-exportMethods(modules)
100
+exportMethods(moduleHeatmap)
100 101
 exportMethods(params)
101 102
 exportMethods(perplexity)
103
+exportMethods(plotCeldaViolin)
104
+exportMethods(plotDimReduceCluster)
105
+exportMethods(plotDimReduceFeature)
106
+exportMethods(plotDimReduceGrid)
107
+exportMethods(plotDimReduceModule)
108
+exportMethods(plotGridSearchPerplexity)
109
+exportMethods(recursiveSplitCell)
110
+exportMethods(recursiveSplitModule)
102 111
 exportMethods(resList)
112
+exportMethods(resamplePerplexity)
103 113
 exportMethods(runParams)
104 114
 exportMethods(sampleLabel)
105 115
 exportMethods(selectBestModel)
... ...
@@ -121,9 +131,6 @@ importFrom(MCMCprecision,fit_dirichlet)
121 131
 importFrom(RColorBrewer,brewer.pal)
122 132
 importFrom(Rtsne,Rtsne)
123 133
 importFrom(S4Vectors,mcols)
124
-importFrom(SummarizedExperiment,assay)
125
-importFrom(SummarizedExperiment,assayNames)
126
-importFrom(SummarizedExperiment,colData)
127 134
 importFrom(data.table,as.data.table)
128 135
 importFrom(digest,digest)
129 136
 importFrom(doParallel,registerDoParallel)
... ...
@@ -265,19 +265,19 @@ setMethod("moduleHeatmap",
265 265
         if (class(celdaMod)[1] == "celda_CG") {
266 266
             if (methods::.hasSlot(celdaMod, "clusters")) {
267 267
                 cell <-
268
-                    distinctColors(length(unique(celdaMod@clusters$z)))[
269
-                        sort(unique(celdaMod@clusters$z[cellIx]))
268
+                    distinctColors(length(unique(celdaClusters(celdaMod)$z)))[
269
+                        sort(unique(celdaClusters(celdaMod)$z[cellIx]))
270 270
                         ]
271
-                names(cell) <- sort(unique(celdaMod@clusters$z[cellIx]))
271
+                names(cell) <- sort(unique(celdaClusters(celdaMod)$z[cellIx]))
272 272
                 anno_cell_colors <- list(cell = cell)
273
-                zToPlot <- celdaMod@clusters$z[cellIndices]
273
+                zToPlot <- celdaClusters(celdaMod)$z[cellIndices]
274 274
             }
275 275
         }
276 276
 
277 277
         plt <- plotHeatmap(
278 278
             filteredNormCounts,
279 279
             z = zToPlot,
280
-            y = celdaMod@clusters$y[geneIx],
280
+            y = celdaClusters(celdaMod)$y[geneIx],
281 281
             scaleRow = scaleRow,
282 282
             colorScheme = "divergent",
283 283
             showNamesFeature = showFeaturenames,
... ...
@@ -682,7 +682,7 @@ setMethod("featureModuleLookup", signature(sce = "SingleCellExperiment"),
682 682
     }
683 683
     for (x in seq(length(feature))) {
684 684
         if (feature[x] %in% rownames(sce)) {
685
-            list[x] <- modules(sce)[which(rownames(sce) ==
685
+            list[x] <- celdaModules(sce)[which(rownames(sce) ==
686 686
                     feature[x])]
687 687
         } else {
688 688
             list[x] <- paste0(
... ...
@@ -711,7 +711,7 @@ setMethod("featureModuleLookup", signature(sce = "SingleCellExperiment"),
711 711
         seq(length(feature)),
712 712
         function(x) {
713 713
             if (feature[x] %in% rownames(sce)) {
714
-                return(modules(sce)[which(rownames(sce) ==
714
+                return(celdaModules(sce)[which(rownames(sce) ==
715 715
                         feature[x])])
716 716
             } else {
717 717
                 return(paste0(
... ...
@@ -47,7 +47,7 @@
47 47
 #'  \link[S4Vectors]{metadata} \code{"celda_grid_search"} slot.
48 48
 #' @seealso \link{celda_G} for feature clustering, \link{celda_C} for
49 49
 #'  clustering of cells, and \link{celda_CG} for simultaneous clustering of
50
-#'  features and cells. \link{subsetCeldaList} can subset the \link{celdaList}
50
+#'  features and cells. \link{subsetCeldaList} can subset the \code{celdaList}
51 51
 #'  object. \link{selectBestModel} can get the best model for each combination
52 52
 #'  of parameters.
53 53
 #' @import foreach
... ...
@@ -606,6 +606,7 @@ setMethod("selectBestModel", signature(x = "SingleCellExperiment"),
606 606
 )
607 607
 
608 608
 
609
+#' @rdname selectBestModel
609 610
 #' @examples
610 611
 #' data(celdaCGGridSearchRes)
611 612
 #' ## Returns same result as running celdaGridSearch with "bestOnly = TRUE"
... ...
@@ -2729,7 +2729,7 @@ subUnderscore <- function(x, n) {
2729 2729
 #' # Get features matrix and cluster assignments
2730 2730
 #' factorized <- factorizeMatrix(sim_counts$counts, cm)
2731 2731
 #' features <- factorized$proportions$cell
2732
-#' class <- clusters(cm)$z
2732
+#' class <- celdaClusters(cm)
2733 2733
 #'
2734 2734
 #' # Generate Decision Tree
2735 2735
 #' DecTree <- findMarkersTree(features, class, threshold = 1)
... ...
@@ -81,7 +81,7 @@
81 81
     verbose = FALSE,
82 82
     reorder = FALSE
83 83
   )
84
-  overallZ <- as.integer(as.factor(res@clusters$z))
84
+  overallZ <- as.integer(as.factor(celdaClusters(res)$z))
85 85
   currentK <- max(overallZ)
86 86
 
87 87
   counter <- 0
... ...
@@ -112,7 +112,7 @@
112 112
         splitOnIter = -1,
113 113
         splitOnLast = FALSE,
114 114
         verbose = FALSE)
115
-      tempZ <- as.integer(as.factor(clustLabel@clusters$z))
115
+      tempZ <- as.integer(as.factor(celdaClusters(clustLabel)$z))
116 116
 
117 117
       # Reassign clusters with label > 1
118 118
       splitIx <- tempZ > 1
... ...
@@ -245,7 +245,7 @@
245 245
     splitOnLast = FALSE,
246 246
     verbose = FALSE,
247 247
     reorder = FALSE)
248
-  overallY <- as.integer(as.factor(res@clusters$y))
248
+  overallY <- as.integer(as.factor(celdaClusters(res)$y))
249 249
   currentL <- max(overallY)
250 250
 
251 251
   counter <- 0
... ...
@@ -281,7 +281,7 @@
281 281
         splitOnLast = FALSE,
282 282
         verbose = FALSE
283 283
       )
284
-      tempY <- as.integer(as.factor(clustLabel@clusters$y))
284
+      tempY <- as.integer(as.factor(celdaClusters(clustLabel)$y))
285 285
 
286 286
       # Reassign clusters with label > 1
287 287
       splitIx <- tempY > 1
... ...
@@ -67,7 +67,6 @@ setMethod("resamplePerplexity",
67 67
 
68 68
 #' @rdname resamplePerplexity
69 69
 #' @examples
70
-#' @examples
71 70
 #' data(celdaCGSim, celdaCGGridSearchRes)
72 71
 #' celdaCGGridSearchRes <- resamplePerplexity(
73 72
 #'   celdaCGSim$counts,
... ...
@@ -185,7 +185,7 @@ setMethod(
185 185
             newCounts,
186 186
             phi,
187 187
             psi,
188
-            clusters(celdaMod)$y,
188
+            celdaClusters(celdaMod)$y,
189 189
             params(celdaMod)$L
190 190
         ) # + sum(etaProb)
191 191
         perplexity <- exp(- (logPx / sum(newCounts)))
... ...
@@ -1196,10 +1196,9 @@ setMethod("recursiveSplitModule",
1196 1196
       gamma = gamma,
1197 1197
       delta = delta,
1198 1198
       verbose = FALSE,
1199
-      reorder = reorder
1200
-    )
1201
-    currentL <- length(unique(celdaClusters(modelInitial)y)) + 1
1202
-    overallY <- celdaClusters(modelInitial)y
1199
+      reorder = reorder)
1200
+    currentL <- length(unique(celdaClusters(modelInitial)$y)) + 1
1201
+    overallY <- celdaClusters(modelInitial)$y
1203 1202
 
1204 1203
     resList <- list(modelInitial)
1205 1204
     while (currentL <= maxL) {
1206 1205
similarity index 69%
1207 1206
rename from man/clusters.Rd
1208 1207
rename to man/celdaClusters.Rd
... ...
@@ -1,24 +1,24 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/accessors.R
3
-\name{clusters}
4
-\alias{clusters}
5
-\alias{clusters,SingleCellExperiment-method}
6
-\alias{clusters,celdaModel-method}
7
-\alias{clusters<-}
8
-\alias{clusters<-,SingleCellExperiment-method}
3
+\name{celdaClusters}
4
+\alias{celdaClusters}
5
+\alias{celdaClusters,SingleCellExperiment-method}
6
+\alias{celdaClusters,celdaModel-method}
7
+\alias{celdaClusters<-}
8
+\alias{celdaClusters<-,SingleCellExperiment-method}
9 9
 \title{Get or set the cell cluster labels from a celda
10 10
  \linkS4class{SingleCellExperiment}  object or celda model
11 11
  object.}
12 12
 \usage{
13
-clusters(x)
13
+celdaClusters(x)
14 14
 
15
-\S4method{clusters}{SingleCellExperiment}(x)
15
+\S4method{celdaClusters}{SingleCellExperiment}(x)
16 16
 
17
-\S4method{clusters}{celdaModel}(x)
17
+\S4method{celdaClusters}{celdaModel}(x)
18 18
 
19
-clusters(x) <- value
19
+celdaClusters(x) <- value
20 20
 
21
-\S4method{clusters}{SingleCellExperiment}(x) <- value
21
+\S4method{celdaClusters}{SingleCellExperiment}(x) <- value
22 22
 }
23 23
 \arguments{
24 24
 \item{x}{Can be one of
... ...
@@ -45,7 +45,7 @@ Return or set the cell cluster labels determined
45 45
 }
46 46
 \examples{
47 47
 data(sceCeldaCG)
48
-clusters(sceCeldaCG)
48
+celdaClusters(sceCeldaCG)
49 49
 data(celdaCGMod)
50
-clusters(celdaCGMod)
50
+celdaClusters(celdaCGMod)
51 51
 }
... ...
@@ -75,12 +75,12 @@ TRUE.}
75 75
 \item{seed}{Integer. Passed to \link[withr]{with_seed}. For reproducibility,
76 76
 a default value of 12345 is used. Seed values
77 77
 \code{seq(seed, (seed + nchains - 1))} will be supplied to each chain in
78
-\code{nchains} If NULL, no calls to
78
+\code{nchains}. If NULL, no calls to
79 79
 \link[withr]{with_seed} are made.}
80 80
 
81 81
 \item{perplexity}{Logical. Whether to calculate perplexity for each model.
82 82
 If FALSE, then perplexity can be calculated later with
83
-`resamplePerplexity()`. Default TRUE.}
83
+\link{resamplePerplexity}. Default TRUE.}
84 84
 
85 85
 \item{verbose}{Logical. Whether to print log messages during celda chain
86 86
 execution. Default TRUE.}
87 87
similarity index 66%
88 88
rename from man/modules.Rd
89 89
rename to man/celdaModules.Rd
... ...
@@ -1,20 +1,20 @@
1 1
 % Generated by roxygen2: do not edit by hand
2 2
 % Please edit documentation in R/accessors.R
3
-\name{modules}
4
-\alias{modules}
5
-\alias{modules,SingleCellExperiment-method}
6
-\alias{modules<-}
7
-\alias{modules<-,SingleCellExperiment-method}
3
+\name{celdaModules}
4
+\alias{celdaModules}
5
+\alias{celdaModules,SingleCellExperiment-method}
6
+\alias{celdaModules<-}
7
+\alias{celdaModules<-,SingleCellExperiment-method}
8 8
 \title{Get or set the feature module labels from a celda
9 9
  \linkS4class{SingleCellExperiment}  object.}
10 10
 \usage{
11
-modules(sce)
11
+celdaModules(sce)
12 12
 
13
-\S4method{modules}{SingleCellExperiment}(sce)
13
+\S4method{celdaModules}{SingleCellExperiment}(sce)
14 14
 
15
-modules(sce) <- value
15
+celdaModules(sce) <- value
16 16
 
17
-\S4method{modules}{SingleCellExperiment}(sce) <- value
17
+\S4method{celdaModules}{SingleCellExperiment}(sce) <- value
18 18
 }
19 19
 \arguments{
20 20
 \item{sce}{A \linkS4class{SingleCellExperiment} object returned by
... ...
@@ -32,5 +32,5 @@ Return or set the feature module cluster labels determined
32 32
 }
33 33
 \examples{
34 34
 data(celdaCGMod)
35
-modules(celdaCGMod)
35
+celdaModules(celdaCGMod)
36 36
 }
... ...
@@ -43,7 +43,7 @@ Default NULL.}
43 43
 threshold. Default 100.}
44 44
 
45 45
 \item{modules}{Integer vector. Determines which features modules to use for
46
-tSNE. If NULL, all modules will be used. Default NULL.}
46
+UMAP. If NULL, all modules will be used. Default NULL.}
47 47
 
48 48
 \item{seed}{Integer. Passed to \link[withr]{with_seed}. For reproducibility,
49 49
 a default value of 12345 is used. If NULL, no calls to
... ...
@@ -67,7 +67,7 @@ Rows represent features and columns represent cells.}
67 67
 
68 68
 \item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
69 69
 slot to use if \code{x} is a
70
-\link[SingleCellExperiment]{SingleCellExperiment} object. Default "counts".}
70
+\linkS4class{SingleCellExperiment} object. Default "counts".}
71 71
 
72 72
 \item{sampleLabel}{Vector or factor. Denotes the sample label for each cell
73 73
 (column) in the count matrix.}
... ...
@@ -2,10 +2,24 @@
2 2
 % Please edit documentation in R/diffExp.R
3 3
 \name{differentialExpression}
4 4
 \alias{differentialExpression}
5
+\alias{differentialExpression,SingleCellExperiment-method}
6
+\alias{differentialExpression,matrix-method}
5 7
 \title{Differential expression for cell subpopulations using MAST}
6 8
 \usage{
7
-differentialExpression(
8
-  counts,
9
+differentialExpression(x, ...)
10
+
11
+\S4method{differentialExpression}{SingleCellExperiment}(
12
+  x,
13
+  useAssay = "counts",
14
+  c1,
15
+  c2 = NULL,
16
+  onlyPos = FALSE,
17
+  log2fcThreshold = NULL,
18
+  fdrThreshold = 1
19
+)
20
+
21
+\S4method{differentialExpression}{matrix}(
22
+  x,
9 23
   celdaMod,
10 24
   c1,
11 25
   c2 = NULL,
... ...
@@ -15,11 +29,16 @@ differentialExpression(
15 29
 )
16 30
 }
17 31
 \arguments{
18
-\item{counts}{Integer matrix. Rows represent features and columns represent
19
-cells. This matrix should be the same as the one used to generate
20
-`celdaMod`.}
32
+\item{x}{A numeric \link{matrix} of counts or a
33
+\linkS4class{SingleCellExperiment}
34
+with the matrix located in the assay slot under \code{useAssay}.
35
+Rows represent features and columns represent cells. Must contain cluster
36
+labels in \code{celdaClusters(x)} if \code{x} is a
37
+\linkS4class{SingleCellExperiment} object.}
21 38
 
22
-\item{celdaMod}{Celda object of class `celda_C` or `celda_CG`.}
39
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
40
+slot to use if \code{x} is a
41
+\link[SingleCellExperiment]{SingleCellExperiment} object. Default "counts".}
23 42
 
24 43
 \item{c1}{Integer vector. Cell populations to include in group 1 for the
25 44
 differential expression analysis.}
... ...
@@ -39,6 +58,8 @@ applied. Default NULL.}
39 58
 \item{fdrThreshold}{Numeric. A number between 0 and 1 that specifies the
40 59
 false discovery rate (FDR) threshold. Only features below this threshold
41 60
 will be returned. Default 1.}
61
+
62
+\item{celdaMod}{Celda object of class `celda_C` or `celda_CG`.}
42 63
 }
43 64
 \value{
44 65
 Data frame containing MAST results including statistics such as
... ...
@@ -49,9 +70,10 @@ Uses MAST to find differentially expressed features for
49 70
  specified cell subpopulations.
50 71
 }
51 72
 \examples{
73
+data(sceCeldaCG)
74
+clusterDiffexpRes <- differentialExpression(sceCeldaCG, c1 = c(1, 2))
52 75
 data(celdaCGSim, celdaCGMod)
53 76
 clusterDiffexpRes <- differentialExpression(celdaCGSim$counts,
54 77
   celdaCGMod,
55
-  c1 = c(1, 2)
56
-)
78
+  c1 = c(1, 2))
57 79
 }
... ...
@@ -2,10 +2,31 @@
2 2
 % Please edit documentation in R/findMarkersTree.R
3 3
 \name{findMarkersTree}
4 4
 \alias{findMarkersTree}
5
+\alias{findMarkersTree,SingleCellExperiment-method}
6
+\alias{findMarkersTree,matrix-method}
5 7
 \title{Generate marker decision tree from single-cell clustering output}
6 8
 \usage{
7
-findMarkersTree(
8
-  features,
9
+findMarkersTree(x, ...)
10
+
11
+\S4method{findMarkersTree}{SingleCellExperiment}(
12
+  x,
13
+  useAssay = "counts",
14
+  class,
15
+  oneoffMetric = c("modified F1", "pairwise AUC"),
16
+  metaclusters,
17
+  featureLabels,
18
+  counts,
19
+  seurat,
20
+  threshold = 0.9,
21
+  reuseFeatures = FALSE,
22
+  altSplit = TRUE,
23
+  consecutiveOneoff = FALSE,
24
+  autoMetaclusters = TRUE,
25
+  seed = 12345
26
+)
27
+
28
+\S4method{findMarkersTree}{matrix}(
29
+  x,
9 30
   class,
10 31
   oneoffMetric = c("modified F1", "pairwise AUC"),
11 32
   metaclusters,
... ...
@@ -22,7 +43,14 @@ findMarkersTree(
22 43
 )
23 44
 }
24 45
 \arguments{
25
-\item{features}{features-by-samples numeric matrix, e.g. counts matrix.}
46
+\item{x}{A numeric \link{matrix} of counts or a
47
+\linkS4class{SingleCellExperiment}
48
+with the matrix located in the assay slot under \code{useAssay}.
49
+Rows represent features and columns represent cells.}
50
+
51
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
52
+slot to use if \code{x} is a
53
+\link[SingleCellExperiment]{SingleCellExperiment} object. Default "counts".}
26 54
 
27 55
 \item{class}{Vector of cell cluster labels.}
28 56
 
... ...
@@ -41,10 +69,8 @@ modules).}
41 69
 \item{counts}{Numeric counts matrix. Useful when using clusters
42 70
 of features (e.g. gene modules) and user wishes to expand tree results to
43 71
 individual features (e.g. score individual genes within marker gene
44
-modules). Row names should be individual feature names.}
45
-
46
-\item{celda}{A \emph{celda_CG} or \emph{celda_C} object.
47
-Counts matrix has to be provided as well.}
72
+modules). Row names should be individual feature names. Ignored if
73
+\code{x} is a \linkS4class{SingleCellExperiment} object.}
48 74
 
49 75
 \item{seurat}{A seurat object. Note that the seurat functions
50 76
 \emph{RunPCA} and \emph{FindClusters} must have been run on the object.}
... ...
@@ -68,6 +94,9 @@ cluster that includes several clusters within it. Default is TRUE.}
68 94
 
69 95
 \item{seed}{Numeric. Seed used to enable reproducible UMAP results
70 96
 for identifying metaclusters. Default is 12345.}
97
+
98
+\item{celda}{A \emph{celda_CG} or \emph{celda_C} object.
99
+Counts matrix has to be provided as well.}
71 100
 }
72 101
 \value{
73 102
 A named list with six elements:
... ...
@@ -122,15 +151,15 @@ Create a decision tree that identifies gene markers for given
122 151
 \examples{
123 152
 \dontrun{
124 153
 # Generate simulated single-cell dataset using celda
125
-sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100)
154
+sim_counts <- simulateCells("celda_CG", K = 4, L = 10, G = 100)
126 155
 
127 156
 # Celda clustering into 5 clusters & 10 modules
128
-cm <- celda_CG(sim_counts$counts, K = 5, L = 10, verbose = FALSE)
157
+cm <- celda_CG(sim_counts, K = 5, L = 10, verbose = FALSE)
129 158
 
130 159
 # Get features matrix and cluster assignments
131
-factorized <- factorizeMatrix(sim_counts$counts, cm)
160
+factorized <- factorizeMatrix(cm)
132 161
 features <- factorized$proportions$cell
133
-class <- clusters(cm)$z
162
+class <- celdaClusters(cm)
134 163
 
135 164
 # Generate Decision Tree
136 165
 DecTree <- findMarkersTree(features, class)
... ...
@@ -2,22 +2,35 @@
2 2
 % Please edit documentation in R/geneSetEnrich.R
3 3
 \name{geneSetEnrich}
4 4
 \alias{geneSetEnrich}
5
+\alias{geneSetEnrich,SingleCellExperiment-method}
6
+\alias{geneSetEnrich,matrix-method}
5 7
 \title{Gene set enrichment}
6 8
 \usage{
7
-geneSetEnrich(counts, celdaModel, databases, fdr = 0.05)
9
+geneSetEnrich(x, ...)
10
+
11
+\S4method{geneSetEnrich}{SingleCellExperiment}(x, useAssay = "counts", databases, fdr = 0.05)
12
+
13
+\S4method{geneSetEnrich}{matrix}(x, celdaModel, databases, fdr = 0.05)
8 14
 }
9 15
 \arguments{
10
-\item{counts}{Integer count matrix. Rows represent genes and columns
11
-represent cells. Row names of the matrix should be gene names.}
16
+\item{x}{A numeric \link{matrix} of counts or a
17
+\linkS4class{SingleCellExperiment}
18
+with the matrix located in the assay slot under \code{useAssay}.
19
+Rows represent features and columns represent cells. Rownames of the
20
+matrix or \linkS4class{SingleCellExperiment} object should be gene names.}
12 21
 
13
-\item{celdaModel}{Celda object of class `celda_G` or `celda_CG`.}
22
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
23
+slot to use if \code{x} is a
24
+\linkS4class{SingleCellExperiment} object. Default "counts".}
14 25
 
15 26
 \item{databases}{Character vector. Name of reference database. Available
16
-databases can be viewed by running \code{enrichR::listEnrichrDbs()}.}
27
+databases can be viewed by \link[enrichR]{listEnrichrDbs}.}
17 28
 
18 29
 \item{fdr}{False discovery rate (FDR). Numeric. Cutoff value for adjusted
19 30
 p-value, terms with FDR below this value are considered significantly
20 31
 enriched.}
32
+
33
+\item{celdaModel}{Celda object of class \code{celda_G} or \code{celda_CG}.}
21 34
 }
22 35
 \value{
23 36
 List of length 'L' where each member contains the significantly
... ...
@@ -25,21 +38,20 @@ List of length 'L' where each member contains the significantly
25 38
 }
26 39
 \description{
27 40
 Identify and return significantly-enriched terms for each gene
28
- module in a Celda object. Performs gene set enrichment analysis for Celda
29
- identified modules using the enrichR package.
41
+ module in a Celda object or a \linkS4class{SingleCellExperiment} object.
42
+ Performs gene set enrichment analysis for Celda
43
+ identified modules using the \link[enrichR]{enrichr}.
30 44
 }
31 45
 \examples{
32 46
 library(M3DExampleData)
33 47
 counts <- M3DExampleData::Mmus_example_list$data
34
-# subset 100 genes for fast clustering
35
-counts <- counts[1500:2000, ]
48
+# subset 500 genes for fast clustering
49
+counts <- counts[seq(1501, 2000), ]
36 50
 # cluster genes into 10 modules for quick demo
37
-cm <- celda_G(counts = as.matrix(counts), L = 10, verbose = FALSE)
38
-gse <- geneSetEnrich(counts,
39
-  cm,
40
-  databases = c("GO_Biological_Process_2018", "GO_Molecular_Function_2018")
41
-)
51
+sce <- celda_G(counts = as.matrix(counts), L = 10, verbose = FALSE)
52
+gse <- geneSetEnrich(sce,
53
+  databases = c("GO_Biological_Process_2018", "GO_Molecular_Function_2018"))
42 54
 }
43 55
 \author{
44
-Ahmed Youssef
56
+Ahmed Youssef, Zhe Wang
45 57
 }
... ...
@@ -10,10 +10,11 @@ getDecisions(rules, features)
10 10
 getDecisions(rules, features)
11 11
 }
12 12
 \arguments{
13
-\item{rules}{List object. The `rules` element from  `findMarkers`
14
-output. Returns NA if cluster estimation was ambiguous.}
13
+\item{rules}{List object. The \code{rules} element from
14
+\code{findMarkersTree} output. Returns NA if cluster estimation was
15
+ambiguous.}
15 16
 
16
-\item{features}{A L(features) by N(samples) numeric matrix.}
17
+\item{features}{A L (features) by N (samples) numeric matrix.}
17 18
 }
18 19
 \value{
19 20
 A character vector of label predicitions.
... ...
@@ -32,21 +33,19 @@ Get decisions for a matrix of features. Estimate cell
32 33
 library(M3DExampleData)
33 34
 counts <- M3DExampleData::Mmus_example_list$data
34 35
 # Subset 500 genes for fast clustering
35
-counts <- as.matrix(counts[1501:2000, ])
36
-# Cluster genes ans samples each into 10 modules
37
-cm <- celda_CG(counts = counts, L = 10, K = 5, verbose = FALSE)
36
+counts <- as.matrix(counts[seq(1501, 2000), ])
37
+# Cluster genes and samples each into 10 modules
38
+sce <- celda_CG(counts = counts, L = 10, K = 5, verbose = FALSE)
38 39
 # Get features matrix and cluster assignments
39
-factorized <- factorizeMatrix(counts, cm)
40
+factorized <- factorizeMatrix(sce)
40 41
 features <- factorized$proportions$cell
41
-class <- clusters(cm)$z
42
+class <- celdaClusters(sce)
42 43
 # Generate Decision Tree
43
-DecTree <- findMarkers(features,
44
+DecTree <- findMarkersTree(features,
44 45
   class,
45 46
   oneoffMetric = "modified F1",
46 47
   threshold = 1,
47
-  consecutiveOneoff = FALSE
48
-)
49
-
48
+  consecutiveOneoff = FALSE)
50 49
 # Get sample estimates in training data
51 50
 getDecisions(DecTree$rules, features)
52 51
 }
... ...
@@ -2,10 +2,25 @@
2 2
 % Please edit documentation in R/StateHeatmap.R
3 3
 \name{moduleHeatmap}
4 4
 \alias{moduleHeatmap}
5
+\alias{moduleHeatmap,SingleCellExperiment-method}
6
+\alias{moduleHeatmap,matrix-method}
5 7
 \title{Heatmap for featureModules}
6 8
 \usage{
7
-moduleHeatmap(
8
-  counts,
9
+moduleHeatmap(x, ...)
10
+
11
+\S4method{moduleHeatmap}{SingleCellExperiment}(
12
+  x,
13
+  useAssay = "counts",
14
+  featureModule = 1,
15
+  topCells = 100,
16
+  topFeatures = NULL,
17
+  normalizedCounts = NA,
18
+  scaleRow = scale,
19
+  showFeaturenames = TRUE
20
+)
21
+
22
+\S4method{moduleHeatmap}{matrix}(
23
+  x,
9 24
   celdaMod,
10 25
   featureModule = 1,
11 26
   topCells = 100,
... ...
@@ -16,11 +31,14 @@ moduleHeatmap(
16 31
 )
17 32
 }
18 33
 \arguments{
19
-\item{counts}{Integer matrix. Rows represent features and columns represent
20
-cells. This matrix should be the same as the one used to generate
21
-`celdaMod`.}
34
+\item{x}{A numeric \link{matrix} of counts or a
35
+\linkS4class{SingleCellExperiment}
36
+with the matrix located in the assay slot under \code{useAssay}.
37
+Rows represent features and columns represent cells.}
22 38
 
23
-\item{celdaMod}{Celda object of class `celda_G` or `celda_CG`.}
39
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
40
+slot to use if \code{x} is a
41
+\linkS4class{SingleCellExperiment} object. Default "counts".}
24 42
 
25 43
 \item{featureModule}{Integer Vector. The featureModule(s) to display.
26 44
 Multiple modules can be included in a vector.}
... ...
@@ -50,6 +68,9 @@ Default `scale`.}
50 68
 
51 69
 \item{showFeaturenames}{Logical. Wheter feature names should be displayed.
52 70
 Default TRUE.}
71
+
72
+\item{celdaMod}{Celda object of class \link{celda_G} or \link{celda_CG}. Used
73
+only if \code{x} is a matrix object.}
53 74
 }
54 75
 \value{
55 76
 A list containing row and column dendrograms as well as a gtable for
... ...
@@ -66,4 +87,6 @@ Renders a heatmap for selected featureModules. Cells are
66 87
 \examples{
67 88
 data(celdaCGSim, celdaCGMod)
68 89
 moduleHeatmap(celdaCGSim$counts, celdaCGMod)
90
+data(celdaCGSim, celdaCGMod)
91
+moduleHeatmap(celdaCGSim$counts, celdaCGMod)
69 92
 }
... ...
@@ -2,10 +2,23 @@
2 2
 % Please edit documentation in R/plot_dr.R
3 3
 \name{plotCeldaViolin}
4 4
 \alias{plotCeldaViolin}
5
+\alias{plotCeldaViolin,SingleCellExperiment-method}
6
+\alias{plotCeldaViolin,matrix-method}
5 7
 \title{Feature Expression Violin Plot}
6 8
 \usage{
7
-plotCeldaViolin(
8
-  counts,
9
+plotCeldaViolin(x, ...)
10
+
11
+\S4method{plotCeldaViolin}{SingleCellExperiment}(
12
+  x,
13
+  useAssay = "counts",
14
+  features,
15
+  exactMatch = TRUE,
16
+  plotDots = TRUE,
17
+  dotSize = 0.1
18
+)
19
+
20
+\S4method{plotCeldaViolin}{matrix}(
21
+  x,
9 22
   celdaMod,
10 23
   features,
11 24
   exactMatch = TRUE,
... ...
@@ -14,10 +27,13 @@ plotCeldaViolin(
14 27
 )
15 28
 }
16 29
 \arguments{
17
-\item{counts}{Integer matrix. Rows represent features and columns represent
18
-cells.}
30
+\item{x}{Numeric matrix or a \linkS4class{SingleCellExperiment} object
31
+with the matrix located in the assay slot under \code{useAssay}. Rows
32
+represent features and columns represent cells.}
19 33
 
20
-\item{celdaMod}{Celda object of class "celda_G" or "celda_CG".}
34
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
35
+slot to use if \code{x} is a
36
+\linkS4class{SingleCellExperiment} object. Default "counts".}
21 37
 
22 38
 \item{features}{Character vector. Uses these genes for plotting.}
23 39
 
... ...
@@ -31,6 +47,9 @@ curve. Default \code{TRUE}.}
31 47
 
32 48
 \item{dotSize}{Numeric. Size of points if \code{plotDots = TRUE}.
33 49
 Default \code{0.1}.}
50
+
51
+\item{celdaMod}{Celda object of class "celda_G" or "celda_CG". Used only if
52
+\code{x} is a matrix object.}
34 53
 }
35 54
 \value{
36 55
 Violin plot for each feature, grouped by celda cluster
... ...
@@ -39,9 +58,9 @@ Violin plot for each feature, grouped by celda cluster
39 58
 Outputs a violin plot for feature expression data.
40 59
 }
41 60
 \examples{
61
+data(sceCeldaCG)
62
+plotCeldaViolin(x = sceCeldaCG, features = "Gene_1")
42 63
 data(celdaCGSim, celdaCGMod)
43
-plotCeldaViolin(
44
-  counts = celdaCGSim$counts,
45
-  celdaMod = celdaCGMod, features = "Gene_1"
46
-)
64
+plotCeldaViolin(counts = celdaCGSim$counts, celdaMod = celdaCGMod,
65
+   features = "Gene_1")
47 66
 }
... ...
@@ -2,12 +2,29 @@
2 2
 % Please edit documentation in R/plot_dr.R
3 3
 \name{plotDimReduceCluster}
4 4
 \alias{plotDimReduceCluster}
5
+\alias{plotDimReduceCluster,SingleCellExperiment-method}
6
+\alias{plotDimReduceCluster,vector-method}
5 7
 \title{Plotting the cell labels on a dimensionality reduction plot}
6 8
 \usage{
7
-plotDimReduceCluster(
9
+plotDimReduceCluster(x, ...)
10
+
11
+\S4method{plotDimReduceCluster}{SingleCellExperiment}(
12
+  dim1,
13
+  dim2,
14
+  x,
15
+  size = 1,
16
+  xlab = "Dimension_1",
17
+  ylab = "Dimension_2",
18
+  specificClusters = NULL,
19
+  labelClusters = FALSE,
20
+  groupBy = NULL,
21
+  labelSize = 3.5
22
+)
23
+
24
+\S4method{plotDimReduceCluster}{vector}(
8 25
   dim1,
9 26
   dim2,
10
-  cluster,
27
+  x,
11 28
   size = 1,
12 29
   xlab = "Dimension_1",
13 30
   ylab = "Dimension_2",
... ...
@@ -18,14 +35,17 @@ plotDimReduceCluster(
18 35
 )
19 36
 }
20 37
 \arguments{
38
+\item{x}{Integer vector of cell cluster labels or a
39
+\linkS4class{SingleCellExperiment} object
40
+containing cluster labels for each cell in \code{"celda_cell_cluster"}
41
+column in \code{colData(x)}.}
42
+
21 43
 \item{dim1}{Numeric vector. First dimension from data
22 44
 dimensionality reduction output.}
23 45
 
24 46
 \item{dim2}{Numeric vector. Second dimension from data
25 47
 dimensionality reduction output.}
26 48
 
27
-\item{cluster}{Integer vector. Contains cluster labels for each cell.}
28
-
29 49
 \item{size}{Numeric. Sets size of point on plot. Default 1.}
30 50
 
31 51
 \item{xlab}{Character vector. Label for the x-axis. Default "Dimension_1".}
... ...
@@ -45,6 +65,8 @@ If NULL, all samples will be plotted together. Default NULL.}
45 65
 
46 66
 \item{labelSize}{Numeric. Sets size of label if labelClusters is TRUE.
47 67
 Default 3.5.}
68
+
69
+\item{cluster}{Integer vector. Contains cluster labels for each cell.}
48 70
 }
49 71
 \value{
50 72
 The plot as a ggplot object
... ...
@@ -57,16 +79,21 @@ Create a scatterplot for each row of a normalized
57 79
 }
58 80
 \examples{
59 81
 \donttest{
60
-data(celdaCGSim, celdaCGMod)
61
-celdaTsne <- celdaTsne(
62
-  counts = celdaCGSim$counts,
63
-  celdaMod = celdaCGMod
64
-)
82
+data(sceCeldaCG)
83
+celdaTsne <- celdaTsne(sceCeldaCG)
65 84
 plotDimReduceCluster(
66 85
   dim1 = celdaTsne[, 1],
67 86
   dim2 = celdaTsne[, 2],
68
-  cluster = as.factor(celdaCGMod@clusters$z),
69
-  specificClusters = c(1, 2, 3)
70
-)
87
+  x = sceCeldaCG,
88
+  specificClusters = c(1, 2, 3))
89
+}
90
+\donttest{
91
+data(sceCeldaCG, celdaCGMod)
92
+celdaTsne <- celdaTsne(sceCeldaCG)
93
+plotDimReduceCluster(
94
+  dim1 = celdaTsne[, 1],
95
+  dim2 = celdaTsne[, 2],
96
+  x = celdaClusters(celdaCGMod),
97
+  specificClusters = c(1, 2, 3))
71 98
 }
72 99
 }
... ...
@@ -2,12 +2,37 @@
2 2
 % Please edit documentation in R/plot_dr.R
3 3
 \name{plotDimReduceFeature}
4 4
 \alias{plotDimReduceFeature}
5
+\alias{plotDimReduceFeature,SingleCellExperiment-method}
6
+\alias{plotDimReduceFeature,matrix-method}
5 7
 \title{Plotting feature expression on a dimensionality reduction plot}
6 8
 \usage{
7
-plotDimReduceFeature(
9
+plotDimReduceFeature(x, ...)
10
+
11
+\S4method{plotDimReduceFeature}{SingleCellExperiment}(
12
+  dim1,
13
+  dim2,
14
+  x,
15
+  useAssay = "counts",
16
+  features,
17
+  headers = NULL,
18
+  normalize = FALSE,
19
+  zscore = TRUE,
20
+  exactMatch = TRUE,
21
+  trim = c(-1, 1),
22
+  size = 1,
23
+  xlab = "Dimension_1",
24
+  ylab = "Dimension_2",
25
+  colorLow = "blue4",
26
+  colorMid = "white",
27
+  colorHigh = "firebrick1",
28
+  midpoint = NULL,
29
+  ncol = NULL
30
+)
31
+
32
+\S4method{plotDimReduceFeature}{matrix}(
8 33
   dim1,
9 34
   dim2,
10
-  counts,
35
+  x,
11 36
   features,
12 37
   headers = NULL,
13 38
   normalize = FALSE,
... ...
@@ -25,14 +50,19 @@ plotDimReduceFeature(
25 50
 )
26 51
 }
27 52
 \arguments{
53
+\item{x}{Numeric matrix or a \linkS4class{SingleCellExperiment} object
54
+with the matrix located in the assay slot under \code{useAssay}. Rows
55
+represent features and columns represent cells.}
56
+
28 57
 \item{dim1}{Numeric vector. First dimension from data
29 58
 dimensionality reduction output.}
30 59
 
31 60
 \item{dim2}{Numeric vector. Second dimension from data dimensionality
32 61
 reduction output.}
33 62
 
34
-\item{counts}{Integer matrix. Rows represent features and columns
35
-represent cells.}
63
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
64
+slot to use if \code{x} is a
65
+\linkS4class{SingleCellExperiment} object. Default "counts".}
36 66
 
37 67
 \item{features}{Character vector. Features in the rownames of counts to plot.}
38 68
 
... ...
@@ -86,18 +116,25 @@ Create a scatterplot for each row of a normalized gene
86 116
 }
87 117
 \examples{
88 118
 \donttest{
89
-data(celdaCGSim, celdaCGMod)
90
-celdaTsne <- celdaTsne(
91
-  counts = celdaCGSim$counts,
92
-  celdaMod = celdaCGMod
93
-)
119
+data(sceCeldaCG)
120
+celdaTsne <- celdaTsne(sceCeldaCG)
94 121
 plotDimReduceFeature(
95 122
   dim1 = celdaTsne[, 1],
96 123
   dim2 = celdaTsne[, 2],
97
-  counts = celdaCGSim$counts,
124
+  x = sceCeldaCG,
98 125
   normalize = TRUE,
99 126
   features = c("Gene_99"),
100
-  exactMatch = TRUE
101
-)
127
+  exactMatch = TRUE)
128
+}
129
+\donttest{
130
+data(sceCeldaCG)
131
+celdaTsne <- celdaTsne(sceCeldaCG)
132
+plotDimReduceFeature(
133
+  dim1 = celdaTsne[, 1],
134
+  dim2 = celdaTsne[, 2],
135
+  x = counts(sceCeldaCG),
136
+  normalize = TRUE,
137
+  features = c("Gene_99"),
138
+  exactMatch = TRUE)
102 139
 }
103 140
 }
... ...
@@ -2,18 +2,39 @@
2 2
 % Please edit documentation in R/plot_dr.R
3 3
 \name{plotDimReduceGrid}
4 4
 \alias{plotDimReduceGrid}
5
+\alias{plotDimReduceGrid,SingleCellExperiment-method}
6
+\alias{plotDimReduceGrid,matrix-method}
5 7
 \title{Mapping the dimensionality reduction plot}
6 8
 \usage{
7
-plotDimReduceGrid(
9
+plotDimReduceGrid(x, ...)
10
+
11
+\S4method{plotDimReduceGrid}{SingleCellExperiment}(
12
+  dim1,
13
+  dim2,
14
+  x,
15
+  useAssay = "counts",
16
+  size = 1,
17
+  xlab = "Dimension_1",
18
+  ylab = "Dimension_2",
19
+  colorLow = "blue4",
20
+  colorMid = "white",
21
+  colorHigh = "firebrick1",
22
+  midpoint = NULL,
23
+  varLabel = NULL,
24
+  ncol = NULL,
25
+  headers = NULL
26
+)
27
+
28
+\S4method{plotDimReduceGrid}{matrix}(
8 29
   dim1,
9 30
   dim2,
10
-  matrix,
31
+  x,
11 32
   size = 1,
12 33
   xlab = "Dimension_1",
13 34
   ylab = "Dimension_2",
14
-  colorLow = "grey",
15
-  colorMid = NULL,
16
-  colorHigh = "blue",
35
+  colorLow = "blue4",
36
+  colorMid = "white",
37
+  colorHigh = "firebrick1",
17 38
   midpoint = NULL,
18 39
   varLabel = NULL,
19 40
   ncol = NULL,
... ...
@@ -21,14 +42,19 @@ plotDimReduceGrid(
21 42
 )
22 43
 }
23 44
 \arguments{
45
+\item{x}{Numeric matrix or a \linkS4class{SingleCellExperiment} object
46
+with the matrix located in the assay slot under \code{useAssay}. Each
47
+row of the matrix will be plotted as a separate facet.}
48
+
24 49
 \item{dim1}{Numeric vector. First dimension from data dimensionality
25 50
 reduction output.}
26 51
 
27 52
 \item{dim2}{Numeric vector. Second dimension from data dimensionality
28 53
 reduction output.}
29 54
 
30
-\item{matrix}{Numeric matrix. Each row of the matrix will be plotted as
31
-a separate facet.}
55
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
56
+slot to use if \code{x} is a
57
+\linkS4class{SingleCellExperiment} object. Default "counts".}
32 58
 
33 59
 \item{size}{Numeric. Sets size of point on plot. Default 1.}
34 60
 
... ...
@@ -38,14 +64,15 @@ a separate facet.}
38 64
 
39 65
 \item{colorLow}{Character. A color available from `colors()`.
40 66
 The color will be used to signify the lowest values on the scale.
41
-Default 'grey'.}
67
+Default "blue4".}
42 68
 
43 69
 \item{colorMid}{Character. A color available from `colors()`.
44
-The color will be used to signify the midpoint on the scale.}
70
+The color will be used to signify the midpoint on the scale. Default
71
+"white".}
45 72
 
46 73
 \item{colorHigh}{Character. A color available from `colors()`.
47 74
 The color will be used to signify the highest values on the scale.
48
-Default 'blue'.}
75
+Default "firebrick1".}
49 76
 
50 77
 \item{midpoint}{Numeric. The value indicating the midpoint of the
51 78
 diverging color scheme. If \code{NULL}, defaults to the mean
... ...
@@ -67,20 +94,20 @@ Creates a scatterplot given two dimensions from a data
67 94
  dimensionality reduction tool (e.g tSNE) output.
68 95
 }
69 96
 \examples{
70
-data(celdaCGSim, celdaCGMod)
71
-celdaTsne <- celdaTsne(
72
-  counts = celdaCGSim$counts,
73
-  celdaMod = celdaCGMod
74
-)
97
+data(sceCeldaCG)
98
+celdaTsne <- celdaTsne(sceCeldaCG)
75 99
 plotDimReduceGrid(celdaTsne[, 1],
76 100
   celdaTsne[, 2],
77
-  matrix = celdaCGSim$counts,
101
+  x = sceCeldaCG,
78 102
   xlab = "Dimension1",
79 103
   ylab = "Dimension2",
80
-  varLabel = "tsne",
81
-  size = 1,
82
-  colorLow = "grey",
83
-  colorMid = NULL,
84
-  colorHigh = "blue"
85
-)
104
+  varLabel = "tSNE")
105
+data(sceCeldaCG)
106
+celdaTsne <- celdaTsne(sceCeldaCG)
107
+plotDimReduceGrid(celdaTsne[, 1],
108
+  celdaTsne[, 2],
109
+  x = counts(sceCeldaCG),
110
+  xlab = "Dimension1",
111
+  ylab = "Dimension2",
112
+  varLabel = "tSNE")
86 113
 }
... ...
@@ -2,37 +2,59 @@
2 2
 % Please edit documentation in R/plot_dr.R
3 3
 \name{plotDimReduceModule}
4 4
 \alias{plotDimReduceModule}
5
+\alias{plotDimReduceModule,SingleCellExperiment-method}
6
+\alias{plotDimReduceModule,matrix-method}
5 7
 \title{Plotting the Celda module probability on a
6 8
  dimensionality reduction plot}
7 9
 \usage{
8
-plotDimReduceModule(
10
+plotDimReduceModule(x, ...)
11
+
12
+\S4method{plotDimReduceModule}{SingleCellExperiment}(
13
+  dim1,
14
+  dim2,
15
+  x,
16
+  useAssay = "counts",
17
+  modules = NULL,
18
+  rescale = TRUE,
19
+  size = 1,
20
+  xlab = "Dimension_1",
21
+  ylab = "Dimension_2",
22
+  colorLow = "blue4",
23
+  colorMid = "white",
24
+  colorHigh = "firebrick1",
25
+  ncol = NULL
26
+)
27
+
28
+\S4method{plotDimReduceModule}{matrix}(
9 29
   dim1,
10 30
   dim2,
11
-  counts,
31
+  x,
12 32
   celdaMod,
13 33
   modules = NULL,
14 34
   rescale = TRUE,
15 35
   size = 1,
16 36
   xlab = "Dimension_1",
17 37
   ylab = "Dimension_2",
18
-  colorLow = "grey",
19
-  colorMid = NULL,
20
-  colorHigh = "blue",
38
+  colorLow = "blue4",
39
+  colorMid = "white",
40
+  colorHigh = "firebrick1",
21 41
   ncol = NULL
22 42
 )
23 43
 }
24 44
 \arguments{
45
+\item{x}{Numeric matrix or a \linkS4class{SingleCellExperiment} object
46
+with the matrix located in the assay slot under \code{useAssay}. Rows
47
+represent features and columns represent cells.}
48
+
25 49
 \item{dim1}{Numeric vector.
26 50
 First dimension from data dimensionality reduction output.}
27 51
 
28 52
 \item{dim2}{Numeric vector.
29 53
 Second dimension from data dimensionality reduction output.}
30 54
 
31
-\item{counts}{Integer matrix.
32
-Rows represent features and columns represent cells.
33
-This matrix should be the same as the one used to generate `celdaMod`.}
34
-
35
-\item{celdaMod}{Celda object of class "celda_G" or "celda_CG".}
55
+\item{useAssay}{A string specifying which \link[SummarizedExperiment]{assay}
56
+slot to use if \code{x} is a
57
+\linkS4class{SingleCellExperiment} object. Default "counts".}
36 58
 
37 59
 \item{modules}{Character vector. Module(s) from celda model to be plotted.
38 60
 e.g. c("1", "2").}
... ...
@@ -48,17 +70,21 @@ Whether rows of the matrix should be rescaled to [0, 1]. Default TRUE.}
48 70
 
49 71
 \item{colorLow}{Character. A color available from `colors()`.
50 72
 The color will be used to signify the lowest values on the scale.
51
-Default 'grey'.}
73
+Default "blue4".}
52 74
 
53 75
 \item{colorMid}{Character. A color available from `colors()`.
54
-The color will be used to signify the midpoint on the scale.}
76
+The color will be used to signify the midpoint on the scale. Default
77
+"white".}
55 78
 
56 79
 \item{colorHigh}{Character. A color available from `colors()`.
57 80
 The color will be used to signify the highest values on the scale.
58
-Default 'blue'.}
81
+Default "firebrick1".}
59 82
 
60 83
 \item{ncol}{Integer. Passed to \link[ggplot2]{facet_wrap}. Specify the
61 84
 number of columns for facet wrap.}
85
+
86
+\item{celdaMod}{Celda object of class "celda_G" or "celda_CG". Used only if
87
+\code{x} is a matrix object.}
62 88
 }
63 89
 \value{
64 90
 The plot as a ggplot object
... ...
@@ -71,15 +97,22 @@ Create a scatterplot for each row of a normalized
71 97
 }
72 98
 \examples{
73 99
 \donttest{
74
-data(celdaCGSim, celdaCGMod)
75
-celdaTsne <- celdaTsne(
76
-  counts = celdaCGSim$counts,
77
-  celdaMod = celdaCGMod
78
-)
100
+data(sceCeldaCG)
101
+celdaTsne <- celdaTsne(sceCeldaCG)
79 102
 plotDimReduceModule(
80
-  dim1 = celdaTsne[, 1], dim2 = celdaTsne[, 2],
81
-  counts = celdaCGSim$counts, celdaMod = celdaCGMod,
82
-  modules = c("1", "2")
83
-)
103
+  dim1 = celdaTsne[, 1],
104
+  dim2 = celdaTsne[, 2],
105
+  x = sceCeldaCG,
106
+  modules = c("1", "2"))
107
+}
108
+\donttest{
109
+data(sceCeldaCG, celdaCGMod)
110
+celdaTsne <- celdaTsne(sceCeldaCG)
111
+plotDimReduceModule(
112
+  dim1 = celdaTsne[, 1],
113
+  dim2 = celdaTsne[, 2],
114
+  x = counts(sceCeldaCG),
115
+  celdaMod = celdaCGMod,
116
+  modules = c("1", "2"))
84 117
 }
85 118
 }
... ...
@@ -2,14 +2,21 @@
2 2
 % Please edit documentation in R/model_performance.R
3 3
 \name{plotGridSearchPerplexity}
4 4
 \alias{plotGridSearchPerplexity}
5
+\alias{plotGridSearchPerplexity,SingleCellExperiment-method}
6
+\alias{plotGridSearchPerplexity,celdaList-method}
5 7
 \title{Visualize perplexity of a list of celda models}
6 8
 \usage{
7
-plotGridSearchPerplexity(celdaList, sep = 1)
9
+plotGridSearchPerplexity(x, ...)
10
+
11
+\S4method{plotGridSearchPerplexity}{SingleCellExperiment}(x, sep = 1)
12
+
13
+\S4method{plotGridSearchPerplexity}{celdaList}(x, sep = 1)
8 14
 }
9 15
 \arguments{
10
-\item{celdaList}{Object of class 'celdaList'.}
16
+\item{x}{A \linkS4class{SingleCellExperiment} object returned from
17
+\link{celdaGridSearch} or an object of class \code{celdaList}.}
11 18
 
12
-\item{sep}{Numeric. Breaks in the x axis of the resulting plo.t.}
19
+\item{sep}{Numeric. Breaks in the x axis of the resulting plot.}
13 20
 }
14 21
 \value{
15 22
 A ggplot plot object showing perplexity as a function of clustering
... ...
@@ -20,11 +27,13 @@ Visualize perplexity of every model in a celdaList, by unique
20 27
  K/L combinations
21 28
 }
22 29
 \examples{
30
+data(sceCeldaCGGridSearch)
31
+sce <- resamplePerplexity(sceCeldaCGGridSearch)
32
+plotGridSearchPerplexity(sce)
23 33
 data(celdaCGSim, celdaCGGridSearchRes)
24 34
 ## Run various combinations of parameters with 'celdaGridSearch'
25 35
 celdaCGGridSearchRes <- resamplePerplexity(
26 36
   celdaCGSim$counts,
27
-  celdaCGGridSearchRes
28
-)
37
+  celdaCGGridSearchRes)
29 38
 plotGridSearchPerplexity(celdaCGGridSearchRes)
30 39
 }
31 40
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/model_performance.R
3
-\name{plotGridSearchPerplexitycelda_C}
4
-\alias{plotGridSearchPerplexitycelda_C}
5
-\title{Plot perplexity as a function of K from celda_C models}
6
-\usage{
7
-plotGridSearchPerplexitycelda_C(celdaList, sep)
8
-}
9
-\arguments{
10
-\item{celdaList}{Object of class 'celdaList'.}
11
-
12
-\item{sep}{Numeric. Breaks in the x axis of the resulting plot.}
13
-}
14
-\value{
15
-A ggplot plot object showing perplexity as a function of clustering
16
-  parameters.
17
-}
18
-\description{
19
-Plots perplexity as a function of the cell (K) clusters as
20
-  generated by celdaGridSearch().
21
-}
22
-\examples{
23
-data(celdaCGSim, celdaCGGridSearchRes)
24
-celdaCGGridSearchRes <- resamplePerplexity(
25
-  celdaCGSim$counts,
26
-  celdaCGGridSearchRes
27
-)
28
-plotGridSearchPerplexity(celdaCGGridSearchRes)
29
-}
30 0
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/model_performance.R
3
-\name{plotGridSearchPerplexitycelda_CG}
4
-\alias{plotGridSearchPerplexitycelda_CG}
5
-\title{Plot perplexity as a function of K and L from celda_CG models}
6
-\usage{
7
-plotGridSearchPerplexitycelda_CG(celdaList, sep)
8
-}
9
-\arguments{
10
-\item{celdaList}{Object of class 'celdaList'.}
11
-
12
-\item{sep}{Numeric. Breaks in the x axis of the resulting plot.}
13
-}
14
-\value{
15
-A ggplot plot object showing perplexity as a function of clustering
16
- parameters.
17
-}
18
-\description{
19
-This function plots perplexity as a function of the cell/gene
20
- (K/L) clusters as generated by celdaGridSearch().
21
-}
22
-\examples{
23
-data(celdaCGSim, celdaCGGridSearchRes)
24
-celdaCGGridSearchRes <- resamplePerplexity(
25
-  celdaCGSim$counts,
26
-  celdaCGGridSearchRes
27
-)
28
-plotGridSearchPerplexity(celdaCGGridSearchRes)
29
-}
30 0
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-% Generated by roxygen2: do not edit by hand
2
-% Please edit documentation in R/model_performance.R
3
-\name{plotGridSearchPerplexitycelda_G}
4
-\alias{plotGridSearchPerplexitycelda_G}
5
-\title{Plot perplexity as a function of L from a celda_G model}
6
-\usage{
7
-plotGridSearchPerplexitycelda_G(celdaList, sep)
8
-}
9
-\arguments{
10
-\item{celdaList}{Object of class 'celdaList'.}
11
-
12
-\item{sep}{Numeric. Breaks in the x axis of the resulting plot.}
13
-}
14
-\value{
15
-A ggplot plot object showing perplexity as a function of clustering
16
-  parameters.
17
-}
18
-\description{
19
-Plots perplexity as a function of the gene (L) clusters as
20
-  generated by celdaGridSearch().
21
-}
22
-\examples{
23
-data(celdaCGSim, celdaCGGridSearchRes)
24
-celdaCGGridSearchRes <- resamplePerplexity(
25
-  celdaCGSim$counts,
26
-  celdaCGGridSearchRes
27
-)
28
-plotGridSearchPerplexity(celdaCGGridSearchRes)
29
-}
... ...
@@ -149,6 +149,6 @@ Renders a heatmap based on a matrix of counts where rows are
149 149
 \examples{
150 150
 data(celdaCGSim, celdaCGMod)
151 151
 plotHeatmap(celdaCGSim$counts,
152
-  z = celdaCGMod@clusters$z, y = celdaCGMod@clusters$y
152
+  z = celdaCGMod@celdaClusters$z, y = celdaCGMod@celdaClusters$y
153 153
 )
154 154
 }
... ...
@@ -50,7 +50,7 @@ cm <- celda_CG(sim_counts$counts, K = 5, L = 10, verbose = FALSE)
50 50
 # Get features matrix and cluster assignments
51 51
 factorized <- factorizeMatrix(sim_counts$counts, cm)
52 52
 features <- factorized$proportions$cell
53
-class <- clusters(cm)$z
53
+class <- celdaClusters(cm)
54 54
 
55 55
 # Generate Decision Tree
56 56
 DecTree <- findMarkersTree(features, class, threshold = 1)
... ...
@@ -14,7 +14,7 @@ plotMarkerHeatmap(
14 14
 )
15 15
 }
16 16
 \arguments{
17
-\item{tree}{A decision tree from CELDA's \emph{findMarkersTree} function.}
17
+\item{tree}{A decision tree returned from \link{findMarkersTree} function.}
18 18
 
19 19
 \item{counts}{Numeric matrix. Gene-by-cell counts matrix.}
20 20
 
... ...
@@ -43,23 +43,22 @@ Creates heatmap for a specified branch point in a marker tree.
43 43
 \examples{
44 44
 \dontrun{
45 45
 # Generate simulated single-cell dataset using celda
46
-sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100)
46
+sim_counts <- simulateCells("celda_CG", K = 4, L = 10, G = 100)
47 47
 
48 48
 # Celda clustering into 5 clusters & 10 modules
49
-cm <- celda_CG(sim_counts$counts, K = 5, L = 10, verbose = FALSE)
49
+cm <- celda_CG(sim_counts, K = 5, L = 10, verbose = FALSE)
50 50
 
51 51
 # Get features matrix and cluster assignments
52
-factorized <- factorizeMatrix(sim_counts$counts, cm)
52
+factorized <- factorizeMatrix(cm)
53 53
 features <- factorized$proportions$cell
54
-class <- clusters(cm)$z
54
+class <- celdaClusters(cm)
55 55
 
56 56
 # Generate Decision Tree
57 57
 DecTree <- findMarkersTree(features, class, threshold = 1)
58 58
 
59 59
 # Plot example heatmap
60
-plotMarkerHeatmap(DecTree, sim_counts$counts,
60
+plotMarkerHeatmap(DecTree, assay(sim_counts),
61 61
   branchPoint = "top_level",
62
-  featureLabels = paste0("L", clusters(cm)$y)
63
-)
62
+  featureLabels = paste0("L", celdaModules(cm)))
64 63
 }
65 64
 }
... ...
@@ -12,11 +12,11 @@ recodeClusterY(sce, from, to)
12 12
 \code{celda_feature_module} in \link[SummarizedExperiment]{rowData}.}
13 13
 
14 14
 \item{from}{Numeric vector. Unique values in the range of
15
-\code{seq(modules(sce))} that correspond to the original module labels
15
+\code{seq(celdaModules(sce))} that correspond to the original module labels
16 16
 in \code{sce}.}
17 17
 
18 18
 \item{to}{Numeric vector. Unique values in the range of
19
-\code{seq(modules(sce))} that correspond to the new module labels.}
19
+\code{seq(celdaModules(sce))} that correspond to the new module labels.}
20 20
 }
21 21
 \value{
22 22
 @return \linkS4class{SingleCellExperiment} object with recoded