inferAmbience {DropletUtils} | R Documentation

## Infer the ambient profile

### Description

Infer the ambient profile from a filtered HTO count matrix containing only counts for cells.

### Usage

    inferAmbience(x, min.prop = 0.05)

### Arguments

`x` | A numeric matrix-like object containing counts for each HTO (row) and cell (column).
`min.prop` | Numeric scalar in (0, 1) specifying the expected minimum proportion of barcodes contributed by each sample.

### Details

In some cases, we want to know the ambient profile but we only have the HTO count matrix for the cell-containing libraries. This can be useful in functions such as `hashedDrops` or as a reference profile in `medianSizeFactors`. However, as we only have the cell-containing libraries, we cannot use `estimateAmbience`.

This function allows us to obtain the ambient profile under the assumption that each HTO only labels a minority of the cells. Specifically, it will fit a two-component mixture model to each HTO's count distribution. All barcodes assigned to the lower component are considered to have background counts for that HTO, and the mean of those counts is used as an estimate of the ambient contribution.

The initialization of the mixture model is controlled by `min.prop`, which starts the means of the lower and upper components at the `min.prop` and `1-min.prop` quantiles, respectively. This means that each sample is expected to contribute somewhere between `[min.prop, 1-min.prop]` barcodes. Larger values improve convergence but require stronger assumptions about the relative proportions of multiplexed samples.

### Value

A numeric vector of length equal to `nrow(x)`, containing the estimated ambient proportions for each HTO.

### Author(s)

Aaron Lun

### See Also

`hashedDrops`, where this function is used in the absence of an ambient profile.

`estimateAmbience`, which should be used when the raw matrix (prior to filtering for cells) is available.

### Examples

    x <- rbind(
        rpois(1000, rep(c(100, 1), c(100, 900))),
        rpois(1000, rep(c(2, 100, 2), c(100, 100, 800))),
        rpois(1000, rep(c(3, 100, 3), c(200, 700, 100)))
    )

    # Should be close to 1, 2, 3
    inferAmbience(x)

[Package DropletUtils version 1.10.3 Index]