Skip to content

Commit 8462492

Browse files
authored
Ia/fix lapply plot bug (#2240)
* fix suppresswarnings typo * fix legend plotting lapply on R<4.3
1 parent f97e19d commit 8462492

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

R/RNAIntegration.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ addGeneIntegrationMatrix <- function(
478478
colnames(mat) <- as.character(colnames(mat))
479479
#Log-Normalize
480480
mat <- log(mat + 1) #use natural log
481-
seuratATAC <- supressWarninggs(Seurat::CreateSeuratObject(counts = as.matrix(mat[head(seq_len(nrow(mat)), 5), , drop = FALSE])))
481+
seuratATAC <- suppressWarnings(Seurat::CreateSeuratObject(counts = as.matrix(mat[head(seq_len(nrow(mat)), 5), , drop = FALSE])))
482482
seuratATAC[["GeneScore"]] <- Seurat::CreateAssayObject(counts = mat)
483483

484484
#Clean Memory

R/VisualizeData.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,11 +882,14 @@ plotGroups <- function(
882882

883883
#adapted from https://github.com/jwdink/egg/blob/master/R/set_panel_size.r
884884
g <- ggplotGrob(p)
885-
886885
legend_indices <- grep("guide-box", g$layout$name)
887886
# ggplot versions > 3.5 can have multiple guide boxes, and are non automatically removed if is a "zeroGrob"
888887
# Do filtering wrt only non "zeroGrob" legends
889-
legend <- legend_indices[sapply(legend_indices, function(idx) class(g$grobs[[idx]])[1] != "zeroGrob")]
888+
if (length(legend_indices) != 0) {
889+
legend <- legend_indices[unlist(lapply(legend_indices, function(idx) class(g$grobs[[idx]])[1] != "zeroGrob"))]
890+
} else {
891+
legend <- legend_indices
892+
}
890893
# add correct ones to legend
891894
if(length(legend)!=0){
892895
gl <- g$grobs[[legend]]

0 commit comments

Comments
 (0)