average_clusters: Average expression values per cluster

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Average expression values per cluster

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
average_clusters(
  mat,
  metadata,
  cluster_col = "cluster",
  if_log = TRUE,
  cell_col = NULL,
  low_threshold = 0,
  method = "mean",
  output_log = TRUE,
  subclusterpower = 0,
  cut_n = NULL
)

Arguments

mat

expression matrix

metadata

data.frame or vector containing cluster assignments per cell. Order must match column order in supplied matrix. If a data.frame provide the cluster_col parameters.

cluster_col

column in metadata with cluster number

if_log

input data is natural log, averaging will be done on unlogged data

cell_col

if provided, will reorder matrix first

low_threshold

option to remove clusters with too few cells

method

whether to take mean (default) or median

output_log

whether to report log results

subclusterpower

whether to get multiple averages per original cluster

cut_n

set on a limit of genes as expressed, lower ranked genes are set to 0, considered unexpressed

Value

average expression matrix, with genes for row names, and clusters for column names

Examples

1
2
3
4
5
6
7
mat <- average_clusters(
    mat = pbmc_matrix_small,
    metadata = pbmc_meta,
    cluster_col = "classified",
    if_log = FALSE
)
mat[1:3, 1:3]

Example output

       Naive CD4 T Memory CD4 T CD14+ Mono
PPBP    0.01892718   0.02607889 0.08947514
LYZ     0.65070360   0.67842980 1.80412017
S100A9  0.22047491   0.26729285 1.71088164

clustifyr documentation built on Nov. 8, 2020, 5:32 p.m.