weights_ZINB {benchdamic} | R Documentation

## weights_ZINB

### Description

Computes the observational weights of the counts under a zero-inflated negative binomial (ZINB) model. For each count, the ZINB distribution is parametrized by three parameters: the mean value and the dispersion of the negative binomial distribution, and the probability of the zero component.

### Usage

    weights_ZINB(
      object,
      design,
      K = 0,
      commondispersion = TRUE,
      zeroinflation = TRUE,
      verbose = FALSE,
      ...
    )

### Arguments

`object` | phyloseq object containing the counts and the sample data.
`design` | character name of the metadata columns, formula, or design matrix with rows corresponding to samples and columns to coefficients to be estimated (the user needs to explicitly include the intercept in the design).
`K` | integer. Number of latent factors.
`commondispersion` | Whether or not a single dispersion for all features is estimated (default TRUE).
`zeroinflation` | Whether or not a ZINB model should be fitted. If FALSE, a negative binomial model is fitted instead.
`verbose` | Print helpful messages.
`...` | Additional parameters to describe the model, see `zinbModel`.

### Value

A matrix of weights.

### See Also

`zinbFit` for zero-inflated negative binomial parameters' estimation and `computeObservationalWeights` for weights extraction.

### Examples

    set.seed(1)
    # Create a very simple phyloseq object
    counts <- matrix(rnbinom(n = 60, size = 3, prob = 0.5), nrow = 10, ncol = 6)
    metadata <- data.frame("Sample" = c("S1", "S2", "S3", "S4", "S5", "S6"))
    ps <- phyloseq::phyloseq(phyloseq::otu_table(counts, taxa_are_rows = TRUE),
        phyloseq::sample_data(metadata))
    # Calculate the ZINB weights
    zinbweights <- weights_ZINB(object = ps, K = 0, design = "~ 1")

[Package benchdamic version 1.0.0 Index]