Skip to content

Commit

Permalink
Function renamiming.
Browse files Browse the repository at this point in the history
  • Loading branch information
enblacar committed Jan 22, 2025
1 parent 2e07864 commit 7452f76
Show file tree
Hide file tree
Showing 32 changed files with 337 additions and 272 deletions.
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(do_AffinityAnalysisPlot)
export(do_AffinityHeatmap)
export(do_AlluvialPlot)
export(do_BarPlot)
export(do_BeeSwarmPlot)
Expand All @@ -16,20 +16,20 @@ export(do_EnrichmentHeatmap)
export(do_ExpressionHeatmap)
export(do_FeaturePlot)
export(do_GeyserPlot)
export(do_GroupwiseDEPlot)
export(do_GroupwiseDEHeatmap)
export(do_LigandReceptorPlot)
export(do_LoadingsHeatmap)
export(do_MetadataPlot)
export(do_NebulosaPlot)
export(do_PackageReport)
export(do_PathwayActivityPlot)
export(do_PathwayActivityHeatmap)
export(do_RankedEnrichmentHeatmap)
export(do_RankedExpressionHeatmap)
export(do_RidgePlot)
export(do_SCEnrichmentHeatmap)
export(do_SCExpressionHeatmap)
export(do_SavePlot)
export(do_TFActivityPlot)
export(do_TFActivityHeatmap)
export(do_TermEnrichmentPlot)
export(do_ViolinPlot)
export(do_VolcanoPlot)
Expand Down
38 changes: 32 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# SCpbur v2.0.3 (In Development)
# SCpbur v3.0.0 (In Development)

## Reason for the mejor version change
- Due to the preparation for the publication of SCpubr's manuscript, a major effort has been made to further standardize and wrap up the package nicely.
- Some functions have been removed, and many have been renamed, for consistency.
- Development versions have been transferred to the normal release, with the exception of `SCpubr::do_SavePlot()`.

## General
- Enhanced startup message for clarity. Not it guides the user to run `SCpubr::package_report(extended = TRUE)` to get an overview of the missing dependencies.
- Added black border to glyphs in legends.

## Added functions
- `do_WafflePlot()`: This function displays proportions as a pictogram grid of 10x10 tiles. It helps to visually see at a glance the proportions of your data. This fails to correctly convey decimal proportions and completely ignores heavily under-represented classes in your dataset.
Expand All @@ -15,9 +21,13 @@ The reason behind it is that they, together with do_TermEnrichmentPlot() targete

## Renamed functions
- `do_DiffusionMapPlot()` is now called `do_RankedEnrichmentHeatmap()`. As it now accepts any dimensional reduction and not only diffusion maps.
- `save_plot()` (development release only) is now called `do_SavePlot()`. This is a preparation for the version `2.0.3` which will launch together with the publication.
- `package_report()` is now called `do_PackageReport()`. This is a preparation for the version `2.0.3` which will launch together with the publication.
- `do_LoadingsPlot()` is now called `do_LoadingsHeatmap()`. This is a preparation for the version `2.0.3` which will launch together with the publication.
- `save_plot()` (development release only) is now called `do_SavePlot()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `package_report()` is now called `do_PackageReport()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `do_LoadingsPlot()` is now called `do_LoadingsHeatmap()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `do_AffinityAnalysisPlot()` is now called `do_AffinityHeatmap()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `do_PathwayActivityPlot()` is now called `do_PathwayActivityHeatmap()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `do_TFActivityPlot()` is now called `do_TFActivityHeatmap()`. This is a preparation for the version `3.0.0` which will launch together with the publication.
- `do_GroupwiseDEPlot()` is now called `do_GroupwiseDEHeatmap()`. This is a preparation for the version `3.0.0` which will launch together with the publication.

## Heavily modified functions.
- `do_TermEnrichmentPlot()`: Recoded the whole function. Now accepts the result of using `clusterProfiler::enrichGO()`, `clusterProfiler::enrichKEGG()`, etc. The output is a dot plot with the terms on the Y axis, the Gene Ratio in the X, colored by the adjusted p-value and size mapped to the Gene Count.
Expand All @@ -26,6 +36,9 @@ The reason behind it is that they, together with do_TermEnrichmentPlot() targete

The reason of these modification is to allow for a much clearer and concise output than before.

## do_AffinityHeatmap()
- Changed legend title to "Z-Scored | ulm score", for consistency with other functions in the package.

## 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.
- Modified the legend items to have a black border.
Expand Down Expand Up @@ -58,7 +71,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)](https://github.com/enblacar/SCpubr/issues/76)
- Fixed a bug in which `font.family` would not be applied when `label = TRUE`.

## do_DotPlot()
- Fixed a bug that caused sequential palettes to not be checked properly.
Expand All @@ -80,14 +93,27 @@ 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)](https://github.com/enblacar/SCpubr/issues/76)
- Fixed a bug in which `font.family` would not be applied when `label = TRUE`.
- Added `scale.limits` parameter to control the range of values the color scale should take. This is specially useful if you want to plot several features and make the color comparable between them.

## do_GroupwiseDEHeatmap()
- Reduced the legend title texts to allow for more room in the plot.

## 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`.

