fitNB: Fit Negative Binomial Mixture Model The function fits a...

Description Usage Arguments Value Examples

View source: R/siberRaw2.R

Description

This function directly maximize the log likelihood function through optimization. With this function, three models can be fitted: (1) negative binomial mixture with equal dispersion (E model); (2) negative binomial mixture with unequal dispersion (V model); (3) 0-inflated negative binomial model. The 0-inflated negative binomial has the following density function: P(Y=y)=π D(y) + (1-π)NB(μ, φ) where D is the point mass at 0 while NB(μ, φ) is the density of negative binomial distribution with mean μ and dispersion φ. The variance is μ+φ μ^2. The rule to fit 0-inflated model is that the observed percentage of count exceeds the user specified threshold. This rule overrides the model argument when observed percentae of zero count exceeds the threshold.

Usage

1
fitNB(y, d = NULL, inits = NULL, model = "V", zeroPercentThr = 0.2)

Arguments

y

A vector representing the RNAseq raw count.

d

A vector of the same length as y representing the normalization constant to be applied to the data. For the LN model, the original data would be devided by this vector.

inits

Initial value to fit the mixture model. A vector with elements mu1, mu2, phi1, phi2 and pi1. For 0-inflated model, only mu2, phi2, pi1 are used while the other elements can be arbitrary.

model

Character specifying E or V model. E model fits the mixture model with equal variance while V model doesn't put any constraint.

zeroPercentThr

A scalar specifying the minimum percent of zero counts needed when fitting a zero-inflated Negative Binomial model. This parameter is used to deal with zero-inflation in RNAseq count data. When the percent of zero exceeds this threshold, rather than fitting a 2-component negative binomial mixture, a mixture of point mass at 0 and negative binomial is fitted.

Value

A vector consisting parameter estimates of mu1, mu2, sigma1, sigma2, pi1, logLik and BIC. For 0-inflated model, mu1=sigma1=0.

Examples

1
2
3
set.seed(1000)
dat <- rnbinom(100, mu=1000, size=1/0.2)
fitNB(y=dat)

nickytong/SIBER documentation built on May 23, 2019, 5:08 p.m.