ambientProfileEmpty {DropletUtils} | R Documentation

## Estimate the ambient profile from empty droplets

### Description

Estimate the transcript proportions in the ambient solution from an unfiltered count matrix, assuming that low-count barcodes correspond to “known empty” droplets. Zeroes are filled in using the Good-Turing method.

### Usage

    estimateAmbience(...)

    ambientProfileEmpty(m, ...)

    ## S4 method for signature 'ANY'
    ambientProfileEmpty(
      m,
      lower = 100,
      by.rank = NULL,
      round = TRUE,
      good.turing = TRUE,
      BPPARAM = SerialParam()
    )

    ## S4 method for signature 'SummarizedExperiment'
    ambientProfileEmpty(m, ..., assay.type = "counts")

### Arguments

`...` | For the generic, further arguments to pass to individual methods. For the SummarizedExperiment method, further arguments to pass to the ANY method. For `estimateAmbience`, arguments to pass to `ambientProfileEmpty`.
`m` | A numeric matrix-like object - usually a dgTMatrix or dgCMatrix - containing droplet data prior to any filtering or cell calling. Columns represent barcoded droplets, rows represent genes. For `emptyDrops`, this may also be a SummarizedExperiment object containing such a matrix.
`lower` | A numeric scalar specifying the lower bound on the total UMI count, at or below which all barcodes are assumed to correspond to empty droplets.
`by.rank` | An integer scalar or vector of length 2, used as an alternative to `lower` to identifying assumed empty droplets - see Details.
`round` | Logical scalar indicating whether to check for non-integer values in `m` and, if present, round them for ambient profile estimation (see `?ambientProfileEmpty`) and the multinomial simulations.
`good.turing` | Logical scalar indicating whether to perform Good-Turing estimation of the proportions.
`BPPARAM` | A BiocParallelParam object indicating whether parallelization should be used.
`assay.type` | Integer or string specifying the assay containing the count matrix.

### Details

This function obtains an estimate of the composition of the ambient pool of RNA based on the barcodes with total UMI counts less than or equal to `lower`. For each gene, counts are summed across all low-count barcodes and the resulting count vector is used for Good-Turing estimation of the proportions for each transcript. The aim here is to obtain reasonable proportions for genes with counts of zero in low-count barcodes but non-zero counts for other barcodes (thus avoiding likelihoods of zero when modelling the latter with the proportions).

This function will also attempt to detect whether `m` contains non-integer values by seeing if the column and row sums are discrete. If such values are present, `m` is first `round`ed to the nearest integer value before proceeding. This may be relevant when the count matrix is generated from pseudo-alignment methods like Alevin (see the tximeta package for details). Rounding is performed by default as discrete count values are necessary for the Good-Turing algorithm, but if `m` is known to be discrete, setting `round=FALSE` can provide a small efficiency improvement.

Setting `good.turing=FALSE` may be convenient to obtain raw counts for use in further modelling.

`estimateAmbience` is soft-deprecated; use `ambientProfileEmpty` instead.

### Value

A numeric vector of length equal to `nrow(m)`, containing the estimated proportion of each transcript in the ambient solution.

If `good.turing=FALSE`, the vector instead contains the sum of counts for each gene across all low-count barcodes.

### Behavior at zero counts

Good-Turing returns zero probabilities for zero counts if none of the summed counts are equal to 1. This is technically correct but not helpful, so we protect against this by adding a single “pseudo-feature” with a count of 1 to the profile. The modified profile is used to calculate a Good-Turing estimate of observing any feature that has zero counts, which is then divided to get the per-feature probability. We scale down all the other probabilities to make space for this new pseudo-probability, which has some properties of unclear utility (see https://github.com/MarioniLab/DropletUtils/issues/39).

Note that genes with counts of zero across all barcodes in `m` automatically have proportions of zero. This ensures that the estimation is not affected by the presence/absence of non-expressed genes in different annotations. In any case, such genes are likely to be completely irrelevant to downstream steps and can be safely ignored.

### Finding the assumed empty droplets

The default approach is to assume that all barcodes with total counts less than or equal to `lower` are empty. This is generally effective but may not be adequate for datasets with unusually low or high sequencing depth, such that all or none of the barcodes are detected as empty respectively. For example, there is no obvious choice for `lower` in CITE-seq data given that the coverage can be highly variable.

In such cases, an alternative approach can be used by passing an integer to the `by.rank` argument. This specifies the number of barcodes with the highest total counts to ignore; the remaining barcodes are assumed to be ambient. The idea is that, even if the exact threshold is unknown, we can be certain that a given experiment does not contain more than a particular number of genuine cell-containing barcodes based on the number of cells that were loaded into the machine. By setting `by.rank` to something greater than this a priori known number, we exclude the most likely candidates and use the remaining barcodes to compute the ambient profile.

### Author(s)

Aaron Lun

### See Also

`emptyDrops` and `hashedDrops`, where the ambient profile estimates are used for testing.

`ambientContribMaximum` and related functions, to estimate the contribution of ambient contamination in each library.

### Examples

    # Mocking up some data:
    set.seed(0)
    my.counts <- DropletUtils:::simCounts()

    ambience <- ambientProfileEmpty(my.counts)
    head(ambience)

[Package DropletUtils version 1.12.3 Index]