fit_ZINB: Calculate Summary Statistics

Description Usage Arguments Details Value See Also Examples

Description

Calculates summary statistics to facilitate the fitting of a ZINB model, performs various data input checks.

Usage

1
2
3
4
5
	fit_ZINB_to_matrix(counts)
	fit_NB_to_matrix(counts)
	fit_ZINB_to_SCE(sce, lab_column="cell_type1")
	fit_zero_inflated_negative_binomial(obs, g_row, vals, e=0.00001)
	

Arguments

counts

a numeric matrix of raw UMI or read counts, columns = samples, rows = genes.

obs

a single row from a count matrix

g_row

index/row number of the "obs" row

vals

summary statistics from calculate_summary_values

e

acceptable error for convergence of the EM algorithm

sce

a SingleCellExperiment object.

lab_column

name of the column containing the cell-type ids.

Details

fit_ZINB_to_matrix calculates summary statistics and runs fit_zero_inflated_negative_binomial on each row of the count matrix.

fit_ZINB_to_SCE calculates summary statistics and runs fit_zero_inflated_negative_binomial on each gene of the count matrix within the SCE object automatically splitting it by cell-type labels in the specified column.

fit_NB_to_matrix calculates summary statistics and fits a library size adjusted negative binomial to each row of the count matrix.

fit_zero_inflated_negative_binomial fit a library-size adjusted zero-inflated negative binomial model to the expression of one gene using an expectation-maximization (EM) algorithm.

Library size adjusted zero-inflated negative binomial model:

X ~ NBinom(muij, rj) *( 1-dj) + 0*dj

mu_ij = li*muj = mean expression of gene j in cell i li = relative library size of cell i muj = mean expression of gene j rj = dispersion (size parameter of R's nbinom functions) dj = dropout rate of gene j

Value

fit_zero_inflated_negative_binomial a vector of mu, r, and d of the ZINB. fit_ZINB_to_matrix a table of mu, r, and d for each gene in the matrix. fit_ZINB_to_SCE a list of tables of mu, r, and d for each gene for each cell-type. fit_NB_to_matrix a table of mu and r for each gene in the matrix.

See Also

calculate_summary_values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
	counts <- matrix(rnbinom(10000, mu=10, size=0.5), ncol=20);
	fits <- fit_NB_to_matrix(counts);

	z_inflate <- matrix(runif(10000), ncol=20) < 0.2
	counts[z_inflate] <- 0;
	fits <- fit_ZINB_to_matrix(counts);

	vals <- calculate_summary_values(counts);
	fit <- fit_zero_inflated_negative_binomial(counts[3,], 3, vals)
	require("SingleCellExperiment")
	sce <- SingleCellExperiment(assays=list("counts"=counts));
	sce$cell_type = rep(c(1,2), each=10)
	out <- fit_ZINB_to_SCE(sce, "cell_type")

tallulandrews/TreeOfCells documentation built on April 26, 2020, 2:43 p.m.