diff --git a/NEWS.md b/NEWS.md index 952303a..70191b8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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. @@ -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`. diff --git a/R/do_DimPlot.R b/R/do_DimPlot.R index 0b7f89e..6d345fb 100644 --- a/R/do_DimPlot.R +++ b/R/do_DimPlot.R @@ -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)){ diff --git a/R/do_DotPlot.R b/R/do_DotPlot.R index 01e570b..6002d8b 100644 --- a/R/do_DotPlot.R +++ b/R/do_DotPlot.R @@ -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 "), diff --git a/R/do_FeaturePlot.R b/R/do_FeaturePlot.R index abd1525..9a8230f 100644 --- a/R/do_FeaturePlot.R +++ b/R/do_FeaturePlot.R @@ -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){ diff --git a/man/do_VolcanoPlot.Rd b/man/do_VolcanoPlot.Rd index 81aec55..dc7c360 100644 --- a/man/do_VolcanoPlot.Rd +++ b/man/do_VolcanoPlot.Rd @@ -23,6 +23,7 @@ do_VolcanoPlot( add_gene_tags = TRUE, add_tag_side = "both", order_tags_by = "both", + tag_size = 6, n_genes = 5, use_labels = FALSE, colors.use = "steelblue", @@ -73,6 +74,8 @@ do_VolcanoPlot( \item{order_tags_by}{\strong{\code{\link[base]{character}}} | Either "both", "pvalue" or "logfc".} +\item{tag_size}{\strong{\code{\link[base]{numeric}}} | Size of the text/label for the tags.} + \item{n_genes}{\strong{\code{\link[base]{numeric}}} | Number of top genes to plot.} \item{use_labels}{\strong{\code{\link[base]{logical}}} | Whether to use labels instead of text for the tags.}