fitTrendPoisson {scran} | R Documentation

## Generate a trend for Poisson noise

### Description

Create a mean-variance trend for log-normalized expression values derived from Poisson-distributed counts.

### Usage

    fitTrendPoisson(
      means,
      size.factors,
      npts = 1000,
      dispersion = 0,
      pseudo.count = 1,
      BPPARAM = SerialParam(),
      ...
    )

### Arguments

`means` | A numeric vector of length 2 or more, containing the range of mean counts observed in the dataset.
`size.factors` | A numeric vector of size factors for all cells in the dataset.
`npts` | An integer scalar specifying the number of interpolation points to use.
`dispersion` | A numeric scalar specifying the dispersion for the NB distribution. If zero, a Poisson distribution is used.
`pseudo.count` | A numeric scalar specifying the pseudo-count to be added to the scaled counts before log-transformation.
`BPPARAM` | A BiocParallelParam object indicating how parallelization should be performed across interpolation points.
`...` | Further arguments to pass to `fitTrendVar` for trend fitting.

### Details

This function is useful for modelling technical noise in highly diverse datasets without spike-ins, where fitting a trend to the endogenous genes would not be appropriate given the strong biological heterogeneity. It is mostly intended for UMI datasets where the technical noise is close to Poisson-distributed.

This function operates by simulating Poisson or negative binomial-distributed counts, computing log-transformed normalized expression values from those counts, calculating the mean and variance and then passing those metrics to `fitTrendVar`. The log-transformation ensures that variance is modelled in the same space that is used for downstream analyses like PCA.

Simulations are performed across a range of values in `means` to achieve reliable interpolation, with the stability of the trend determined by the number of simulation points in `npts`. The number of cells is determined from the length of `size.factors`, which are used to scale the distribution means prior to sampling counts.

### Value

A named list is returned containing:

`trend`:

  A function that returns the fitted value of the trend at any value of the mean.

`std.dev`:

  A numeric scalar containing the robust standard deviation of the ratio of `var` to the fitted value of the trend across all features used for trend fitting.

### Author(s)

Aaron Lun

### See Also

`fitTrendVar`, which is used to fit the trend.

### Examples

    # Mocking up means and size factors:
    sf <- 2^rnorm(1000, sd=0.1)
    sf <- sf/mean(sf)
    means <- rexp(100, 0.1)

    # Using these to construct a Poisson trend:
    out <- fitTrendPoisson(means, sf)
    curve(out$trend(x), xlim=c(0, 10))

[Package scran version 1.22.1 Index]