Skip to content

Commit

Permalink
Add a plethora of tiny enhancements. See NEWS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
enblacar committed Oct 24, 2022
1 parent 9ec4fd6 commit 124303d
Show file tree
Hide file tree
Showing 30 changed files with 398 additions and 232 deletions.
23 changes: 17 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,47 @@ Take this a teaser of things to come in the next version.
## General changes

- Change color palette when using `enforce_symmetry = TRUE` to have the middle color as `grey95` instead of the previous one, which made middle values seem closer to the positive end of the scale.
- Modify internal structure of all functions to abide with [tidyselect v1.2.0 lifecycle modifications](https://tidyselect.r-lib.org/news/index.html#lifecycle-changes-1-2-0).
- Modified internal structure of all functions to abide with [tidyselect v1.2.0 lifecycle modifications](https://tidyselect.r-lib.org/news/index.html#lifecycle-changes-1-2-0).
- Modified `rotate_x_axis_labels` parameter in all functions that made use of it. Now, instead of accepting a `logical`, accepts a `numeric`: either `0`, `45` or `90`, corresponding to the degrees in which the X axis labels should be rotated. ([#5](https://github.com/enblacar/SCpubr/issues/5#issuecomment-1289203453))

## `SCpubr::do_CopyNumberVariantPlot`

- Modified the code for `SCpubr::do_CopyNumberVariantPlot` to also report results for the whole chromosome as well as for each chromosome arm.
- Include the `verbose` argument to `SCpubr::do_CopyNumberVariantPlot` to silence the messages when there are not enough genes in the chromosome to perform the analysis.

## `SCpubr::do_DimPlot()`

- Fixed a typo that prevented labels to be bold in `SCpubr::do_DimPlot()` when cell borders are displayed.
- Added `group.by` and `split.by` functionality to `SCpubr::do_DimPlot()`. ([#4](https://github.com/enblacar/SCpubr/issues/4))

## `SCpubr::do_FeaturePlot()`
## `SCpubr::do_DotPLot()`
- Added ticks to axes.
- Modified default colors to convey a better aesthetic.

## `SCpubr::do_FeaturePlot()`
- Fixed potential bugs in `SCpubr::do_FeaturePlot` when setting `enforce_symmetry = TRUE`.
- Changed default value of `order` in `SCpubr::do_FeaturePlot()` from `TRUE` to `FALSE`.
- Added `min.cutoff` and `max.cutoff` parameters to `SCpubr::do_FeaturePlot()`. This allows to effectively subset the color scale to the values provided. Cells outside the range will be converted to the min or max values provided, respectively. ([#2](https://github.com/enblacar/SCpubr/issues/2))

## `SCpubr::do_GroupwiseDEPlot()`
## `SCpubr::do_GeyserPlot()`
- Added `flip` parameter.

## `SCpubr::do_GroupwiseDEPlot()`
- Fixed bug in `SCpubr::do_GroupwiseDEPlot` in which the heatmap could not be computed. ([#3](https://github.com/enblacar/SCpubr/issues/3))
- Added extra checks to ensure proper input in `SCpubr::do_GroupwiseDEPlot`. ([#3](https://github.com/enblacar/SCpubr/issues/3))

## `SCpubr::do_RidgePlot()`
## `SCpubr::do_LigandReceptorPlot()` (development release)
- Changed parameter `x_labels_angle` to `rotate_x_axis_labels` to keep a consistent terminology.

## `SCpubr::do_RidgePlot()`
- Fixed a typo that made the lines in `panel.grid.minor` to be displayed in `SCpubr::do_Ridgeplot()`.
- Added `flip` parameter.

## `SCpubr::do_ViolinPlot()`

- Added `split.by` functionality to `SCpubr::do_ViolinPlot()`. ([#4](https://github.com/enblacar/SCpubr/issues/4), [#5](https://github.com/enblacar/SCpubr/issues/5))
- Added `flip` parameter.
- Now multiple features can be queried ad the same time. ([#5](https://github.com/enblacar/SCpubr/issues/5#issuecomment-1289203453))
- Changed `feature` parameter to `features`, to better reflect the multiple feature behavior.
- Recreated `Seurat`'s `share.y.lims` behavior and set it to `share.y.lims` parameter. ([#5](https://github.com/enblacar/SCpubr/issues/5#issuecomment-1289203453))

# SCpubr v1.0.1

Expand Down
13 changes: 7 additions & 6 deletions R/do_BarPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ do_BarPlot <- function(sample,
font.size = 14,
font.type = "sans",
legend.position = "bottom",
rotate_x_axis_labels = TRUE,
rotate_x_axis_labels = 45,
legend.title = NULL,
xlab = NULL,
ylab = NULL,
Expand All @@ -43,12 +43,12 @@ do_BarPlot <- function(sample,

# Check logical parameters.
logical_list <- list("order" = order,
"rotate_x_axis_labels" = rotate_x_axis_labels,
"flip" = flip,
"plot.grid" = plot.grid)
check_type(parameters = logical_list, required_type = "logical", test_function = is.logical)
# Check numeric parameters.
numeric_list <- list("font.size" = font.size)
numeric_list <- list("font.size" = font.size,
"rotate_x_axis_labels" = rotate_x_axis_labels)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.

Expand All @@ -73,6 +73,7 @@ do_BarPlot <- function(sample,
check_parameters(parameter = font.type, parameter_name = "font.type")
check_parameters(parameter = legend.position, parameter_name = "legend.position")
check_parameters(parameter = grid.type, parameter_name = "grid.type")
check_parameters(parameter = rotate_x_axis_labels, parameter_name = "rotate_x_axis_labels")

# Get the general table.
assertthat::assert_that(class(sample@meta.data[, group.by]) %in% c("character", "factor"),
Expand Down Expand Up @@ -124,9 +125,9 @@ do_BarPlot <- function(sample,
axis.line.y = if (isTRUE(flip)) {ggplot2::element_line(color = "black")} else if (isFALSE(flip)) {ggplot2::element_blank()},
axis.text.x = ggplot2::element_text(color = "black",
face = "bold",
angle = ifelse(isTRUE(rotate_x_axis_labels), 45, 0),
hjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 0.5),
vjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 1)),
angle = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["angle"]],
hjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["hjust"]],
vjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["vjust"]]),
axis.text.y = ggplot2::element_text(color = "black", face = "bold"),
axis.ticks = ggplot2::element_line(color = "black"),
plot.title.position = "plot",
Expand Down
14 changes: 7 additions & 7 deletions R/do_BoxPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ do_BoxPlot <- function(sample,
slot = "data",
font.size = 14,
font.type = "sans",
rotate_x_axis_labels = TRUE,
rotate_x_axis_labels = 45,
colors.use = NULL,
na.value = "grey75",
plot.title = NULL,
Expand Down Expand Up @@ -65,7 +65,6 @@ do_BoxPlot <- function(sample,
slot <- check_and_set_slot(slot = slot)
# Check logical parameters.
logical_list <- list("flip" = flip,
"rotate_x_axis_labels" = rotate_x_axis_labels,
"plot.grid" = plot.grid,
"order" = order,
"use_silhouette" = use_silhouette,
Expand All @@ -75,7 +74,8 @@ do_BoxPlot <- function(sample,
numeric_list <- list("font.size" = font.size,
"outlier.alpha" = outlier.alpha,
"boxplot.linewidth" = boxplot.linewidth,
"boxplot.width" = boxplot.width)
"boxplot.width" = boxplot.width,
"rotate_x_axis_labels" = rotate_x_axis_labels)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.
character_list <- list("feature" = feature,
Expand Down Expand Up @@ -115,7 +115,7 @@ do_BoxPlot <- function(sample,
check_parameters(parameter = font.type, parameter_name = "font.type")
check_parameters(parameter = legend.position, parameter_name = "legend.position")
check_parameters(parameter = grid.type, parameter_name = "grid.type")

check_parameters(parameter = rotate_x_axis_labels, parameter_name = "rotate_x_axis_labels")

if (is.null(group.by)){
sample[["group.by"]] <- Seurat::Idents(sample)
Expand Down Expand Up @@ -220,9 +220,9 @@ do_BoxPlot <- function(sample,
axis.line.y = if (isTRUE(flip)) {ggplot2::element_line(color = "black")} else if (isFALSE(flip)) {ggplot2::element_blank()},
axis.text.x = ggplot2::element_text(color = "black",
face = "bold",
angle = ifelse(isTRUE(rotate_x_axis_labels), 45, 0),
hjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 0.5),
vjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 1)),
angle = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["angle"]],
hjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["hjust"]],
vjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["vjust"]]),
axis.text.y = ggplot2::element_text(color = "black", face = "bold"),
axis.ticks = ggplot2::element_line(color = "black"),
panel.grid.major = ggplot2::element_blank(),
Expand Down
7 changes: 4 additions & 3 deletions R/do_CopyNumberVariantPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ do_CopyNumberVariantPlot <- function(sample,
font.type = "sans",
border.size = 2,
border.color = "black",
rotate_x_axis_labels = TRUE,
rotate_x_axis_labels = 45,
plot_cell_borders = TRUE,
enforce_symmetry = TRUE,
legend.title = NULL,
Expand All @@ -44,7 +44,6 @@ do_CopyNumberVariantPlot <- function(sample,

# Check logical parameters.
logical_list <- list("using_metacells" = using_metacells,
"rotate_x_axis_labels" = rotate_x_axis_labels,
"enforce_symmetry" = enforce_symmetry,
"plot_cell_borders" = plot_cell_borders)
check_type(parameters = logical_list, required_type = "logical", test_function = is.logical)
Expand All @@ -56,7 +55,8 @@ do_CopyNumberVariantPlot <- function(sample,
"legend.tickwidth" = legend.tickwidth,
"pt.size" = pt.size,
"border.size" = border.size,
"viridis_direction" = viridis_direction)
"viridis_direction" = viridis_direction,
"rotate_x_axis_labels" = rotate_x_axis_labels)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.
character_list <- list("group.by" = group.by,
Expand All @@ -82,6 +82,7 @@ do_CopyNumberVariantPlot <- function(sample,
check_parameters(parameter = legend.position, parameter_name = "legend.position")
check_parameters(parameter = viridis_color_map, parameter_name = "viridis_color_map")
check_parameters(parameter = viridis_direction, parameter_name = "viridis_direction")
check_parameters(parameter = rotate_x_axis_labels, parameter_name = "rotate_x_axis_labels")

if (is.null(chromosome_focus)){
chromosome_list <- c(as.character(seq(1, 22)))
Expand Down
16 changes: 9 additions & 7 deletions R/do_DotPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ do_DotPlot <- function(sample,
legend.framecolor = "grey50",
legend.tickcolor = "white",
dot.scale = 6,
colors.use = c("#1BFFFF", "#2E3192"),
colors.use = c("#1BFFFF25", "#2E3192"),
plot.title = NULL,
plot.subtitle = NULL,
plot.caption = NULL,
Expand All @@ -40,7 +40,7 @@ do_DotPlot <- function(sample,
font.type = "sans",
cluster.idents = FALSE,
flip = FALSE,
rotate_x_axis_labels = TRUE,
rotate_x_axis_labels = 45,
scale.by = "size",
use_viridis = FALSE,
viridis_color_map = "G",
Expand All @@ -60,7 +60,6 @@ do_DotPlot <- function(sample,
# Check logical parameters.
logical_list <- list("flip" = flip,
"cluster.idents" = cluster.idents,
"rotate_x_axis_labels" = rotate_x_axis_labels,
"use_viridis" = use_viridis,
"dot_border" = dot_border,
"plot.grid" = plot.grid)
Expand All @@ -72,7 +71,8 @@ do_DotPlot <- function(sample,
"legend.tickwidth" = legend.tickwidth,
"legend.length" = legend.length,
"legend.width" = legend.width,
"viridis_direction" = viridis_direction)
"viridis_direction" = viridis_direction,
"rotate_x_axis_labels" = rotate_x_axis_labels)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.
character_list <- list("legend.position" = legend.position,
Expand Down Expand Up @@ -125,6 +125,7 @@ do_DotPlot <- function(sample,
check_parameters(parameter = viridis_direction, parameter_name = "viridis_direction")
check_parameters(parameter = viridis_color_map, parameter_name = "viridis_color_map")
check_parameters(parameter = grid.type, parameter_name = "grid.type")
check_parameters(parameter = rotate_x_axis_labels, parameter_name = "rotate_x_axis_labels")

# Check colors.
check_colors(colors.use)
Expand Down Expand Up @@ -200,10 +201,11 @@ do_DotPlot <- function(sample,
ggplot2::theme_minimal(base_size = font.size) +
ggplot2::theme(axis.text.x = ggplot2::element_text(color = "black",
face = "bold",
angle = ifelse(isTRUE(rotate_x_axis_labels), 45, 0),
hjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 0.5),
vjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 1)),
angle = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["angle"]],
hjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["hjust"]],
vjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["vjust"]]),
axis.text.y = ggplot2::element_text(face = "bold", color = "black"),
axis.ticks = ggplot2::element_line(color = "black"),
axis.line = ggplot2::element_line(color = "black"),
axis.title = ggplot2::element_text(face = "bold"),
plot.title = ggplot2::element_text(face = "bold", hjust = 0),
Expand Down
27 changes: 18 additions & 9 deletions R/do_GeyserPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ do_GeyserPlot <- function(sample,
legend.type = "colorbar",
font.size = 14,
font.type = "sans",
rotate_x_axis_labels = TRUE,
rotate_x_axis_labels = 45,
viridis_color_map = "G",
viridis_direction = 1,
colors.use = NULL,
Expand All @@ -60,7 +60,8 @@ do_GeyserPlot <- function(sample,
plot.subtitle = NULL,
plot.caption = NULL,
xlab = "Groups",
ylab = feature){
ylab = feature,
flip = FALSE){

check_suggests(function_name = "do_GeyserPlot")
# Check if the sample provided is a Seurat object.
Expand All @@ -69,8 +70,8 @@ do_GeyserPlot <- function(sample,
# Check logical parameters.
logical_list <- list("enforce_symmetry" = enforce_symmetry,
"order_by_mean" = order_by_mean,
"rotate_x_axis_labels" = rotate_x_axis_labels,
"plot_cell_borders" = plot_cell_borders)
"plot_cell_borders" = plot_cell_borders,
"flip" = flip)
check_type(parameters = logical_list, required_type = "logical", test_function = is.logical)
# Check numeric parameters.
numeric_list <- list("pt.size" = pt.size,
Expand All @@ -84,7 +85,8 @@ do_GeyserPlot <- function(sample,
"legend.ncol" = legend.ncol,
"legend.nrow" = legend.nrow,
"legend.icon.size" = legend.icon.size,
"viridis_direction" = viridis_direction)
"viridis_direction" = viridis_direction,
"rotate_x_axis_labels" = rotate_x_axis_labels)
check_type(parameters = numeric_list, required_type = "numeric", test_function = is.numeric)
# Check character parameters.

Expand Down Expand Up @@ -119,6 +121,7 @@ do_GeyserPlot <- function(sample,
check_parameters(parameter = viridis_direction, parameter_name = "viridis_direction")
check_parameters(parameter = viridis_color_map, parameter_name = "viridis_color_map")
check_parameters(parameter = scale_type, parameter_name = "scale_type")
check_parameters(parameter = rotate_x_axis_labels, parameter_name = "rotate_x_axis_labels")

`%>%` <- magrittr::`%>%`
# Check the assay.
Expand Down Expand Up @@ -364,12 +367,13 @@ do_GeyserPlot <- function(sample,
ggplot2::theme_minimal(base_size = font.size) +
ggplot2::theme(axis.title = ggplot2::element_text(color = "black",
face = "bold"),
axis.line.x = ggplot2::element_line(color = "black"),
axis.line.x = if (isFALSE(flip)) {ggplot2::element_line(color = "black")} else if (isTRUE(flip)) {ggplot2::element_blank()},
axis.line.y = if (isTRUE(flip)) {ggplot2::element_line(color = "black")} else if (isFALSE(flip)) {ggplot2::element_blank()},
axis.text.x = ggplot2::element_text(color = "black",
face = "bold",
angle = ifelse(isTRUE(rotate_x_axis_labels), 45, 0),
hjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 0.5),
vjust = ifelse(isTRUE(rotate_x_axis_labels), 1, 1)),
angle = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["angle"]],
hjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["hjust"]],
vjust = get_axis_parameters(angle = rotate_x_axis_labels, flip = flip)[["vjust"]]),
axis.text.y = ggplot2::element_text(color = "black", face = "bold"),
axis.ticks = ggplot2::element_line(color = "black"),
panel.grid.major = ggplot2::element_blank(),
Expand Down Expand Up @@ -420,5 +424,10 @@ do_GeyserPlot <- function(sample,
}
list.out[[feature]] <- p
}

if (isTRUE(flip)){
p <- p +
ggplot2::coord_flip()
}
return(if (length(features) > 1) {list.out} else {p})
}
Loading

0 comments on commit 124303d

Please sign in to comment.