From b4050b2896bc372536165c75cf616d6277d68534 Mon Sep 17 00:00:00 2001 From: Joselyn Chavez Date: Tue, 5 Dec 2023 15:40:22 -0500 Subject: [PATCH 01/10] update deploy --- _pkgdown.yml | 6 ++++++ inst/pkgdown.yml | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 inst/pkgdown.yml diff --git a/_pkgdown.yml b/_pkgdown.yml index e07fac2..7b86c4c 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -8,6 +8,9 @@ authors: Joselyn C. Chávez-Fuentes: href: https://josschavezf.github.io +deploy: + install_metadata: true + template: bootstrap: 5 bslib: @@ -32,6 +35,9 @@ navbar: href: https://github.com/drieslab/GiottoVisuals/ aria-label: github +news: + cran_dates: false + home: sidebar: structure: [links, license, community, citation, authors, dev] diff --git a/inst/pkgdown.yml b/inst/pkgdown.yml new file mode 100644 index 0000000..84934d9 --- /dev/null +++ b/inst/pkgdown.yml @@ -0,0 +1,9 @@ +pandoc: 3.1.1 +pkgdown: 2.0.7 +pkgdown_sha: ~ +articles: {} +last_built: 2023-12-05T20:39Z +urls: + reference: https://drieslab.github.io/GiottoVisuals/reference + article: https://drieslab.github.io/GiottoVisuals/articles + From 823d4eea3e2bd88b8c0464c9f90e8438be134044 Mon Sep 17 00:00:00 2001 From: Joselyn Chavez Date: Tue, 5 Dec 2023 15:42:13 -0500 Subject: [PATCH 02/10] update date --- inst/pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/pkgdown.yml b/inst/pkgdown.yml index 84934d9..f853f24 100644 --- a/inst/pkgdown.yml +++ b/inst/pkgdown.yml @@ -2,7 +2,7 @@ pandoc: 3.1.1 pkgdown: 2.0.7 pkgdown_sha: ~ articles: {} -last_built: 2023-12-05T20:39Z +last_built: 2023-12-05T20:41Z urls: reference: https://drieslab.github.io/GiottoVisuals/reference article: https://drieslab.github.io/GiottoVisuals/articles From bcdbeb15e5d790c47eb0ebcaa8714cc2c73c6953 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Mon, 11 Dec 2023 04:24:29 -0500 Subject: [PATCH 03/10] start modules split --- DESCRIPTION | 6 +++--- NEWS.md | 17 +++++++++++++++++ R/plot_heatmap.R | 4 ++-- R/vis_spatial.R | 20 ++++++++++---------- tests/testthat/test_color_palettes.R | 15 --------------- 5 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 NEWS.md diff --git a/DESCRIPTION b/DESCRIPTION index e401b12..00c0152 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GiottoVisuals Title: Visuals for the Giotto spatial biology analysis ecosystem -Version: 0.1.0 +Version: 0.1.0.1 Authors@R: c( person("Ruben", "Dries", email = "rubendries@gmail.com", role = c("aut", "cre")), @@ -27,14 +27,14 @@ Depends: base (>= 3.5.0), utils (>= 3.5.0), R (>= 3.5.0), - GiottoUtils, - GiottoClass Imports: checkmate, colorRamp2, cowplot (>= 0.9.4), data.table, ggplot2 (>= 3.1.1), + GiottoUtils (>= 0.1.0.1), + GiottoClass (>= 0.1.0.1), ggrepel, igraph (>= 1.2.4.1), methods, diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..e738516 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,17 @@ + +# Giotto Visuals 0.1.1 (TBD) + +## Breaking Changes +- Removed: `getDistinctColors()` to *GiottoUtils* + +## Added + + +## Changes +- Changed: Package internal functions now have `.` prefix +- Changed: *GiottoUtils* and *GiottoClass* moved to Imports + + +# Giotto Visuals 0.1.0 (23/11/29) + +Initial release diff --git a/R/plot_heatmap.R b/R/plot_heatmap.R index a13dc4e..9314076 100644 --- a/R/plot_heatmap.R +++ b/R/plot_heatmap.R @@ -412,7 +412,7 @@ plotMetaDataHeatmap = function(gobject, main_factor = ifelse(length(metadata_cols) == 1, metadata_cols, first_meta_col) testmain = metaDT[, mean(value), by = c('variable', main_factor)] - testmain_matrix <- dcast_dt_string(testmain, 'variable', main_factor, 'V1') + testmain_matrix <- dt_dcast_string(testmain, 'variable', main_factor, 'V1') testmain_mat = as.matrix(testmain_matrix[,-1]); rownames(testmain_mat) = testmain_matrix$variable # for clusters @@ -674,7 +674,7 @@ plotMetaDataCellsHeatmap = function(gobject, main_factor <- ifelse(length(metadata_cols) == 1, metadata_cols, first_meta_col) testmain <- metaDT[, mean(value), by = c('variable', main_factor)] - testmain_matrix <- dcast_dt_string(testmain, 'variable', main_factor, 'V1') + testmain_matrix <- dt_dcast_string(testmain, 'variable', main_factor, 'V1') testmain_mat <- as.matrix(testmain_matrix[,-1]); rownames(testmain_mat) = testmain_matrix$variable # for clusters diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 4567c38..597e868 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -106,7 +106,7 @@ spatPlot2D_single = function(gobject, save_param = list(), default_save_name = 'spatPlot2D_single') { - guard_against_notgiotto(gobject) + assert_giotto(gobject) if(verbose == TRUE) { cat('\n verbose == TRUE \n') @@ -581,7 +581,7 @@ spatPlot2D = function(gobject, save_param = list(), default_save_name = 'spatPlot2D') { - guard_against_notgiotto(gobject) + assert_giotto(gobject) ## check group_by if(is.null(group_by)) { @@ -1112,7 +1112,7 @@ dimPlot2D_single <- function(gobject, default_save_name = 'dimPlot2D_single' ){ - guard_against_notgiotto(gobject) + assert_giotto(gobject) # Set feat_type and spat_unit spat_unit = set_default_spat_unit(gobject = gobject, @@ -1469,7 +1469,7 @@ dimPlot2D = function(gobject, default_save_name = 'dimPlot2D') { # arg_list <- c(as.list(environment())) # get all args as list - guard_against_notgiotto(gobject) + assert_giotto(gobject) ## check group_by if(is.null(group_by)) { @@ -1697,7 +1697,7 @@ plotUMAP_2D = function(gobject, default_save_name = 'UMAP_2D', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'umap', @@ -1723,7 +1723,7 @@ plotUMAP = function(gobject, default_save_name = 'UMAP', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'umap', @@ -1753,7 +1753,7 @@ plotTSNE_2D = function(gobject, default_save_name = 'tSNE_2D', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'tsne', @@ -1779,7 +1779,7 @@ plotTSNE = function(gobject, default_save_name = 'tSNE', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'tsne', @@ -1807,7 +1807,7 @@ plotPCA_2D = function(gobject, default_save_name = 'PCA_2D', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'pca', @@ -1835,7 +1835,7 @@ plotPCA = function(gobject, default_save_name = 'PCA', ...) { - guard_against_notgiotto(gobject) + assert_giotto(gobject) dimPlot2D(gobject = gobject, dim_reduction_to_use = 'pca', diff --git a/tests/testthat/test_color_palettes.R b/tests/testthat/test_color_palettes.R index c344ab8..75e218f 100644 --- a/tests/testthat/test_color_palettes.R +++ b/tests/testthat/test_color_palettes.R @@ -1,19 +1,4 @@ -test_that('distinct: n colors are supplied', { - expect_no_condition(getDistinctColors(10)) - out444 = getDistinctColors(444) - expect_character(out444, unique = TRUE, len = 444L) - expect_warning(getDistinctColors(500), regexp = 'not enough unique colors in R') -}) - -# test_that('rainbow: n colors are supplied', { -# expect_no_condition(getRainbowColors(10)) -# out10 = getRainbowColors(10) -# expect_character(out10, unique = TRUE, len = 10L) -# -# expect_character(getRainbowColors(100), unique = TRUE) -# expect_character(getRainbowColors(101), unique = FALSE) -# }) test_that('getColors: error thrown when too few colors requested', { error_pattern = 'colors wanted must be at least 1' From 2f7dc018783c33f630438038c76f1b084cdff66f Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:35:23 -0500 Subject: [PATCH 04/10] Mark internals with `.` prefix --- R/aux_defaults.R | 14 +-- R/aux_save.R | 12 +- R/aux_visuals.R | 8 +- R/color_palettes.R | 42 +++---- R/gstop.R | 24 ++++ R/plot_heatmap.R | 157 +++++++++++++---------- R/plot_sankey.R | 62 +++++----- R/vis_spatial.R | 50 ++++---- R/vis_spatial_in_situ.R | 186 ++++++++++++++-------------- man/createHeatmap_DT.Rd | 8 +- man/decide_cluster_order.Rd | 8 +- man/dimPlot_2D_plotly.Rd | 8 +- man/dimPlot_3D_plotly.Rd | 8 +- man/plot_save.Rd | 12 +- man/sankey_compare.Rd | 6 +- man/sankey_relation_pair.Rd | 8 +- man/spatInSituPlotDensity_single.Rd | 8 +- man/spatInSituPlotHex_single.Rd | 8 +- man/spatPlot2D_single.Rd | 10 +- man/spatPlot_2D_plotly.Rd | 8 +- man/spatPlot_3D_plotly.Rd | 8 +- 21 files changed, 356 insertions(+), 299 deletions(-) create mode 100644 R/gstop.R diff --git a/R/aux_defaults.R b/R/aux_defaults.R index 418cf9b..161ccfa 100644 --- a/R/aux_defaults.R +++ b/R/aux_defaults.R @@ -109,7 +109,7 @@ set_default_color_discrete = function( return(simple_palette_factory(col = colors, rev = reverse, strategy = strategy)) } else { # assume call to getColors() otherwise # return wrapped - return(get_palette_factory(pal = colors, rev = reverse, strategy = strategy)) + return(.get_palette_factory(pal = colors, rev = reverse, strategy = strategy)) } } } @@ -360,14 +360,14 @@ set_default_color_continuous <- function( # evaluate 'colors' switch( style, - 'divergent' = evaluate_color_gradient_divergent(colors = colors, + 'divergent' = .evaluate_color_gradient_divergent(colors = colors, reverse = reverse, midpoint = midpoint, grad2 = grad2, grad = grad, gradn = gradn, ...), - 'sequential' = evaluate_color_gradient_sequential(colors = colors, + 'sequential' = .evaluate_color_gradient_sequential(colors = colors, reverse = reverse, gradn = gradn, grad = grad, @@ -376,7 +376,7 @@ set_default_color_continuous <- function( } -evaluate_color_gradient_divergent = function(colors, +.evaluate_color_gradient_divergent = function(colors, reverse, midpoint, grad2, @@ -400,7 +400,7 @@ evaluate_color_gradient_divergent = function(colors, ...) } else if (length(colors) == 1L) { # assume call to getColors() otherwise # return wrapped - colors <- get_palette_factory(pal = colors, rev = reverse, strategy = 'cutoff')(256) + colors <- .get_palette_factory(pal = colors, rev = reverse, strategy = 'cutoff')(256) gradient <- gradn(colors = colors, rescaler = mid_rescaler(mid = midpoint), ...) } else { # assume custom palette gradient <- gradn(colors = colors, rescaler = mid_rescaler(mid = midpoint), ...) @@ -413,7 +413,7 @@ evaluate_color_gradient_divergent = function(colors, gradient } -evaluate_color_gradient_sequential = function(colors, +.evaluate_color_gradient_sequential = function(colors, reverse, gradn, grad, @@ -429,7 +429,7 @@ evaluate_color_gradient_sequential = function(colors, ...) } else if (length(colors) == 1L) { # assume call to getColors() otherwise # return wrapped - colors <- get_palette_factory(pal = colors, rev = reverse, strategy = 'cutoff')(256) + colors <- .get_palette_factory(pal = colors, rev = reverse, strategy = 'cutoff')(256) gradient <- gradn(colors = colors, ...) } else { # assume custom palette gradient <- gradn(colors = colors, ...) diff --git a/R/aux_save.R b/R/aux_save.R index 6bff3dd..7d30721 100644 --- a/R/aux_save.R +++ b/R/aux_save.R @@ -31,9 +31,9 @@ NULL -#' @describeIn plot_save ggplot saving. ... passes to cowplot::save_plot +#' @describeIn plot_save (internal) ggplot saving. ... passes to cowplot::save_plot #' @keywords internal -ggplot_save_function = function(gobject, +.ggplot_save_function = function(gobject, plot_object, save_dir = NULL, save_folder = NULL, @@ -124,9 +124,9 @@ ggplot_save_function = function(gobject, -#' @describeIn plot_save base and general saving. ... passes to grDevices png, tiff, pdf, svg +#' @describeIn plot_save (internal) base and general saving. ... passes to grDevices png, tiff, pdf, svg #' @keywords internal -general_save_function = function(gobject, +.general_save_function = function(gobject, plot_object, save_dir = NULL, save_folder = NULL, @@ -266,7 +266,7 @@ all_plots_save_function = function(gobject, if(any('ggplot' %in% class(plot_object))) { - ggplot_save_function(gobject = gobject, + .ggplot_save_function(gobject = gobject, plot_object = plot_object, save_dir = save_dir, save_folder = save_folder, @@ -288,7 +288,7 @@ all_plots_save_function = function(gobject, } else { - general_save_function(gobject = gobject, + .general_save_function(gobject = gobject, plot_object = plot_object, save_dir = save_dir, save_folder = save_folder, diff --git a/R/aux_visuals.R b/R/aux_visuals.R index f106002..0029d29 100644 --- a/R/aux_visuals.R +++ b/R/aux_visuals.R @@ -5,8 +5,8 @@ NULL # clusters #### -#' @title decide_cluster_order -#' @name decide_cluster_order +#' @title Decide cluster order +#' @name .decide_cluster_order #' @description creates order for clusters #' @inheritParams data_access_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") @@ -19,7 +19,7 @@ NULL #' @return custom #' @details Calculates order for clusters. #' @keywords internal -decide_cluster_order = function(gobject, +.decide_cluster_order = function(gobject, spat_unit = NULL, feat_type = NULL, expression_values = c('normalized', 'scaled', 'custom'), @@ -113,7 +113,7 @@ aes_string2 <- function(...){ } -#' @title gg_input +#' @title gg input #' @name gg_input #' @description modular handling of ggplot inputs for functions that may either #' append additional information to a ggplot object or be where the ggobject is diff --git a/R/color_palettes.R b/R/color_palettes.R index 5a8e513..528b85f 100644 --- a/R/color_palettes.R +++ b/R/color_palettes.R @@ -95,16 +95,16 @@ getColors <- function(pal = 'viridis', out = switch( pkg_to_use, 'hcl' = grDevices::hcl.colors(n = n, palette = pal), - 'base' = get_base_colors(n = n, pal = pal), - 'RColorBrewer' = get_rcolorbrewer_colors(n = n, pal = pal, strategy = strategy), - 'viridis' = get_viridis_colors(n = n, pal = pal), - 'wesanderson' = get_wes_anderson_colors(n = n, pal = pal), - 'ggsci' = get_ggsci_colors(n = n, pal = pal, strategy = strategy), - 'nord' = get_nord_colors(n = n, pal = pal), - 'palettetown' = get_palettetown_colors(n = n, pal = pal, strategy = strategy), - 'palr' = get_palr_colors(n = n, pal = pal), - 'NineteenEightyR' = get_ninteeneightyr_colors(n = n, pal = pal, strategy = strategy), - 'rcartocolor' = get_rcarto_colors(n = n, pal = pal, strategy = strategy) + 'base' = .get_base_colors(n = n, pal = pal), + 'RColorBrewer' = .get_rcolorbrewer_colors(n = n, pal = pal, strategy = strategy), + 'viridis' = .get_viridis_colors(n = n, pal = pal), + 'wesanderson' = .get_wes_anderson_colors(n = n, pal = pal), + 'ggsci' = .get_ggsci_colors(n = n, pal = pal, strategy = strategy), + 'nord' = .get_nord_colors(n = n, pal = pal), + 'palettetown' = .get_palettetown_colors(n = n, pal = pal, strategy = strategy), + 'palr' = .get_palr_colors(n = n, pal = pal), + 'NineteenEightyR' = .get_ninteeneightyr_colors(n = n, pal = pal, strategy = strategy), + 'rcartocolor' = .get_rcarto_colors(n = n, pal = pal, strategy = strategy) ) if(rev) return(rev(out)) @@ -168,7 +168,7 @@ getDistinctColors <- function(n) { # get palettes #### -get_rcolorbrewer_colors <- function(n, pal, strategy) { +.get_rcolorbrewer_colors <- function(n, pal, strategy) { # DT vars rn = maxcolors = NULL @@ -185,7 +185,7 @@ get_rcolorbrewer_colors <- function(n, pal, strategy) { return(out) } -get_ggsci_colors <- function(n, pal, strategy) { +.get_ggsci_colors <- function(n, pal, strategy) { package_check('ggsci') pal_fullname <- paste0('ggsci::pal_', pal, '()') @@ -200,7 +200,7 @@ get_ggsci_colors <- function(n, pal, strategy) { ) } -get_viridis_colors <- function(n, pal = 'viridis') { +.get_viridis_colors <- function(n, pal = 'viridis') { # viridisLite should always be installed if viridis is there package_check('viridisLite') return( @@ -218,7 +218,7 @@ get_viridis_colors <- function(n, pal = 'viridis') { ) } -get_base_colors = function(n, pal = 'rainbow') { +.get_base_colors = function(n, pal = 'rainbow') { return( switch( pal, @@ -233,18 +233,18 @@ get_base_colors = function(n, pal = 'rainbow') { ) } -get_wes_anderson_colors = function(n, pal) { +.get_wes_anderson_colors = function(n, pal) { package_check('wesanderson') out = wesanderson::wes_palette(name = pal, n = n, type = 'continuous') return(out) } -get_nord_colors = function(n, pal) { +.get_nord_colors = function(n, pal) { package_check('nord') return(nord::nord(palette = pal, n = n)) } -get_palettetown_colors = function(n, pal, strategy) { +.get_palettetown_colors = function(n, pal, strategy) { package_check('palettetown') colors = get_continuous_colors( palettetown::ichooseyou(pokemon = pal), @@ -253,7 +253,7 @@ get_palettetown_colors = function(n, pal, strategy) { ) } -get_palr_colors = function(n, pal) { +.get_palr_colors = function(n, pal) { package_check('palr') return( switch( @@ -270,7 +270,7 @@ get_palr_colors = function(n, pal) { ) } -get_ninteeneightyr_colors = function(n, pal, strategy) { +.get_ninteeneightyr_colors = function(n, pal, strategy) { package_check('NineteenEightyR', repository = 'github', github_repo = 'm-clark/NineteenEightyR') @@ -293,7 +293,7 @@ get_ninteeneightyr_colors = function(n, pal, strategy) { return(get_continuous_colors(col = pal_col, n = n, strategy)) } -get_rcarto_colors = function(n, pal, strategy) { +.get_rcarto_colors = function(n, pal, strategy) { package_check('rcartocolor', repository = 'CRAN') pal_col = suppressWarnings({ @@ -369,7 +369,7 @@ simple_palette_factory = function(col, rev = FALSE, strategy = 'interpolate') { #' @param strategy policy when insufficient colors are available #' @param strategy strategy to use #' @seealso [set_default_color_discrete()] -get_palette_factory = function(pal, rev = FALSE, strategy = 'interpolate') { +.get_palette_factory = function(pal, rev = FALSE, strategy = 'interpolate') { function(n) { col = getColors(pal = pal, n = n, rev = rev, strategy = 'cutoff') diff --git a/R/gstop.R b/R/gstop.R new file mode 100644 index 0000000..847776e --- /dev/null +++ b/R/gstop.R @@ -0,0 +1,24 @@ +# Use this function internal to this package +# .n should be increased when called from a nested location if capturing the +# original call is desired. +# .n should be increased to 2L when within a generic method +.gstop <- function(..., + sep = " ", + strWidth = 100, + errWidth = FALSE, + .prefix = " ", + .initial = "", + .n = 1L, + .call = FALSE) { + GiottoUtils::gstop( + ..., + sep = sep, + strWidth = strWidth, + errWidth = errWidth, + .module = "GiottoVisuals", + .prefix = .prefix, + .initial = .initial, + .n = .n + 1L, + .call = .call + ) +} diff --git a/R/plot_heatmap.R b/R/plot_heatmap.R index 9314076..4d09d8c 100644 --- a/R/plot_heatmap.R +++ b/R/plot_heatmap.R @@ -161,20 +161,22 @@ plotHeatmap <- function(gobject, show_values = match.arg(show_values, choices = c('rescaled', 'z-scaled', 'original')) - heatmap_data = createHeatmap_DT(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - expression_values = expression_values, - feats = feats, - cluster_column = cluster_column, - cluster_order = cluster_order, - cluster_custom_order = cluster_custom_order, - cluster_cor_method = cluster_cor_method, - cluster_hclust_method = cluster_hclust_method, - feat_order = feat_order, - feat_custom_order = feat_custom_order, - feat_cor_method = feat_cor_method, - feat_hclust_method = feat_hclust_method) + heatmap_data = .create_heatmap_dt( + gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + expression_values = expression_values, + feats = feats, + cluster_column = cluster_column, + cluster_order = cluster_order, + cluster_custom_order = cluster_custom_order, + cluster_cor_method = cluster_cor_method, + cluster_hclust_method = cluster_hclust_method, + feat_order = feat_order, + feat_custom_order = feat_custom_order, + feat_cor_method = feat_cor_method, + feat_hclust_method = feat_hclust_method + ) cell_order_DT = heatmap_data[['cell_DT']] subset_values_DT = heatmap_data[['DT']] @@ -781,8 +783,8 @@ plotMetaDataCellsHeatmap = function(gobject, -#' @title createHeatmap_DT -#' @name createHeatmap_DT +#' @title Create heatmap data.table +#' @name .create_heatmap_dt #' @description creates order for clusters #' @inheritParams data_access_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") @@ -799,75 +801,88 @@ plotMetaDataCellsHeatmap = function(gobject, #' @return list #' @details Creates input data.tables for plotHeatmap function. #' @keywords internal -createHeatmap_DT = function(gobject, - spat_unit = NULL, - feat_type = NULL, - expression_values = c('normalized', 'scaled', 'custom'), - feats, - cluster_column = NULL, - cluster_order = c('size', 'correlation', 'custom'), - cluster_custom_order = NULL, - cluster_cor_method = 'pearson', - cluster_hclust_method = 'ward.D', - feat_order = c('correlation', 'custom'), - feat_custom_order = NULL, - feat_cor_method = 'pearson', - feat_hclust_method = 'complete') { +.create_heatmap_dt <- function( + gobject, + spat_unit = NULL, + feat_type = NULL, + expression_values = c('normalized', 'scaled', 'custom'), + feats, + cluster_column = NULL, + cluster_order = c('size', 'correlation', 'custom'), + cluster_custom_order = NULL, + cluster_cor_method = 'pearson', + cluster_hclust_method = 'ward.D', + feat_order = c('correlation', 'custom'), + feat_custom_order = NULL, + feat_cor_method = 'pearson', + feat_hclust_method = 'complete' +) { # Set feat_type and spat_unit - spat_unit = set_default_spat_unit(gobject = gobject, - spat_unit = spat_unit) - feat_type = set_default_feat_type(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type) + spat_unit <- set_default_spat_unit(gobject = gobject, + spat_unit = spat_unit) + feat_type <- set_default_feat_type(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type) # epxression data - values = match.arg(expression_values, unique(c('normalized', 'scaled', 'custom', expression_values))) - expr_values = get_expression_values(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - values = values, - output = 'matrix') + values <- match.arg( + expression_values, + unique(c('normalized', 'scaled', 'custom', expression_values)) + ) + expr_values <- get_expression_values(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + values = values, + output = 'matrix') # subset expression data - detected_feats = feats[feats %in% rownames(expr_values)] - subset_values = expr_values[rownames(expr_values) %in% detected_feats, ] + detected_feats <- feats[feats %in% rownames(expr_values)] + subset_values <- expr_values[rownames(expr_values) %in% detected_feats, ] # metadata - cell_metadata = pDataDT(gobject, - spat_unit = spat_unit, - feat_type = feat_type) + cell_metadata <- pDataDT(gobject, + spat_unit = spat_unit, + feat_type = feat_type) # feat order - feat_order = match.arg(feat_order, c('correlation', 'custom')) + feat_order <- match.arg(feat_order, c('correlation', 'custom')) ### cluster order ### - clus_sort_names = decide_cluster_order(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - expression_values = expression_values, - feats = feats, - cluster_column = cluster_column, - cluster_order = cluster_order, - cluster_custom_order = cluster_custom_order, - cor_method = cluster_cor_method, - hclust_method = cluster_hclust_method) + clus_sort_names <- .decide_cluster_order( + gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + expression_values = expression_values, + feats = feats, + cluster_column = cluster_column, + cluster_order = cluster_order, + cluster_custom_order = cluster_custom_order, + cor_method = cluster_cor_method, + hclust_method = cluster_hclust_method + ) ## data.table ## - subset_values_DT <- data.table::as.data.table(reshape2::melt(as.matrix(subset_values), - varnames = c('feats', 'cells'), - value.name = 'expression', - as.is = TRUE)) - subset_values_DT <- merge(subset_values_DT, - by.x = 'cells', - cell_metadata[, c('cell_ID', cluster_column), with = F], - by.y = 'cell_ID') + subset_values_DT <- data.table::as.data.table( + reshape2::melt( + as.matrix(subset_values), + varnames = c('feats', 'cells'), + value.name = 'expression', + as.is = TRUE + ) + ) + subset_values_DT <- merge( + subset_values_DT, + by.x = 'cells', + cell_metadata[, c('cell_ID', cluster_column), with = FALSE], + by.y = 'cell_ID' + ) subset_values_DT[, (cluster_column) := factor(x = get(cluster_column), levels = clus_sort_names)] - # data.table variables + # NSE vars z_scores = scale_scores = V1 = cells = NULL subset_values_DT[, feats := factor(feats, unique(detected_feats))] @@ -904,7 +919,7 @@ createHeatmap_DT = function(gobject, } else if(feat_order == 'custom') { if(is.null(feat_custom_order)) { - stop('\n with custom feat order the feat_custom_order parameter needs to be provided \n') + .gstop('with custom feat order, the feat_custom_order parameter needs to be provided') } subset_values_DT[, 'feats' := factor(feats, feat_custom_order)] @@ -912,5 +927,11 @@ createHeatmap_DT = function(gobject, cell_order_DT[['cells']] = factor(cell_order_DT[['cells']], levels = as.character(cell_order_DT[['cells']])) - return(list(DT = subset_values_DT, x_lines = x_lines, cell_DT = cell_order_DT)) + return( + list( + DT = subset_values_DT, + x_lines = x_lines, + cell_DT = cell_order_DT + ) + ) } diff --git a/R/plot_sankey.R b/R/plot_sankey.R index d41ff27..a0cb174 100644 --- a/R/plot_sankey.R +++ b/R/plot_sankey.R @@ -314,7 +314,7 @@ sankeySetAddresses = function(x) { #' @title Calculations for a sankey relationship pair -#' @name sankey_compare +#' @name .sankey_compare #' @description #' Generate the data.table of source, target, and value for a relation pair as #' well as the list of node names to be used with sankey plotting. @@ -324,7 +324,7 @@ sankeySetAddresses = function(x) { #' @keywords internal #' @return list with 1. node names and 2. data.table with cols source, target, #' and value -sankey_compare = function(data_dt, idx_start = 0) { +.sankey_compare = function(data_dt, idx_start = 0) { # DT vars source = target = value = NULL @@ -371,17 +371,17 @@ sankey_compare = function(data_dt, idx_start = 0) { -#' @name sankey_relation_pair +#' @name .sankey_relation_pair #' @title Calculations for a sankey relationship pair #' @description #' Get matched values to compare from the giotto object. Comparison columns -#' are then passed as a data.table to `sankey_compare` to be calculated. +#' are then passed as a data.table to `.sankey_compare` to be calculated. #' @param g giotto object #' @param gsp giottoSankeyPlan object #' @param rel_idx index of relation pair in `gsp` #' @param node_idx_start starting index to assign new nodes #' @keywords internal -sankey_relation_pair = function(g, gsp, rel_idx, node_idx_start = 0) { +.sankey_relation_pair = function(g, gsp, rel_idx, node_idx_start = 0) { rel = gsp@relations[rel_idx] from_address = sankeySetAddresses(gsp)[rel$from + 1] @@ -443,7 +443,7 @@ sankey_relation_pair = function(g, gsp, rel_idx, node_idx_start = 0) { test_dt = meta_from[meta_to] test_dt[, (id_col) := NULL] - res = sankey_compare(data_dt = test_dt, + res = .sankey_compare(data_dt = test_dt, idx_start = node_idx_start) return(res) @@ -554,7 +554,7 @@ setMethod( for (rel_i in seq(nrow(sankeyRelate(y)))) { - rel_data = sankey_relation_pair( + rel_data = .sankey_relation_pair( g = x, gsp = y, rel_idx = rel_i, @@ -572,7 +572,7 @@ setMethod( # create nodes table nodes = data.table::data.table(name = nodes) - sankey_networkd3( + .sankey_networkd3( Links = links_dt, Nodes = nodes, Source = 'source', @@ -641,13 +641,13 @@ setMethod( } test_dt = meta_cm[][, y, with = FALSE] - res = sankey_compare(data_dt = test_dt) + res = .sankey_compare(data_dt = test_dt) links_dt = res$links # create nodes table nodes = data.table::data.table(name = res$nodes) - sankey_networkd3( + .sankey_networkd3( Links = links_dt, Nodes = nodes, Source = 'source', @@ -672,13 +672,13 @@ setMethod( GiottoUtils::package_check("networkD3") x = data.table::as.data.table(x) - res = sankey_compare(data_dt = x) + res = .sankey_compare(data_dt = x) links_dt = res$links # create nodes table nodes = data.table::data.table(name = res$nodes) - sankey_networkd3( + .sankey_networkd3( Links = links_dt, Nodes = nodes, Source = 'source', @@ -712,7 +712,7 @@ setMethod( for (dt_i in seq_along(x)) { - rel_data = sankey_compare( + rel_data = .sankey_compare( data_dt = data.table::as.data.table(x[[dt_i]]), idx_start = node_idx_start ) @@ -728,7 +728,7 @@ setMethod( # create nodes table nodes_dt = data.table::data.table(name = nodes) - sankey_networkd3( + .sankey_networkd3( Links = links_dt, Nodes = nodes_dt, Source = 'source', @@ -764,21 +764,27 @@ setMethod( }) -sankey_networkd3 = function(Links, - Nodes, - Source = 'source', - Target = 'target', - Value = 'value', - NodeID = 'name', - nodePadding = 1, - sinksRight = FALSE, - focus_names = NULL, - unfocused_replacer = '', - unfocused_color = FALSE, - ...) { - # DT vars - color = NULL +#' @name .sankey_networkd3 +#' @title Create networkd3 sankey +#' @description Wrapper for networkd3's sankeyNetwork function. Adds some +#' additional params for controlling the plot. +#' @keywords internal +.sankey_networkd3 <- function(Links, + Nodes, + Source = 'source', + Target = 'target', + Value = 'value', + NodeID = 'name', + nodePadding = 1, + sinksRight = FALSE, + focus_names = NULL, + unfocused_replacer = '', + unfocused_color = FALSE, + ...) { + + # NSE vars + color <- NULL args_list <- list() diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 597e868..5e6b364 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -13,8 +13,8 @@ -#' @title spatPlot2D_single -#' @name spatPlot2D_single +#' @title .spatPlot2D_single +#' @name .spatPlot2D_single #' @description Visualize cells according to spatial coordinates #' @inheritParams data_access_params #' @inheritParams plot_output_params @@ -45,7 +45,7 @@ #' @details Description of parameters. #' @keywords internal #' @seealso \code{\link{spatPlot3D}} -spatPlot2D_single = function(gobject, +.spatPlot2D_single = function(gobject, feat_type = NULL, spat_unit = NULL, show_image = F, @@ -586,7 +586,7 @@ spatPlot2D = function(gobject, ## check group_by if(is.null(group_by)) { - spatPlot2D_single(gobject = gobject, + .spatPlot2D_single(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, show_image = show_image, @@ -724,7 +724,7 @@ spatPlot2D = function(gobject, spec_image_name = image_name } - pl = spatPlot2D_single(gobject = temp_gobject, + pl = .spatPlot2D_single(gobject = temp_gobject, spat_unit = spat_unit, feat_type = feat_type, show_image = show_image, @@ -1062,7 +1062,7 @@ spatDeconvPlot = function(gobject, # Create a single 2D dimplot. This is looped through by dimPlot2D() if needed. #' @noRd #' @keywords internal -dimPlot2D_single <- function(gobject, +.dimPlot2D_single <- function(gobject, spat_unit = NULL, feat_type = NULL, dim_reduction_to_use = 'umap', @@ -1474,7 +1474,7 @@ dimPlot2D = function(gobject, ## check group_by if(is.null(group_by)) { - dimPlot2D_single(gobject = gobject, + .dimPlot2D_single(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, dim_reduction_to_use = dim_reduction_to_use, @@ -1583,7 +1583,7 @@ dimPlot2D = function(gobject, feat_type = feat_type, cell_ids = subset_cell_IDs) - pl = dimPlot2D_single(gobject = temp_gobject, + pl = .dimPlot2D_single(gobject = temp_gobject, spat_unit = spat_unit, feat_type = feat_type, dim_reduction_to_use = dim_reduction_to_use, @@ -1630,7 +1630,7 @@ dimPlot2D = function(gobject, return_plot = TRUE, save_plot = FALSE, save_param = list(), - default_save_name = 'dimPlot2D_single') + default_save_name = default_save_name) savelist[[group_id]] <- pl @@ -4234,12 +4234,12 @@ spatDimCellPlot = function(...) { # ** dimension plot #### -#' @title dimPlot_2D_plotly -#' @name dimPlot_2D_plotly +#' @title .dimPlot_2d_plotly +#' @name .dimPlot_2d_plotly #' @description Visualize cells at their 2D dimension reduction coordinates with plotly #' @return plotly object #' @keywords internal -dimPlot_2D_plotly <- function(gobject, +.dimPlot_2d_plotly <- function(gobject, spat_unit = NULL, feat_type = NULL, dim_reduction_to_use = 'umap', @@ -4497,12 +4497,12 @@ dimPlot_2D_plotly <- function(gobject, } -#' @title dimPlot_3D_plotly -#' @name dimPlot_3D_plotly +#' @title .dimPlot_3d_plotly +#' @name .dimPlot_3d_plotly #' @description Visualize cells at their 3D dimension reduction coordinates with plotly #' @return plotly object #' @keywords internal -dimPlot_3D_plotly <- function(gobject, +.dimPlot_3d_plotly <- function(gobject, spat_unit = NULL, feat_type = NULL, dim_reduction_to_use = 'umap', @@ -4820,7 +4820,7 @@ dimPlot3D = function(gobject, if(is.null(dim3_to_use)){ cat('create 2D plot\n') - pl = dimPlot_2D_plotly(gobject = gobject, + pl = .dimPlot_2d_plotly(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, dim_reduction_to_use = dim_reduction_to_use, @@ -4851,7 +4851,7 @@ dimPlot3D = function(gobject, else{ cat('create 3D plot\n') - pl = dimPlot_3D_plotly(gobject = gobject, + pl = .dimPlot_3d_plotly(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, dim_reduction_to_use = dim_reduction_to_use, @@ -4985,12 +4985,12 @@ plotPCA_3D = function(gobject, # ** #### # ** spatial 3D plot #### -#' @title spatPlot_2D_plotly -#' @name spatPlot_2D_plotly +#' @title .spatPlot_2d_plotly +#' @name .spatPlot_2d_plotly #' @description Visualize cells at their 2D spatial locations with plotly #' @return plotly object #' @keywords internal -spatPlot_2D_plotly = function(gobject, +.spatPlot_2d_plotly = function(gobject, spat_unit = NULL, feat_type = NULL, spat_loc_name = 'raw', @@ -5236,12 +5236,12 @@ spatPlot_2D_plotly = function(gobject, -#' @title spatPlot_3D_plotly -#' @name spatPlot_3D_plotly +#' @title .spatPlot_3d_plotly +#' @name .spatPlot_3d_plotly #' @description Visualize cells at their 3D spatial locations with plotly #' @return plotly object #' @keywords internal -spatPlot_3D_plotly = function(gobject, +.spatPlot_3d_plotly = function(gobject, spat_unit = NULL, feat_type = NULL, spat_loc_name = 'raw', @@ -5511,7 +5511,7 @@ spatPlot3D = function(gobject, if(is.null(sdimz)){ cat('create 2D plot\n') - pl = spatPlot_2D_plotly(gobject = gobject, + pl = .spatPlot_2d_plotly(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, sdimx = sdimx, @@ -5543,7 +5543,7 @@ spatPlot3D = function(gobject, else{ cat('create 3D plot\n') - pl = spatPlot_3D_plotly(gobject = gobject, + pl = .spatPlot_3d_plotly(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, sdimx = sdimx, diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 0c48043..84a04f1 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -66,52 +66,54 @@ #' #' @family In Situ visualizations #' @export -spatInSituPlotPoints <- function(gobject, - show_image = FALSE, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - spat_unit = NULL, - spat_loc_name = NULL, - feats = NULL, - feat_type = 'rna', - feats_color_code = NULL, - feat_shape_code = NULL, - sdimx = 'x', - sdimy = 'y', - spat_enr_names = NULL, - point_size = 1.5, - stroke = 0.5, - expand_counts = FALSE, - count_info_column = 'count', - jitter = c(0,0), - show_polygon = TRUE, - use_overlap = TRUE, - polygon_feat_type = 'cell', - polygon_color = 'black', - polygon_bg_color = 'black', - polygon_fill = NULL, - polygon_fill_gradient = NULL, - polygon_fill_gradient_midpoint = NULL, - polygon_fill_gradient_style = c('divergent', 'sequential'), - polygon_fill_as_factor = NULL, - polygon_fill_code = NULL, - polygon_alpha = 0.5, - polygon_line_size = 0.4, - axis_text = 8, - axis_title = 8, - legend_text = 6, - coord_fix_ratio = 1, - background_color = 'black', - show_legend = TRUE, - plot_method = c('ggplot', 'scattermore', 'scattermost'), - plot_last = c('polygons', 'points'), - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = 'spatInSituPlotPoints', - verbose = TRUE) { +spatInSituPlotPoints <- function( + gobject, + show_image = FALSE, + gimage = NULL, + image_name = NULL, + largeImage_name = NULL, + spat_unit = NULL, + spat_loc_name = NULL, + feats = NULL, + feat_type = 'rna', + feats_color_code = NULL, + feat_shape_code = NULL, + sdimx = 'x', + sdimy = 'y', + spat_enr_names = NULL, + point_size = 1.5, + stroke = 0.5, + expand_counts = FALSE, + count_info_column = 'count', + jitter = c(0,0), + show_polygon = TRUE, + use_overlap = TRUE, + polygon_feat_type = 'cell', + polygon_color = 'black', + polygon_bg_color = 'black', + polygon_fill = NULL, + polygon_fill_gradient = NULL, + polygon_fill_gradient_midpoint = NULL, + polygon_fill_gradient_style = c('divergent', 'sequential'), + polygon_fill_as_factor = NULL, + polygon_fill_code = NULL, + polygon_alpha = 0.5, + polygon_line_size = 0.4, + axis_text = 8, + axis_title = 8, + legend_text = 6, + coord_fix_ratio = 1, + background_color = 'black', + show_legend = TRUE, + plot_method = c('ggplot', 'scattermore', 'scattermost'), + plot_last = c('polygons', 'points'), + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = 'spatInSituPlotPoints', + verbose = TRUE +) { # set polygon_feat_type avail_poly_names = list_spatial_info_names(gobject = gobject) @@ -426,13 +428,13 @@ spatInSituPlotPoints <- function(gobject, # hexbin #### -#' @title spatInSituPlotHex_single -#' @name spatInSituPlotHex_single +#' @title Spatial in-situ hexbin plot - single +#' @name .spatInSituPlotHex_single #' @description function to plot hexbins at the spatial in situ level #' @return ggplot #' @details This function can plot one feature for one modality. #' @keywords internal -spatInSituPlotHex_single = function(gobject, +.spatInSituPlotHex_single = function(gobject, feat = NULL, feat_type = 'rna', sdimx = 'x', @@ -614,26 +616,28 @@ spatInSituPlotHex = function(gobject, for(sel_feat in feats) { - pl = spatInSituPlotHex_single(gobject = gobject, - feat = sel_feat, - feat_type = feat_type, - sdimx = sdimx, - sdimy = sdimy, - binwidth = binwidth, - min_axis_bins = min_axis_bins, - alpha = alpha, - show_polygon = show_polygon, - polygon_feat_type = polygon_feat_type, - polygon_color = polygon_color, - polygon_fill = polygon_fill, - polygon_fill_as_factor = polygon_fill_as_factor, - polygon_alpha = polygon_alpha, - polygon_size = polygon_line_size, - coord_fix_ratio = coord_fix_ratio, - axis_text = axis_text, - axis_title = axis_title, - legend_text = legend_text, - background_color = background_color) + pl = .spatInSituPlotHex_single( + gobject = gobject, + feat = sel_feat, + feat_type = feat_type, + sdimx = sdimx, + sdimy = sdimy, + binwidth = binwidth, + min_axis_bins = min_axis_bins, + alpha = alpha, + show_polygon = show_polygon, + polygon_feat_type = polygon_feat_type, + polygon_color = polygon_color, + polygon_fill = polygon_fill, + polygon_fill_as_factor = polygon_fill_as_factor, + polygon_alpha = polygon_alpha, + polygon_size = polygon_line_size, + coord_fix_ratio = coord_fix_ratio, + axis_text = axis_text, + axis_title = axis_title, + legend_text = legend_text, + background_color = background_color + ) savelist[[sel_feat]] = pl @@ -682,13 +686,13 @@ spatInSituPlotHex = function(gobject, # density #### -#' @title spatInSituPlotDensity_single -#' @name spatInSituPlotDensity_single +#' @title Spatial in-situ density plot - single +#' @name .spatInSituPlotDensity_single #' @description low level function to plot density plots at the spatial in situ level #' @return ggplot #' @details This function can plot one feature for one modality. #' @keywords internal -spatInSituPlotDensity_single = function(gobject, +.spatInSituPlotDensity_single = function(gobject, feat = NULL, feat_type = 'rna', sdimx = 'x', @@ -862,24 +866,26 @@ spatInSituPlotDensity = function(gobject, for(sel_feat in feats) { - pl = spatInSituPlotDensity_single(gobject = gobject, - feat = sel_feat, - feat_type = feat_type, - sdimx = sdimx, - sdimy = sdimy, - alpha = alpha, - show_polygon = show_polygon, - polygon_feat_type = polygon_feat_type, - polygon_color = polygon_color, - polygon_fill = polygon_fill, - polygon_fill_as_factor = polygon_fill_as_factor, - polygon_alpha = polygon_alpha, - polygon_size = polygon_line_size, - coord_fix_ratio = coord_fix_ratio, - axis_text = axis_text, - axis_title = axis_title, - legend_text = legend_text, - background_color = background_color) + pl = .spatInSituPlotDensity_single( + gobject = gobject, + feat = sel_feat, + feat_type = feat_type, + sdimx = sdimx, + sdimy = sdimy, + alpha = alpha, + show_polygon = show_polygon, + polygon_feat_type = polygon_feat_type, + polygon_color = polygon_color, + polygon_fill = polygon_fill, + polygon_fill_as_factor = polygon_fill_as_factor, + polygon_alpha = polygon_alpha, + polygon_size = polygon_line_size, + coord_fix_ratio = coord_fix_ratio, + axis_text = axis_text, + axis_title = axis_title, + legend_text = legend_text, + background_color = background_color + ) savelist[[sel_feat]] = pl diff --git a/man/createHeatmap_DT.Rd b/man/createHeatmap_DT.Rd index bdfc154..791fa23 100644 --- a/man/createHeatmap_DT.Rd +++ b/man/createHeatmap_DT.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot_heatmap.R -\name{createHeatmap_DT} -\alias{createHeatmap_DT} -\title{createHeatmap_DT} +\name{.create_heatmap_dt} +\alias{.create_heatmap_dt} +\title{.create_heatmap_dt} \usage{ -createHeatmap_DT( +.create_heatmap_dt( gobject, spat_unit = NULL, feat_type = NULL, diff --git a/man/decide_cluster_order.Rd b/man/decide_cluster_order.Rd index debe774..8198882 100644 --- a/man/decide_cluster_order.Rd +++ b/man/decide_cluster_order.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/aux_visuals.R -\name{decide_cluster_order} -\alias{decide_cluster_order} -\title{decide_cluster_order} +\name{.decide_cluster_order} +\alias{.decide_cluster_order} +\title{.decide_cluster_order} \usage{ -decide_cluster_order( +.decide_cluster_order( gobject, spat_unit = NULL, feat_type = NULL, diff --git a/man/dimPlot_2D_plotly.Rd b/man/dimPlot_2D_plotly.Rd index 9b8602d..ad527f3 100644 --- a/man/dimPlot_2D_plotly.Rd +++ b/man/dimPlot_2D_plotly.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial.R -\name{dimPlot_2D_plotly} -\alias{dimPlot_2D_plotly} -\title{dimPlot_2D_plotly} +\name{.dimPlot_2d_plotly} +\alias{.dimPlot_2d_plotly} +\title{.dimPlot_2d_plotly} \usage{ -dimPlot_2D_plotly( +.dimPlot_2d_plotly( gobject, spat_unit = NULL, feat_type = NULL, diff --git a/man/dimPlot_3D_plotly.Rd b/man/dimPlot_3D_plotly.Rd index 4350427..13bf672 100644 --- a/man/dimPlot_3D_plotly.Rd +++ b/man/dimPlot_3D_plotly.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial.R -\name{dimPlot_3D_plotly} -\alias{dimPlot_3D_plotly} -\title{dimPlot_3D_plotly} +\name{.dimPlot_3d_plotly} +\alias{.dimPlot_3d_plotly} +\title{.dimPlot_3d_plotly} \usage{ -dimPlot_3D_plotly( +.dimPlot_3d_plotly( gobject, spat_unit = NULL, feat_type = NULL, diff --git a/man/plot_save.Rd b/man/plot_save.Rd index a106c53..2ac110c 100644 --- a/man/plot_save.Rd +++ b/man/plot_save.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/aux_save.R \name{plot_save} \alias{plot_save} -\alias{ggplot_save_function} -\alias{general_save_function} +\alias{.ggplot_save_function} +\alias{.general_save_function} \alias{all_plots_save_function} \title{Plot saving} \usage{ -ggplot_save_function( +.ggplot_save_function( gobject, plot_object, save_dir = NULL, @@ -29,7 +29,7 @@ ggplot_save_function( ... ) -general_save_function( +.general_save_function( gobject, plot_object, save_dir = NULL, @@ -116,9 +116,9 @@ Functions to automatically save plots to directory of interest } \section{Functions}{ \itemize{ -\item \code{ggplot_save_function()}: ggplot saving. ... passes to cowplot::save_plot +\item \code{.ggplot_save_function()}: ggplot saving. ... passes to cowplot::save_plot -\item \code{general_save_function()}: base and general saving. ... passes to grDevices png, tiff, pdf, svg +\item \code{.general_save_function()}: base and general saving. ... passes to grDevices png, tiff, pdf, svg }} \seealso{ diff --git a/man/sankey_compare.Rd b/man/sankey_compare.Rd index 4f72523..4883629 100644 --- a/man/sankey_compare.Rd +++ b/man/sankey_compare.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot_sankey.R -\name{sankey_compare} -\alias{sankey_compare} +\name{.sankey_compare} +\alias{.sankey_compare} \title{Calculations for a sankey relationship pair} \usage{ -sankey_compare(data_dt, idx_start = 0) +.sankey_compare(data_dt, idx_start = 0) } \arguments{ \item{data_dt}{data.table with two columns. Each should contain diff --git a/man/sankey_relation_pair.Rd b/man/sankey_relation_pair.Rd index 9ca4842..07385a0 100644 --- a/man/sankey_relation_pair.Rd +++ b/man/sankey_relation_pair.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot_sankey.R -\name{sankey_relation_pair} -\alias{sankey_relation_pair} +\name{.sankey_relation_pair} +\alias{.sankey_relation_pair} \title{Calculations for a sankey relationship pair} \usage{ -sankey_relation_pair(g, gsp, rel_idx, node_idx_start = 0) +.sankey_relation_pair(g, gsp, rel_idx, node_idx_start = 0) } \arguments{ \item{g}{giotto object} @@ -17,6 +17,6 @@ sankey_relation_pair(g, gsp, rel_idx, node_idx_start = 0) } \description{ Get matched values to compare from the giotto object. Comparison columns -are then passed as a data.table to \code{sankey_compare} to be calculated. +are then passed as a data.table to \code{.sankey_compare} to be calculated. } \keyword{internal} diff --git a/man/spatInSituPlotDensity_single.Rd b/man/spatInSituPlotDensity_single.Rd index 41c0593..b50ad62 100644 --- a/man/spatInSituPlotDensity_single.Rd +++ b/man/spatInSituPlotDensity_single.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial_in_situ.R -\name{spatInSituPlotDensity_single} -\alias{spatInSituPlotDensity_single} -\title{spatInSituPlotDensity_single} +\name{.spatInSituPlotDensity_single} +\alias{.spatInSituPlotDensity_single} +\title{.spatInSituPlotDensity_single} \usage{ -spatInSituPlotDensity_single( +.spatInSituPlotDensity_single( gobject, feat = NULL, feat_type = "rna", diff --git a/man/spatInSituPlotHex_single.Rd b/man/spatInSituPlotHex_single.Rd index d41c773..848d084 100644 --- a/man/spatInSituPlotHex_single.Rd +++ b/man/spatInSituPlotHex_single.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial_in_situ.R -\name{spatInSituPlotHex_single} -\alias{spatInSituPlotHex_single} -\title{spatInSituPlotHex_single} +\name{.spatInSituPlotHex_single} +\alias{.spatInSituPlotHex_single} +\title{.spatInSituPlotHex_single} \usage{ -spatInSituPlotHex_single( +.spatInSituPlotHex_single( gobject, feat = NULL, feat_type = "rna", diff --git a/man/spatPlot2D_single.Rd b/man/spatPlot2D_single.Rd index 0a16d15..be2bc11 100644 --- a/man/spatPlot2D_single.Rd +++ b/man/spatPlot2D_single.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial.R -\name{spatPlot2D_single} -\alias{spatPlot2D_single} -\title{spatPlot2D_single} +\name{.spatPlot2D_single} +\alias{.spatPlot2D_single} +\title{.spatPlot2D_single} \usage{ -spatPlot2D_single( +.spatPlot2D_single( gobject, feat_type = NULL, spat_unit = NULL, @@ -64,7 +64,7 @@ spatPlot2D_single( save_plot = NA, verbose = FALSE, save_param = list(), - default_save_name = "spatPlot2D_single" + default_save_name = ".spatPlot2D_single" ) } \arguments{ diff --git a/man/spatPlot_2D_plotly.Rd b/man/spatPlot_2D_plotly.Rd index 0d64d87..7b8c8dc 100644 --- a/man/spatPlot_2D_plotly.Rd +++ b/man/spatPlot_2D_plotly.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial.R -\name{spatPlot_2D_plotly} -\alias{spatPlot_2D_plotly} -\title{spatPlot_2D_plotly} +\name{.spatPlot_2d_plotly} +\alias{.spatPlot_2d_plotly} +\title{.spatPlot_2d_plotly} \usage{ -spatPlot_2D_plotly( +.spatPlot_2d_plotly( gobject, spat_unit = NULL, feat_type = NULL, diff --git a/man/spatPlot_3D_plotly.Rd b/man/spatPlot_3D_plotly.Rd index cacfe41..7da4116 100644 --- a/man/spatPlot_3D_plotly.Rd +++ b/man/spatPlot_3D_plotly.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/vis_spatial.R -\name{spatPlot_3D_plotly} -\alias{spatPlot_3D_plotly} -\title{spatPlot_3D_plotly} +\name{.spatPlot_3d_plotly} +\alias{.spatPlot_3d_plotly} +\title{.spatPlot_3d_plotly} \usage{ -spatPlot_3D_plotly( +.spatPlot_3d_plotly( gobject, spat_unit = NULL, feat_type = NULL, From 9776b4a3160f8485638be8defdb00d3cd9e9e4f2 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:49:12 -0500 Subject: [PATCH 05/10] Minor changes and docs - Switch usage of `spatVector_to_dt` to `as.data.table` with geom = "XY" - switched some `stop()` calls to `.gstop()` --- DESCRIPTION | 1 + R/aux_visuals.R | 8 ++++-- R/color_palettes.R | 4 +-- R/plot_sankey.R | 4 +-- R/vis_spatial_in_situ.R | 18 ++++++------- ...Heatmap_DT.Rd => dot-create_heatmap_dt.Rd} | 2 +- ...r_order.Rd => dot-decide_cluster_order.Rd} | 2 +- ..._2D_plotly.Rd => dot-dimPlot_2d_plotly.Rd} | 0 ..._3D_plotly.Rd => dot-dimPlot_3d_plotly.Rd} | 0 ...ankey_compare.Rd => dot-sankey_compare.Rd} | 0 man/dot-sankey_networkd3.Rd | 26 +++++++++++++++++++ ...on_pair.Rd => dot-sankey_relation_pair.Rd} | 0 ...Rd => dot-spatInSituPlotDensity_single.Rd} | 2 +- ...gle.Rd => dot-spatInSituPlotHex_single.Rd} | 2 +- ...t2D_single.Rd => dot-spatPlot2D_single.Rd} | 2 +- ...2D_plotly.Rd => dot-spatPlot_2d_plotly.Rd} | 0 ...3D_plotly.Rd => dot-spatPlot_3d_plotly.Rd} | 0 man/gg_input.Rd | 2 +- man/plot_save.Rd | 4 +-- 19 files changed, 53 insertions(+), 24 deletions(-) rename man/{createHeatmap_DT.Rd => dot-create_heatmap_dt.Rd} (98%) rename man/{decide_cluster_order.Rd => dot-decide_cluster_order.Rd} (97%) rename man/{dimPlot_2D_plotly.Rd => dot-dimPlot_2d_plotly.Rd} (100%) rename man/{dimPlot_3D_plotly.Rd => dot-dimPlot_3d_plotly.Rd} (100%) rename man/{sankey_compare.Rd => dot-sankey_compare.Rd} (100%) create mode 100644 man/dot-sankey_networkd3.Rd rename man/{sankey_relation_pair.Rd => dot-sankey_relation_pair.Rd} (100%) rename man/{spatInSituPlotDensity_single.Rd => dot-spatInSituPlotDensity_single.Rd} (94%) rename man/{spatInSituPlotHex_single.Rd => dot-spatInSituPlotHex_single.Rd} (94%) rename man/{spatPlot2D_single.Rd => dot-spatPlot2D_single.Rd} (98%) rename man/{spatPlot_2D_plotly.Rd => dot-spatPlot_2d_plotly.Rd} (100%) rename man/{spatPlot_3D_plotly.Rd => dot-spatPlot_3d_plotly.Rd} (100%) diff --git a/DESCRIPTION b/DESCRIPTION index 00c0152..d3e6045 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -84,6 +84,7 @@ Collate: 'dd.R' 'gg_info_layers.R' 'globals.R' + 'gstop.R' 'plot_dendrogram.R' 'plot_heatmap.R' 'plot_sankey.R' diff --git a/R/aux_visuals.R b/R/aux_visuals.R index 0029d29..37add03 100644 --- a/R/aux_visuals.R +++ b/R/aux_visuals.R @@ -55,8 +55,12 @@ NULL feat_type = feat_type) ## check parameters - if(is.null(cluster_column)) stop('\n cluster column must be selected \n') - if(!cluster_column %in% colnames(cell_metadata)) stop('\n cluster column is not found \n') + if(is.null(cluster_column)) .gstop('cluster column must be selected') + if(!cluster_column %in% colnames(cell_metadata)) { + .gstop('cluster column is not found in', + str_bracket(spat_unit), str_bracket(feat_type), + 'metadata') + } ## cluster order ## cluster_order = match.arg(cluster_order, c('size', 'correlation', 'custom')) diff --git a/R/color_palettes.R b/R/color_palettes.R index 528b85f..8e017fc 100644 --- a/R/color_palettes.R +++ b/R/color_palettes.R @@ -86,8 +86,8 @@ getColors <- function(pal = 'viridis', pkg_to_use = 'palr' } if(inherits(try_val, 'try-error')) { - stop(wrap_txt(pal, 'not discovered in supported palette packages:', - names(pal_names), errWidth = TRUE)) + .gstop(pal, 'not discovered in supported palette packages:', + names(pal_names)) } pal = try_val } diff --git a/R/plot_sankey.R b/R/plot_sankey.R index a0cb174..9f21357 100644 --- a/R/plot_sankey.R +++ b/R/plot_sankey.R @@ -116,10 +116,10 @@ setMethod( signature(x = 'giottoSankeyPlan', add = 'logical', value = 'numeric'), function(x, add, value) { - if (length(value) != 2L) stop(GiottoUtils::wrap_txt( + if (length(value) != 2L) .gstop( "When value is provided as numeric/integer, input must be length of 2,", "designating nodes 'from' and 'to'" - )) + ) value = as.integer(value) if (add) { diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 84a04f1..991158a 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -253,10 +253,6 @@ spatInSituPlotPoints <- function( data.table::setnames(polygon_dt, old = 'cell_ID', new = 'poly_ID') - #polygon_info = get_polygon_info(gobject = gobject, - # polygon_name = polygon_feat_type) - #polygon_dt = spatVector_to_dt(polygon_info) - plot = plot_cell_polygon_layer( ggobject = plot, instrs = instructions(gobject), @@ -307,10 +303,6 @@ spatInSituPlotPoints <- function( data.table::setnames(polygon_dt, old = 'cell_ID', new = 'poly_ID') - #polygon_info = get_polygon_info(gobject = gobject, - # polygon_name = polygon_feat_type) - #polygon_dt = spatVector_to_dt(polygon_info) - plot = plot_cell_polygon_layer( ggobject = plot, instrs = instructions(gobject), @@ -475,7 +467,10 @@ spatInSituPlotPoints <- function( polygon_info = get_polygon_info(gobject = gobject, polygon_name = polygon_feat_type) - polygon_dt = spatVector_to_dt(polygon_info) + polygon_dt = data.table::as.data.table( + polygon_info, + geom = "XY" + ) plot = plot_cell_polygon_layer(ggobject = plot, instrs = instructions(gobject), @@ -728,7 +723,10 @@ spatInSituPlotHex = function(gobject, polygon_info = get_polygon_info(gobject = gobject, polygon_name = polygon_feat_type) - polygon_dt = spatVector_to_dt(polygon_info) + polygon_dt <- data.table::as.data.table( + polygon_info, + geom = "XY" + ) #polygon_dt = combineSpatialCellMetadataInfo(gobject, feat_type = polygon_feat_type) #polygon_dt = polygon_dt[[polygon_feat_type]] diff --git a/man/createHeatmap_DT.Rd b/man/dot-create_heatmap_dt.Rd similarity index 98% rename from man/createHeatmap_DT.Rd rename to man/dot-create_heatmap_dt.Rd index 791fa23..b23c1be 100644 --- a/man/createHeatmap_DT.Rd +++ b/man/dot-create_heatmap_dt.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plot_heatmap.R \name{.create_heatmap_dt} \alias{.create_heatmap_dt} -\title{.create_heatmap_dt} +\title{Create heatmap data.table} \usage{ .create_heatmap_dt( gobject, diff --git a/man/decide_cluster_order.Rd b/man/dot-decide_cluster_order.Rd similarity index 97% rename from man/decide_cluster_order.Rd rename to man/dot-decide_cluster_order.Rd index 8198882..fa89e00 100644 --- a/man/decide_cluster_order.Rd +++ b/man/dot-decide_cluster_order.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/aux_visuals.R \name{.decide_cluster_order} \alias{.decide_cluster_order} -\title{.decide_cluster_order} +\title{Decide cluster order} \usage{ .decide_cluster_order( gobject, diff --git a/man/dimPlot_2D_plotly.Rd b/man/dot-dimPlot_2d_plotly.Rd similarity index 100% rename from man/dimPlot_2D_plotly.Rd rename to man/dot-dimPlot_2d_plotly.Rd diff --git a/man/dimPlot_3D_plotly.Rd b/man/dot-dimPlot_3d_plotly.Rd similarity index 100% rename from man/dimPlot_3D_plotly.Rd rename to man/dot-dimPlot_3d_plotly.Rd diff --git a/man/sankey_compare.Rd b/man/dot-sankey_compare.Rd similarity index 100% rename from man/sankey_compare.Rd rename to man/dot-sankey_compare.Rd diff --git a/man/dot-sankey_networkd3.Rd b/man/dot-sankey_networkd3.Rd new file mode 100644 index 0000000..0500c15 --- /dev/null +++ b/man/dot-sankey_networkd3.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_sankey.R +\name{.sankey_networkd3} +\alias{.sankey_networkd3} +\title{Create networkd3 sankey} +\usage{ +.sankey_networkd3( + Links, + Nodes, + Source = "source", + Target = "target", + Value = "value", + NodeID = "name", + nodePadding = 1, + sinksRight = FALSE, + focus_names = NULL, + unfocused_replacer = "", + unfocused_color = FALSE, + ... +) +} +\description{ +Wrapper for networkd3's sankeyNetwork function. Adds some +additional params for controlling the plot. +} +\keyword{internal} diff --git a/man/sankey_relation_pair.Rd b/man/dot-sankey_relation_pair.Rd similarity index 100% rename from man/sankey_relation_pair.Rd rename to man/dot-sankey_relation_pair.Rd diff --git a/man/spatInSituPlotDensity_single.Rd b/man/dot-spatInSituPlotDensity_single.Rd similarity index 94% rename from man/spatInSituPlotDensity_single.Rd rename to man/dot-spatInSituPlotDensity_single.Rd index b50ad62..6018378 100644 --- a/man/spatInSituPlotDensity_single.Rd +++ b/man/dot-spatInSituPlotDensity_single.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/vis_spatial_in_situ.R \name{.spatInSituPlotDensity_single} \alias{.spatInSituPlotDensity_single} -\title{.spatInSituPlotDensity_single} +\title{Spatial in-situ density plot - single} \usage{ .spatInSituPlotDensity_single( gobject, diff --git a/man/spatInSituPlotHex_single.Rd b/man/dot-spatInSituPlotHex_single.Rd similarity index 94% rename from man/spatInSituPlotHex_single.Rd rename to man/dot-spatInSituPlotHex_single.Rd index 848d084..62b9100 100644 --- a/man/spatInSituPlotHex_single.Rd +++ b/man/dot-spatInSituPlotHex_single.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/vis_spatial_in_situ.R \name{.spatInSituPlotHex_single} \alias{.spatInSituPlotHex_single} -\title{.spatInSituPlotHex_single} +\title{Spatial in-situ hexbin plot - single} \usage{ .spatInSituPlotHex_single( gobject, diff --git a/man/spatPlot2D_single.Rd b/man/dot-spatPlot2D_single.Rd similarity index 98% rename from man/spatPlot2D_single.Rd rename to man/dot-spatPlot2D_single.Rd index be2bc11..49baa24 100644 --- a/man/spatPlot2D_single.Rd +++ b/man/dot-spatPlot2D_single.Rd @@ -64,7 +64,7 @@ save_plot = NA, verbose = FALSE, save_param = list(), - default_save_name = ".spatPlot2D_single" + default_save_name = "spatPlot2D_single" ) } \arguments{ diff --git a/man/spatPlot_2D_plotly.Rd b/man/dot-spatPlot_2d_plotly.Rd similarity index 100% rename from man/spatPlot_2D_plotly.Rd rename to man/dot-spatPlot_2d_plotly.Rd diff --git a/man/spatPlot_3D_plotly.Rd b/man/dot-spatPlot_3d_plotly.Rd similarity index 100% rename from man/spatPlot_3D_plotly.Rd rename to man/dot-spatPlot_3d_plotly.Rd diff --git a/man/gg_input.Rd b/man/gg_input.Rd index a0d8502..413672c 100644 --- a/man/gg_input.Rd +++ b/man/gg_input.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/aux_visuals.R \name{gg_input} \alias{gg_input} -\title{gg_input} +\title{gg input} \usage{ gg_input(ggobject) } diff --git a/man/plot_save.Rd b/man/plot_save.Rd index 2ac110c..4d0adce 100644 --- a/man/plot_save.Rd +++ b/man/plot_save.Rd @@ -116,9 +116,9 @@ Functions to automatically save plots to directory of interest } \section{Functions}{ \itemize{ -\item \code{.ggplot_save_function()}: ggplot saving. ... passes to cowplot::save_plot +\item \code{.ggplot_save_function()}: (internal) ggplot saving. ... passes to cowplot::save_plot -\item \code{.general_save_function()}: base and general saving. ... passes to grDevices png, tiff, pdf, svg +\item \code{.general_save_function()}: (internal) base and general saving. ... passes to grDevices png, tiff, pdf, svg }} \seealso{ From 8027dad5b2475b5335589dc6d9c00cd8b1794437 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:02:48 -0500 Subject: [PATCH 06/10] Remove `getDistinctColors` --- NAMESPACE | 1 - R/color_palettes.R | 49 ---------------------------------------- man/getDistinctColors.Rd | 17 -------------- 3 files changed, 67 deletions(-) delete mode 100644 man/getDistinctColors.Rd diff --git a/NAMESPACE b/NAMESPACE index 7603471..6735407 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,7 +15,6 @@ export(dimPlot2D) export(dimPlot3D) export(expand_feature_info) export(getColors) -export(getDistinctColors) export(get_continuous_colors) export(gg_simple_scatter) export(giottoSankeyPlan) diff --git a/R/color_palettes.R b/R/color_palettes.R index 8e017fc..3997299 100644 --- a/R/color_palettes.R +++ b/R/color_palettes.R @@ -115,55 +115,6 @@ getColors <- function(pal = 'viridis', -#' @title getDistinctColors -#' @description Returns a number of distinct colors based on the RGB scale -#' @param n number of colors wanted -#' @return character vector of hexadecimal distinct colors -#' @export -getDistinctColors <- function(n) { - - if(n < 1) stop(wrap_txt('getDistinctColors \'n\' colors wanted must be at least 1\n', errWidth = TRUE), call. = FALSE) - - qual_col_pals <- RColorBrewer::brewer.pal.info[RColorBrewer::brewer.pal.info$category == 'qual',] - col_vector <- unique(unlist(mapply(RColorBrewer::brewer.pal, qual_col_pals$maxcolors, rownames(qual_col_pals)))); - - if(n > length(col_vector)) { - - # get all possible colors - all_colors = grDevices::colors() - all_colors_no_grey = grep(x = all_colors, pattern = 'grey|gray', value = T, invert = T) - grey_colors = grep(x = all_colors, pattern = 'grey', value = T, invert = F) - admitted_grey_colors = grey_colors[seq(1, 110, 10)] - broad_colors = c(all_colors_no_grey, admitted_grey_colors) - - set.seed(1234) - on.exit(set.seed(Sys.time())) - # if too many colors requested, warn about recycling - if(n > length(broad_colors)) { - warning('\n not enough unique colors in R, maximum = 444 \n') - col_vector = sample(x = broad_colors, size = n, replace = TRUE) - } else { - col_vector = sample(x = broad_colors, size = n, replace = FALSE) - } - - } else { - - xxx <- grDevices::col2rgb(col_vector); - dist_mat <- as.matrix(stats::dist(t(xxx))); - diag(dist_mat) <- 1e10; - while (length(col_vector) > n) { - minv <- apply(dist_mat,1,function(x)min(x)); - idx <- which(minv==min(minv))[1]; - dist_mat <- dist_mat[-idx, -idx]; - col_vector <- col_vector[-idx] - } - - } - return(col_vector) -} - - - # get palettes #### diff --git a/man/getDistinctColors.Rd b/man/getDistinctColors.Rd deleted file mode 100644 index 8a51e8d..0000000 --- a/man/getDistinctColors.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/color_palettes.R -\name{getDistinctColors} -\alias{getDistinctColors} -\title{getDistinctColors} -\usage{ -getDistinctColors(n) -} -\arguments{ -\item{n}{number of colors wanted} -} -\value{ -character vector of hexadecimal distinct colors -} -\description{ -Returns a number of distinct colors based on the RGB scale -} From 50cc8164e3ebcc14fa8a8aa74374513effca723d Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Wed, 13 Dec 2023 02:58:28 -0500 Subject: [PATCH 07/10] Get colors from utils --- NAMESPACE | 2 ++ R/package_imports.R | 5 +++++ R/suite_rexports.R | 0 man/reexports.Rd | 6 +++++- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 R/suite_rexports.R diff --git a/NAMESPACE b/NAMESPACE index 6735407..10547c0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,8 @@ export(dimPlot2D) export(dimPlot3D) export(expand_feature_info) export(getColors) +export(getDistinctColors) +export(getRainbowColors) export(get_continuous_colors) export(gg_simple_scatter) export(giottoSankeyPlan) diff --git a/R/package_imports.R b/R/package_imports.R index 20103d5..55026fa 100644 --- a/R/package_imports.R +++ b/R/package_imports.R @@ -10,3 +10,8 @@ #' @import ggplot2 #' @import utils NULL + +#' @export +GiottoUtils::getRainbowColors +#' @export +GiottoUtils::getDistinctColors diff --git a/R/suite_rexports.R b/R/suite_rexports.R new file mode 100644 index 0000000..e69de29 diff --git a/man/reexports.Rd b/man/reexports.Rd index 3524c95..addde0b 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -1,8 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/colorRamp2.R +% Please edit documentation in R/package_imports.R, R/colorRamp2.R \docType{import} \name{reexports} \alias{reexports} +\alias{getRainbowColors} +\alias{getDistinctColors} \alias{colorRamp2} \title{Objects exported from other packages} \keyword{internal} @@ -12,5 +14,7 @@ below to see their documentation. \describe{ \item{colorRamp2}{\code{\link[colorRamp2]{colorRamp2}}} + + \item{GiottoUtils}{\code{\link[GiottoUtils]{getDistinctColors}}, \code{\link[GiottoUtils]{getRainbowColors}}} }} From 01e608f4ec010c0b2f6c5c3df976be58978853f6 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:23:53 -0500 Subject: [PATCH 08/10] update for new gstop defaults --- DESCRIPTION | 1 + R/gstop.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d3e6045..48e6c22 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -91,6 +91,7 @@ Collate: 'plot_scatter.R' 'plot_violin.R' 'spatialDE_visuals.R' + 'suite_rexports.R' 'vis_spatial.R' 'vis_spatial_in_situ.R' 'viz_spatial_network.R' diff --git a/R/gstop.R b/R/gstop.R index 847776e..e4eaf03 100644 --- a/R/gstop.R +++ b/R/gstop.R @@ -9,7 +9,7 @@ .prefix = " ", .initial = "", .n = 1L, - .call = FALSE) { + .call = TRUE) { GiottoUtils::gstop( ..., sep = sep, From 08fab4fcb3a62d1478f74a92963841fab6e39a60 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Thu, 14 Dec 2023 01:46:13 -0500 Subject: [PATCH 09/10] chore: move re-exports to new script --- DESCRIPTION | 2 +- R/package_imports.R | 5 ----- R/suite_reexports.R | 4 ++++ R/suite_rexports.R | 0 man/reexports.Rd | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 R/suite_reexports.R delete mode 100644 R/suite_rexports.R diff --git a/DESCRIPTION b/DESCRIPTION index 48e6c22..82909e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -91,7 +91,7 @@ Collate: 'plot_scatter.R' 'plot_violin.R' 'spatialDE_visuals.R' - 'suite_rexports.R' + 'suite_reexports.R' 'vis_spatial.R' 'vis_spatial_in_situ.R' 'viz_spatial_network.R' diff --git a/R/package_imports.R b/R/package_imports.R index 55026fa..20103d5 100644 --- a/R/package_imports.R +++ b/R/package_imports.R @@ -10,8 +10,3 @@ #' @import ggplot2 #' @import utils NULL - -#' @export -GiottoUtils::getRainbowColors -#' @export -GiottoUtils::getDistinctColors diff --git a/R/suite_reexports.R b/R/suite_reexports.R new file mode 100644 index 0000000..92d685d --- /dev/null +++ b/R/suite_reexports.R @@ -0,0 +1,4 @@ +#' @export +GiottoUtils::getRainbowColors +#' @export +GiottoUtils::getDistinctColors diff --git a/R/suite_rexports.R b/R/suite_rexports.R deleted file mode 100644 index e69de29..0000000 diff --git a/man/reexports.Rd b/man/reexports.Rd index addde0b..411a3ed 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/package_imports.R, R/colorRamp2.R +% Please edit documentation in R/colorRamp2.R, R/suite_reexports.R \docType{import} \name{reexports} \alias{reexports} +\alias{colorRamp2} \alias{getRainbowColors} \alias{getDistinctColors} -\alias{colorRamp2} \title{Objects exported from other packages} \keyword{internal} \description{ From 573bdf6b57fac5f57986a06d1865dd8b75395a87 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Thu, 14 Dec 2023 03:06:04 -0500 Subject: [PATCH 10/10] Update NEWS.md --- NEWS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e738516..88a77d6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,11 +5,12 @@ - Removed: `getDistinctColors()` to *GiottoUtils* ## Added - +- Add: `getDistinctColors()` and `getRainbowColors()` as re-exports from *GiottoUtils* ## Changes - Changed: Package internal functions now have `.` prefix - Changed: *GiottoUtils* and *GiottoClass* moved to Imports +- Changed: Other internal function naming changes to bring in line with updates to *GiottoUtils* # Giotto Visuals 0.1.0 (23/11/29)