var_rows: Find most variable rows

Description Usage Arguments Value Examples

View source: R/CA.R

Description

Calculates the variance of the chi-square components matrix and selects the top e.g 5000 rows.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

elagralinska/APLpackage documentation built on Dec. 20, 2021, 4:15 a.m.