Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
faster logmap labels
Browse files Browse the repository at this point in the history
mihem committed Dec 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 1a140c7 commit 9f8b465
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions R/logmap.R
Original file line number Diff line number Diff line change
@@ -234,17 +234,18 @@ labels.LogMap <- function(
select <- select[1L]
select <- match.arg(arg = select)
values <- intersect(x = values, y = rownames(x = object))
p <- progressor(along = values)
obs <- sapply(
X = values,
FUN = function(x) {
vals <- colnames(x = object)[which(x = object[x, , drop = TRUE])]
p()
return(vals)
},
simplify = FALSE,
USE.NAMES = TRUE
)
mat <- as.matrix(object)
cols <- colnames(object)
idx <- match(values, rownames(object))
obs <- vector("list", length(values))
names(obs) <- values
for (i in seq_along(idx)) {
id <- idx[i]
vals <- cols[mat[id, , drop = FALSE]]
if (length(vals) > 0) {
obs[[i]] <- vals
}
}
obs <- Filter(f = length, x = obs)
obs <- switch(
EXPR = select,
@@ -280,6 +281,7 @@ labels.LogMap <- function(
return(obs)
}


#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Internal
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

0 comments on commit 9f8b465

Please sign in to comment.