var_rows: Find most variable rows

View source: R/CA.R

var_rowsR Documentation

Find most variable rows

Description

Calculates the variance of the chi-square component matrix and selects the rows with the highest variance, e.g. 5,000.

Usage

var_rows(mat, top = 5000)

Arguments

mat

A numeric matrix. For sequencing a count matrix, gene expression values with genes in rows and samples/cells in columns. Should contain row and column names.

top

Integer. Number of most variable rows to retain. Default 5000.

Value

Returns a matrix, which consists of the top variable rows of mat.

Examples

set.seed(1234)

# Simulate counts
cnts <- mapply(function(x){rpois(n = 500, lambda = x)},
              x = sample(1:20, 50, replace = TRUE))
rownames(cnts) <- paste0("gene_", 1:nrow(cnts))
colnames(cnts) <- paste0("cell_", 1:ncol(cnts))

# Choose top 5000 most variable genes
cnts <- var_rows(mat = cnts, top = 5000)



ClemensKohl/APL documentation built on May 25, 2024, 3:15 p.m.