Skip to content

Commit e33763c

Browse files
authored
Set alpha=Inf as the default for testEmptyDrops. (#118)
This is because a finite alpha is not universally safer; despite representing an overdispersed multinomial, using it to compute p-values for a multinomial-distributed vector will actually be anticonservative! This means that an inaccurate alpha cannot be brushed under the carpet. Previously, I was trusting that any finite alpha would be safer than alpha=Inf, but it seems that this is not true. We can't just ignore poor estimates of alpha that we get from the assumed-ambient counts. So, we keep it simple and set the default to alpha=Inf, which is exactly correct for the multinomial case, i.e., independent sampling of molecules into droplet (which should represent most scenarios, hopefully). This also reduces runtime and aligns with the CellRanger defaults.
1 parent e0fb389 commit e33763c

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: DropletUtils
2-
Version: 1.27.1
3-
Date: 2024-12-04
2+
Version: 1.27.2
3+
Date: 2024-12-10
44
Title: Utilities for Handling Single-Cell Droplet Data
55
Authors@R: c(
66
person("Aaron", "Lun", role = "aut"),

R/emptyDrops.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,20 @@
7575
#' The latter is a \dQuote{no frills} version that is largely intended for use within other functions.
7676
#'
7777
#' @section Handling overdispersion:
78+
#' By default, \code{alpha=Inf} which means that the count vector is modelled with a multinomial distribution.
79+
#' This is appropriate when molecules are independently sampled into each droplet.
80+
#'
7881
#' If \code{alpha} is set to a positive number, sampling is assumed to follow a Dirichlet-multinomial (DM) distribution.
7982
#' The parameter vector of the DM distribution is defined as the estimated ambient profile scaled by \code{alpha}.
80-
#' Smaller values of \code{alpha} model overdispersion in the counts, due to dependencies in sampling between molecules.
83+
#' Smaller values of \code{alpha} model overdispersion in the counts, due to dependencies in sampling between molecules (e.g., aggregates, PCR duplication).
8184
#' If \code{alpha=NULL}, a maximum likelihood estimate is obtained from the count profiles for all barcodes with totals less than or equal to \code{lower}.
82-
#' If \code{alpha=Inf}, the sampling of molecules is modelled with a multinomial distribution.
8385
#'
8486
#' Users can check whether the model is suitable by extracting the p-values for all barcodes with \code{test.ambient=TRUE}.
8587
#' Under the null hypothesis, the p-values for presumed ambient barcodes (i.e., with total counts less than or equal to \code{lower}) should be uniformly distributed.
86-
#' Skews in the p-value distribution are indicative of an inaccuracy in the model and/or its estimates (of \code{alpha} or the ambient profile).
87-
#'
88+
#' Skews in the p-value distribution are indicative of an inaccuracy in the model.
89+
#' For example, an inaccurate \code{alpha} or ambient profile will manifest in the overenrichment of low p-values.
90+
#' Conversely, very sparse data will often exhibit in a enrichment of p-values at 1 as the Good-Turing probabilities in the ambient profile cannot be zero.
91+
#'
8892
#' @section \code{NA} values in the results:
8993
#' We assume that barcodes with total UMI counts less than or equal to \code{lower} correspond to empty droplets.
9094
#' These are used to estimate the ambient expression profile against which the remaining barcodes are tested.
@@ -181,7 +185,7 @@ NULL
181185

182186
#' @export
183187
#' @rdname emptyDrops
184-
testEmptyDrops <- function(m, lower=100, niters=10000, test.ambient=FALSE, ignore=NULL, alpha=NULL, round=TRUE, by.rank=NULL, known.empty=NULL, BPPARAM=SerialParam()) {
188+
testEmptyDrops <- function(m, lower=100, niters=10000, test.ambient=FALSE, ignore=NULL, alpha=Inf, round=TRUE, by.rank=NULL, known.empty=NULL, BPPARAM=SerialParam()) {
185189
ambfun <- function(mat, totals) {
186190
assumed.empty <- .get_putative_empty(totals, lower, by.rank, known.empty)
187191
astats <- .compute_ambient_stats(mat, totals, assumed.empty)

inst/NEWS.Rd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
\item Use a more stable algorithm for identifying the knee point in \code{barcodeRanks()}.
77
The new algorithm is based on maximizing the distance from a line between the plateau and the inflection point.
88
Previously, we tried to minimize the signed curvature but this was susceptible to many local minima due to the instability of the empirical second derivative, even after smoothing.
9+
10+
\item Set \code{alpha=Inf} as the default for \code{testEmptyDrops()}.
11+
This is motivated by the realization that an underestimated \code{alpha} can still yield anticonservative p-values and is not universally safer than \code{alpha=Inf}.
12+
Defaulting \code{alpha=Inf} is preferable as it is at least correct in the expected case of multinomial sampling.
913
}}
1014

1115
\section{Version 1.18.0}{\itemize{

man/emptyDrops.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)