diff --git a/NAMESPACE b/NAMESPACE index b5cbbd0..306af5a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) diff --git a/NEWS.md b/NEWS.md index f71c810..6b0adce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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. @@ -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. @@ -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. @@ -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. @@ -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 | 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 | 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. diff --git a/R/do_AffinityAnalysisPlot.R b/R/do_AffinityHeatmap.R similarity index 88% rename from R/do_AffinityAnalysisPlot.R rename to R/do_AffinityHeatmap.R index c2bef41..352bde1 100644 --- a/R/do_AffinityAnalysisPlot.R +++ b/R/do_AffinityHeatmap.R @@ -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) @@ -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) diff --git a/R/do_FeaturePlot.R b/R/do_FeaturePlot.R index 58d9ba4..8d0f572 100644 --- a/R/do_FeaturePlot.R +++ b/R/do_FeaturePlot.R @@ -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}}. @@ -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", @@ -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") @@ -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, @@ -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], @@ -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, @@ -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, diff --git a/R/do_GroupwiseDEPlot.R b/R/do_GroupwiseDEHeatmap.R similarity index 98% rename from R/do_GroupwiseDEPlot.R rename to R/do_GroupwiseDEHeatmap.R index 0091de7..eee6068 100644 --- a/R/do_GroupwiseDEPlot.R +++ b/R/do_GroupwiseDEHeatmap.R @@ -8,8 +8,8 @@ #' @return A dotplot composed of 3 main panels: -log10(adjusted p-value), log2(FC) and mean expression by cluster. #' @export #' -#' @example /man/examples/examples_do_GroupwiseDEPlot.R -do_GroupwiseDEPlot <- function(sample, +#' @example /man/examples/examples_do_GroupwiseDEHeatmap.R +do_GroupwiseDEHeatmap <- function(sample, de_genes, group.by = NULL, assay = NULL, @@ -62,7 +62,7 @@ do_GroupwiseDEPlot <- function(sample, # Add lengthy error messages. withr::local_options(.new = list("warning.length" = 8170)) - check_suggests(function_name = "do_GroupwiseDEPlot") + check_suggests(function_name = "do_GroupwiseDEHeatmap") # Check if the sample provided is a Seurat object. check_Seurat(sample = sample) @@ -384,10 +384,10 @@ do_GroupwiseDEPlot <- 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")) + - ggplot2::guides(size = ggplot2::guide_legend(title = "Percent Expressed", + ggplot2::guides(size = ggplot2::guide_legend(title = "Pct. Exp.", title.position = "top", title.hjust = 0.5, - ncol = 2, + ncol = 1, nrow = legend.nrow, byrow = legend.byrow, override.aes = ggplot2::aes(fill = "black"))) @@ -395,7 +395,7 @@ do_GroupwiseDEPlot <- function(sample, # Add leyend modifiers. p1 <- modify_continuous_legend(p = p1, # nocov start - legend.title = if (is.null(legend.title)){"Avg. Expression"} else {legend.title}, + legend.title = if (is.null(legend.title)){"Avg. Exp."} else {legend.title}, # nocov end legend.aes = "fill", legend.type = legend.type, @@ -511,7 +511,7 @@ do_GroupwiseDEPlot <- function(sample, # Add leyend modifiers. p3 <- modify_continuous_legend(p = p3, # nocov start - legend.title = expression(bold(paste("-", log["10"], "(p.adjust)"))), + legend.title = expression(bold(paste("-", log["10"], "(p.adj.)"))), # nocov end legend.aes = "fill", legend.type = legend.type, @@ -574,6 +574,10 @@ do_GroupwiseDEPlot <- function(sample, paste(rep("B", 1), collapse = "\n"), paste(rep("C", 1), collapse = "\n"), paste(rep("D", length(order.use)), collapse = "\n"), + paste(rep("D", length(order.use)), collapse = "\n"), + paste(rep("D", length(order.use)), collapse = "\n"), + paste(rep("E", 2), collapse = "\n"), + paste(rep("E", 2), collapse = "\n"), paste(rep("E", 2), collapse = "\n")), collapse = "\n") } else { first <- paste(c(rep("D", length(order.use)), "C", "B", "A"), collapse = "") diff --git a/R/do_LigandReceptorPlot.R b/R/do_LigandReceptorPlot.R index 5efbb2f..8a2b16e 100644 --- a/R/do_LigandReceptorPlot.R +++ b/R/do_LigandReceptorPlot.R @@ -1,6 +1,6 @@ #' Visualize Ligand-Receptor analysis output. #' -#' This function makes use of [liana](https://github.com/saezlab/liana) package to run Ligand-Receptor analysis. Takes the output of liana and generates a dot-plot visualization according to the user's specifications. +#' This function takes the output of liana and generates a dot-plot visualization according to the user's specifications. #' #' @inheritParams doc_function #' @param liana_output \strong{\code{\link[tibble]{tibble}}} | Object resulting from running \link[liana]{liana_wrap} and \link[liana]{liana_aggregate}. diff --git a/R/do_LoadingsHeatmap.R b/R/do_LoadingsHeatmap.R index fa286a2..db96cf4 100644 --- a/R/do_LoadingsHeatmap.R +++ b/R/do_LoadingsHeatmap.R @@ -41,7 +41,6 @@ do_LoadingsHeatmap <- function(sample, viridis.direction = -1, diverging.palette = "RdBu", diverging.direction = -1, - flip = FALSE, min.cutoff.loadings = NA, max.cutoff.loadings = NA, min.cutoff.expression = NA, @@ -59,8 +58,7 @@ do_LoadingsHeatmap <- function(sample, check_suggests("do_LoadingsHeatmap") # Check logical parameters. - logical_list <- list("use_viridis" = use_viridis, - "flip" = flip) + logical_list <- list("use_viridis" = use_viridis) check_type(parameters = logical_list, required_type = "logical", test_function = is.logical) # Check numeric parameters. numeric_list <- list("axis.text.x.angle" = axis.text.x.angle, @@ -330,7 +328,7 @@ do_LoadingsHeatmap <- function(sample, limits = scale.setup$limits) + ggplot2::coord_equal() + ggplot2::xlab("Top genes") + - ggplot2::ylab("PCs") + ggplot2::ylab("PC") limits <- c(min(data.expression$mean_Expression, na.rm = TRUE), max(data.expression$mean_Expression, na.rm = TRUE)) @@ -446,9 +444,6 @@ do_LoadingsHeatmap <- function(sample, panel.background = ggplot2::element_rect(fill = "white", color = "white"), legend.background = ggplot2::element_rect(fill = "white", color = "white")) } - list.plots[["Loadings"]] <- list.plots[["Loadings"]] + - ggplot2::xlab(paste0("Top and bottom ", top_loadings, " genes in PCA loadings")) + - ggplot2::theme(axis.title.x.top = ggplot2::element_text(face = "bold", color = "black")) p <- patchwork::wrap_plots(A = list.plots$Loadings, B = list.plots$Expression, diff --git a/R/do_PathwayActivityPlot.R b/R/do_PathwayActivityHeatmap.R similarity index 98% rename from R/do_PathwayActivityPlot.R rename to R/do_PathwayActivityHeatmap.R index d85e7b0..cb915bf 100644 --- a/R/do_PathwayActivityPlot.R +++ b/R/do_PathwayActivityHeatmap.R @@ -6,9 +6,9 @@ #' @return A ggplot2 object. #' @export #' -#' @example /man/examples/examples_do_PathwayActivityPlot.R +#' @example /man/examples/examples_do_PathwayActivityHeatmap.R -do_PathwayActivityPlot <- function(sample, +do_PathwayActivityHeatmap <- function(sample, activities, group.by = NULL, split.by = NULL, @@ -54,7 +54,7 @@ do_PathwayActivityPlot <- function(sample, withr::local_options(.new = list("warning.length" = 8170)) - check_suggests(function_name = "do_PathwayActivityPlot") + check_suggests(function_name = "do_PathwayActivityHeatmap") # Check if the sample provided is a Seurat object. check_Seurat(sample = sample) @@ -333,7 +333,7 @@ do_PathwayActivityPlot <- function(sample, ggplot2::coord_equal() + ggplot2::scale_fill_gradientn(colors = colors.gradient, na.value = na.value, - name = paste0("Pathway score | ", statistic, ifelse(slot == "scale.data", " | Scaled + Centered", "")), + name = paste0(ifelse(slot == "scale.data", "Z-scored | ", ""), statistic, " score"), breaks = scale.setup$breaks, labels = scale.setup$labels, limits = scale.setup$limits) @@ -345,7 +345,7 @@ do_PathwayActivityPlot <- function(sample, } p <- modify_continuous_legend(p = p, - legend.title = paste0("Pathway score | ", statistic), + legend.title = paste0(ifelse(slot == "scale.data", "Z-scored | ", ""), statistic, " score"), legend.aes = "fill", legend.type = legend.type, legend.position = legend.position, diff --git a/R/do_RankedEnrichmentHeatmap.R b/R/do_RankedEnrichmentHeatmap.R index 598e05d..1c71292 100644 --- a/R/do_RankedEnrichmentHeatmap.R +++ b/R/do_RankedEnrichmentHeatmap.R @@ -163,7 +163,7 @@ do_RankedEnrichmentHeatmap <- function(sample, if (!is.na(subsample)){ # Perform subsampling. - sample <- sample[, sample(colnames(sample, subsample))] + sample <- sample[, sample(colnames(sample), subsample)] } # Check group.by. @@ -324,7 +324,7 @@ do_RankedEnrichmentHeatmap <- function(sample, labels = scale.setup$labels, limits = scale.setup$limits) + ggplot2::xlab(paste0("Ordering of cells along ", dc.use)) + - ggplot2::ylab("Gene sets") + + ggplot2::ylab("Gene set") + ggplot2::guides(y.sec = guide_axis_label_trans(~paste0(levels(.data$Gene_Set)))) # Modify the appearance of the plot. diff --git a/R/do_RankedExpressionHeatmap.R b/R/do_RankedExpressionHeatmap.R index 2e69e30..ddd7e3f 100644 --- a/R/do_RankedExpressionHeatmap.R +++ b/R/do_RankedExpressionHeatmap.R @@ -157,7 +157,7 @@ do_RankedExpressionHeatmap <- function(sample, if (!is.na(subsample)){ # Perform subsampling. - sample <- sample[, sample(colnames(sample, subsample))] + sample <- sample[, sample(colnames(sample), subsample)] } # Check group.by. diff --git a/R/do_SCEnrichmentHeatmap.R b/R/do_SCEnrichmentHeatmap.R index ad1366a..caf03f4 100644 --- a/R/do_SCEnrichmentHeatmap.R +++ b/R/do_SCEnrichmentHeatmap.R @@ -32,7 +32,7 @@ do_SCEnrichmentHeatmap <- function(sample, nbin = 24, ctrl = 100, xlab = "Cells", - ylab = "Genes", + ylab = "Gene set", font.size = 14, font.type = "sans", plot.title = NULL, @@ -442,6 +442,8 @@ do_SCEnrichmentHeatmap <- function(sample, ggplot2::guides(fill = ggplot2::guide_legend(title = name, title.position = "top", title.hjust = 0.5, + override.aes = list(color = "black", + shape = 22), ncol = legend.ncol, nrow = legend.nrow, byrow = legend.byrow)) + diff --git a/R/do_SCExpressionHeatmap.R b/R/do_SCExpressionHeatmap.R index ba79a8f..66528c3 100644 --- a/R/do_SCExpressionHeatmap.R +++ b/R/do_SCExpressionHeatmap.R @@ -375,7 +375,7 @@ do_SCExpressionHeatmap <- function(sample, ggplot2::ggplot(mapping = ggplot2::aes(x = .data$cell, y = .data$y_row, fill = .data$y)) + - ggplot2::geom_raster(interpolate = interpolate) + + ggplot2::geom_tile() + ggplot2::facet_grid(~ .data$group.by, scales = "free_x", space = if(isTRUE(proportional.size)) {"fixed"} else {"free"}) + @@ -383,6 +383,8 @@ do_SCExpressionHeatmap <- function(sample, ggplot2::guides(fill = ggplot2::guide_legend(title = name, title.position = "top", title.hjust = 0.5, + override.aes = list(color = "black", + shape = 22), ncol = legend.ncol, nrow = legend.nrow, byrow = legend.byrow)) + @@ -422,7 +424,7 @@ do_SCExpressionHeatmap <- function(sample, ggplot2::ggplot(mapping = ggplot2::aes(x = .data$cell, y = .data$gene, fill = .data$expression)) + - ggplot2::geom_raster() + ggplot2::geom_raster(interpolate = interpolate) p <- p + ggplot2::facet_grid(~ .data$group.by, diff --git a/R/do_SavePlot.R b/R/do_SavePlot.R index ca560bc..539d621 100644 --- a/R/do_SavePlot.R +++ b/R/do_SavePlot.R @@ -17,6 +17,7 @@ #' } #' @param dpi \strong{\code{\link[base]{numeric}}} | Dpi to use. #' @param width,height \strong{\code{\link[base]{numeric}}} | Width and height of the figure (inches). +#' @param dpi \strong{\code{\link[base]{logical}}} | Whether to remove size limitation when saving ggplot2 objects. #' #' @return Nothing. #' @export @@ -29,14 +30,16 @@ do_SavePlot <- function(plot, dpi = 300, output_format = "publication", width = 8, - height = 8){ + height = 8, + limitsize = TRUE){ # nocov start # Checks for packages. check_suggests(function_name = "do_SavePlot") # Check logical parameters. - logical_list <- list("create_path" = create_path) + logical_list <- list("create_path" = create_path, + "limitsize" = limitsize) check_type(parameters = logical_list, required_type = "logical", test_function = is.logical) # Check numeric parameters. numeric_list <- list("dpi" = dpi, @@ -91,7 +94,8 @@ do_SavePlot <- function(plot, dpi = dpi, width = width, height = height, - device = device) + device = device, + limitsize = limitsize) }) } # Is it a heatmap? diff --git a/R/do_TFActivityPlot.R b/R/do_TFActivityHeatmap.R similarity index 98% rename from R/do_TFActivityPlot.R rename to R/do_TFActivityHeatmap.R index 1eedf35..5aec438 100644 --- a/R/do_TFActivityPlot.R +++ b/R/do_TFActivityHeatmap.R @@ -10,9 +10,9 @@ #' @return A ggplot2 object. #' @export #' -#' @example /man/examples/examples_do_TFActivityPlot.R +#' @example /man/examples/examples_do_TFActivityHeatmap.R -do_TFActivityPlot <- function(sample, +do_TFActivityHeatmap <- function(sample, activities, n_tfs = 25, slot = "scale.data", @@ -57,7 +57,7 @@ do_TFActivityPlot <- function(sample, # Add lengthy error messages. withr::local_options(.new = list("warning.length" = 8170)) - check_suggests(function_name = "do_TFActivityPlot") + check_suggests(function_name = "do_TFActivityHeatmap") # Check if the sample provided is a Seurat object. check_Seurat(sample = sample) @@ -362,7 +362,7 @@ do_TFActivityPlot <- function(sample, ggplot2::coord_equal() + ggplot2::scale_fill_gradientn(colors = colors.gradient, na.value = na.value, - name = paste0("Regulon score | ", statistic, ifelse(slot == "scale.data", " | Scaled + Centered", "")), + name = paste0(ifelse(slot == "scale.data", "Z-scored | ", ""), statistic, " score"), breaks = scale.setup$breaks, labels = scale.setup$labels, limits = scale.setup$limits) @@ -376,7 +376,7 @@ do_TFActivityPlot <- function(sample, } p <- modify_continuous_legend(p = p, - legend.title = paste0("Regulon score | ", statistic), + legend.title = paste0(ifelse(slot == "scale.data", "Z-scored | ", ""), statistic, " score"), legend.aes = "fill", legend.type = legend.type, legend.position = legend.position, diff --git a/R/utils.R b/R/utils.R index 9b45710..1ab6e38 100644 --- a/R/utils.R +++ b/R/utils.R @@ -409,7 +409,7 @@ return_dependencies <- function(){ "RColorBrewer", "labeling", "withr"), - "do_AffinityAnalysisPlot" = "decoupleR", + "do_AffinityHeatmap" = "decoupleR", "do_AlluvialPlot" = "ggalluvial", "do_BarPlot" = c("colorspace", "ggrepel"), "do_BeeSwarmPlot" = c("colorspace", "ggbeeswarm", "ggrastr"), @@ -425,19 +425,19 @@ return_dependencies <- function(){ "do_ExpressionHeatmap" = NULL, "do_FeaturePlot" = c("scattermore", "MASS"), "do_GeyserPlot" = "ggdist", - "do_GroupwiseDEPlot" = NULL, + "do_GroupwiseDEHeatmap" = NULL, "do_MetadataPlot" = "cluster", "do_LigandReceptorPlot" = "liana", "do_LoadingsHeatmap" = NULL, "do_RankedEnrichmentHeatmap" = "Matrix", "do_RankedExpressionHeatmap" = NULL, "do_NebulosaPlot" = "Nebulosa", - "do_PathwayActivityPlot" = NULL, + "do_PathwayActivityHeatmap" = NULL, "do_RidgePlot" = "ggridges", "do_SCExpressionHeatmap" = NULL, "do_SCEnrichmentHeatmap" = c("UCell"), "do_TermEnrichmentPlot" = c("enrichplot"), - "do_TFActivityPlot" = NULL, + "do_TFActivityHeatmap" = NULL, "do_ViolinPlot" = NULL, "do_VolcanoPlot" = "ggrepel", "do_WafflePlot" = "waffle", @@ -605,22 +605,12 @@ do_PackageReport <- function(startup = FALSE, functions <- sort(unique(names(return_dependencies()))) if (rev(strsplit(as.character( as.character(utils::packageVersion("SCpubr"))), split = "\\.")[[1]])[1] >= 9000){ - names.use <- unname(vapply(functions, function(x){if (x %in% c("do_LigandReceptorPlot", - "do_SavePlot", - "do_MetadataPlot", - "do_SCExpressionHeatmap", - "do_SCEnrichmentHeatmap", - "do_AffinityAnalysisPlot")){x <- paste0(x, cli::col_cyan(" | DEV"))} else {x}}, FUN.VALUE = character(1))) + names.use <- unname(vapply(functions, function(x){if (x %in% c("do_SavePlot")){x <- paste0(x, cli::col_cyan(" | DEV"))} else {x}}, FUN.VALUE = character(1))) functions <- vapply(functions, check_suggests, passive = TRUE, FUN.VALUE = logical(1)) names(functions) <- names.use # nocov start } else { - functions <- functions[!(functions %in% c("do_LigandReceptorPlot", - "do_SavePlot", - "do_MetadataPlot", - "do_SCExpressionHeatmap", - "do_SCEnrichmentHeatmap", - "do_AffinityAnalysisPlot"))] + functions <- functions[!(functions %in% c("do_SavePlot"))] functions <- vapply(functions, check_suggests, passive = TRUE, FUN.VALUE = logical(1)) } # nocov end diff --git a/man/do_AffinityAnalysisPlot.Rd b/man/do_AffinityHeatmap.Rd similarity index 93% rename from man/do_AffinityAnalysisPlot.Rd rename to man/do_AffinityHeatmap.Rd index 0923e69..4fe4305 100644 --- a/man/do_AffinityAnalysisPlot.Rd +++ b/man/do_AffinityHeatmap.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/do_AffinityAnalysisPlot.R -\name{do_AffinityAnalysisPlot} -\alias{do_AffinityAnalysisPlot} +% Please edit documentation in R/do_AffinityHeatmap.R +\name{do_AffinityHeatmap} +\alias{do_AffinityHeatmap} \title{Compute affinity of gene sets to cell populations using decoupleR.} \usage{ -do_AffinityAnalysisPlot( +do_AffinityHeatmap( sample, input_gene_list, subsample = 2500, @@ -164,7 +164,7 @@ Major contributions to this function: \examples{ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_AffinityAnalysisPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_AffinityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -178,13 +178,13 @@ Major contributions to this function: "C" = rownames(sample)[11:15]) # Default parameters. - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, - input_gene_list = genes, - nbin = 1, - ctrl = 5, - flavor = "Seurat", - subsample = NA, - verbose = FALSE) + p <- SCpubr::do_AffinityHeatmap(sample = sample, + input_gene_list = genes, + nbin = 1, + ctrl = 5, + flavor = "Seurat", + subsample = NA, + verbose = FALSE) p } else if (base::isFALSE(value)){ diff --git a/man/do_FeaturePlot.Rd b/man/do_FeaturePlot.Rd index 18be631..4802579 100644 --- a/man/do_FeaturePlot.Rd +++ b/man/do_FeaturePlot.Rd @@ -62,6 +62,7 @@ do_FeaturePlot( 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", @@ -204,6 +205,8 @@ do_FeaturePlot( \item{min.cutoff, max.cutoff}{\strong{\code{\link[base]{numeric}}} | Set the min/max ends of the color scale. Any cell/group with a value lower than min.cutoff will turn into min.cutoff and any cell with a value higher than max.cutoff will turn into max.cutoff. In FeaturePlots, provide as many values as features. Use NAs to skip a feature.} +\item{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}.} + \item{plot_density_contour}{\strong{\code{\link[base]{logical}}} | Whether to plot density contours in the UMAP.} \item{contour.position}{\strong{\code{\link[base]{character}}} | Whether to plot density contours on top or at the bottom of the visualization layers, thus overlapping the clusters/cells or not.} diff --git a/man/do_GroupwiseDEPlot.Rd b/man/do_GroupwiseDEHeatmap.Rd similarity index 97% rename from man/do_GroupwiseDEPlot.Rd rename to man/do_GroupwiseDEHeatmap.Rd index 7971377..6519df0 100644 --- a/man/do_GroupwiseDEPlot.Rd +++ b/man/do_GroupwiseDEHeatmap.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/do_GroupwiseDEPlot.R -\name{do_GroupwiseDEPlot} -\alias{do_GroupwiseDEPlot} +% Please edit documentation in R/do_GroupwiseDEHeatmap.R +\name{do_GroupwiseDEHeatmap} +\alias{do_GroupwiseDEHeatmap} \title{Compute a dotplot with the results of a group-wise DE analysis.} \usage{ -do_GroupwiseDEPlot( +do_GroupwiseDEHeatmap( sample, de_genes, group.by = NULL, @@ -165,7 +165,7 @@ Compute a dotplot with the results of a group-wise DE analysis. \examples{ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_GroupwiseDEPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_GroupwiseDEHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -177,7 +177,7 @@ Compute a dotplot with the results of a group-wise DE analysis. de_genes <- readRDS(system.file("extdata/de_genes_example.rds", package = "SCpubr")) # Default output. - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes) p diff --git a/man/do_LigandReceptorPlot.Rd b/man/do_LigandReceptorPlot.Rd index 2d89896..8fb71e7 100644 --- a/man/do_LigandReceptorPlot.Rd +++ b/man/do_LigandReceptorPlot.Rd @@ -167,7 +167,7 @@ do_LigandReceptorPlot( A ggplot2 plot with the results of the Ligand-Receptor analysis. } \description{ -This function makes use of \href{https://github.com/saezlab/liana}{liana} package to run Ligand-Receptor analysis. Takes the output of liana and generates a dot-plot visualization according to the user's specifications. +This function takes the output of liana and generates a dot-plot visualization according to the user's specifications. } \examples{ \donttest{ diff --git a/man/do_LoadingsHeatmap.Rd b/man/do_LoadingsHeatmap.Rd index 798f32c..30717ba 100644 --- a/man/do_LoadingsHeatmap.Rd +++ b/man/do_LoadingsHeatmap.Rd @@ -35,7 +35,6 @@ do_LoadingsHeatmap( viridis.direction = -1, diverging.palette = "RdBu", diverging.direction = -1, - flip = FALSE, min.cutoff.loadings = NA, max.cutoff.loadings = NA, min.cutoff.expression = NA, @@ -122,8 +121,6 @@ do_LoadingsHeatmap( \item{diverging.direction}{\strong{\code{\link[base]{numeric}}} | Either 1 or -1. Direction of the divering palette. This basically flips the two ends.} -\item{flip}{\strong{\code{\link[base]{logical}}} | Whether to invert the axis of the displayed plot.} - \item{min.cutoff.loadings, max.cutoff.loadings}{\strong{\code{\link[base]{numeric}}} | Cutoff to subset the scale of the Loading score heatmap. NA will use quantiles 0.05 and 0.95.} \item{min.cutoff.expression, max.cutoff.expression}{\strong{\code{\link[base]{numeric}}} | Cutoff to subset the scale of the expression heatmap. NA will use 0 (no quantile) and quantile 0.95.} diff --git a/man/do_PathwayActivityPlot.Rd b/man/do_PathwayActivityHeatmap.Rd similarity index 96% rename from man/do_PathwayActivityPlot.Rd rename to man/do_PathwayActivityHeatmap.Rd index 4356c51..fb7142f 100644 --- a/man/do_PathwayActivityPlot.Rd +++ b/man/do_PathwayActivityHeatmap.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/do_PathwayActivityPlot.R -\name{do_PathwayActivityPlot} -\alias{do_PathwayActivityPlot} +% Please edit documentation in R/do_PathwayActivityHeatmap.R +\name{do_PathwayActivityHeatmap} +\alias{do_PathwayActivityHeatmap} \title{Plot Pathway Activities from decoupleR using Progeny prior knowledge.} \usage{ -do_PathwayActivityPlot( +do_PathwayActivityHeatmap( sample, activities, group.by = NULL, @@ -152,7 +152,7 @@ Plot Pathway Activities from decoupleR using Progeny prior knowledge. \examples{ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_PathwayActivityPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_PathwayActivityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -166,7 +166,7 @@ Plot Pathway Activities from decoupleR using Progeny prior knowledge. package = "SCpubr")) # General heatmap. - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities) p <- out$heatmaps$average_scores p diff --git a/man/do_SCEnrichmentHeatmap.Rd b/man/do_SCEnrichmentHeatmap.Rd index 7a9c85a..8de4890 100644 --- a/man/do_SCEnrichmentHeatmap.Rd +++ b/man/do_SCEnrichmentHeatmap.Rd @@ -23,7 +23,7 @@ do_SCEnrichmentHeatmap( nbin = 24, ctrl = 100, xlab = "Cells", - ylab = "Genes", + ylab = "Gene set", font.size = 14, font.type = "sans", plot.title = NULL, diff --git a/man/do_SavePlot.Rd b/man/do_SavePlot.Rd index ee0f775..6ab4de1 100644 --- a/man/do_SavePlot.Rd +++ b/man/do_SavePlot.Rd @@ -12,7 +12,8 @@ do_SavePlot( dpi = 300, output_format = "publication", width = 8, - height = 8 + height = 8, + limitsize = TRUE ) } \arguments{ @@ -24,7 +25,7 @@ do_SavePlot( \item{file_name}{\strong{\code{\link[base]{character}}} | Name of the file (without extension, it will be added automatically).} -\item{dpi}{\strong{\code{\link[base]{numeric}}} | Dpi to use.} +\item{dpi}{\strong{\code{\link[base]{logical}}} | Whether to remove size limitation when saving ggplot2 objects.} \item{output_format}{\strong{\code{\link[base]{character}}} | Output format of the saved figure. One of: \itemize{ diff --git a/man/do_TFActivityPlot.Rd b/man/do_TFActivityHeatmap.Rd similarity index 97% rename from man/do_TFActivityPlot.Rd rename to man/do_TFActivityHeatmap.Rd index 505f63a..b5f64ae 100644 --- a/man/do_TFActivityPlot.Rd +++ b/man/do_TFActivityHeatmap.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/do_TFActivityPlot.R -\name{do_TFActivityPlot} -\alias{do_TFActivityPlot} +% Please edit documentation in R/do_TFActivityHeatmap.R +\name{do_TFActivityHeatmap} +\alias{do_TFActivityHeatmap} \title{Plot TF Activities from decoupleR using Dorothea prior knowledge.} \usage{ -do_TFActivityPlot( +do_TFActivityHeatmap( sample, activities, n_tfs = 25, @@ -152,7 +152,7 @@ Plot TF Activities from decoupleR using Dorothea prior knowledge. \examples{ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_TFActivityPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_TFActivityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -166,7 +166,7 @@ Plot TF Activities from decoupleR using Dorothea prior knowledge. package = "SCpubr")) # General heatmap. - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities) p <- out$heatmaps$average_scores p diff --git a/man/examples/examples_do_AffinityAnalysisPlot.R b/man/examples/examples_do_AffinityHeatmap.R similarity index 58% rename from man/examples/examples_do_AffinityAnalysisPlot.R rename to man/examples/examples_do_AffinityHeatmap.R index 3a2eec7..59566e1 100644 --- a/man/examples/examples_do_AffinityAnalysisPlot.R +++ b/man/examples/examples_do_AffinityHeatmap.R @@ -1,6 +1,6 @@ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_AffinityAnalysisPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_AffinityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -14,13 +14,13 @@ "C" = rownames(sample)[11:15]) # Default parameters. - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, - input_gene_list = genes, - nbin = 1, - ctrl = 5, - flavor = "Seurat", - subsample = NA, - verbose = FALSE) + p <- SCpubr::do_AffinityHeatmap(sample = sample, + input_gene_list = genes, + nbin = 1, + ctrl = 5, + flavor = "Seurat", + subsample = NA, + verbose = FALSE) p } else if (base::isFALSE(value)){ diff --git a/man/examples/examples_do_GroupwiseDEPlot.R b/man/examples/examples_do_GroupwiseDEHeatmap.R similarity index 90% rename from man/examples/examples_do_GroupwiseDEPlot.R rename to man/examples/examples_do_GroupwiseDEHeatmap.R index 7c23701..6c280e6 100644 --- a/man/examples/examples_do_GroupwiseDEPlot.R +++ b/man/examples/examples_do_GroupwiseDEHeatmap.R @@ -1,6 +1,6 @@ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_GroupwiseDEPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_GroupwiseDEHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -12,7 +12,7 @@ de_genes <- readRDS(system.file("extdata/de_genes_example.rds", package = "SCpubr")) # Default output. - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes) p diff --git a/man/examples/examples_do_PathwayActivityPlot.R b/man/examples/examples_do_PathwayActivityHeatmap.R similarity index 90% rename from man/examples/examples_do_PathwayActivityPlot.R rename to man/examples/examples_do_PathwayActivityHeatmap.R index 0955d8e..b57359b 100644 --- a/man/examples/examples_do_PathwayActivityPlot.R +++ b/man/examples/examples_do_PathwayActivityHeatmap.R @@ -1,6 +1,6 @@ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_PathwayActivityPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_PathwayActivityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -14,7 +14,7 @@ package = "SCpubr")) # General heatmap. - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities) p <- out$heatmaps$average_scores p diff --git a/man/examples/examples_do_TFActivityPlot.R b/man/examples/examples_do_TFActivityHeatmap.R similarity index 91% rename from man/examples/examples_do_TFActivityPlot.R rename to man/examples/examples_do_TFActivityHeatmap.R index 1255862..3782668 100644 --- a/man/examples/examples_do_TFActivityPlot.R +++ b/man/examples/examples_do_TFActivityHeatmap.R @@ -1,6 +1,6 @@ \donttest{ # Check Suggests. - value <- SCpubr:::check_suggests(function_name = "do_TFActivityPlot", passive = TRUE) + value <- SCpubr:::check_suggests(function_name = "do_TFActivityHeatmap", passive = TRUE) if (isTRUE(value)){ # Consult the full documentation in https://enblacar.github.io/SCpubr-book/ @@ -14,7 +14,7 @@ package = "SCpubr")) # General heatmap. - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities) p <- out$heatmaps$average_scores p diff --git a/tests/testthat/test-do_AffinityAnalysisPlot.R b/tests/testthat/test-do_AffinityHeatmap.R similarity index 85% rename from tests/testthat/test-do_AffinityAnalysisPlot.R rename to tests/testthat/test-do_AffinityHeatmap.R index 3588401..84f1b79 100644 --- a/tests/testthat/test-do_AffinityAnalysisPlot.R +++ b/tests/testthat/test-do_AffinityHeatmap.R @@ -1,11 +1,11 @@ -if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ +if (base::isFALSE(dep_check[["do_AffinityHeatmap"]])){ - testthat::test_that("do_AffinityAnalysisPlot: CRAN essentials", { + testthat::test_that("do_AffinityHeatmap: CRAN essentials", { genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = NA, nbin = 1, @@ -16,13 +16,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - default", { + testthat::test_that("do_AffinityHeatmap: PASS - default", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -35,7 +35,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ "B" = rownames(sample)[6:11], "C" = rownames(sample)[12:19]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -44,7 +44,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = FALSE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -54,7 +54,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -64,7 +64,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = FALSE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -74,7 +74,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -89,7 +89,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -99,7 +99,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ return_object = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -109,13 +109,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - robustness", { + testthat::test_that("do_AffinityHeatmap: PASS - robustness", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -124,7 +124,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = FALSE) testthat::expect_type(p, "list") - suppressMessages({testthat::expect_message({p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + suppressMessages({testthat::expect_message({p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -136,7 +136,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ genes <- list("A" = rownames(sample)[1:3], "B" = rownames(sample)[6:10], "C" = rownames(sample)[9:15]) - testthat::expect_error({SCpubr::do_AffinityAnalysisPlot(sample = sample, + testthat::expect_error({SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -146,7 +146,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ "B" = rownames(sample)[16:40], "C" = rownames(sample)[41:80]) - SCpubr::do_AffinityAnalysisPlot(sample = sample, + SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -156,13 +156,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - symmetry", { + testthat::test_that("do_AffinityHeatmap: PASS - symmetry", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -172,7 +172,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ use_viridis = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -182,7 +182,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ use_viridis = FALSE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -192,13 +192,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - add enrichment", { + testthat::test_that("do_AffinityHeatmap: PASS - add enrichment", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -208,7 +208,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -218,7 +218,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = FALSE) testthat::expect_type(p, "list") - suppressMessages({testthat::expect_message({ p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + suppressMessages({testthat::expect_message({ p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -227,7 +227,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ use_viridis = TRUE)})}) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -237,7 +237,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flavor = "UCell") testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -246,7 +246,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ use_viridis = FALSE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -256,13 +256,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - flip", { + testthat::test_that("do_AffinityHeatmap: PASS - flip", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -271,7 +271,7 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ flip = TRUE) testthat::expect_type(p, "list") - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -281,13 +281,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - cutoffs", { + testthat::test_that("do_AffinityHeatmap: PASS - cutoffs", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -298,13 +298,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - multiple group.by", { + testthat::test_that("do_AffinityHeatmap: PASS - multiple group.by", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, group.by = c("seurat_clusters", "orig.ident"), subsample = 100, @@ -314,13 +314,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - verbose", { + testthat::test_that("do_AffinityHeatmap: PASS - verbose", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:10], "C" = rownames(sample)[11:15]) - testthat::expect_message({p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + testthat::expect_message({p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -330,13 +330,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - underscores", { + testthat::test_that("do_AffinityHeatmap: PASS - underscores", { testthat::skip_on_cran() genes <- list("_A" = rownames(sample)[1:5], "_B" = rownames(sample)[6:10], "_C" = rownames(sample)[11:15]) - testthat::expect_warning({p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + testthat::expect_warning({p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, @@ -345,13 +345,13 @@ if (base::isFALSE(dep_check[["do_AffinityAnalysisPlot"]])){ testthat::expect_type(p, "list") }) - testthat::test_that("do_AffinityAnalysisPlot: PASS - different length of gene sets", { + testthat::test_that("do_AffinityHeatmap: PASS - different length of gene sets", { testthat::skip_on_cran() genes <- list("A" = rownames(sample)[1:5], "B" = rownames(sample)[6:15], "C" = rownames(sample)[15:30]) - p <- SCpubr::do_AffinityAnalysisPlot(sample = sample, + p <- SCpubr::do_AffinityHeatmap(sample = sample, input_gene_list = genes, subsample = 100, nbin = 1, diff --git a/tests/testthat/test-do_GroupwiseDEPlot.R b/tests/testthat/test-do_GroupwiseDEHeatmap.R similarity index 83% rename from tests/testthat/test-do_GroupwiseDEPlot.R rename to tests/testthat/test-do_GroupwiseDEHeatmap.R index 53d4380..8ef7e8e 100644 --- a/tests/testthat/test-do_GroupwiseDEPlot.R +++ b/tests/testthat/test-do_GroupwiseDEHeatmap.R @@ -1,5 +1,5 @@ -if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ - testthat::test_that("do_GroupwiseDEPlot: CRAN essentials", { +if(base::isFALSE(dep_check[["do_GroupwiseDEHeatmap"]])){ + testthat::test_that("do_GroupwiseDEHeatmap: CRAN essentials", { suppressWarnings({ sample <- SeuratObject::SetAssayData(object = sample, assay = "SCT", @@ -9,20 +9,20 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ slot = "data"))) }) - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data") testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes_scaled, assay = "SCT", slot = "scale.data") testthat::expect_type(p, "list") }) - testthat::test_that("do_GroupwiseDEPlot: PASS - default", { + testthat::test_that("do_GroupwiseDEHeatmap: PASS - default", { testthat::skip_on_cran() @@ -35,7 +35,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ slot = "data"))) }) - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -43,7 +43,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ sequential.direction = 1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -51,7 +51,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ sequential.direction = -1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -59,7 +59,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ viridis.direction = 1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -67,14 +67,14 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ viridis.direction = -1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes_scaled, assay = "SCT", slot = "scale.data") testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -83,7 +83,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ min.cutoff = 1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -91,7 +91,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ min.cutoff = 1) testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -101,7 +101,7 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ }) - testthat::test_that("do_GroupwiseDEPlot: PASS - heatmap legend side", { + testthat::test_that("do_GroupwiseDEHeatmap: PASS - heatmap legend side", { testthat::skip_on_cran() suppressWarnings({ @@ -113,14 +113,14 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ slot = "data"))) }) - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", legend.position = "right") testthat::expect_type(p, "list") - p <- SCpubr::do_GroupwiseDEPlot(sample = sample, + p <- SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes_scaled, assay = "SCT", slot = "scale.data", @@ -129,10 +129,10 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ }) - testthat::test_that("do_GroupwiseDEPlot: FAIL - wrong direction", { + testthat::test_that("do_GroupwiseDEHeatmap: FAIL - wrong direction", { testthat::skip_on_cran() - testthat::expect_error({SCpubr::do_GroupwiseDEPlot(sample = sample, + testthat::expect_error({SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", @@ -141,21 +141,21 @@ if(base::isFALSE(dep_check[["do_GroupwiseDEPlot"]])){ testthat::test_that("do_ExpressionHeatmap: FAIL", { testthat::skip_on_cran() - testthat::expect_error({SCpubr::do_GroupwiseDEPlot(sample = sample, + testthat::expect_error({SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", viridis.direction = 1, min.cutoff = -10)}) - testthat::expect_error({SCpubr::do_GroupwiseDEPlot(sample = sample, + testthat::expect_error({SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", viridis.direction = 1, max.cutoff = 200)}) - testthat::expect_error({SCpubr::do_GroupwiseDEPlot(sample = sample, + testthat::expect_error({SCpubr::do_GroupwiseDEHeatmap(sample = sample, de_genes = de_genes, assay = "SCT", slot = "data", diff --git a/tests/testthat/test-do_PathwayActivityPlot.R b/tests/testthat/test-do_PathwayActivityHeatmap.R similarity index 70% rename from tests/testthat/test-do_PathwayActivityPlot.R rename to tests/testthat/test-do_PathwayActivityHeatmap.R index 94ff4a4..2f2eae8 100644 --- a/tests/testthat/test-do_PathwayActivityPlot.R +++ b/tests/testthat/test-do_PathwayActivityHeatmap.R @@ -1,54 +1,54 @@ -if (base::isFALSE(dep_check[["do_PathwayActivityPlot"]])){ +if (base::isFALSE(dep_check[["do_PathwayActivityHeatmap"]])){ - testthat::test_that("do_PathwayActivityPlot: CRAN essentials", { + testthat::test_that("do_PathwayActivityHeatmap: CRAN essentials", { - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities) testthat::expect_type(out, "list") }) - testthat::test_that("do_PathwayActivityPlot: PASS - minimal input", { + testthat::test_that("do_PathwayActivityHeatmap: PASS - minimal input", { testthat::skip_on_cran() sample$annotation <- sample(c("A", "B"), ncol(sample), replace = TRUE) - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, group.by = "orig.ident") testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, group.by = c("orig.ident", "seurat_clusters", "annotation")) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, split.by = "annotation") testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, flip = TRUE) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, flip = FALSE) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, legend.position = "right") testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, legend.position = "right", return_object = TRUE) @@ -62,41 +62,41 @@ if (base::isFALSE(dep_check[["do_PathwayActivityPlot"]])){ - testthat::test_that("do_PathwayActivityPlot: PASS - all group.by", { + testthat::test_that("do_PathwayActivityHeatmap: PASS - all group.by", { testthat::skip_on_cran() - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, group.by = "orig.ident") testthat::expect_type(out, "list") }) - testthat::test_that("do_PathwayActivityPlot: PASS - all split.by 2", { + testthat::test_that("do_PathwayActivityHeatmap: PASS - all split.by 2", { testthat::skip_on_cran() - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, min.cutoff = -0.1, max.cutoff = NA) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, min.cutoff = NA, max.cutoff = 0.1) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, min.cutoff = -0.1) testthat::expect_type(out, "list") - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, max.cutoff = 0.1) testthat::expect_type(out, "list") @@ -104,7 +104,7 @@ if (base::isFALSE(dep_check[["do_PathwayActivityPlot"]])){ - out <- SCpubr::do_PathwayActivityPlot(sample = sample, + out <- SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, max.cutoff = 0.1, min.cutoff = -0.1) @@ -113,24 +113,24 @@ if (base::isFALSE(dep_check[["do_PathwayActivityPlot"]])){ - testthat::test_that("do_PathwayActivityPlot: FAIL", { + testthat::test_that("do_PathwayActivityHeatmap: FAIL", { testthat::skip_on_cran() - testthat::expect_error({SCpubr::do_PathwayActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, min.cutoff = -10)}) - testthat::expect_error({SCpubr::do_PathwayActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, max.cutoff = 200)}) - testthat::expect_error({SCpubr::do_PathwayActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, max.cutoff = 1, min.cutoff = 2)}) sample$annotation <- sample(c("A", "B"), ncol(sample), replace = TRUE) - testthat::expect_error({SCpubr::do_PathwayActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_PathwayActivityHeatmap(sample = sample, activities = progeny_activities, group.by = c("seurat_clusters", "orig.ident"), split.by = "annotation")}) diff --git a/tests/testthat/test-do_TFActivityPlot.R b/tests/testthat/test-do_TFActivityHeatmap.R similarity index 70% rename from tests/testthat/test-do_TFActivityPlot.R rename to tests/testthat/test-do_TFActivityHeatmap.R index 70e9672..6c2bc8c 100644 --- a/tests/testthat/test-do_TFActivityPlot.R +++ b/tests/testthat/test-do_TFActivityHeatmap.R @@ -1,79 +1,79 @@ -if(base::isFALSE(dep_check[["do_TFActivityPlot"]])){ +if(base::isFALSE(dep_check[["do_TFActivityHeatmap"]])){ - testthat::test_that("do_TFActivityPlot: PASS - minimal input", { - out <- SCpubr::do_TFActivityPlot(sample = sample, + testthat::test_that("do_TFActivityHeatmap: PASS - minimal input", { + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities) testthat::expect_type(out, "list") }) - testthat::test_that("do_TFActivityPlot: PASS - minimal input", { + testthat::test_that("do_TFActivityHeatmap: PASS - minimal input", { testthat::skip_on_cran() sample$annotation <- sample(c("A", "B"), ncol(sample), replace = TRUE) - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, group.by = "orig.ident") testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, group.by = c("orig.ident", "seurat_clusters", "annotation")) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, tfs.use = c("PDX1", "E2F1")) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, split.by = "annotation") testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, flip = TRUE) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, flip = FALSE) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, flip = TRUE) testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, legend.position = "right") testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, legend.position = "right") testthat::expect_type(out, "list") - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, legend.position = "right", return_object = TRUE) testthat::expect_type(out, "list") }) - testthat::test_that("do_TFActivityPlot: PASS - minimal input", { + testthat::test_that("do_TFActivityHeatmap: PASS - minimal input", { testthat::skip_on_cran() - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, flip = TRUE) testthat::expect_type(out, "list") @@ -81,12 +81,12 @@ if(base::isFALSE(dep_check[["do_TFActivityPlot"]])){ - testthat::test_that("do_TFActivityPlot: PASS - all group.by", { + testthat::test_that("do_TFActivityHeatmap: PASS - all group.by", { testthat::skip_on_cran() - out <- SCpubr::do_TFActivityPlot(sample = sample, + out <- SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, group.by = "orig.ident") testthat::expect_type(out, "list") @@ -95,23 +95,23 @@ if(base::isFALSE(dep_check[["do_TFActivityPlot"]])){ - testthat::test_that("do_PathwayActivityPlot: FAIL", { + testthat::test_that("do_TFActivityHeatmap: FAIL", { testthat::skip_on_cran() - testthat::expect_error({SCpubr::do_TFActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, min.cutoff = -10)}) - testthat::expect_error({SCpubr::do_TFActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, max.cutoff = 200)}) - testthat::expect_error({SCpubr::do_TFActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, max.cutoff = 1, min.cutoff = 2)}) sample$annotation <- sample(c("A", "B"), ncol(sample), replace = TRUE) - testthat::expect_error({SCpubr::do_TFActivityPlot(sample = sample, + testthat::expect_error({SCpubr::do_TFActivityHeatmap(sample = sample, activities = dorothea_activities, group.by = c("seurat_clusters", "orig.ident"), split.by = "annotation")})