fit_marginals: Fit the marginal distributions for each row of a count matrix

View source: R/model_fitting.R

fit_marginalsR Documentation

Fit the marginal distributions for each row of a count matrix

Description

Fit the marginal distributions for each row of a count matrix

Usage

fit_marginals(
  x,
  marginal = c("auto_choose", "zinb", "nb", "poisson"),
  pval_cutoff = 0.05,
  epsilon = 1e-05,
  jitter = TRUE,
  DT = TRUE
)

Arguments

x

A matrix of shape p by n that contains count values.

marginal

Specification of the types of marginal distribution. Default value is 'auto_choose' which chooses between ZINB, NB, ZIP and Poisson by a likelihood ratio test (lrt) and whether there is underdispersion. 'zinb' will fit the ZINB model. If there is underdispersion, it will choose between ZIP and Poisson by a lrt. Otherwise, it will try to fit the ZINB model. If in this case, there is no zero at all or an error occurs, it will fit an NB model instead. 'nb' fits the NB model that chooses between NB and Poisson depending on whether there is underdispersion. 'poisson' simply fits the Poisson model.

pval_cutoff

Cutoff of p-value of the lrt that determines whether there is zero inflation.

epsilon

Threshold value for preventing the transformed quantile to collapse to 0 or 1.

jitter

Logical, whether a random projection should be performed in the distributional transform.

DT

Logical, whether distributional transformed should be performed. If set to FALSE, the returned object u will be NULL.

Value

a list with the following components:

params

a matrix of shape p by 3. The values of each column are: the ZI proportion, the dispersion parameter (for Poisson, it's Inf), and the mean parameter.

u

NULL or a matrix of the same shape as x, which records the transformed quantiles, by DT.


JSB-UCLA/scDesign2 documentation built on Nov. 2, 2024, 4:26 a.m.