File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ Suggests:
2828 AUCell,
2929 BiocParallel,
3030 BiocStyle,
31+ DelayedMatrixStats,
3132 dplyr,
3233 fgsea,
3334 GSEABase,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ export(splitEnrichment)
1818import(ggplot2)
1919importFrom(MatrixGenerics,rowMeans2)
2020importFrom(MatrixGenerics,rowSds)
21+ importFrom(MatrixGenerics,rowSums2)
2122importFrom(SummarizedExperiment,colData)
2223importFrom(ggdist,stat_pointinterval)
2324importFrom(grDevices,hcl.pals)
Original file line number Diff line number Diff line change 150150# -----------------------------------------------------------------------------
151151# EXPRESSION MATRIX EXTRACTOR -------------------------------------------------
152152# -----------------------------------------------------------------------------
153+ # ' @importFrom MatrixGenerics rowSums2
153154.cntEval <- function (obj , assay = " RNA" , type = " counts" ) {
154155 if (.is_seurat(obj )) {
155156 # Use generic accessor if available
177178 } else {
178179 cnts <- obj
179180 }
181+ # Conditionally require DelayedMatrixStats if cnts is dgCMatrix
182+ if (inherits(cnts , " dgCMatrix" )) {
183+ if (! requireNamespace(" DelayedMatrixStats" , quietly = TRUE )) {
184+ stop(" Package 'DelayedMatrixStats' is required to handle sparse matrices. Please install it with BiocManager::install('DelayedMatrixStats')." )
185+ }
186+ loadNamespace(" DelayedMatrixStats" )
187+ }
180188 cnts [MatrixGenerics :: rowSums2(cnts ) != 0 , , drop = FALSE ]
181189}
182190
183-
184191# -----------------------------------------------------------------------------
185192# ATTACH / PULL ENRICHMENT MATRICES ------------------------------------------
186193# -----------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments