average.expression: Average gene expression in clusters

Description Usage Arguments Details Value Examples

View source: R/average_expression.R

Description

Average gene expression by ident class in a Seurat object to find cluster centers using fast sparse matrix methods.

Usage

 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"
)

Arguments

object

Seurat object

ident

Ident with sample clustering information (default is the \@active.ident)

assay

Assay to average (default is the \@active.assay)

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 \@reduction object if return.seurat = TRUE, other than the default "dclus" name

Details

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.

Value

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

Examples

 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)

zdebruine/scNMF documentation built on Jan. 1, 2021, 1:50 p.m.