Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibity with DelayedArray 0.31.7 #110

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: DropletUtils
Version: 1.25.0
Date: 2022-11-21
Version: 1.25.1
Date: 2024-07-09
Title: Utilities for Handling Single-Cell Droplet Data
Authors@R: c(
person("Aaron", "Lun", role = "aut"),
Expand All @@ -21,7 +21,8 @@ Imports:
GenomicRanges,
SummarizedExperiment,
BiocParallel,
DelayedArray,
SparseArray (>= 1.5.18),
DelayedArray (>= 0.31.9),
DelayedMatrixStats,
HDF5Array,
rhdf5,
Expand Down Expand Up @@ -63,4 +64,4 @@ LinkingTo:
dqrng,
scuttle
SystemRequirements: C++11, GNU make
RoxygenNote: 7.3.0
RoxygenNote: 7.3.2
7 changes: 3 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ exportMethods(hashedDrops)
exportMethods(removeAmbience)
import(SingleCellExperiment)
importClassesFrom(DelayedArray,DelayedArray)
importClassesFrom(DelayedArray,SparseArraySeed)
importClassesFrom(Matrix,CsparseMatrix)
importClassesFrom(Matrix,dgCMatrix)
importClassesFrom(SparseArray,COO_SparseArray)
importClassesFrom(SparseArray,SparseArray)
importFrom(BiocGenerics,match)
importFrom(BiocParallel,SerialParam)
importFrom(BiocParallel,bplapply)
Expand All @@ -54,15 +56,12 @@ importFrom(BiocParallel,bpnworkers)
importFrom(BiocParallel,bpstart)
importFrom(BiocParallel,bpstop)
importFrom(DelayedArray,DelayedArray)
importFrom(DelayedArray,SparseArraySeed)
importFrom(DelayedArray,blockApply)
importFrom(DelayedArray,colAutoGrid)
importFrom(DelayedArray,currentViewport)
importFrom(DelayedArray,getAutoBPPARAM)
importFrom(DelayedArray,makeNindexFromArrayViewport)
importFrom(DelayedArray,seed)
importFrom(DelayedArray,setAutoBPPARAM)
importFrom(DelayedArray,which)
importFrom(DelayedArray,write_block)
importFrom(DelayedMatrixStats,colMins)
importFrom(DelayedMatrixStats,colQuantiles)
Expand Down
8 changes: 6 additions & 2 deletions R/removeAmbience.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ NULL

#' @importFrom methods is
#' @importFrom stats pnbinom qnbinom
#' @importClassesFrom Matrix CsparseMatrix
#' @importFrom edgeR q2qnbinom
#' @importClassesFrom SparseArray SparseArray
#' @importFrom DelayedArray makeNindexFromArrayViewport write_block currentViewport
.remap_quantiles <- function(block, matches, old.means, new.means, size.factors, group.sf, dispersion, sink) {
vp <- currentViewport()
Expand Down Expand Up @@ -139,8 +141,10 @@ NULL
if (!is.null(sink)) {
write_block(sink, vp, q)
NULL
} else if (is(block, "SparseArraySeed")) {
as(q, "CsparseMatrix")
} else if (is(block, "SparseArray")) { # that's if we don't want to return
as(q, "CsparseMatrix") # any SparseArray derivatives at
# all, even though SVT_SparseArray
# objects would probably be fine
} else {
q
}
Expand Down
24 changes: 11 additions & 13 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@
as.integer(round(colSums(m)))
}

#' @importFrom DelayedArray DelayedArray SparseArraySeed which seed
#' @importFrom beachmat whichNonZero
#' @importClassesFrom DelayedArray DelayedArray SparseArraySeed
#' @importClassesFrom SparseArray COO_SparseArray
#' @importFrom DelayedArray setAutoBPPARAM DelayedArray
#' @importClassesFrom DelayedArray DelayedArray
.realize_DA_to_memory <- function(m, BPPARAM) {
if (is(m, "DelayedArray")) {
if (!is(seed(m), "SparseArraySeed")) {
idx <- whichNonZero(m, BPPARAM)
m <- DelayedArray(
SparseArraySeed(
nzindex=cbind(idx$i, idx$j),
nzdata=idx$x,
dim=dim(m),
dimnames=dimnames(m)
)
)
if (!is(m@seed, "COO_SparseArray")) {
# Coercion from DelayedArray to COO_SparseArray uses block
# processing.
old <- .parallelize(BPPARAM)
on.exit(setAutoBPPARAM(old))
new_seed <- as(m, "COO_SparseArray")

m <- DelayedArray(new_seed)
}
}

Expand Down
Loading