From 220515aafdbd988acc8764dcec1de2f21697fb5e Mon Sep 17 00:00:00 2001 From: Jonathan Griffiths <7976085+jonathangriffiths@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:55:30 +0100 Subject: [PATCH] deprecate beachmat::whichNonZero --- DESCRIPTION | 2 +- NAMESPACE | 3 ++- R/emptyDrops.R | 17 ++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fe9144d..5558039 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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( diff --git a/NAMESPACE b/NAMESPACE index fdd3dfe..ef24259 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/emptyDrops.R b/R/emptyDrops.R index 1b8479a..84e8ec2 100644 --- a/R/emptyDrops.R +++ b/R/emptyDrops.R @@ -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) @@ -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) {