Skip to content

Commit

Permalink
Bug fixes and addition of do_RankedExpressionPlot().
Browse files Browse the repository at this point in the history
  • Loading branch information
enblacar committed Jul 10, 2024
1 parent 73c2479 commit 4f28a43
Show file tree
Hide file tree
Showing 16 changed files with 861 additions and 144 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export(do_ChordDiagramPlot)
export(do_ColorPalette)
export(do_CopyNumberVariantPlot)
export(do_CorrelationPlot)
export(do_DiffusionMapPlot)
export(do_DimPlot)
export(do_DotPlot)
export(do_EnrichmentHeatmap)
Expand All @@ -23,6 +22,8 @@ export(do_LoadingsPlot)
export(do_MetadataPlot)
export(do_NebulosaPlot)
export(do_PathwayActivityPlot)
export(do_RankedEnrichmentPlot)
export(do_RankedExpressionPlot)
export(do_RidgePlot)
export(do_SCEnrichmentHeatmap)
export(do_SCExpressionHeatmap)
Expand Down
18 changes: 15 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
# SCpbur v2.0.3 (In Development)

## 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.
- `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.
- `do_RankedExpressionPlot()` to plot expression values as a heatmap along a diffusion component.

## Removed functions
- `do_FunctionalAnnotationPlot()`.
- `do_GroupedGOTermPlot()`.

The reason behind it is that they, together with do_TermEnrichmentPlot() targetted the same analysis and, therefore, were redundant.

## Renamed functions
- `do_DiffusionMapPlot()` is now called `do_RankedEnrichmentPlot()`. As it now accepts any dimensional reduction and not only diffusion maps.

## 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.
- `do_DotPlot()`: Removed dependencies with `Seurat::DotPlot()`.
- `do_DiffusionMapPlot()`, `do_EnrichmentHeatmap()` and `do_SCEnrichmentHeatmap()` do not longer accept `flavor = "AUCell"` due to dependency issues and lack of development support.
- `do_RankedEnrichmentPlot()`, `do_EnrichmentHeatmap()` and `do_SCEnrichmentHeatmap()` do not longer accept `flavor = "AUCell"` due to dependency issues and lack of development support.

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

## 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.
- Added `legend.ncol`, `legend.nrow` and `legend.byrow` parameters to control legend behavior.
- Fixed a bug in which `map_signif_levels` would only accept a logical and not custom mappings.
- When `map_signif_levels` is used, the mapping now appears as a plot legend for clarity.

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

## do_DimPlot()
- Fixed a bug caused by using `cells.highlight` with only one cell.
- Fixed a bug causing the "Combined" plot resulting of the use of `split.by` and `group.by` to have a different size than the rest of panels when `ncol` parameter was also used.
- Fixed a bug causing a "selected_cells" plot title to show up when using `cells.highlight` and `idents.highlight`.
- Changed the plot title of the "Combined" plot to either `group.by` or `split.by` depending of the usage context.
- 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.
Expand Down Expand Up @@ -56,6 +63,11 @@ The reason of these modification is to allow for a much clearer and concise outp

## 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.
- Fixed a bug in which color palettes would not display by default when using `split.by`.

## do_VolcanoPlot()
- Fixed an issue in which tags would be duplicated when using `use_labels = TRUE` in combination with `order_tabs_by = "both"`.

# SCpbur v2.0.2

Expand Down
27 changes: 24 additions & 3 deletions R/do_BoxPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ do_BoxPlot <- function(sample,
use_test = FALSE,
comparisons = NULL,
test = "wilcox.test",
map_signif_level = TRUE,
map_signif_level = c("***" = 0.001, "**" = 0.01, "*" = 0.05),
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
Expand All @@ -79,7 +79,6 @@ do_BoxPlot <- function(sample,
"plot.grid" = plot.grid,
"order" = order,
"use_silhouette" = use_silhouette,
"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.
Expand Down Expand Up @@ -213,7 +212,21 @@ do_BoxPlot <- function(sample,
crayon_key("order"),
crayon_body(".")))
}



if (!is.null(map_signif_level)){
assertthat::assert_that(base::isTRUE(is.logical(map_signif_level) | is.numeric(map_signif_level)),
msg = paste0(add_cross(), crayon_body("Parameter "),
crayon_key("map_signif_level"),
crayon_body(" needs to be a "),
crayon_key("logical"),
crayon_body(" or a "),
crayon_key("custom mapping"),
crayon_body(" such as "),
crayon_key('c("***" = 0.001, "**" = 0.01, "*" = 0.05)'),
crayon_body(".")))
}

if (isTRUE(use_silhouette) & is.null(split.by)){
p <- data %>%
ggplot2::ggplot(mapping = ggplot2::aes(x = .data[["group.by"]],
Expand Down Expand Up @@ -317,6 +330,14 @@ do_BoxPlot <- function(sample,
textsize = font.size - 8,
family = font.type,
fontface = "bold")

if (!is.logical(map_signif_level)){
caption <- c()
for (i in seq_len(length(map_signif_level))){caption <- append(caption, paste0(names(map_signif_level)[i], " = ", format(map_signif_level[i], scientific = FALSE)))}
caption <- paste(caption, collapse = ", ")

p <- p + ggplot2::labs(caption = caption)
}
} else {
stop(paste0(add_cross(), crayon_body("Please provide the pair of groups to test.")), call. = FALSE)
}
Expand Down
8 changes: 6 additions & 2 deletions R/do_DotPlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ do_DotPlot <- function(sample,
if (isTRUE(cluster)){
row_order <- rownames(data.cluster)[stats::hclust(stats::dist(data.cluster, method = "euclidean"), method = "ward.D")$order]
} else {
row_order <- rownames(data.cluster)
row_order <- features
}
}

Expand All @@ -286,7 +286,11 @@ do_DotPlot <- function(sample,
if (isTRUE(cluster)){
col_order <- colnames(data.cluster)[stats::hclust(stats::dist(t(data.cluster), method = "euclidean"), method = "ward.D")$order]
} else {
col_order <- colnames(data.cluster)
if (is.factor(sample@meta.data[, group.by])){
col_order <- levels(sample@meta.data[, group.by])
} else {
col_order <- sort(unique(sample@meta.data[, group.by]))
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/do_FeaturePlot.R
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ do_FeaturePlot <- function(sample,
}

# Generate the final plot with patchwork and use the "ncol" parameter value for the number of columns.
p <- patchwork::wrap_plots(list.plots, nrow = 1)
p <- patchwork::wrap_plots(list.plots, nrow = ncol)

}

Expand Down
Loading

0 comments on commit 4f28a43

Please sign in to comment.