Description Usage Arguments Details Value Examples
View source: R/average_expression.R
Average gene expression by ident class in a Seurat object to find cluster centers using fast sparse matrix methods.
1 2 3 4 5 6 7 8 9 10 | average.expression(
object,
ident = "active.ident",
assay = "active.assay",
slot = "counts",
verbose = TRUE,
details = FALSE,
return.seurat = FALSE,
reduction.name = "dclus"
)
|
object |
Seurat object |
ident |
Ident with sample clustering information (default is the |
assay |
Assay to average (default is the |
slot |
Slot to average (default is "counts") |
verbose |
Boolean, show progress bar (default is TRUE) |
details |
Boolean, calculate additional statistics about each cluster (default is FALSE) |
return.seurat |
Return the input Seurat object with the cluster centers as a new dimensional reduction object (default = FALSE for consistency with Seurat AverageExpression()) |
reduction.name |
Name of |
By default, average.expression
averages gene counts by grouping cells by the active identity in the active assay of the counts slot of the Seurat object.
The assay, the identity, and the slot can be specified if other than the active ones or the count slot.
If return.seurat is specified as TRUE, average.expression
returns the Seurat object with cluster centers in a dimensional reduction object.
By default, the \@reductions
slot is named with the parameter reduction.name = "dclus"
.
Additional statistics will be calculated on cluster centers if details = TRUE
, specifically the cells per center, the number of cells in each center, and the cosine distances of cells in that cluster to the cluster center.
average.expression
uses Matrix::rowMeans
to perform sparse matrix averaging of each cluster.
dense matrix of cluster centers if settings are default. If details = TRUE, returns a list of cluster centers matrix, cells.per.center, cells.in.center, and a vector of cosine distances for all cells to their assigned center
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
library(SeuratData)
library(scNMF)
InstallData(pbmc3k)
pbmc3k <- NormalizeData(pbmc3k)
pbmc3k <- cluster.divisive(pbmc3k)
cluster.centers <- average.expression(pbmc3k)
# or
cluster.centers <- average.expression(pbmc3k, details = TRUE, slot = "logcounts", assay = "RNA", ident = "leaf.idents") # but you probably don't want to use logcounts
or
pbmc3k <- average.expression(pbmc3k, return.seurat = TRUE)
#or
pbmc3k <- average.expression(pbmc3k, return.seurat = TRUE, reduction.name = "div_clust")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.