emptyDrops {DropletUtils} | R Documentation

## Identify empty droplets

### Description

Distinguish between droplets containing cells and ambient RNA in a droplet-based single-cell RNA sequencing experiment.

### Usage

    testEmptyDrops(m, lower=100, niters=10000, test.ambient=FALSE,
        ignore=NULL, alpha=NULL, BPPARAM=SerialParam())

    emptyDrops(m, lower=100, retain=NULL, barcode.args=list(), ...)

### Arguments

`m` | A numeric matrix object, usually a dgTMatrix or dgCMatrix. Columns represent barcoded droplets, rows represent genes.
`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.
`niters` | An integer scalar specifying the number of iterations to use for the Monte Carlo p-value calculations.
`test.ambient` | A logical scalar indicating whether results should be returned for barcodes with totals less than or equal to `lower`.
`ignore` | A numeric scalar specifying the lower bound on the total UMI count, at or below which barcodes will be ignored (see Details for how this differs from `lower`).
`alpha` | A numeric scalar specifying the scaling parameter for the Dirichlet-multinomial sampling scheme.
`BPPARAM` | A BiocParallelParam object indicating whether parallelization should be used to compute p-values.
`retain` | A numeric scalar specifying the threshold for the total UMI count above which all barcodes are assumed to contain cells.
`barcode.args` | Further arguments to pass to `barcodeRanks`.
`...` | Further arguments to pass to `testEmptyDrops`.

### Value

`testEmptyDrops` will return a DataFrame with the following components:

`Total`:

  Integer, the total UMI count for each barcode.

`LogProb`:

  Numeric, the log-probability of observing the barcode's count vector under the null model.

`PValue`:

  Numeric, the Monte Carlo p-value against the null model.

`Limited`:

  Logical, indicating whether a lower p-value could be obtained by increasing `npts`.

For barcodes with counts below `lower`, `NA` values are returned for all fields if `test.ambient=FALSE`. This is to ensure that the number of rows in the output DataFrame is identical to `ncol(m)`.

`emptyDrops` will return a DataFrame like `testEmptyDrops`, with an additional `FDR` field.

The metadata of the output DataFrame will contains the ambient profile in `ambient`, the estimated/specified value of `alpha`, the specified value of `lower` and the number of iterations in `niters`. For `emptyDrops`, the metadata will also contain the retention threshold in `retain`.

### Details about `testEmptyDrops`

The `testEmptyDrops` function will obtain 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`. This assumes that a cell-containing droplet would generally have higher total counts than empty droplets containing RNA from the ambient pool. Counts for the low-count barcodes are pooled together, and an estimate of the proportion vector for the ambient pool is calculated using `goodTuringProportions`. The count vector for each barcode above `lower` is then tested for a significant deviation from these proportions.

The null hypothesis is that transcript molecules are included into droplets by multinomial sampling from the ambient profile. For each barcode, the probability of obtaining its count vector based on the null model is computed. Then, `niters` count vectors are simulated from the null model. The proportion of simulated vectors with probabilities lower than the observed multinomial probability for that barcode is used to calculate the p-value. We use this Monte Carlo approach as an exact multinomial p-value is difficult to calculate.

The `ignore` argument can also be set to ignore barcodes with total counts less than or equal to `ignore`. This differs from the `lower` argument in that the ignored barcodes are not necessarily used to compute the ambient profile. Users can interpret `ignore` as the minimum total count required for a barcode to be considered as a potential cell. In contrast, `lower` is the maximum total count below which all barcodes are assumed to be empty droplets.

### Details about `emptyDrops`

The `emptyDrops` function combines the results of `testEmptyDrops` with `barcodeRanks` to identify droplets that are likely to contain cells. Specifically, the total count `K` at the knee point is determined, and barcodes that contain more than `K` total counts are always retained. This ensures that cells with profiles that are very similar to the ambient pool are not inadvertently discarded. If `retain` is specified, this is used instead of `K`, which may be useful if the knee point was not correctly identified in complex log-rank curves. Users can set `retain=Inf` to disable automatic retention of barcodes with large totals.

The Benjamini-Hochberg correction is also applied to the Monte Carlo p-values to correct for multiple testing. Cells can then be defined by taking all barcodes with significantly non-ambient profiles, e.g., at a false discovery rate of 1%. All barcodes with total counts above `K` (or `retain`) are assigned p-values of zero during correction, reflecting our assumption that they are true positives. This ensures that their Monte Carlo p-values do not affect the correction of other genes, and also means that they will have FDR values of zero. Nonetheless, their original Monte Carlo p-values are still reported in the output.

### Handling overdispersion

If `alpha` is set to a positive number, sampling is assumed to follow a Dirichlet-multinomial (DM) distribution. The parameter vector of the DM distribution is defined as the estimated ambient profile scaled by `alpha`. Smaller values of `alpha` model overdispersion in the counts, due to dependencies in sampling between molecules. If `alpha=NULL`, a maximum likelihood estimate is obtained from the count profiles for all barcodes with totals less than or equal to `lower`. If `alpha=Inf`, the sampling of molecules is modelled with a multinomial distribution.

Users can check whether the model is suitable by extracting the p-values for all barcodes with `test.ambient=TRUE`. Under the null hypothesis, the p-values for presumed ambient barcodes (i.e., with total counts below `lower`) should be uniformly distributed. Skews in the p-value distribution are indicative of an inaccuracy in the model and/or its estimates (of `alpha` or the ambient profile).

### Author(s)

Aaron Lun

### References

Lun A, Riesenfeld S, Andrews T, Dao TP, Gomes T, participants in the 1st Human Cell Atlas Jamboree, Marioni JC (2018). Distinguishing cells from empty droplets in droplet-based single-cell RNA sequencing data. biorXiv.

Phipson B, Smyth GK (2010). Permutation P-values should never be zero: calculating exact P-values when permutations are randomly drawn. Stat. Appl. Genet. Mol. Biol. 9:Article 39.

### See Also

`barcodeRanks`, `defaultDrops`

### Examples

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

    # Identify likely cell-containing droplets.
    out <- emptyDrops(my.counts)
    out

    is.cell <- out$FDR <= 0.01
    sum(is.cell, na.rm=TRUE)

    # Check if p-values are lower-bounded by 'npts'
    # (increase 'npts' if any Limited==TRUE and Sig==FALSE)
    table(Sig=is.cell, Limited=out$Limited)

[Package DropletUtils version 1.2.2 Index]