Skip to content

Commit

Permalink
deprecate beachmat::whichNonZero
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangriffiths committed Jul 23, 2024
1 parent ded6e8d commit 220515a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: DropletUtils
Version: 1.25.1
Version: 1.25.2
Date: 2024-07-09
Title: Utilities for Handling Single-Cell Droplet Data
Authors@R: c(
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ importFrom(S4Vectors,extractROWS)
importFrom(S4Vectors,make_zero_col_DFrame)
importFrom(S4Vectors,metadata)
importFrom(SingleCellExperiment,SingleCellExperiment)
importFrom(SparseArray,nzvals)
importFrom(SparseArray,nzwhich)
importFrom(SummarizedExperiment,assay)
importFrom(SummarizedExperiment,colData)
importFrom(beachmat,colBlockApply)
importFrom(beachmat,whichNonZero)
importFrom(dqrng,generateSeedVectors)
importFrom(edgeR,goodTuringProportions)
importFrom(edgeR,q2qnbinom)
Expand Down
17 changes: 8 additions & 9 deletions R/emptyDrops.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ testEmptyDrops <- function(m, lower=100, niters=10000, test.ambient=FALSE, ignor
list(seeds=seeds.per.core, streams=streams.per.core)
}

#' @importFrom beachmat whichNonZero
#' @importFrom SparseArray nzwhich nzvals
.compute_multinom_prob_data <- function(block, prop, alpha=Inf, BPPARAM=SerialParam())
# Efficiently calculates the data-dependent component of the log-multinomial probability
# for a column-wise chunk of the full matrix (or, indeed, the full matrix itself).
# Also does so for the Dirichlet-multinomial log-probability for a given 'alpha'.
{
nonzero <- whichNonZero(block)
i <- nonzero$i
j <- nonzero$j
x <- nonzero$x
idx <- nzwhich(block, arr.ind=TRUE)
i <- idx[,1]
j <- idx[,2]
x <- nzvals(block)

if (is.infinite(alpha)) {
p.n0 <- x * log(prop[i]) - lfactorial(x)
Expand All @@ -346,14 +346,13 @@ testEmptyDrops <- function(m, lower=100, niters=10000, test.ambient=FALSE, ignor
}
}

#' @importFrom beachmat whichNonZero
#' @importFrom SparseArray nzwhich nzvals
#' @importFrom stats optimize
.estimate_alpha <- function(mat, prop, totals, interval=c(0.01, 10000))
# Efficiently finds the MLE for the overdispersion parameter of a Dirichlet-multinomial distribution.
{
nonzero <- whichNonZero(mat)
i <- nonzero$i
x <- nonzero$x
i <- nzwhich(x, arr.ind=TRUE)[,1]
x <- nzvals(x)

per.prop <- prop[i]
LOGLIK <- function(alpha) {
Expand Down

0 comments on commit 220515a

Please sign in to comment.