Skip to content

Commit

Permalink
Fixed bug in which font.family would not apply correctly when label =…
Browse files Browse the repository at this point in the history
… TRUE in do_DimPlot and do_FeaturePlot.
  • Loading branch information
enblacar committed Aug 15, 2024
1 parent fea9b84 commit 7aa71c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The reason of these modification is to allow for a much clearer and concise outp
- Added `split.by.combined` parameter and set its default value to `TRUE`. This allows to toggle on or off whether to display the combined view when `split.by` is used.
- However, when `split.by`is used alongside `group.by`, it is now enforced to show the combined plot (`split.by.combined = TRUE`), to avoid bugs.
- Added `legend.dot.border` parameter to select whether we want a black border around the legend dots or not.
- Fixed a bug in which `font.family` would not be applied when `label = TRUE`. (#76)

## do_DotPlot()
- Fixed a bug that caused sequential palettes to not be checked properly.
Expand All @@ -62,6 +63,7 @@ The reason of these modification is to allow for a much clearer and concise outp
## do_FeaturePlot()
- Fixed a bug in which legend titles would not show up as intended.
- Enabled the use of several legend titles when multiple features are provided. The number of legend titles and features have to be equal.
- Fixed a bug in which `font.family` would not be applied when `label = TRUE`. (#76)

## do_LigandReceptorPlot()
- Added a new parameter `top_interactions_by_group` which when set to `TRUE` will report for each pair of `source` and `target`, as many interactions as stated in `top_interactions`.
Expand Down
16 changes: 15 additions & 1 deletion R/do_DimPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,21 @@ do_DimPlot <- function(sample,
panel.background = ggplot2::element_rect(fill = "white", color = "white"),
legend.background = ggplot2::element_rect(fill = "white", color = "white"))
}


# Add font.family to geom_text and geom_label.
if (length(p$patches$plots) > 0){
num.plots <- length(p$patches$plots)
} else {
num.plots <- 1
}
for (plot.use in seq(1, num.plots)){
for (layer.use in seq(1, length(p[[plot.use]]$layers))){
if (sum(stringr::str_detect(class(p[[plot.use]]$layers[[layer.use]]$geom), "GeomText|GeomLabel"))){
p[[plot.use]]$layers[[layer.use]]$aes_params$family <- font.family
}
}
}


# Add plot title to the plots.
if (!is.null(plot.title)){
Expand Down
2 changes: 1 addition & 1 deletion R/do_DotPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ do_DotPlot <- function(sample,
crayon_key("0"),
crayon_body(".")))

assertthat::assert_that(slot == "scale.data",
assertthat::assert_that(slot == "data",
msg = paste0(add_cross(), crayon_body("Please set "),
crayon_key("slot"),
crayon_body(" to "),
Expand Down
17 changes: 17 additions & 0 deletions R/do_FeaturePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,23 @@ do_FeaturePlot <- function(sample,
plot.background = ggplot2::element_rect(fill = "white", color = "white"),
panel.background = ggplot2::element_rect(fill = "white", color = "white"),
legend.background = ggplot2::element_rect(fill = "white", color = "white"))


# Add font.family to geom_text and geom_label.
if (length(p$patches$plots) > 0){
num.plots <- length(p$patches$plots)
} else {
num.plots <- 1
}
for (plot.use in seq(1, num.plots)){
for (layer.use in seq(1, length(p[[plot.use]]$layers))){
if (sum(stringr::str_detect(class(p[[plot.use]]$layers[[layer.use]]$geom), "GeomText|GeomLabel"))){
p[[plot.use]]$layers[[layer.use]]$aes_params$family <- font.family
}
}
}


if (is.null(split.by) & legend.position != "none"){
counter <- 0
for (feature in features){
Expand Down
3 changes: 3 additions & 0 deletions man/do_VolcanoPlot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7aa71c2

Please sign in to comment.