Skip to content

Commit 2904308

Browse files
csonesonmbstadler
andcommitted
More efficient way of extracting not-all-NA columns in removeAllNAReads
Co-authored-by: Michael Stadler <stadler.michael@gmail.com> Co-authored-by: Charlotte Soneson <charlottesoneson@gmail.com>
1 parent d78a9b3 commit 2904308

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/filterReads.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@
2626
#' removeAllNAReads(assay(se[1:10, ], "mod_prob"))
2727
#'
2828
#' @importFrom S4Vectors endoapply
29-
#' @importFrom SparseArray colSums is_nonna
29+
#' @importFrom SparseArray nnawhich
3030
#' @importFrom BiocGenerics rownames rownames<-
3131
removeAllNAReads <- function(x, prune = TRUE) {
3232
.assertScalar(x = prune, type = "logical")
3333

3434
rnms <- rownames(x)
3535
x <- endoapply(x, function(y) {
3636
if (!is.null(dim(y))) {
37-
y <- y[, colSums(is_nonna(y)) > 0, drop = FALSE]
37+
nna <- nnawhich(y, arr.ind = TRUE)
38+
y <- y[, unique(nna[, 2]), drop = FALSE]
3839
}
3940
y
4041
})

0 commit comments

Comments
 (0)