Skip to content

Commit

Permalink
faster logmap labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mihem committed Dec 7, 2024
1 parent aedfad0 commit 8cd2086
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
Expand Up @@ -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,
Expand Down Expand Up @@ -280,6 +281,7 @@ labels.LogMap <- function(
return(obs)
}


#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Internal
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down

0 comments on commit 8cd2086

Please sign in to comment.