diff --git a/DESCRIPTION b/DESCRIPTION index 6553c319..ed6b537e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,14 +23,14 @@ Imports: plyr, foreach, ggplot2, RColorBrewer, grid, scales, gtable, MCMCprecision, ggrepel, Rtsne, withr, scater (>= 1.14.4), scran, dbscan, DelayedArray, stringr, ComplexHeatmap, gridExtra, - circlize + circlize, dendextend, ggdendro, pROC Suggests: testthat, knitr, roxygen2, rmarkdown, biomaRt, covr, BiocManager, BiocStyle, TENxPBMCData, singleCellTK, M3DExampleData LinkingTo: Rcpp, RcppEigen License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 BugReports: https://github.com/campbio/celda/issues biocViews: SingleCell, GeneExpression, Clustering, Sequencing, Bayesian, ImmunoOncology, DataImport NeedsCompilation: yes diff --git a/R/findMarkersTree.R b/R/findMarkersTree.R index 164b40f3..e62d0fb8 100644 --- a/R/findMarkersTree.R +++ b/R/findMarkersTree.R @@ -32,7 +32,7 @@ #' are solely defined by the absence of markers. Default is TRUE. #' @param consecutiveOneoff Logical. Whether or not to allow one-off splits at #' consecutive brances. Default is FALSE. -#' @param autoMetaclusters. Logical. Whether to identify metaclusters prior to +#' @param autoMetaclusters Logical. Whether to identify metaclusters prior to #' creating the tree based on the distance between clusters in a UMAP #' dimensionality reduction projection. A metacluster is simply a large #' cluster that includes several clusters within it. Default is TRUE. @@ -2339,18 +2339,21 @@ subUnderscore <- function(x, n) unlist(lapply( #' @param boxColor Character value. Color of rule labels. Default is black. #' @examples #' # Generate simulated single-cell dataset using celda -#' sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +#' sce <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +#' +#' # Select top features +#' sce <- selectFeatures(sce) #' #' # Celda clustering into 5 clusters & 10 modules -#' cm <- celda_CG(sim_counts$counts, K=5, L=10, verbose=FALSE) +#' sce <- celda_CG(sce, K=5, L=10, verbose=FALSE) #' #' # Get features matrix and cluster assignments -#' factorized <- factorizeMatrix(sim_counts$counts, cm) -#' features <- factorized$proportions$cell -#' class <- clusters(cm)$z +#' factorizedCounts <- factorizeMatrix(sce, type = "counts") +#' featureMatrix <- factorizedCounts$counts$cell +#' classes <- as.integer(celdaClusters(sce)) #' #' # Generate Decision Tree -#' DecTree <- findMarkersTree(features,class,threshold = 1) +#' DecTree <- findMarkersTree(featureMatrix, classes) #' #' # Plot dendrogram #' plotDendro(DecTree) @@ -2634,23 +2637,25 @@ plotDendro <- function(tree, #' @return A heatmap visualizing the counts matrix for the cells and genes at #' the specified branch point. #' @examples -#' # Generate simulated single-cell dataset using celda -#' sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +#' sce <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +#' +#' # Select top features +#' sce <- selectFeatures(sce) #' #' # Celda clustering into 5 clusters & 10 modules -#' cm <- celda_CG(sim_counts$counts, K=5, L=10, verbose=FALSE) +#' sce <- celda_CG(sce, K=5, L=10, verbose=FALSE) #' #' # Get features matrix and cluster assignments -#' factorized <- factorizeMatrix(sim_counts$counts, cm) -#' features <- factorized$proportions$cell -#' class <- clusters(cm)$z +#' factorizedCounts <- factorizeMatrix(sce, type = "counts") +#' featureMatrix <- factorizedCounts$counts$cell +#' classes <- as.integer(celdaClusters(sce)) #' #' # Generate Decision Tree -#' DecTree <- findMarkersTree(features,class,threshold = 1) +#' DecTree <- findMarkersTree(featureMatrix, classes) #' #' # Plot example heatmap -#' plotMarkerHeatmap(DecTree, sim_counts$counts, branchPoint = "top_level", -#' featureLabels = paste0("L",clusters(cm)$y)) +#' plotMarkerHeatmap(DecTree, featureMatrix, branchPoint = "top_level", +#' featureLabels = rownames(featureMatrix)) #' #' @export plotMarkerHeatmap <- function(tree, counts, branchPoint, featureLabels, diff --git a/man/findMarkersTree.Rd b/man/findMarkersTree.Rd index 303ad7e9..f887f05e 100644 --- a/man/findMarkersTree.Rd +++ b/man/findMarkersTree.Rd @@ -60,13 +60,13 @@ are solely defined by the absence of markers. Default is TRUE.} \item{consecutiveOneoff}{Logical. Whether or not to allow one-off splits at consecutive brances. Default is FALSE.} -\item{seed}{Numeric. Seed used to enable reproducible UMAP results -for identifying metaclusters. Default is 12345.} - -\item{autoMetaclusters.}{Logical. Whether to identify metaclusters prior to +\item{autoMetaclusters}{Logical. Whether to identify metaclusters prior to creating the tree based on the distance between clusters in a UMAP dimensionality reduction projection. A metacluster is simply a large cluster that includes several clusters within it. Default is TRUE.} + +\item{seed}{Numeric. Seed used to enable reproducible UMAP results +for identifying metaclusters. Default is 12345.} } \value{ A named list with six elements: diff --git a/man/plotDendro.Rd b/man/plotDendro.Rd index e1e43ad8..4b242888 100644 --- a/man/plotDendro.Rd +++ b/man/plotDendro.Rd @@ -41,18 +41,21 @@ Generates a dendrogram of the rules and performance } \examples{ # Generate simulated single-cell dataset using celda -sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +sce <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) + +# Select top features +sce <- selectFeatures(sce) # Celda clustering into 5 clusters & 10 modules -cm <- celda_CG(sim_counts$counts, K=5, L=10, verbose=FALSE) +sce <- celda_CG(sce, K=5, L=10, verbose=FALSE) # Get features matrix and cluster assignments -factorized <- factorizeMatrix(sim_counts$counts, cm) -features <- factorized$proportions$cell -class <- clusters(cm)$z +factorizedCounts <- factorizeMatrix(sce, type = "counts") +featureMatrix <- factorizedCounts$counts$cell +classes <- as.integer(celdaClusters(sce)) # Generate Decision Tree -DecTree <- findMarkersTree(features,class,threshold = 1) +DecTree <- findMarkersTree(featureMatrix, classes) # Plot dendrogram plotDendro(DecTree) diff --git a/man/plotMarkerHeatmap.Rd b/man/plotMarkerHeatmap.Rd index 5263cdd5..28520c05 100644 --- a/man/plotMarkerHeatmap.Rd +++ b/man/plotMarkerHeatmap.Rd @@ -41,22 +41,24 @@ the specified branch point. Creates heatmap for a specified branch point in a marker tree. } \examples{ -# Generate simulated single-cell dataset using celda -sim_counts <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) +sce <- celda::simulateCells("celda_CG", K = 4, L = 10, G = 100) + +# Select top features +sce <- selectFeatures(sce) # Celda clustering into 5 clusters & 10 modules -cm <- celda_CG(sim_counts$counts, K=5, L=10, verbose=FALSE) +sce <- celda_CG(sce, K=5, L=10, verbose=FALSE) # Get features matrix and cluster assignments -factorized <- factorizeMatrix(sim_counts$counts, cm) -features <- factorized$proportions$cell -class <- clusters(cm)$z +factorizedCounts <- factorizeMatrix(sce, type = "counts") +featureMatrix <- factorizedCounts$counts$cell +classes <- as.integer(celdaClusters(sce)) # Generate Decision Tree -DecTree <- findMarkersTree(features,class,threshold = 1) +DecTree <- findMarkersTree(featureMatrix, classes) # Plot example heatmap -plotMarkerHeatmap(DecTree, sim_counts$counts, branchPoint = "top_level", -featureLabels = paste0("L",clusters(cm)$y)) +plotMarkerHeatmap(DecTree, featureMatrix, branchPoint = "top_level", + featureLabels = rownames(featureMatrix)) }