Skip to content

Commit

Permalink
Refactoring of do_DotPlot, do_GroupwiseDEPlot and do_TermEnrichmentAn…
Browse files Browse the repository at this point in the history
…alysis.
  • Loading branch information
enblacar committed Feb 6, 2024
1 parent 088356d commit 6ae82ef
Show file tree
Hide file tree
Showing 8 changed files with 546 additions and 491 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ The reason of these modification is to allow for a much clearer and concise outp
## do_AlluvialPlot()
- Enforced a minimum version of `ggalluvial` to deal with deprecation of functions from `dplyr` and `tidyr` that were still used in `ggalluvial` functions.

## do_BoxPlot()
- Added `legend.ncol`, `legend.nrow` and `legend.byrow` parameters to control legend behaviour.

## do_CopyNumberVariantPlot()
- Added `include_chr_arms` parameter to decide whether the heatmap should include a breakdown of the arms or just keep it by chromosomes.

Expand Down
20 changes: 16 additions & 4 deletions R/do_BoxPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ do_BoxPlot <- function(sample,
legend.title = NULL,
legend.title.position = "top",
legend.position = "bottom",
legend.ncol = NULL,
legend.nrow = NULL,
legend.byrow = FALSE,
boxplot.line.color = "black",
outlier.color = "black",
outlier.alpha = 0.5,
Expand Down Expand Up @@ -76,14 +79,17 @@ do_BoxPlot <- function(sample,
"plot.grid" = plot.grid,
"order" = order,
"use_silhouette" = use_silhouette,
"map_signif_level" = map_signif_level)
"map_signif_level" = map_signif_level,
"legend.byrow" = legend.byrow)
check_type(parameters = logical_list, required_type = "logical", test_function = is.logical)
# Check numeric parameters.
numeric_list <- list("font.size" = font.size,
"outlier.alpha" = outlier.alpha,
"boxplot.linewidth" = boxplot.linewidth,
"boxplot.width" = boxplot.width,
"axis.text.x.angle" = axis.text.x.angle)
"axis.text.x.angle" = axis.text.x.angle,
"legend.nrow" = legend.nrow,
"legend.ncol" = legend.ncol)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.
character_list <- list("feature" = feature,
Expand Down Expand Up @@ -222,7 +228,10 @@ do_BoxPlot <- function(sample,
na.rm = TRUE) +
ggplot2::guides(color = ggplot2::guide_legend(title = legend.title,
title.position = legend.title.position,
title.hjust = 0.5))
title.hjust = 0.5,
ncol = legend.ncol,
nrow = legend.nrow,
byrow = legend.byrow))
} else if (isTRUE(use_silhouette) & !is.null(split.by)){
stop(paste0(add_cross(), crayon_body("Parameter "), crayon_key("use_silhouette"), crayon_body("can not be used alongside "), crayon_key("split.by"), crayon_body(".")), call. = FALSE)
} else if (base::isFALSE(use_silhouette)){
Expand All @@ -249,7 +258,10 @@ do_BoxPlot <- function(sample,
na.rm = TRUE) +
ggplot2::guides(fill = ggplot2::guide_legend(title = legend.title,
title.position = legend.title.position,
title.hjust = 0.5))
title.hjust = 0.5,
ncol = legend.ncol,
nrow = legend.nrow,
byrow = legend.byrow))
}

p <- p +
Expand Down
4 changes: 2 additions & 2 deletions R/do_DotPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ do_DotPlot <- function(sample,
out <- check_cutoffs(min.cutoff = min.cutoff,
max.cutoff = max.cutoff,
limits = range.data)
ragne.data <- out$limits
range.data <- out$limits


scale.setup <- compute_scales(sample = sample,
Expand Down Expand Up @@ -366,7 +366,7 @@ do_DotPlot <- function(sample,
# nocov start
legend.title = if (is.null(legend.title)){"Avg. Expression"} else {legend.title},
# nocov end
legend.aes = if (isTRUE(dot_border)) {"fill"} else {"color"},
legend.aes = "fill",
legend.type = legend.type,
legend.position = legend.position,
legend.length = legend.length,
Expand Down
Loading

0 comments on commit 6ae82ef

Please sign in to comment.