## do_PathwayActivityHeatmap
- Changed legend title to "Z-Scored | <statistic> score", for consistency with other functions in the package.

## do_RidgePlot()
- Removed `size = 1.25` aesthetic from the call to `ggridges::geom_ridge...`.

## do_SavePlot()
- Added `limitsize` parameter, that allows for very big ggplot2-based plots to be saved with big dimensions.

## do_TFActivityHeatmap()
- Changed legend title to "Z-Scored | <statistic> score", for consistency with other functions in the package.

## do_ViolinPlot()
- Added `order` parameter to reorder the groups based on the median. Only works when `split.by` is set to `NULL`.
- Fixed typos in error logging.
Expand Down
100 changes: 50 additions & 50 deletions R/do_AffinityAnalysisPlot.R → R/do_AffinityHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,58 @@
#' @return A list containing different plots.
#' @export
#'
#' @example /man/examples/examples_do_AffinityAnalysisPlot.R

do_AffinityAnalysisPlot <- function(sample,
input_gene_list,
subsample = 2500,
group.by = NULL,
assay = NULL,
slot = NULL,
statistic = "ulm",
number.breaks = 5,
use_viridis = FALSE,
viridis.palette = "G",
viridis.direction = -1,
sequential.palette = "YlGnBu",
sequential.direction = 1,
diverging.palette = "RdBu",
diverging.direction = -1,
enforce_symmetry = TRUE,
legend.position = "bottom",
legend.width = 1,
legend.length = 20,
legend.framewidth = 0.5,
legend.tickwidth = 0.5,
legend.framecolor = "grey50",
legend.tickcolor = "white",
legend.type = "colorbar",
na.value = "grey75",
font.size = 14,
font.type = "sans",
axis.text.x.angle = 45,
flip = FALSE,
colors.use = NULL,
min.cutoff = NA,
max.cutoff = NA,
verbose = TRUE,
return_object = FALSE,
grid.color = "white",
border.color = "black",
flavor = "Seurat",
nbin = 24,
ctrl = 100,
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
axis.title.face = "bold",
axis.text.face = "plain",
legend.title.face = "bold",
legend.text.face = "plain"){
#' @example /man/examples/examples_do_AffinityHeatmap.R

do_AffinityHeatmap <- function(sample,
input_gene_list,
subsample = 2500,
group.by = NULL,
assay = NULL,
slot = NULL,
statistic = "ulm",
number.breaks = 5,
use_viridis = FALSE,
viridis.palette = "G",
viridis.direction = -1,
sequential.palette = "YlGnBu",
sequential.direction = 1,
diverging.palette = "RdBu",
diverging.direction = -1,
enforce_symmetry = TRUE,
legend.position = "bottom",
legend.width = 1,
legend.length = 20,
legend.framewidth = 0.5,
legend.tickwidth = 0.5,
legend.framecolor = "grey50",
legend.tickcolor = "white",
legend.type = "colorbar",
na.value = "grey75",
font.size = 14,
font.type = "sans",
axis.text.x.angle = 45,
flip = FALSE,
colors.use = NULL,
min.cutoff = NA,
max.cutoff = NA,
verbose = TRUE,
return_object = FALSE,
grid.color = "white",
border.color = "black",
flavor = "Seurat",
nbin = 24,
ctrl = 100,
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
axis.title.face = "bold",
axis.text.face = "plain",
legend.title.face = "bold",
legend.text.face = "plain"){
# Add lengthy error messages.
withr::local_options(.new = list("warning.length" = 8170))

check_suggests("do_AffinityAnalysisPlot")
check_suggests("do_AffinityHeatmap")

check_Seurat(sample)

Expand Down Expand Up @@ -392,7 +392,7 @@ do_AffinityAnalysisPlot <- function(sample,
p <- p +
ggplot2::scale_fill_gradientn(colors = colors.gradient,
na.value = na.value,
name = paste0(statistic, " | Scaled and Centered"),
name = paste0("Z-scored | ", statistic, " score"),
breaks = scale.setup$breaks,
labels = scale.setup$labels,
limits = scale.setup$limits)
Expand Down
41 changes: 41 additions & 0 deletions R/do_FeaturePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @param group.by.colors.use \strong{\code{\link[base]{character}}} | Colors to use for the group dots.
#' @param group.by.show.dots \strong{\code{\link[base]{logical}}} | Controls whether to place in the middle of the groups.
#' @param group.by.cell_borders.alpha \strong{\code{\link[base]{numeric}}} | Controls the transparency of the new borders drawn by \strong{\code{group.by.cell_borders}}.
#' @param scale.limits \strong{\code{\link[base]{numeric}}} | Vector of two values (i.e: \code{c(0, 1)}) to limit the scales. Particularly useful to extend the color scale beyond the values in the dataset, contrary to \code{min.cutoff} and \code{max.cutoff}.
#' @param symmetry.type \strong{\code{\link[base]{character}}} | Type of symmetry to be enforced. One of:
#' \itemize{
#' \item \emph{\code{absolute}}: The highest absolute value will be taken into a account to generate the color scale. Works after \strong{\code{min.cutoff}} and \strong{\code{max.cutoff}}.
Expand Down Expand Up @@ -78,6 +79,7 @@ do_FeaturePlot <- function(sample,
plot.axes = FALSE,
min.cutoff = rep(NA, length(features)),
max.cutoff = rep(NA, length(features)),
scale.limits = NULL,
plot_density_contour = FALSE,
contour.position = "bottom",
contour.color = "grey90",
Expand Down Expand Up @@ -249,6 +251,37 @@ do_FeaturePlot <- function(sample,
crayon_body(" higher or equal than "),
crayon_key("0"),
crayon_body(".")))

if (!is.null(scale.limits)){
assertthat::assert_that(length(scale.limits) == 2,
msg = paste0(add_cross(), crayon_body("Please provide a two values to "),
crayon_key("scale.limits"),
crayon_body(".")))
}


if (!is.null(scale.limits)){
comparison <- !is.na(min.cutoff)
for (item in comparison){
assertthat::assert_that(base::isFALSE(item),
msg = paste0(add_cross(), crayon_body("When using "),
crayon_key("scale.limits"),
crayon_body(" you can not provide values to "),
crayon_key("min.cutoff"),
crayon_body(".")))
}

comparison <- !is.na(max.cutoff)
for (item in comparison){
assertthat::assert_that(base::isFALSE(item),
msg = paste0(add_cross(), crayon_body("When using "),
crayon_key("scale.limits"),
crayon_body(" you can not provide values to "),
crayon_key("max.cutoff"),
crayon_body(".")))
}

}


check_colors(border.color, parameter_name = "border.color")
Expand Down Expand Up @@ -421,6 +454,8 @@ do_FeaturePlot <- function(sample,
assay = assay,
reduction = NULL,
slot = slot,
limits.use = scale.limits,
from_data = if (is.null(scale.limits)){FALSE} else {TRUE},
number.breaks = number.breaks,
min.cutoff = min.cutoff,
max.cutoff = max.cutoff,
Expand All @@ -444,6 +479,8 @@ do_FeaturePlot <- function(sample,
assay = assay,
reduction = NULL,
slot = slot,
limits.use = scale.limits,
from_data = if (is.null(scale.limits)){FALSE} else {TRUE},
number.breaks = number.breaks,
min.cutoff = min.cutoff[counter],
max.cutoff = max.cutoff[counter],
Expand Down Expand Up @@ -677,6 +714,8 @@ do_FeaturePlot <- function(sample,
assay = assay,
reduction = NULL,
slot = slot,
limits.use = scale.limits,
from_data = if (is.null(scale.limits)){FALSE} else {TRUE},
number.breaks = number.breaks,
min.cutoff = min.cutoff.use,
max.cutoff = max.cutoff.use,
Expand Down Expand Up @@ -861,6 +900,8 @@ do_FeaturePlot <- function(sample,
feature = feature,
assay = assay,
reduction = NULL,
limits.use = scale.limits,
from_data = if (is.null(scale.limits)){FALSE} else {TRUE},
slot = slot,
number.breaks = number.breaks,
min.cutoff = min.cutoff.use,
Expand Down
Loading

0 comments on commit 7452f76

Please sign in to comment.