From 1ae472776b5cf930d76d7815cef270d02a5dda36 Mon Sep 17 00:00:00 2001 From: josschavezf Date: Sun, 5 May 2024 23:08:16 -0400 Subject: [PATCH 01/23] update R version --- DESCRIPTION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 69ea85a..4e6a866 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,9 +23,9 @@ BugReports: https://github.com/drieslab/Giotto/issues Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Depends: - base (>= 4.3.0), - utils (>= 4.3.0), - R (>= 4.3.0), + base (>= 4.4.0), + utils (>= 4.4.0), + R (>= 4.4.0) Imports: checkmate, colorRamp2, From 955ef30f7b6cf305c7d128e102736dd7db5b4f18 Mon Sep 17 00:00:00 2001 From: josschavezf Date: Fri, 10 May 2024 16:28:16 -0400 Subject: [PATCH 02/23] run devtools document --- man/auto_image_resample.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/auto_image_resample.Rd b/man/auto_image_resample.Rd index 6ecf76e..f77e13f 100644 --- a/man/auto_image_resample.Rd +++ b/man/auto_image_resample.Rd @@ -7,7 +7,7 @@ \usage{ .auto_resample_gimage( img, - plot_ext, + plot_ext = NULL, img_border = 0.125, flex_resample = TRUE, max_sample = getOption("giotto.plot_img_max_sample", 5e+05), From 7b237a0a6f8d03986c56e01486438e4838ac8c29 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 08:00:37 -0400 Subject: [PATCH 03/23] chore: bump for dev --- DESCRIPTION | 2 +- NEWS.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index bcef8f9..9b3e8dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GiottoVisuals Title: Visuals for the Giotto spatial biology analysis ecosystem -Version: 0.2.3 +Version: 0.2.4 Authors@R: c( person("Ruben", "Dries", email = "rubendries@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-7650-7754")), diff --git a/NEWS.md b/NEWS.md index 1035985..87e8b87 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ +# GiottoVisuals 0.2.4 + + # GiottoVisuals 0.2.3 (2024/05/28) ## bug fixes From ddf35bf22a31481a020abacf530b7f62bab3e225 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 10:57:34 -0400 Subject: [PATCH 04/23] chore: update docs for `spatPlot2D()` --- R/vis_spatial.R | 19 ++++++++++++++----- man/spatPlot.Rd | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 16177af..a38e993 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -481,9 +481,6 @@ #' @param theme_param list of additional params passed to `ggplot2::theme()` #' @details coord_fix_ratio: set to NULL to use default ggplot parameters #' @returns ggplot -#' @examples -#' g <- GiottoData::loadGiottoMini("visium") -#' spatPlot2D(g) #' @export spatPlot2D <- function( gobject, @@ -760,8 +757,20 @@ spatPlot2D <- function( #' @family spatial visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") -#' spatPlot(g) +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +#' spatPlot(g, show_image = TRUE, image_name = "image") +#' +#' # the more specific spatPlot2D with networks shown +#' spatPlot2D(g, show_image = TRUE, image_name = "image", show_network = TRUE) +#' +#' # plotting of some cell metadata (number of different features detected) +#' spatPlot2D(g, +#' show_image = TRUE, +#' image_name = "image", +#' cell_color = "nr_feats", +#' color_as_factor = FALSE, +#' gradient_style = "sequential" +#' ) #' @export #' @seealso \code{\link{spatPlot3D}} spatPlot <- function(...) { diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index 139ccbc..fc8b451 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -292,10 +292,20 @@ Visualize cells according to spatial coordinates coord_fix_ratio: set to NULL to use default ggplot parameters } \examples{ -g <- GiottoData::loadGiottoMini("visium") -spatPlot2D(g) -g <- GiottoData::loadGiottoMini("visium") -spatPlot(g) +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +spatPlot(g, show_image = TRUE, image_name = "image") + +# the more specific spatPlot2D with networks shown +spatPlot2D(g, show_image = TRUE, image_name = "image", show_network = TRUE) + +# plotting of some cell metadata (number of different features detected) +spatPlot2D(g, + show_image = TRUE, + image_name = "image", + cell_color = "nr_feats", + color_as_factor = FALSE, + gradient_style = "sequential" +) } \seealso{ \code{\link{spatPlot3D}} From c4790b253bfc80bb65a3bd95d4d42959d19c34ec Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 11:06:25 -0400 Subject: [PATCH 05/23] change: silence loads in examples --- R/aux_visuals.R | 2 +- R/gg_info_layers.R | 2 +- R/plot_dendrogram.R | 4 ++-- R/plot_heatmap.R | 6 +++--- R/plot_violin.R | 2 +- R/vis_spatial.R | 40 ++++++++++++++++++++-------------------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/R/aux_visuals.R b/R/aux_visuals.R index da8bf73..6824742 100644 --- a/R/aux_visuals.R +++ b/R/aux_visuals.R @@ -285,7 +285,7 @@ plotly_network <- function(network, #' #' @returns edges in spatial grid as data.table() #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' #' library(GiottoClass) #' g <- createSpatialGrid(gobject = g, diff --git a/R/gg_info_layers.R b/R/gg_info_layers.R index 9ebe5df..63ae4c7 100644 --- a/R/gg_info_layers.R +++ b/R/gg_info_layers.R @@ -2058,7 +2058,7 @@ plot_point_layer_ggplot_noFILL <- function( #' Numeric. From 0 (transparent) to 1 (fully visible) #' @returns an updated spatial ggplot object #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' #' my_giottoimage <- GiottoClass::createGiottoImage(g, #' mg_object = system.file("image.png", package = "GiottoVisuals"), diff --git a/R/plot_dendrogram.R b/R/plot_dendrogram.R index bccb62a..0fc34bd 100644 --- a/R/plot_dendrogram.R +++ b/R/plot_dendrogram.R @@ -18,7 +18,7 @@ #' @details Expression correlation dendrogram for selected clusters. #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' showClusterDendrogram(g, cluster_column = "leiden_clus") #' #' @export @@ -116,7 +116,7 @@ showClusterDendrogram <- function( #' @inheritDotParams ggdendro::ggdendrogram #' @returns ggdendrogram #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' #' g_expression <- head(GiottoClass::getExpression(g, output = "matrix")) #' g_expression_df <- as.data.frame(as.matrix(g_expression)) diff --git a/R/plot_heatmap.R b/R/plot_heatmap.R index 5463a03..447a24b 100644 --- a/R/plot_heatmap.R +++ b/R/plot_heatmap.R @@ -16,7 +16,7 @@ #' @details Correlation heatmap of selected clusters. #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' showClusterHeatmap(g, cluster_column = "leiden_clus") #' #' @export @@ -147,7 +147,7 @@ showClusterHeatmap <- function( #' \item{2. provide a subset of features to display to feat_label_selection} #' } #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotHeatmap(g, feats = c("Gm19935", "Gna12", "Ccnd2", "Btbd17"), #' cluster_column = "leiden_clus") #' @@ -442,7 +442,7 @@ plotHeatmap <- function( #' instead of feature expression. #' @returns ggplot or data.table #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotMetaDataHeatmap(g, metadata_cols = "leiden_clus", #' selected_feats = c("Gna12", "Ccnd2", "Btbd17", "Gm19935")) #' diff --git a/R/plot_violin.R b/R/plot_violin.R index 64dcec5..0c5a902 100644 --- a/R/plot_violin.R +++ b/R/plot_violin.R @@ -18,7 +18,7 @@ #' @param axis_text_y_size size of y-axis text #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' violinPlot(g, feats = c("Gna12", "Ccnd2", "Btbd17"), #' cluster_column = "leiden_clus") #' diff --git a/R/vis_spatial.R b/R/vis_spatial.R index a38e993..526acf3 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -1370,7 +1370,7 @@ spatDeconvPlot <- function(gobject, #' @returns ggplot #' @family reduced dimension visualizations #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' dimPlot2D(g) #' @export dimPlot2D <- function(gobject, @@ -1634,7 +1634,7 @@ dimPlot2D <- function(gobject, #' @description Visualize cells according to dimension reduction coordinates #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' dimPlot(g) #' @export dimPlot <- function(...) { @@ -1659,7 +1659,7 @@ dimPlot <- function(...) { #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotUMAP_2D(g) #' @export plotUMAP_2D <- function(gobject, @@ -1689,7 +1689,7 @@ plotUMAP_2D <- function(gobject, #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotUMAP(g) #' #' @export @@ -1725,7 +1725,7 @@ plotUMAP <- function(gobject, #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotTSNE_2D(g) #' #' @export @@ -1757,7 +1757,7 @@ plotTSNE_2D <- function(gobject, #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotTSNE(g) #' #' @export @@ -1791,7 +1791,7 @@ plotTSNE <- function(gobject, #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotPCA_2D(g) #' #' @export @@ -1825,7 +1825,7 @@ plotPCA_2D <- function(gobject, #' @family reduced dimension visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' plotPCA(g) #' #' @export @@ -1914,7 +1914,7 @@ plotPCA <- function(gobject, #' @family spatial and dimension reduction visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatDimPlot2D(g) #' #' @export @@ -2196,7 +2196,7 @@ spatDimPlot2D <- function(gobject, #' @param \dots spatDimPlot(...) passes to spatDimPlot2D() #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatDimPlot(g) #' #' @export @@ -2250,7 +2250,7 @@ spatDimPlot <- function(gobject, ...) { #' @family spatial feature expression visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatFeatPlot2D_single(g, feats = c("Gna12", "Ccnd2", "Btbd17")) #' #' @export @@ -2834,7 +2834,7 @@ spatFeatPlot2D_single <- function( #' @family spatial feature expression visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatFeatPlot2D(g, feats = "Gna12") #' #' @export @@ -3083,7 +3083,7 @@ spatFeatPlot2D <- function(gobject, #' @family dimension reduction feature expression visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' dimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) #' #' @export @@ -3530,7 +3530,7 @@ dimFeatPlot2D <- function(gobject, #' @family spatial and dimension reduction feature expression visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatDimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) #' #' @export @@ -3757,7 +3757,7 @@ spatDimFeatPlot2D <- function(gobject, #' @family spatial cell annotation visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatCellPlot2D(g, cell_annotation_values = "leiden_clus") #' #' @export @@ -3951,7 +3951,7 @@ spatCellPlot2D <- function(gobject, #' @param \dots spatCellPlot(...) passes to spatCellPlot2D() #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatCellPlot(g, cell_annotation_values = "leiden_clus") #' #' @export @@ -3979,7 +3979,7 @@ spatCellPlot <- function(...) { #' @family dimension reduction cell annotation visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' dimCellPlot2D( #' g, spat_enr_names = "cluster_metagene", #' cell_annotation_values = as.character(seq(4)) @@ -4156,7 +4156,7 @@ dimCellPlot2D <- function(gobject, #' @param ... dimCellPlot(...) passes to dimCellPlot2D() #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' dimCellPlot(g, cell_annotation_values = "leiden_clus") #' #' @export @@ -4226,7 +4226,7 @@ dimCellPlot <- function(gobject, ...) { #' @family spatial and dimension reduction cell annotation visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatDimCellPlot2D(g, cell_annotation_values = "leiden_clus") #' #' @export @@ -4466,7 +4466,7 @@ spatDimCellPlot2D <- function(gobject, #' @family spatial and dimension reduction cell annotation visualizations #' @returns ggplot #' @examples -#' g <- GiottoData::loadGiottoMini("visium") +#' g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) #' spatDimCellPlot(g, cell_annotation_values = "leiden_clus") #' #' @export From ce6753fd6877e5341db9f4fe366829b7270132a8 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 15:08:23 -0400 Subject: [PATCH 06/23] chore: update examples for 3D --- .github/workflows/dev_check.yml | 1 + R/vis_spatial.R | 11 ++++++++++- R/vis_spatial_in_situ.R | 1 + man/addGiottoImageToSpatPlot.Rd | 2 +- man/create_cluster_dendrogram.Rd | 2 +- man/dimCellPlot.Rd | 4 ++-- man/dimFeatPlot2D.Rd | 2 +- man/dimPlot.Rd | 4 ++-- man/plotHeatmap.Rd | 2 +- man/plotMetaDataHeatmap.Rd | 2 +- man/plotPCA.Rd | 2 +- man/plotPCA_2D.Rd | 2 +- man/plotTSNE.Rd | 2 +- man/plotTSNE_2D.Rd | 2 +- man/plotUMAP.Rd | 2 +- man/plotUMAP_2D.Rd | 2 +- man/plotUMAP_3D.Rd | 2 +- man/plotly_grid.Rd | 2 +- man/showClusterDendrogram.Rd | 2 +- man/showClusterHeatmap.Rd | 2 +- man/spatCellPlot.Rd | 4 ++-- man/spatDimCellPlot.Rd | 2 +- man/spatDimCellPlot2D.Rd | 2 +- man/spatDimFeatPlot2D.Rd | 2 +- man/spatDimPlot.Rd | 4 ++-- man/spatFeatPlot2D.Rd | 2 +- man/spatFeatPlot2D_single.Rd | 2 +- man/spatPlot.Rd | 9 +++++++++ man/violinPlot.Rd | 2 +- 29 files changed, 50 insertions(+), 30 deletions(-) diff --git a/.github/workflows/dev_check.yml b/.github/workflows/dev_check.yml index 62ea727..8e55a35 100644 --- a/.github/workflows/dev_check.yml +++ b/.github/workflows/dev_check.yml @@ -45,6 +45,7 @@ jobs: any::ggalluvial any::ggforce any::ggraph + any::hexbin - name: Set up dependencies (GiottoUtils) run: | diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 526acf3..c2c1a78 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -771,6 +771,15 @@ spatPlot2D <- function( #' color_as_factor = FALSE, #' gradient_style = "sequential" #' ) +#' +#' +#' # load another dataset with 3D data +#' starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) +#' +#' # default is to rescale plot as a 3D cube +#' spatPlot3D(starmap, cell_color = "leiden_clus") +#' # real scaling +#' spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") #' @export #' @seealso \code{\link{spatPlot3D}} spatPlot <- function(...) { @@ -5251,7 +5260,7 @@ dimPlot3D <- function(gobject, #' @returns plotly #' @examples #' g <- GiottoData::loadGiottoMini("starmap") -#' plotUMAP_3D(g) +#' plotUMAP_3D(g, dim_reduction_name = "3D_umap") #' #' @export plotUMAP_3D <- function(gobject, diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 0b910c9..8187a52 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -636,6 +636,7 @@ spatInSituPlotHex <- function( polygon_line_size <- polygon_size } + package_check("hexbin") if (is.null(feats)) { stop("You need to select features (feats) and modify diff --git a/man/addGiottoImageToSpatPlot.Rd b/man/addGiottoImageToSpatPlot.Rd index 3dcaa61..1cbe545 100644 --- a/man/addGiottoImageToSpatPlot.Rd +++ b/man/addGiottoImageToSpatPlot.Rd @@ -30,7 +30,7 @@ an updated spatial ggplot object Add a giotto image to a spatial ggplot object post creation } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) my_giottoimage <- GiottoClass::createGiottoImage(g, mg_object = system.file("image.png", package = "GiottoVisuals"), diff --git a/man/create_cluster_dendrogram.Rd b/man/create_cluster_dendrogram.Rd index a999953..a44539f 100644 --- a/man/create_cluster_dendrogram.Rd +++ b/man/create_cluster_dendrogram.Rd @@ -59,7 +59,7 @@ for the 'col' params then they will be assumed as 1. clus_col, 2. var_col, 3. val_col } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) g_expression <- head(GiottoClass::getExpression(g, output = "matrix")) g_expression_df <- as.data.frame(as.matrix(g_expression)) diff --git a/man/dimCellPlot.Rd b/man/dimCellPlot.Rd index 8eed044..f317fa8 100644 --- a/man/dimCellPlot.Rd +++ b/man/dimCellPlot.Rd @@ -183,13 +183,13 @@ Visualize cells according to dimension reduction coordinates. Description of parameters. For 3D plots see \code{\link{dimPlot3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimCellPlot2D( g, spat_enr_names = "cluster_metagene", cell_annotation_values = as.character(seq(4)) ) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/dimFeatPlot2D.Rd b/man/dimFeatPlot2D.Rd index e3a1753..935e4d0 100644 --- a/man/dimFeatPlot2D.Rd +++ b/man/dimFeatPlot2D.Rd @@ -142,7 +142,7 @@ coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/dimPlot.Rd b/man/dimPlot.Rd index 667e3b1..033cd18 100644 --- a/man/dimPlot.Rd +++ b/man/dimPlot.Rd @@ -234,9 +234,9 @@ plotly (dimplot3D only) Visualize cells according to dimension reduction coordinates } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimPlot(g) } \seealso{ diff --git a/man/plotHeatmap.Rd b/man/plotHeatmap.Rd index d28a6de..5868711 100644 --- a/man/plotHeatmap.Rd +++ b/man/plotHeatmap.Rd @@ -118,7 +118,7 @@ If you want to display many features there are 2 ways to proceed: } } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotHeatmap(g, feats = c("Gm19935", "Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") diff --git a/man/plotMetaDataHeatmap.Rd b/man/plotMetaDataHeatmap.Rd index dd0f72a..d595c67 100644 --- a/man/plotMetaDataHeatmap.Rd +++ b/man/plotMetaDataHeatmap.Rd @@ -123,7 +123,7 @@ is by default on the z-scores. Other options are the original values or z-scores rescaled per feature (-1 to 1). } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotMetaDataHeatmap(g, metadata_cols = "leiden_clus", selected_feats = c("Gna12", "Ccnd2", "Btbd17", "Gm19935")) diff --git a/man/plotPCA.Rd b/man/plotPCA.Rd index 2d2c678..0d54342 100644 --- a/man/plotPCA.Rd +++ b/man/plotPCA.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotPCA(g) } diff --git a/man/plotPCA_2D.Rd b/man/plotPCA_2D.Rd index f0591a9..ef0a6f2 100644 --- a/man/plotPCA_2D.Rd +++ b/man/plotPCA_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotPCA_2D(g) } diff --git a/man/plotTSNE.Rd b/man/plotTSNE.Rd index 3e9afa7..ea5ec02 100644 --- a/man/plotTSNE.Rd +++ b/man/plotTSNE.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotTSNE(g) } diff --git a/man/plotTSNE_2D.Rd b/man/plotTSNE_2D.Rd index 7c1f2bf..58ca03e 100644 --- a/man/plotTSNE_2D.Rd +++ b/man/plotTSNE_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotTSNE_2D(g) } diff --git a/man/plotUMAP.Rd b/man/plotUMAP.Rd index aae42a9..50a4fb8 100644 --- a/man/plotUMAP.Rd +++ b/man/plotUMAP.Rd @@ -85,7 +85,7 @@ ggplot Short wrapper for UMAP visualization } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotUMAP(g) } diff --git a/man/plotUMAP_2D.Rd b/man/plotUMAP_2D.Rd index 6674726..e1150c3 100644 --- a/man/plotUMAP_2D.Rd +++ b/man/plotUMAP_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotUMAP_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotUMAP_2D(g) } \seealso{ diff --git a/man/plotUMAP_3D.Rd b/man/plotUMAP_3D.Rd index a10e961..9d93fca 100644 --- a/man/plotUMAP_3D.Rd +++ b/man/plotUMAP_3D.Rd @@ -68,7 +68,7 @@ Description of parameters. } \examples{ g <- GiottoData::loadGiottoMini("starmap") -plotUMAP_3D(g) +plotUMAP_3D(g, dim_reduction_name = "3D_umap") } \seealso{ diff --git a/man/plotly_grid.Rd b/man/plotly_grid.Rd index 6107166..1bf6328 100644 --- a/man/plotly_grid.Rd +++ b/man/plotly_grid.Rd @@ -30,7 +30,7 @@ edges in spatial grid as data.table() provide grid segment to draw in plot_ly() } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) library(GiottoClass) g <- createSpatialGrid(gobject = g, diff --git a/man/showClusterDendrogram.Rd b/man/showClusterDendrogram.Rd index 6801566..91cedfd 100644 --- a/man/showClusterDendrogram.Rd +++ b/man/showClusterDendrogram.Rd @@ -83,7 +83,7 @@ Creates dendrogram for selected clusters. Expression correlation dendrogram for selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) showClusterDendrogram(g, cluster_column = "leiden_clus") } diff --git a/man/showClusterHeatmap.Rd b/man/showClusterHeatmap.Rd index 3c0e494..3c56b42 100644 --- a/man/showClusterHeatmap.Rd +++ b/man/showClusterHeatmap.Rd @@ -152,7 +152,7 @@ Creates heatmap based on identified clusters Correlation heatmap of selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) showClusterHeatmap(g, cluster_column = "leiden_clus") } diff --git a/man/spatCellPlot.Rd b/man/spatCellPlot.Rd index 45bd5c4..1808ef3 100644 --- a/man/spatCellPlot.Rd +++ b/man/spatCellPlot.Rd @@ -212,10 +212,10 @@ Visualize cells according to spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatCellPlot2D(g, cell_annotation_values = "leiden_clus") -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot.Rd b/man/spatDimCellPlot.Rd index ca09818..ac56647 100644 --- a/man/spatDimCellPlot.Rd +++ b/man/spatDimCellPlot.Rd @@ -116,7 +116,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot2D.Rd b/man/spatDimCellPlot2D.Rd index e9ffe69..4ed5957 100644 --- a/man/spatDimCellPlot2D.Rd +++ b/man/spatDimCellPlot2D.Rd @@ -276,7 +276,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimCellPlot2D(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimFeatPlot2D.Rd b/man/spatDimFeatPlot2D.Rd index 07e3510..a4f4288 100644 --- a/man/spatDimFeatPlot2D.Rd +++ b/man/spatDimFeatPlot2D.Rd @@ -214,7 +214,7 @@ coordinates in ggplot mode Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatDimPlot.Rd b/man/spatDimPlot.Rd index 1ad271b..5079ceb 100644 --- a/man/spatDimPlot.Rd +++ b/man/spatDimPlot.Rd @@ -280,10 +280,10 @@ coordinates 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimPlot(g) } diff --git a/man/spatFeatPlot2D.Rd b/man/spatFeatPlot2D.Rd index 7676ef3..44f132a 100644 --- a/man/spatFeatPlot2D.Rd +++ b/man/spatFeatPlot2D.Rd @@ -180,7 +180,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatFeatPlot2D(g, feats = "Gna12") } diff --git a/man/spatFeatPlot2D_single.Rd b/man/spatFeatPlot2D_single.Rd index 5534e8a..328c1c5 100644 --- a/man/spatFeatPlot2D_single.Rd +++ b/man/spatFeatPlot2D_single.Rd @@ -177,7 +177,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatFeatPlot2D_single(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index fc8b451..f453ba0 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -306,6 +306,15 @@ spatPlot2D(g, color_as_factor = FALSE, gradient_style = "sequential" ) + + +# load another dataset with 3D data +starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) + +# default is to rescale plot as a 3D cube +spatPlot3D(starmap, cell_color = "leiden_clus") +# real scaling +spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") } \seealso{ \code{\link{spatPlot3D}} diff --git a/man/violinPlot.Rd b/man/violinPlot.Rd index 7d0abb6..292d1fd 100644 --- a/man/violinPlot.Rd +++ b/man/violinPlot.Rd @@ -74,7 +74,7 @@ ggplot Creates violinplot for selected clusters } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) violinPlot(g, feats = c("Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") From 961dc22b0e7eb149974c06d2d2282c34ed6d3439 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 15:09:53 -0400 Subject: [PATCH 07/23] Revert "Merge branch 'dev' into dev2" This reverts commit 210ddae99187136e31cf724aa96a5c0b131c21aa, reversing changes made to 118547117584bfe25d1d7427fa0253ce50bedfb4. --- .github/workflows/dev_check.yml | 1 - R/vis_spatial.R | 11 +---------- R/vis_spatial_in_situ.R | 1 - man/addGiottoImageToSpatPlot.Rd | 2 +- man/create_cluster_dendrogram.Rd | 2 +- man/dimCellPlot.Rd | 4 ++-- man/dimFeatPlot2D.Rd | 2 +- man/dimPlot.Rd | 4 ++-- man/plotHeatmap.Rd | 2 +- man/plotMetaDataHeatmap.Rd | 2 +- man/plotPCA.Rd | 2 +- man/plotPCA_2D.Rd | 2 +- man/plotTSNE.Rd | 2 +- man/plotTSNE_2D.Rd | 2 +- man/plotUMAP.Rd | 2 +- man/plotUMAP_2D.Rd | 2 +- man/plotUMAP_3D.Rd | 2 +- man/plotly_grid.Rd | 2 +- man/showClusterDendrogram.Rd | 2 +- man/showClusterHeatmap.Rd | 2 +- man/spatCellPlot.Rd | 4 ++-- man/spatDimCellPlot.Rd | 2 +- man/spatDimCellPlot2D.Rd | 2 +- man/spatDimFeatPlot2D.Rd | 2 +- man/spatDimPlot.Rd | 4 ++-- man/spatFeatPlot2D.Rd | 2 +- man/spatFeatPlot2D_single.Rd | 2 +- man/spatPlot.Rd | 9 --------- man/violinPlot.Rd | 2 +- 29 files changed, 30 insertions(+), 50 deletions(-) diff --git a/.github/workflows/dev_check.yml b/.github/workflows/dev_check.yml index 6fa6420..7d28c0c 100644 --- a/.github/workflows/dev_check.yml +++ b/.github/workflows/dev_check.yml @@ -45,7 +45,6 @@ jobs: any::ggalluvial any::ggforce any::ggraph - any::hexbin - name: Set up dependencies (GiottoUtils) run: | diff --git a/R/vis_spatial.R b/R/vis_spatial.R index c2c1a78..526acf3 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -771,15 +771,6 @@ spatPlot2D <- function( #' color_as_factor = FALSE, #' gradient_style = "sequential" #' ) -#' -#' -#' # load another dataset with 3D data -#' starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) -#' -#' # default is to rescale plot as a 3D cube -#' spatPlot3D(starmap, cell_color = "leiden_clus") -#' # real scaling -#' spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") #' @export #' @seealso \code{\link{spatPlot3D}} spatPlot <- function(...) { @@ -5260,7 +5251,7 @@ dimPlot3D <- function(gobject, #' @returns plotly #' @examples #' g <- GiottoData::loadGiottoMini("starmap") -#' plotUMAP_3D(g, dim_reduction_name = "3D_umap") +#' plotUMAP_3D(g) #' #' @export plotUMAP_3D <- function(gobject, diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 8187a52..0b910c9 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -636,7 +636,6 @@ spatInSituPlotHex <- function( polygon_line_size <- polygon_size } - package_check("hexbin") if (is.null(feats)) { stop("You need to select features (feats) and modify diff --git a/man/addGiottoImageToSpatPlot.Rd b/man/addGiottoImageToSpatPlot.Rd index 1cbe545..3dcaa61 100644 --- a/man/addGiottoImageToSpatPlot.Rd +++ b/man/addGiottoImageToSpatPlot.Rd @@ -30,7 +30,7 @@ an updated spatial ggplot object Add a giotto image to a spatial ggplot object post creation } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") my_giottoimage <- GiottoClass::createGiottoImage(g, mg_object = system.file("image.png", package = "GiottoVisuals"), diff --git a/man/create_cluster_dendrogram.Rd b/man/create_cluster_dendrogram.Rd index a44539f..a999953 100644 --- a/man/create_cluster_dendrogram.Rd +++ b/man/create_cluster_dendrogram.Rd @@ -59,7 +59,7 @@ for the 'col' params then they will be assumed as 1. clus_col, 2. var_col, 3. val_col } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") g_expression <- head(GiottoClass::getExpression(g, output = "matrix")) g_expression_df <- as.data.frame(as.matrix(g_expression)) diff --git a/man/dimCellPlot.Rd b/man/dimCellPlot.Rd index f317fa8..8eed044 100644 --- a/man/dimCellPlot.Rd +++ b/man/dimCellPlot.Rd @@ -183,13 +183,13 @@ Visualize cells according to dimension reduction coordinates. Description of parameters. For 3D plots see \code{\link{dimPlot3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") dimCellPlot2D( g, spat_enr_names = "cluster_metagene", cell_annotation_values = as.character(seq(4)) ) -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") dimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/dimFeatPlot2D.Rd b/man/dimFeatPlot2D.Rd index 935e4d0..e3a1753 100644 --- a/man/dimFeatPlot2D.Rd +++ b/man/dimFeatPlot2D.Rd @@ -142,7 +142,7 @@ coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") dimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/dimPlot.Rd b/man/dimPlot.Rd index 033cd18..667e3b1 100644 --- a/man/dimPlot.Rd +++ b/man/dimPlot.Rd @@ -234,9 +234,9 @@ plotly (dimplot3D only) Visualize cells according to dimension reduction coordinates } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") dimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") dimPlot(g) } \seealso{ diff --git a/man/plotHeatmap.Rd b/man/plotHeatmap.Rd index 5868711..d28a6de 100644 --- a/man/plotHeatmap.Rd +++ b/man/plotHeatmap.Rd @@ -118,7 +118,7 @@ If you want to display many features there are 2 ways to proceed: } } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotHeatmap(g, feats = c("Gm19935", "Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") diff --git a/man/plotMetaDataHeatmap.Rd b/man/plotMetaDataHeatmap.Rd index d595c67..dd0f72a 100644 --- a/man/plotMetaDataHeatmap.Rd +++ b/man/plotMetaDataHeatmap.Rd @@ -123,7 +123,7 @@ is by default on the z-scores. Other options are the original values or z-scores rescaled per feature (-1 to 1). } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotMetaDataHeatmap(g, metadata_cols = "leiden_clus", selected_feats = c("Gna12", "Ccnd2", "Btbd17", "Gm19935")) diff --git a/man/plotPCA.Rd b/man/plotPCA.Rd index 0d54342..2d2c678 100644 --- a/man/plotPCA.Rd +++ b/man/plotPCA.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotPCA(g) } diff --git a/man/plotPCA_2D.Rd b/man/plotPCA_2D.Rd index ef0a6f2..f0591a9 100644 --- a/man/plotPCA_2D.Rd +++ b/man/plotPCA_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotPCA_2D(g) } diff --git a/man/plotTSNE.Rd b/man/plotTSNE.Rd index ea5ec02..3e9afa7 100644 --- a/man/plotTSNE.Rd +++ b/man/plotTSNE.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotTSNE(g) } diff --git a/man/plotTSNE_2D.Rd b/man/plotTSNE_2D.Rd index 58ca03e..7c1f2bf 100644 --- a/man/plotTSNE_2D.Rd +++ b/man/plotTSNE_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotTSNE_2D(g) } diff --git a/man/plotUMAP.Rd b/man/plotUMAP.Rd index 50a4fb8..aae42a9 100644 --- a/man/plotUMAP.Rd +++ b/man/plotUMAP.Rd @@ -85,7 +85,7 @@ ggplot Short wrapper for UMAP visualization } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotUMAP(g) } diff --git a/man/plotUMAP_2D.Rd b/man/plotUMAP_2D.Rd index e1150c3..6674726 100644 --- a/man/plotUMAP_2D.Rd +++ b/man/plotUMAP_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotUMAP_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") plotUMAP_2D(g) } \seealso{ diff --git a/man/plotUMAP_3D.Rd b/man/plotUMAP_3D.Rd index 9d93fca..a10e961 100644 --- a/man/plotUMAP_3D.Rd +++ b/man/plotUMAP_3D.Rd @@ -68,7 +68,7 @@ Description of parameters. } \examples{ g <- GiottoData::loadGiottoMini("starmap") -plotUMAP_3D(g, dim_reduction_name = "3D_umap") +plotUMAP_3D(g) } \seealso{ diff --git a/man/plotly_grid.Rd b/man/plotly_grid.Rd index 1bf6328..6107166 100644 --- a/man/plotly_grid.Rd +++ b/man/plotly_grid.Rd @@ -30,7 +30,7 @@ edges in spatial grid as data.table() provide grid segment to draw in plot_ly() } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") library(GiottoClass) g <- createSpatialGrid(gobject = g, diff --git a/man/showClusterDendrogram.Rd b/man/showClusterDendrogram.Rd index 91cedfd..6801566 100644 --- a/man/showClusterDendrogram.Rd +++ b/man/showClusterDendrogram.Rd @@ -83,7 +83,7 @@ Creates dendrogram for selected clusters. Expression correlation dendrogram for selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") showClusterDendrogram(g, cluster_column = "leiden_clus") } diff --git a/man/showClusterHeatmap.Rd b/man/showClusterHeatmap.Rd index 3c56b42..3c0e494 100644 --- a/man/showClusterHeatmap.Rd +++ b/man/showClusterHeatmap.Rd @@ -152,7 +152,7 @@ Creates heatmap based on identified clusters Correlation heatmap of selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") showClusterHeatmap(g, cluster_column = "leiden_clus") } diff --git a/man/spatCellPlot.Rd b/man/spatCellPlot.Rd index 1808ef3..45bd5c4 100644 --- a/man/spatCellPlot.Rd +++ b/man/spatCellPlot.Rd @@ -212,10 +212,10 @@ Visualize cells according to spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatCellPlot2D(g, cell_annotation_values = "leiden_clus") -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot.Rd b/man/spatDimCellPlot.Rd index ac56647..ca09818 100644 --- a/man/spatDimCellPlot.Rd +++ b/man/spatDimCellPlot.Rd @@ -116,7 +116,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatDimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot2D.Rd b/man/spatDimCellPlot2D.Rd index 4ed5957..e9ffe69 100644 --- a/man/spatDimCellPlot2D.Rd +++ b/man/spatDimCellPlot2D.Rd @@ -276,7 +276,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatDimCellPlot2D(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimFeatPlot2D.Rd b/man/spatDimFeatPlot2D.Rd index a4f4288..07e3510 100644 --- a/man/spatDimFeatPlot2D.Rd +++ b/man/spatDimFeatPlot2D.Rd @@ -214,7 +214,7 @@ coordinates in ggplot mode Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatDimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatDimPlot.Rd b/man/spatDimPlot.Rd index 5079ceb..1ad271b 100644 --- a/man/spatDimPlot.Rd +++ b/man/spatDimPlot.Rd @@ -280,10 +280,10 @@ coordinates 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatDimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatDimPlot(g) } diff --git a/man/spatFeatPlot2D.Rd b/man/spatFeatPlot2D.Rd index 44f132a..7676ef3 100644 --- a/man/spatFeatPlot2D.Rd +++ b/man/spatFeatPlot2D.Rd @@ -180,7 +180,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatFeatPlot2D(g, feats = "Gna12") } diff --git a/man/spatFeatPlot2D_single.Rd b/man/spatFeatPlot2D_single.Rd index 328c1c5..5534e8a 100644 --- a/man/spatFeatPlot2D_single.Rd +++ b/man/spatFeatPlot2D_single.Rd @@ -177,7 +177,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") spatFeatPlot2D_single(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index f453ba0..fc8b451 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -306,15 +306,6 @@ spatPlot2D(g, color_as_factor = FALSE, gradient_style = "sequential" ) - - -# load another dataset with 3D data -starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) - -# default is to rescale plot as a 3D cube -spatPlot3D(starmap, cell_color = "leiden_clus") -# real scaling -spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") } \seealso{ \code{\link{spatPlot3D}} diff --git a/man/violinPlot.Rd b/man/violinPlot.Rd index 292d1fd..7d0abb6 100644 --- a/man/violinPlot.Rd +++ b/man/violinPlot.Rd @@ -74,7 +74,7 @@ ggplot Creates violinplot for selected clusters } \examples{ -g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) +g <- GiottoData::loadGiottoMini("visium") violinPlot(g, feats = c("Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") From 13e9fcb83050e1db8e374e9d50a48c591ea8bbe7 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 15:11:12 -0400 Subject: [PATCH 08/23] Reapply "Merge branch 'dev' into dev2" This reverts commit 961dc22b0e7eb149974c06d2d2282c34ed6d3439. --- .github/workflows/dev_check.yml | 1 + R/vis_spatial.R | 11 ++++++++++- R/vis_spatial_in_situ.R | 1 + man/addGiottoImageToSpatPlot.Rd | 2 +- man/create_cluster_dendrogram.Rd | 2 +- man/dimCellPlot.Rd | 4 ++-- man/dimFeatPlot2D.Rd | 2 +- man/dimPlot.Rd | 4 ++-- man/plotHeatmap.Rd | 2 +- man/plotMetaDataHeatmap.Rd | 2 +- man/plotPCA.Rd | 2 +- man/plotPCA_2D.Rd | 2 +- man/plotTSNE.Rd | 2 +- man/plotTSNE_2D.Rd | 2 +- man/plotUMAP.Rd | 2 +- man/plotUMAP_2D.Rd | 2 +- man/plotUMAP_3D.Rd | 2 +- man/plotly_grid.Rd | 2 +- man/showClusterDendrogram.Rd | 2 +- man/showClusterHeatmap.Rd | 2 +- man/spatCellPlot.Rd | 4 ++-- man/spatDimCellPlot.Rd | 2 +- man/spatDimCellPlot2D.Rd | 2 +- man/spatDimFeatPlot2D.Rd | 2 +- man/spatDimPlot.Rd | 4 ++-- man/spatFeatPlot2D.Rd | 2 +- man/spatFeatPlot2D_single.Rd | 2 +- man/spatPlot.Rd | 9 +++++++++ man/violinPlot.Rd | 2 +- 29 files changed, 50 insertions(+), 30 deletions(-) diff --git a/.github/workflows/dev_check.yml b/.github/workflows/dev_check.yml index 7d28c0c..6fa6420 100644 --- a/.github/workflows/dev_check.yml +++ b/.github/workflows/dev_check.yml @@ -45,6 +45,7 @@ jobs: any::ggalluvial any::ggforce any::ggraph + any::hexbin - name: Set up dependencies (GiottoUtils) run: | diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 526acf3..c2c1a78 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -771,6 +771,15 @@ spatPlot2D <- function( #' color_as_factor = FALSE, #' gradient_style = "sequential" #' ) +#' +#' +#' # load another dataset with 3D data +#' starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) +#' +#' # default is to rescale plot as a 3D cube +#' spatPlot3D(starmap, cell_color = "leiden_clus") +#' # real scaling +#' spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") #' @export #' @seealso \code{\link{spatPlot3D}} spatPlot <- function(...) { @@ -5251,7 +5260,7 @@ dimPlot3D <- function(gobject, #' @returns plotly #' @examples #' g <- GiottoData::loadGiottoMini("starmap") -#' plotUMAP_3D(g) +#' plotUMAP_3D(g, dim_reduction_name = "3D_umap") #' #' @export plotUMAP_3D <- function(gobject, diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 0b910c9..8187a52 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -636,6 +636,7 @@ spatInSituPlotHex <- function( polygon_line_size <- polygon_size } + package_check("hexbin") if (is.null(feats)) { stop("You need to select features (feats) and modify diff --git a/man/addGiottoImageToSpatPlot.Rd b/man/addGiottoImageToSpatPlot.Rd index 3dcaa61..1cbe545 100644 --- a/man/addGiottoImageToSpatPlot.Rd +++ b/man/addGiottoImageToSpatPlot.Rd @@ -30,7 +30,7 @@ an updated spatial ggplot object Add a giotto image to a spatial ggplot object post creation } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) my_giottoimage <- GiottoClass::createGiottoImage(g, mg_object = system.file("image.png", package = "GiottoVisuals"), diff --git a/man/create_cluster_dendrogram.Rd b/man/create_cluster_dendrogram.Rd index a999953..a44539f 100644 --- a/man/create_cluster_dendrogram.Rd +++ b/man/create_cluster_dendrogram.Rd @@ -59,7 +59,7 @@ for the 'col' params then they will be assumed as 1. clus_col, 2. var_col, 3. val_col } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) g_expression <- head(GiottoClass::getExpression(g, output = "matrix")) g_expression_df <- as.data.frame(as.matrix(g_expression)) diff --git a/man/dimCellPlot.Rd b/man/dimCellPlot.Rd index 8eed044..f317fa8 100644 --- a/man/dimCellPlot.Rd +++ b/man/dimCellPlot.Rd @@ -183,13 +183,13 @@ Visualize cells according to dimension reduction coordinates. Description of parameters. For 3D plots see \code{\link{dimPlot3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimCellPlot2D( g, spat_enr_names = "cluster_metagene", cell_annotation_values = as.character(seq(4)) ) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/dimFeatPlot2D.Rd b/man/dimFeatPlot2D.Rd index e3a1753..935e4d0 100644 --- a/man/dimFeatPlot2D.Rd +++ b/man/dimFeatPlot2D.Rd @@ -142,7 +142,7 @@ coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/dimPlot.Rd b/man/dimPlot.Rd index 667e3b1..033cd18 100644 --- a/man/dimPlot.Rd +++ b/man/dimPlot.Rd @@ -234,9 +234,9 @@ plotly (dimplot3D only) Visualize cells according to dimension reduction coordinates } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) dimPlot(g) } \seealso{ diff --git a/man/plotHeatmap.Rd b/man/plotHeatmap.Rd index d28a6de..5868711 100644 --- a/man/plotHeatmap.Rd +++ b/man/plotHeatmap.Rd @@ -118,7 +118,7 @@ If you want to display many features there are 2 ways to proceed: } } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotHeatmap(g, feats = c("Gm19935", "Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") diff --git a/man/plotMetaDataHeatmap.Rd b/man/plotMetaDataHeatmap.Rd index dd0f72a..d595c67 100644 --- a/man/plotMetaDataHeatmap.Rd +++ b/man/plotMetaDataHeatmap.Rd @@ -123,7 +123,7 @@ is by default on the z-scores. Other options are the original values or z-scores rescaled per feature (-1 to 1). } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotMetaDataHeatmap(g, metadata_cols = "leiden_clus", selected_feats = c("Gna12", "Ccnd2", "Btbd17", "Gm19935")) diff --git a/man/plotPCA.Rd b/man/plotPCA.Rd index 2d2c678..0d54342 100644 --- a/man/plotPCA.Rd +++ b/man/plotPCA.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotPCA(g) } diff --git a/man/plotPCA_2D.Rd b/man/plotPCA_2D.Rd index f0591a9..ef0a6f2 100644 --- a/man/plotPCA_2D.Rd +++ b/man/plotPCA_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotPCA_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotPCA_2D(g) } diff --git a/man/plotTSNE.Rd b/man/plotTSNE.Rd index 3e9afa7..ea5ec02 100644 --- a/man/plotTSNE.Rd +++ b/man/plotTSNE.Rd @@ -89,7 +89,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotTSNE(g) } diff --git a/man/plotTSNE_2D.Rd b/man/plotTSNE_2D.Rd index 7c1f2bf..58ca03e 100644 --- a/man/plotTSNE_2D.Rd +++ b/man/plotTSNE_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotTSNE_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotTSNE_2D(g) } diff --git a/man/plotUMAP.Rd b/man/plotUMAP.Rd index aae42a9..50a4fb8 100644 --- a/man/plotUMAP.Rd +++ b/man/plotUMAP.Rd @@ -85,7 +85,7 @@ ggplot Short wrapper for UMAP visualization } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotUMAP(g) } diff --git a/man/plotUMAP_2D.Rd b/man/plotUMAP_2D.Rd index 6674726..e1150c3 100644 --- a/man/plotUMAP_2D.Rd +++ b/man/plotUMAP_2D.Rd @@ -94,7 +94,7 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotUMAP_3D}} } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) plotUMAP_2D(g) } \seealso{ diff --git a/man/plotUMAP_3D.Rd b/man/plotUMAP_3D.Rd index a10e961..9d93fca 100644 --- a/man/plotUMAP_3D.Rd +++ b/man/plotUMAP_3D.Rd @@ -68,7 +68,7 @@ Description of parameters. } \examples{ g <- GiottoData::loadGiottoMini("starmap") -plotUMAP_3D(g) +plotUMAP_3D(g, dim_reduction_name = "3D_umap") } \seealso{ diff --git a/man/plotly_grid.Rd b/man/plotly_grid.Rd index 6107166..1bf6328 100644 --- a/man/plotly_grid.Rd +++ b/man/plotly_grid.Rd @@ -30,7 +30,7 @@ edges in spatial grid as data.table() provide grid segment to draw in plot_ly() } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) library(GiottoClass) g <- createSpatialGrid(gobject = g, diff --git a/man/showClusterDendrogram.Rd b/man/showClusterDendrogram.Rd index 6801566..91cedfd 100644 --- a/man/showClusterDendrogram.Rd +++ b/man/showClusterDendrogram.Rd @@ -83,7 +83,7 @@ Creates dendrogram for selected clusters. Expression correlation dendrogram for selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) showClusterDendrogram(g, cluster_column = "leiden_clus") } diff --git a/man/showClusterHeatmap.Rd b/man/showClusterHeatmap.Rd index 3c0e494..3c56b42 100644 --- a/man/showClusterHeatmap.Rd +++ b/man/showClusterHeatmap.Rd @@ -152,7 +152,7 @@ Creates heatmap based on identified clusters Correlation heatmap of selected clusters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) showClusterHeatmap(g, cluster_column = "leiden_clus") } diff --git a/man/spatCellPlot.Rd b/man/spatCellPlot.Rd index 45bd5c4..1808ef3 100644 --- a/man/spatCellPlot.Rd +++ b/man/spatCellPlot.Rd @@ -212,10 +212,10 @@ Visualize cells according to spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatCellPlot2D(g, cell_annotation_values = "leiden_clus") -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot.Rd b/man/spatDimCellPlot.Rd index ca09818..ac56647 100644 --- a/man/spatDimCellPlot.Rd +++ b/man/spatDimCellPlot.Rd @@ -116,7 +116,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimCellPlot(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimCellPlot2D.Rd b/man/spatDimCellPlot2D.Rd index e9ffe69..4ed5957 100644 --- a/man/spatDimCellPlot2D.Rd +++ b/man/spatDimCellPlot2D.Rd @@ -276,7 +276,7 @@ AND dimension reduction coordinates in 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimCellPlot2D(g, cell_annotation_values = "leiden_clus") } diff --git a/man/spatDimFeatPlot2D.Rd b/man/spatDimFeatPlot2D.Rd index 07e3510..a4f4288 100644 --- a/man/spatDimFeatPlot2D.Rd +++ b/man/spatDimFeatPlot2D.Rd @@ -214,7 +214,7 @@ coordinates in ggplot mode Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimFeatPlot2D(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatDimPlot.Rd b/man/spatDimPlot.Rd index 1ad271b..5079ceb 100644 --- a/man/spatDimPlot.Rd +++ b/man/spatDimPlot.Rd @@ -280,10 +280,10 @@ coordinates 2D Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimPlot2D(g) -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatDimPlot(g) } diff --git a/man/spatFeatPlot2D.Rd b/man/spatFeatPlot2D.Rd index 7676ef3..44f132a 100644 --- a/man/spatFeatPlot2D.Rd +++ b/man/spatFeatPlot2D.Rd @@ -180,7 +180,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatFeatPlot2D(g, feats = "Gna12") } diff --git a/man/spatFeatPlot2D_single.Rd b/man/spatFeatPlot2D_single.Rd index 5534e8a..328c1c5 100644 --- a/man/spatFeatPlot2D_single.Rd +++ b/man/spatFeatPlot2D_single.Rd @@ -177,7 +177,7 @@ spatial coordinates Description of parameters. } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) spatFeatPlot2D_single(g, feats = c("Gna12", "Ccnd2", "Btbd17")) } diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index fc8b451..f453ba0 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -306,6 +306,15 @@ spatPlot2D(g, color_as_factor = FALSE, gradient_style = "sequential" ) + + +# load another dataset with 3D data +starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) + +# default is to rescale plot as a 3D cube +spatPlot3D(starmap, cell_color = "leiden_clus") +# real scaling +spatPlot3D(g, cell_color = "leiden_clus", axis_scale = "real") } \seealso{ \code{\link{spatPlot3D}} diff --git a/man/violinPlot.Rd b/man/violinPlot.Rd index 7d0abb6..292d1fd 100644 --- a/man/violinPlot.Rd +++ b/man/violinPlot.Rd @@ -74,7 +74,7 @@ ggplot Creates violinplot for selected clusters } \examples{ -g <- GiottoData::loadGiottoMini("visium") +g <- GiottoData::loadGiottoMini("visium", verbose = FALSE) violinPlot(g, feats = c("Gna12", "Ccnd2", "Btbd17"), cluster_column = "leiden_clus") From aa1efd3d43e16ec7a813b1a26f9ca7f30ee128cc Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Tue, 28 May 2024 15:41:41 -0400 Subject: [PATCH 09/23] fix: typo --- R/vis_spatial.R | 2 +- man/spatPlot.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/vis_spatial.R b/R/vis_spatial.R index c2c1a78..38fe2f8 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -774,7 +774,7 @@ spatPlot2D <- function( #' #' #' # load another dataset with 3D data -#' starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) +#' starmap <- GiottoData::loadGiottoMini("starmap", verbose = FALSE) #' #' # default is to rescale plot as a 3D cube #' spatPlot3D(starmap, cell_color = "leiden_clus") diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index f453ba0..a165bc2 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -309,7 +309,7 @@ spatPlot2D(g, # load another dataset with 3D data -starmap <- GiottoData::loadGiottoData("starmap", verbose = FALSE) +starmap <- GiottoData::loadGiottoMini("starmap", verbose = FALSE) # default is to rescale plot as a 3D cube spatPlot3D(starmap, cell_color = "leiden_clus") From d3baa51f2902e813eac72c0b12cdfa397de04578 Mon Sep 17 00:00:00 2001 From: Ruben Dries Date: Tue, 4 Jun 2024 15:18:20 -0400 Subject: [PATCH 10/23] add xlim and ylim to spatInSituPlotPoints --- R/vis_spatial_in_situ.R | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/R/vis_spatial_in_situ.R b/R/vis_spatial_in_situ.R index 36f3987..94573fe 100644 --- a/R/vis_spatial_in_situ.R +++ b/R/vis_spatial_in_situ.R @@ -24,6 +24,8 @@ #' @param feat_type feature types of the feats #' @param sdimx spatial dimension x #' @param sdimy spatial dimension y +#' @param xlim limits of x-scale (min/max vector) +#' @param ylim limits of y-scale (min/max vector) #' @param point_size size of the points #' @param stroke stroke to apply to feature points #' @param expand_counts expand feature coordinate counts (see details) @@ -69,6 +71,8 @@ spatInSituPlotPoints <- function(gobject, feat_shape_code = NULL, sdimx = 'x', sdimy = 'y', + xlim = NULL, + ylim = NULL, point_size = 1.5, stroke = 0.5, expand_counts = FALSE, @@ -342,11 +346,20 @@ spatInSituPlotPoints <- function(gobject, panel.background = element_rect(fill = background_color)) - + # subset data based on x and y limits + if(!is.null(xlim)) { + plot <- plot + ggplot2::xlim(xlim) + } + if(!is.null(ylim)) { + plot <- plot + ggplot2::ylim(ylim) + } + + # fix coordinates if(!is.null(coord_fix_ratio)) { plot = plot + ggplot2::coord_fixed(ratio = coord_fix_ratio) } + return(plot_output_handler( gobject = gobject, plot_object = plot, From d07d176178de0d1dc536a92021745437da375d9f Mon Sep 17 00:00:00 2001 From: josschavezf Date: Tue, 11 Jun 2024 14:37:37 -0400 Subject: [PATCH 11/23] fix example in dimFeatPlot3D --- R/vis_spatial.R | 85 ++++++++++++++++++++++---------------------- man/dimFeatPlot3D.Rd | 2 +- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 38fe2f8..4df1d1a 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -7514,40 +7514,41 @@ spatGenePlot3D <- function(...) { #' @returns plotly #' @examples #' g <- GiottoData::loadGiottoMini("starmap") -#' dimFeatPlot3D(g, genes = "Slc17a7") -#' +#' +#' dimFeatPlot3D(g, genes = "Slc17a7", dim_reduction_name = "3D_umap") #' @export -dimFeatPlot3D <- function(gobject, - feat_type = NULL, - spat_unit = NULL, - expression_values = c("normalized", "scaled", "custom"), - genes = NULL, - dim_reduction_to_use = "umap", - dim_reduction_name = "umap", - dim1_to_use = 1, - dim2_to_use = 2, - dim3_to_use = 3, - show_NN_network = FALSE, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - network_color = "lightgray", - cluster_column = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = TRUE, - other_cell_color = "lightgrey", - other_point_size = 1, - edge_alpha = NULL, - point_size = 2, - genes_high_color = NULL, - genes_mid_color = "white", - genes_low_color = "blue", - show_legend = TRUE, - show_plot = NULL, - return_plot = NULL, - save_plot = NULL, - save_param = list(), - default_save_name = "dimFeatPlot3D") { +dimFeatPlot3D <- function( + gobject, + feat_type = NULL, + spat_unit = NULL, + expression_values = c("normalized", "scaled", "custom"), + genes = NULL, + dim_reduction_to_use = "umap", + dim_reduction_name = "umap", + dim1_to_use = 1, + dim2_to_use = 2, + dim3_to_use = 3, + show_NN_network = FALSE, + nn_network_to_use = "sNN", + network_name = "sNN.pca", + network_color = "lightgray", + cluster_column = NULL, + select_cell_groups = NULL, + select_cells = NULL, + show_other_cells = TRUE, + other_cell_color = "lightgrey", + other_point_size = 1, + edge_alpha = NULL, + point_size = 2, + genes_high_color = NULL, + genes_mid_color = "white", + genes_low_color = "blue", + show_legend = TRUE, + show_plot = NULL, + return_plot = NULL, + save_plot = NULL, + save_param = list(), + default_save_name = "dimFeatPlot3D") { # Set feat_type and spat_unit spat_unit <- set_default_spat_unit( gobject = gobject, @@ -7562,7 +7563,7 @@ dimFeatPlot3D <- function(gobject, ## select genes ## selected_genes <- genes values <- match.arg(expression_values, c("normalized", "scaled", "custom")) - expr_values <- get_expression_values( + expr_values <- getExpression( gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, @@ -7597,11 +7598,11 @@ dimFeatPlot3D <- function(gobject, ## dimension reduction ## - dim_dfr <- get_dimReduction(gobject, - reduction = "cells", - reduction_method = dim_reduction_to_use, - name = dim_reduction_name, - output = "data.table" + dim_dfr <- getDimReduction(gobject, + reduction = "cells", + reduction_method = dim_reduction_to_use, + name = dim_reduction_name, + output = "data.table" ) dim_dfr <- dim_dfr[, c(dim1_to_use, dim2_to_use, dim3_to_use)] dim_names <- colnames(dim_dfr) @@ -7620,12 +7621,12 @@ dimFeatPlot3D <- function(gobject, # create input for network if (show_NN_network == TRUE) { # nn_network - selected_nn_network <- get_NearestNetwork( + selected_nn_network <- getNearestNetwork( gobject = gobject, feat_type = feat_type, spat_unit = spat_unit, - nn_network_to_use = nn_network_to_use, - network_name = network_name, + nn_type = nn_network_to_use, + name = network_name, output = "igraph" ) network_DT <- data.table::as.data.table(igraph::as_data_frame( diff --git a/man/dimFeatPlot3D.Rd b/man/dimFeatPlot3D.Rd index 5e7fc73..e55ee71 100644 --- a/man/dimFeatPlot3D.Rd +++ b/man/dimFeatPlot3D.Rd @@ -126,7 +126,7 @@ Description of parameters. }} \examples{ g <- GiottoData::loadGiottoMini("starmap") -dimFeatPlot3D(g, genes = "Slc17a7") +dimFeatPlot3D(g, genes = "Slc17a7", dim_reduction_name = "3D_umap") } \concept{dimension reduction gene expression visualizations} From f30a4455e6d8014c1f06cd2cbd89ae294fb02a1d Mon Sep 17 00:00:00 2001 From: josschavezf Date: Tue, 11 Jun 2024 14:37:49 -0400 Subject: [PATCH 12/23] run devtools::document --- man/spatInSituPlotPoints.Rd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/man/spatInSituPlotPoints.Rd b/man/spatInSituPlotPoints.Rd index aa05353..0fcd97e 100644 --- a/man/spatInSituPlotPoints.Rd +++ b/man/spatInSituPlotPoints.Rd @@ -18,6 +18,8 @@ spatInSituPlotPoints( feat_shape_code = NULL, sdimx = "x", sdimy = "y", + xlim = NULL, + ylim = NULL, spat_enr_names = NULL, point_size = 1.5, stroke = 0.5, @@ -81,6 +83,10 @@ spatInSituPlotPoints( \item{sdimy}{spatial dimension y} +\item{xlim}{limits of x-scale (min/max vector)} + +\item{ylim}{limits of y-scale (min/max vector)} + \item{spat_enr_names}{character. names of spatial enrichment results to include} From e98f98ba3cba89aa09dd80ba6250cba3f8be617e Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:28:01 -0400 Subject: [PATCH 13/23] feat: `.ext_to_dummy_df()` as refactored internal --- R/gg_info_layers.R | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/R/gg_info_layers.R b/R/gg_info_layers.R index 63ae4c7..b7f1b0e 100644 --- a/R/gg_info_layers.R +++ b/R/gg_info_layers.R @@ -1412,10 +1412,7 @@ plot_spat_image_layer_ggplot <- function( ... ) - bounds_dt <- data.table::data.table( - sdimx = e[][c(1, 2)], - sdimy = e[][c(3, 4)] - ) + bounds_dt <- .ext_to_dummy_df(e) # Assign region to plot gg_obj <- gg_obj + geom_blank(data = bounds_dt, aes(sdimx, sdimy)) @@ -1436,7 +1433,15 @@ plot_spat_image_layer_ggplot <- function( return(gg_obj) } - +# internal to convert a SpatExtent into a data.frame with x and y values that +# ggplot2 can use to determine bounds of placement +.ext_to_dummy_df <- function(x) { + data.frame( + sdimx = x[][c(1, 2)], + sdimy = x[][c(3, 4)], + row.names = NULL + ) +} From 9f771a0d59f2186727d45789406d2711568a2a78 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Wed, 3 Jul 2024 14:36:45 -0400 Subject: [PATCH 14/23] feat: reexport ggrepel functions --- NAMESPACE | 4 ++++ R/suite_reexports.R | 5 +++++ man/reexports.Rd | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 13d0472..ddbbf63 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,8 @@ export(dimPlot) export(dimPlot2D) export(dimPlot3D) export(expand_feature_info) +export(geom_label_repel) +export(geom_text_repel) export(getColors) export(getDistinctColors) export(getRainbowColors) @@ -107,6 +109,8 @@ importFrom(GiottoUtils,getRainbowColors) importFrom(colorRamp2,colorRamp2) importFrom(data.table,dcast) importFrom(data.table,dcast.data.table) +importFrom(ggrepel,geom_label_repel) +importFrom(ggrepel,geom_text_repel) importFrom(igraph,as_data_frame) importFrom(methods,new) importFrom(methods,setGeneric) diff --git a/R/suite_reexports.R b/R/suite_reexports.R index 92d685d..b8cef91 100644 --- a/R/suite_reexports.R +++ b/R/suite_reexports.R @@ -2,3 +2,8 @@ GiottoUtils::getRainbowColors #' @export GiottoUtils::getDistinctColors + +#' @export +ggrepel::geom_text_repel +#' @export +ggrepel::geom_label_repel diff --git a/man/reexports.Rd b/man/reexports.Rd index 6259261..1096a60 100644 --- a/man/reexports.Rd +++ b/man/reexports.Rd @@ -6,6 +6,8 @@ \alias{colorRamp2} \alias{getRainbowColors} \alias{getDistinctColors} +\alias{geom_text_repel} +\alias{geom_label_repel} \title{Objects exported from other packages} \value{ a function to create continous colors @@ -22,6 +24,8 @@ below to see their documentation. \describe{ \item{colorRamp2}{\code{\link[colorRamp2]{colorRamp2}}} + \item{ggrepel}{\code{\link[ggrepel:geom_text_repel]{geom_label_repel}}, \code{\link[ggrepel]{geom_text_repel}}} + \item{GiottoUtils}{\code{\link[GiottoUtils]{getDistinctColors}}, \code{\link[GiottoUtils]{getRainbowColors}}} }} From 2c6273aef64d0bcfa1649e198d8a52576489aceb Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Fri, 5 Jul 2024 16:30:57 -0400 Subject: [PATCH 15/23] feat: max_window and colorize support - rework image array processing - add more efficient single channel code - refactor image array processing to `.gg_process_img_array()` - add `giottoLargeImage` color and max_window support --- R/gg_annotation_raster.R | 108 +++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/R/gg_annotation_raster.R b/R/gg_annotation_raster.R index 0e0d318..29c3087 100644 --- a/R/gg_annotation_raster.R +++ b/R/gg_annotation_raster.R @@ -73,57 +73,26 @@ setMethod( } # get plotting minmax - extent <- terra::ext(gimage@raster_object)[seq_len(4)] + extent <- terra::ext(gimage)[seq_len(4)] xmin <- extent[["xmin"]] xmax <- extent[["xmax"]] ymin <- extent[["ymin"]] ymax <- extent[["ymax"]] - # convert raster object into array with 3 channels - img_array <- terra::as.array(gimage@raster_object) - - # TODO: check if required, fixes NaN values - # replacing NA's by zero or another value directly in raster object? - # raster[is.na(raster[])] <- 0 - if (is.nan(max(img_array[, , 1]))) { - img_array[, , 1][is.nan(img_array[, , 1])] <- max(img_array[, , 1], - na.rm = TRUE + # convert raster object into array with 3 channels + alpha + img_array_rgb <- terra::as.array(gimage@raster_object) %>% + .gg_process_img_array( + maxval = gimage@max_window, + col = gimage@colors ) - } - - if (dim(img_array)[3] > 1) { - if (is.nan(max(img_array[, , 2]))) { - img_array[, , 2][is.nan(img_array[, , 2])] <- - max(img_array[, , 2], na.rm = TRUE) - } - } - - if (dim(img_array)[3] > 2) { - if (is.nan(max(img_array[, , 3]))) { - img_array[, , 3][is.nan(img_array[, , 3])] <- - max(img_array[, , 3], na.rm = TRUE) - } - } - - img_array <- img_array / max(img_array, na.rm = TRUE) - if (dim(img_array)[3] == 1) { - img_array_RGB <- array(NA, dim = c(dim(img_array)[seq_len(2)], 3)) - img_array_RGB[, , seq_len(3)] <- img_array - } else { - img_array_RGB <- img_array - } - - # handle NA values - img_array_RGB[is.na(img_array_RGB)] <- 0 # append to ggobj ggobj <- ggobj + annotation_raster( - img_array_RGB, + img_array_rgb, xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax ) - # TODO geom_raster to accommodate single-channel return(ggobj) } ) @@ -322,4 +291,67 @@ setMethod( return(img) } +# make an image array compatible with ggplot::annotation_raster() +# maxval is the cutoff after which everything is max intensity +# returns: +# - if rgb, a properly scaled and cleaned array +# - if single channel, a native raster +.gg_process_img_array <- function(x, maxval = NULL, col = NULL) { + nlyr <- dim(x)[3L] # number of channels/layers + if (is.na(nlyr)) nlyr <- 1L + # NOTE: 4 layers allowed (rgba), but may conflict with actual 4 info + # layer cases which SHOULD be converted to 3 layer + # + # more than 4 layers -> directly ignore layers past the 3rd + if (nlyr > 4L) { + nlyr <- 3L + x <- x[, , seq_len(3)] + } + + # handle NaN values -- set as max value of that layer + # these may arise due to save artefacting when values are larger than + # expected + for (lyr in seq_len(nlyr)) { + if (is.nan(max(x[, , lyr]))) { + x[, , lyr][is.nan(x[, , lyr])] <- + max(x[, , lyr], na.rm = TRUE) + } + } + + # handle NA values -- set as 0 + x[is.na(x)] <- 0 + + if (nlyr == 1L) { + # SINGLE CHANNEL # + # max window cutoff + if (!is.null(maxval)) x[x > maxval] <- maxval + # colorize + if (is.null(col)) { + col <- getMonochromeColors("white", n = 256) + } + r <- .colorize_single_channel_raster(x, col = col) + } else { + # RGB EXPECTED # + # convert to range 0:1 (needed for as.raster()) + x <- scales::rescale(x, to = c(0, 1)) + r <- as.raster(x) + } + + return(r) +} + +# `x` is array to use +# `col` is character vector of colors to use +.colorize_single_channel_raster <- function(x, col) { + if (!is.na(dim(x)[3L]))x <- x[,, 1L] # convert to matrix + r <- range(x, na.rm = TRUE) + x <- (x - r[1])/(r[2] - r[1]) + x <- round(x * (length(col) - 1) + 1) + x[] <- col[x] + as.raster(x) +} + + + + From 64a7af78064aef54649ee96c04674ef7581611ec Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:20:08 -0400 Subject: [PATCH 16/23] chore: update news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 87e8b87..38e0b36 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # GiottoVisuals 0.2.4 +## enhancements +- `giottoLargeImage` `max_window` and `colors` slot info is now followed during ggplot plotting # GiottoVisuals 0.2.3 (2024/05/28) From 87d13f2842a91d23a8309947a74ce803b2d39ce3 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:21:40 -0400 Subject: [PATCH 17/23] chore: update news --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 38e0b36..83a1723 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ ## enhancements - `giottoLargeImage` `max_window` and `colors` slot info is now followed during ggplot plotting +## new +- `geom_text_repel()` and `geom_label_repel()` from `ggplot2` are now re-exported + # GiottoVisuals 0.2.3 (2024/05/28) ## bug fixes From ee22d11c6eece9cbaa2d203bdebb51561368704e Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Sat, 6 Jul 2024 19:21:01 -0400 Subject: [PATCH 18/23] chore: formatting and docs --- R/gg_annotation_raster.R | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/R/gg_annotation_raster.R b/R/gg_annotation_raster.R index 29c3087..4886a00 100644 --- a/R/gg_annotation_raster.R +++ b/R/gg_annotation_raster.R @@ -63,14 +63,13 @@ setMethod( signature(ggobj = "gg", gimage = "giottoLargeImage"), function(ggobj, gimage, ext = NULL, ...) { - # apply plot ext - if (!is.null(ext)) { - gimage <- .auto_resample_gimage( - img = gimage, - plot_ext = ext, - ... - ) - } + # resample from extent + if (is.null(ext)) ext <- ext(gimage) + gimage <- .auto_resample_gimage( + img = gimage, + plot_ext = ext, + ... + ) # get plotting minmax extent <- terra::ext(gimage)[seq_len(4)] @@ -213,16 +212,17 @@ setMethod( ) ) { + # 1. determine image and cropping extents img_ext <- terra::ext(img) if (is.null(plot_ext)) crop_ext <- img_ext # default else crop_ext <- ext(plot_ext) bound_poly <- as.polygons(crop_ext) - # override max_crop if needed + # 1.5. override max_crop if needed if (max_sample > max_crop) max_crop <- max_sample - # apply img border - # - cropping with extent larger than the image extent works + # 2. apply img border expansion + # - note: cropping with extent larger than the image extent works if (img_border > 0) { crop_ext <- bound_poly %>% @@ -233,19 +233,22 @@ setMethod( crop_ext <- ext(crop(bound_poly, crop_ext)) } - # determine ratio of crop vs original + # 3. determine ratio of crop vs original original_dims <- dim(img)[c(2L, 1L)] # x, y ordering ratios <- range(crop_ext) / range(img_ext) # x, y ordering crop_dims <- original_dims * ratios crop_area_px <- prod(crop_dims) + # 4. perform flexible resample/crop if (!isTRUE(flex_resample) || crop_area_px <= max_crop) { # [METHOD A]: # 1. Crop if needed # 2. resample to final image if (!isTRUE(flex_resample) && crop_area_px > max_crop) { - warning("Plotting large regions with flex_resample == FALSE will - increase time and may require scratch space.") + warning( + "Plotting large regions with flex_resample == FALSE will\n ", + "increase time and may require scratch space." + ) } vmsg(.is_debug = TRUE, @@ -291,11 +294,14 @@ setMethod( return(img) } + + + + + # make an image array compatible with ggplot::annotation_raster() # maxval is the cutoff after which everything is max intensity -# returns: -# - if rgb, a properly scaled and cleaned array -# - if single channel, a native raster +# returns: raster .gg_process_img_array <- function(x, maxval = NULL, col = NULL) { nlyr <- dim(x)[3L] # number of channels/layers if (is.na(nlyr)) nlyr <- 1L From 820903c599c4fbd96b806ccf0a642fbd7907feaa Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:32:48 -0400 Subject: [PATCH 19/23] feat: ggplot `giottoAffineImage` compatibility - refactor `gg_annotation_raster()` internals - add compatibility for plotting with `giottoAffineImage` --- R/gg_annotation_raster.R | 161 ++++++++++++++++++++++++++------------- 1 file changed, 106 insertions(+), 55 deletions(-) diff --git a/R/gg_annotation_raster.R b/R/gg_annotation_raster.R index 4886a00..6766327 100644 --- a/R/gg_annotation_raster.R +++ b/R/gg_annotation_raster.R @@ -62,41 +62,42 @@ setMethod( "gg_annotation_raster", signature(ggobj = "gg", gimage = "giottoLargeImage"), function(ggobj, gimage, ext = NULL, ...) { - # resample from extent if (is.null(ext)) ext <- ext(gimage) gimage <- .auto_resample_gimage( img = gimage, plot_ext = ext, + crop_ratio_fun = .img_to_crop_ratio_gimage, + sample_fun = .sample_gimage, ... ) - # get plotting minmax - extent <- terra::ext(gimage)[seq_len(4)] - xmin <- extent[["xmin"]] - xmax <- extent[["xmax"]] - ymin <- extent[["ymin"]] - ymax <- extent[["ymax"]] - - # convert raster object into array with 3 channels + alpha - img_array_rgb <- terra::as.array(gimage@raster_object) %>% - .gg_process_img_array( - maxval = gimage@max_window, - col = gimage@colors - ) - - # append to ggobj - ggobj <- ggobj + annotation_raster( - img_array_rgb, - xmin = xmin, xmax = xmax, - ymin = ymin, ymax = ymax - ) + ggobj <- .gg_append_image(ggobj = ggobj, gimage = gimage) return(ggobj) } ) +#' @rdname gg_annotation_raster +setMethod( + "gg_annotation_raster", + signature(ggobj = "gg", gimage = "giottoAffineImage"), + function(ggobj, gimage, ext, ...) { + # resample from extent + if (is.null(ext)) ext <- ext(gimage) + gimage <- .auto_resample_gimage( + img = gimage, + plot_ext = ext, + crop_ratio_fun = .img_to_crop_ratio_gaffimage, + sample_fun = .sample_gaffimage, + ... + ) + ggobj <- .gg_append_image(ggobj = ggobj, gimage = gimage) + + return(ggobj) + } +) @@ -170,7 +171,7 @@ setMethod( #' determines if this switching behavior happens. #' When set to \code{FALSE}, only method A is used. #' @param img giotto image to plot -#' @param plot_ext extent of plot (required) +#' @param plot_ext extent of plot (defaults to the image extent) #' @param img_border if not 0 or FALSE, expand plot_ext by this percentage on #' each side before applying crop on image. See details #' @param flex_resample logical. Default = TRUE. Forces usage of method A when @@ -204,6 +205,8 @@ setMethod( img, plot_ext = NULL, img_border = 0.125, + crop_ratio_fun = .img_to_crop_ratio_gimage, + sample_fun = .sample_gimage, flex_resample = TRUE, max_sample = getOption("giotto.plot_img_max_sample", 5e5), max_crop = getOption("giotto.plot_img_max_crop", 1e8), @@ -212,17 +215,16 @@ setMethod( ) ) { - # 1. determine image and cropping extents - img_ext <- terra::ext(img) - if (is.null(plot_ext)) crop_ext <- img_ext # default + # 1. determine source image and cropping extents + if (is.null(plot_ext)) crop_ext <- ext(img) # default to img extent else crop_ext <- ext(plot_ext) bound_poly <- as.polygons(crop_ext) - # 1.5. override max_crop if needed + # 1.1. override max_crop if needed if (max_sample > max_crop) max_crop <- max_sample - # 2. apply img border expansion - # - note: cropping with extent larger than the image extent works + # 1.2. apply img border expansion + # - note: cropping with extent larger than the image extent is supported if (img_border > 0) { crop_ext <- bound_poly %>% @@ -233,13 +235,13 @@ setMethod( crop_ext <- ext(crop(bound_poly, crop_ext)) } - # 3. determine ratio of crop vs original + # 2. determine cropping area original_dims <- dim(img)[c(2L, 1L)] # x, y ordering - ratios <- range(crop_ext) / range(img_ext) # x, y ordering + ratios <- crop_ratio_fun(img = img, crop_ext = crop_ext) # x, y ordering crop_dims <- original_dims * ratios crop_area_px <- prod(crop_dims) - # 4. perform flexible resample/crop + # 3. perform flexible resample/crop based on cropping area if (!isTRUE(flex_resample) || crop_area_px <= max_crop) { # [METHOD A]: # 1. Crop if needed @@ -255,16 +257,8 @@ setMethod( sprintf("img auto_res: [A] | area: %f | max: %f", crop_area_px, max_crop)) - crop_img <- terra::crop( - x = img@raster_object, - y = crop_ext - ) - img@raster_object <- terra::spatSample( - crop_img, - size = max_sample, - method = "regular", - as.raster = TRUE - ) + crop_img <- terra::crop(img, crop_ext) + res <- sample_fun(crop_img, size = max_sample) } else { # [METHOD B]: # 1. Oversample @@ -280,21 +274,60 @@ setMethod( sprintf("img auto_res: [B] | scalef: %f | max_scale: %f", scalef, max_resample_scale)) - oversample_img <- terra::spatSample( - img@raster_object, - size = round(max_sample * scalef), - method = "regular", - as.raster = TRUE - ) - img@raster_object <- terra::crop( - x = oversample_img, - y = crop_ext - ) + oversample_img <- sample_fun(img, size = round(max_sample * scalef)) + res <- terra::crop(oversample_img, crop_ext) } - return(img) + return(res) +} + + + + +# determine ratio of crop vs full image extent +.img_to_crop_ratio_gimage <- function(img, crop_ext) { + img_ext <- ext(img) + ratio <- range(crop_ext) / range(img_ext) + # crops larger than the image are possible, but meaningless for this + # calculate. so the ratios are capped at 1. + ratio[ratio > 1] <- 1 + return(ratio) } +.img_to_crop_ratio_gaffimage <- function(img, crop_ext) { + # Do not use the ext() method for giottoAffineImage + # Instead use the mapping applied to the underlying SpatRaster. + # For giottoAffineImage, these two values are usually different. + img_ext <- ext(img@raster_object) + # find the extent needed in the source (untransformed) image + crop_bound <- terra::as.polygons(crop_ext) + crop_bound$id <- "bound" # affine() requires ID values + crop_ext <- ext(affine(crop_bound, img@affine, inv = TRUE)) + ratio <- range(crop_ext) / range(img_ext) + # crops larger than the image are possible, but meaningless for this + # calculate. so the ratios are capped at 1. + ratio[ratio > 1] <- 1 + return(ratio) +} + + + + +# pull sampled values from original image into target spatial mapping +# should return a giottoLargeImage +.sample_gimage <- function(x, size) { + x@raster_object <- terra::spatSample( + x = x@raster_object, + size = size, + method = "regular", + as.raster = TRUE + ) + return(x) +} +.sample_gaffimage <- function(x, size) { + res <- x@funs$realize_magick(size = size) + return(res) +} @@ -302,7 +335,7 @@ setMethod( # make an image array compatible with ggplot::annotation_raster() # maxval is the cutoff after which everything is max intensity # returns: raster -.gg_process_img_array <- function(x, maxval = NULL, col = NULL) { +.gg_imgarray_2_raster <- function(x, maxval = NULL, col = NULL) { nlyr <- dim(x)[3L] # number of channels/layers if (is.na(nlyr)) nlyr <- 1L # NOTE: 4 layers allowed (rgba), but may conflict with actual 4 info @@ -346,6 +379,9 @@ setMethod( return(r) } + + + # `x` is array to use # `col` is character vector of colors to use .colorize_single_channel_raster <- function(x, col) { @@ -357,7 +393,22 @@ setMethod( as.raster(x) } +# append a giotto image object containing a SpatRaster that has already been +# resampled/pulled into memory. Output is a `gg` object +.gg_append_image <- function(ggobj, gimage) { + # convert gimage to a raster + r <- terra::as.array(gimage@raster_object) %>% + .gg_imgarray_2_raster( + maxval = gimage@max_window, + col = gimage@colors + ) + # append to ggobj + extent <- ext(gimage)[seq_len(4L)] + ggobj <- ggobj + annotation_raster(r, + xmin = extent[["xmin"]], xmax = extent[["xmax"]], + ymin = extent[["ymin"]], ymax = extent[["ymax"]] + ) - - + return(ggobj) +} From 599949d5007149a24de03c76aec7660e4a150a56 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:35:11 -0400 Subject: [PATCH 20/23] chore: document --- man/auto_image_resample.Rd | 4 +++- man/gg_annotation_raster.Rd | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/man/auto_image_resample.Rd b/man/auto_image_resample.Rd index f77e13f..bb49060 100644 --- a/man/auto_image_resample.Rd +++ b/man/auto_image_resample.Rd @@ -9,6 +9,8 @@ img, plot_ext = NULL, img_border = 0.125, + crop_ratio_fun = .img_to_crop_ratio_gimage, + sample_fun = .sample_gimage, flex_resample = TRUE, max_sample = getOption("giotto.plot_img_max_sample", 5e+05), max_crop = getOption("giotto.plot_img_max_crop", 1e+08), @@ -18,7 +20,7 @@ \arguments{ \item{img}{giotto image to plot} -\item{plot_ext}{extent of plot (required)} +\item{plot_ext}{extent of plot (defaults to the image extent)} \item{img_border}{if not 0 or FALSE, expand plot_ext by this percentage on each side before applying crop on image. See details} diff --git a/man/gg_annotation_raster.Rd b/man/gg_annotation_raster.Rd index 2b81d22..18e4bc3 100644 --- a/man/gg_annotation_raster.Rd +++ b/man/gg_annotation_raster.Rd @@ -5,6 +5,7 @@ \alias{gg_annotation_raster,gg,list-method} \alias{gg_annotation_raster,gg,giottoImage-method} \alias{gg_annotation_raster,gg,giottoLargeImage-method} +\alias{gg_annotation_raster,gg,giottoAffineImage-method} \title{Append image to ggplot as annotation_raster} \usage{ \S4method{gg_annotation_raster}{gg,list}(ggobj, gimage, ...) @@ -12,6 +13,8 @@ \S4method{gg_annotation_raster}{gg,giottoImage}(ggobj, gimage, ...) \S4method{gg_annotation_raster}{gg,giottoLargeImage}(ggobj, gimage, ext = NULL, ...) + +\S4method{gg_annotation_raster}{gg,giottoAffineImage}(ggobj, gimage, ext, ...) } \arguments{ \item{ggobj}{ggplot2 \code{gg} object} From ad8f20cb0c1d836a74b0e8a873ba38c7ba46fa97 Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:35:19 -0400 Subject: [PATCH 21/23] chore: update news --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 83a1723..d1076ef 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ ## enhancements - `giottoLargeImage` `max_window` and `colors` slot info is now followed during ggplot plotting +- `giottoAffineImage` compatibility for giotto ggplot2 plotting functions ## new - `geom_text_repel()` and `geom_label_repel()` from `ggplot2` are now re-exported From 22412aee8b9d85a66ab5d0768fbeda544e4b573d Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:43:12 -0400 Subject: [PATCH 22/23] chore: formatting --- R/gg_annotation_raster.R | 2 +- R/vis_spatial.R | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/R/gg_annotation_raster.R b/R/gg_annotation_raster.R index 6766327..0a54671 100644 --- a/R/gg_annotation_raster.R +++ b/R/gg_annotation_raster.R @@ -1,5 +1,4 @@ #' @name gg_annotation_raster -#' @keywords internal #' @title Append image to ggplot as annotation_raster #' @param ggobj ggplot2 `gg` object #' @param gimage `giottoLargeImage`, `giottoImage` or `list` thereof @@ -9,6 +8,7 @@ #' `giottoLargeImage` passes to automated resampling params see #' `?auto_image_resample` for details #' @return `gg` object with images to plot appended as annotation rasters +#' @keywords internal NULL #' @rdname gg_annotation_raster diff --git a/R/vis_spatial.R b/R/vis_spatial.R index 4df1d1a..888b35f 100644 --- a/R/vis_spatial.R +++ b/R/vis_spatial.R @@ -357,24 +357,24 @@ ) pl <- switch(point_shape, - "border" = do.call( - plot_spat_point_layer_ggplot, - args = c( - point_general_params, - point_border_specific_params - ) - ), - "no_border" = do.call( - plot_spat_point_layer_ggplot_noFILL, - args = point_general_params - ), - "voronoi" = do.call( - plot_spat_voronoi_layer_ggplot, - args = c( - point_general_params, - point_voronoi_specific_params - ) - ) + "border" = do.call( + plot_spat_point_layer_ggplot, + args = c( + point_general_params, + point_border_specific_params + ) + ), + "no_border" = do.call( + plot_spat_point_layer_ggplot_noFILL, + args = point_general_params + ), + "voronoi" = do.call( + plot_spat_voronoi_layer_ggplot, + args = c( + point_general_params, + point_voronoi_specific_params + ) + ) ) @@ -7514,7 +7514,7 @@ spatGenePlot3D <- function(...) { #' @returns plotly #' @examples #' g <- GiottoData::loadGiottoMini("starmap") -#' +#' #' dimFeatPlot3D(g, genes = "Slc17a7", dim_reduction_name = "3D_umap") #' @export dimFeatPlot3D <- function( From 0c705da1c775e1b3abca3aace43751dcb777933e Mon Sep 17 00:00:00 2001 From: George Chen <72078254+jiajic@users.noreply.github.com> Date: Fri, 26 Jul 2024 19:51:05 -0400 Subject: [PATCH 23/23] enh: gg_annotation_raster - now also performs geom_blank() - new params `geom_blank` for whether to do the above, and `ext` for extent to use. --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 1 + R/gg_annotation_raster.R | 133 +++++++++++++++++++++++++----------- R/gg_info_layers.R | 28 +------- man/gg_annotation_raster.Rd | 24 ++++--- 6 files changed, 113 insertions(+), 76 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5fa3d2f..e8bc476 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,7 +21,7 @@ Encoding: UTF-8 URL: https://drieslab.github.io/Giotto/, https://github.com/drieslab/Giotto, https://drieslab.github.io/GiottoVisuals/ BugReports: https://github.com/drieslab/Giotto/issues Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Depends: base (>= 4.4.0), utils (>= 4.4.0), diff --git a/NAMESPACE b/NAMESPACE index ddbbf63..e881cae 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -93,6 +93,7 @@ export(violinPlot) exportClasses(giottoSankeyPlan) exportMethods("+") exportMethods("sankeyRelate<-") +exportMethods(gg_annotation_raster) exportMethods(sankeyPlot) exportMethods(sankeyRelate) import(GiottoClass) diff --git a/NEWS.md b/NEWS.md index d1076ef..cc7ab2e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,7 @@ ## enhancements - `giottoLargeImage` `max_window` and `colors` slot info is now followed during ggplot plotting - `giottoAffineImage` compatibility for giotto ggplot2 plotting functions +- `gg_annotation_raster()` now also performs `geom_blank()` with the extent provided through `ext` param. This can be turned off by setting `geom_blank() = FALSE` ## new - `geom_text_repel()` and `geom_label_repel()` from `ggplot2` are now re-exported diff --git a/R/gg_annotation_raster.R b/R/gg_annotation_raster.R index 0a54671..cd1ada8 100644 --- a/R/gg_annotation_raster.R +++ b/R/gg_annotation_raster.R @@ -1,69 +1,87 @@ #' @name gg_annotation_raster #' @title Append image to ggplot as annotation_raster +#' @description +#' Add a spatially mapped image to a *ggplot2* `gg` object. +#' For terra-based images, the image will be a cropped and sampled version +#' of the full size image on disk that has sufficient resolution for the size +#' of the plot requested. +#' #' @param ggobj ggplot2 `gg` object #' @param gimage `giottoLargeImage`, `giottoImage` or `list` thereof +#' @param ext Object that responds to `ext()`. Defines the plot spatial ROI +#' This extent defines which portions of the image(s) will be plotted/should +#' be sampled for. The default is the same extent as the image. +#' @param geom_blank logical. Whether to apply `[ggplot2::geom_blank()]` to the +#' `gg` object so that the image can be plotted by itself. #' @param \dots additional params to pass #' @details #' No ... params are implemented for `giottoImage`. \cr ... params for #' `giottoLargeImage` passes to automated resampling params see #' `?auto_image_resample` for details #' @return `gg` object with images to plot appended as annotation rasters -#' @keywords internal NULL +# * list #### #' @rdname gg_annotation_raster +#' @export setMethod( "gg_annotation_raster", signature(ggobj = "gg", gimage = "list"), - function(ggobj, gimage, ...) { + function(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) { + + # apply geom_blank + ext <- ext %null% ext(gimage[[1L]]) + if (geom_blank) ggobj <- .gg_geom_blank(ggobj, ext) + + # attach images in a loop for (i in seq_along(gimage)) { - ggobj <- gg_annotation_raster(ggobj, gimage[[i]], ...) + ggobj <- gg_annotation_raster( + ggobj, gimage[[i]], + ext = ext, + geom_blank = FALSE, # hardcode FALSE since already done. + ... + ) } return(ggobj) } ) +# * giottoImage #### #' @rdname gg_annotation_raster +#' @export setMethod( "gg_annotation_raster", signature(ggobj = "gg", gimage = "giottoImage"), - function(ggobj, gimage, ...) { - # extract min and max from object - my_xmax <- gimage@minmax[1] - my_xmin <- gimage@minmax[2] - my_ymax <- gimage@minmax[3] - my_ymin <- gimage@minmax[4] + function(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) { + + # apply geom_blank + ext <- ext %null% ext(gimage) + if (geom_blank) ggobj <- .gg_geom_blank(ggobj, ext) # convert giotto image object into array img_array <- as.numeric(gimage@mg_object[[1]]) - # extract adjustments from object - xmax_b <- gimage@boundaries[1] - xmin_b <- gimage@boundaries[2] - ymax_b <- gimage@boundaries[3] - ymin_b <- gimage@boundaries[4] - # append to ggobj - ggobj <- ggobj + annotation_raster( - img_array, - xmin = my_xmin - xmin_b, xmax = my_xmax + xmax_b, - ymin = my_ymin - ymin_b, ymax = my_ymax + ymax_b - ) + ggobj <- .gg_append_imagearray(ggobj, img_array, ext) # TODO geom_raster to accommodate single-channel return(ggobj) } ) +# * giottoLargeImage #### #' @rdname gg_annotation_raster -#' @param ext Object that responds to `ext()`. Defines the plot spatial ROI -#' that the image should be sampled for. +#' @export setMethod( "gg_annotation_raster", signature(ggobj = "gg", gimage = "giottoLargeImage"), - function(ggobj, gimage, ext = NULL, ...) { + function(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) { + + # geom_blank + ext <- ext %null% ext(gimage) + if (geom_blank) ggobj <- .gg_geom_blank(ggobj, ext) + # resample from extent - if (is.null(ext)) ext <- ext(gimage) gimage <- .auto_resample_gimage( img = gimage, plot_ext = ext, @@ -72,19 +90,26 @@ setMethod( ... ) - ggobj <- .gg_append_image(ggobj = ggobj, gimage = gimage) + # append raster to gg + ggobj <- .gg_append_spatraster(ggobj = ggobj, gimage = gimage) return(ggobj) } ) +# * giottoAffineImage #### #' @rdname gg_annotation_raster +#' @export setMethod( "gg_annotation_raster", signature(ggobj = "gg", gimage = "giottoAffineImage"), - function(ggobj, gimage, ext, ...) { + function(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) { + + # geom_blank + ext <- ext %null% ext(gimage) + if (geom_blank) ggobj <- .gg_geom_blank(ggobj, ext) + # resample from extent - if (is.null(ext)) ext <- ext(gimage) gimage <- .auto_resample_gimage( img = gimage, plot_ext = ext, @@ -93,7 +118,8 @@ setMethod( ... ) - ggobj <- .gg_append_image(ggobj = ggobj, gimage = gimage) + # append raster to gg + ggobj <- .gg_append_spatraster(ggobj = ggobj, gimage = gimage) return(ggobj) } @@ -135,6 +161,29 @@ setMethod( return(e) } +# internal to convert a SpatExtent into a data.frame with x and y values that +# ggplot2 can use to determine bounds of placement +.ext_to_dummy_df <- function(x) { + data.frame( + sdimx = x[][c(1, 2)], + sdimy = x[][c(3, 4)], + row.names = NULL + ) +} + +# apply a region to plot to the gg object. Input should be a SpatExtent or +# coercible. Returns ggobject with geom_blank assigned +.gg_geom_blank <- function(ggobj, e) { + # NSE vars + sdimx <- sdimy <- NULL + + # create minimal dummy value data.frame of spatial locations that cover + # the spatial region to plot + bounds_dt <- .ext_to_dummy_df(e) + # assign region to plot + ggobj <- ggobj + geom_blank(data = bounds_dt, aes(sdimx, sdimy)) + return(ggobj) +} #' @name auto_image_resample #' @title Optimized image resampling @@ -385,30 +434,36 @@ setMethod( # `x` is array to use # `col` is character vector of colors to use .colorize_single_channel_raster <- function(x, col) { - if (!is.na(dim(x)[3L]))x <- x[,, 1L] # convert to matrix + if (!is.na(dim(x)[3L])) x <- x[,, 1L] # convert to matrix r <- range(x, na.rm = TRUE) x <- (x - r[1])/(r[2] - r[1]) x <- round(x * (length(col) - 1) + 1) x[] <- col[x] - as.raster(x) + terra::as.raster(x) +} + +# append image array to a gg object +.gg_append_imagearray <- function(ggobj, a, ext) { + # append to ggobj + extent <- ext(ext)[seq_len(4L)] + ggobj <- ggobj + annotation_raster(a, + xmin = extent[["xmin"]], xmax = extent[["xmax"]], + ymin = extent[["ymin"]], ymax = extent[["ymax"]] + ) } # append a giotto image object containing a SpatRaster that has already been # resampled/pulled into memory. Output is a `gg` object -.gg_append_image <- function(ggobj, gimage) { +.gg_append_spatraster <- function(ggobj, gimage) { # convert gimage to a raster - r <- terra::as.array(gimage@raster_object) %>% + a <- terra::as.array(gimage@raster_object) %>% .gg_imgarray_2_raster( maxval = gimage@max_window, col = gimage@colors ) - # append to ggobj - extent <- ext(gimage)[seq_len(4L)] - ggobj <- ggobj + annotation_raster(r, - xmin = extent[["xmin"]], xmax = extent[["xmax"]], - ymin = extent[["ymin"]], ymax = extent[["ymax"]] - ) - + ggobj <- .gg_append_imagearray(ggobj, a, ext(gimage)) return(ggobj) } + + diff --git a/R/gg_info_layers.R b/R/gg_info_layers.R index b7f1b0e..ae86de6 100644 --- a/R/gg_info_layers.R +++ b/R/gg_info_layers.R @@ -1396,9 +1396,6 @@ plot_spat_image_layer_ggplot <- function( stop("A giotto object and a giotto image need to be provided") } - # NSE vars - sdimx <- sdimy <- NULL - # prefer extent detection from polygon if (!is.null(polygon_feat_type)) spat_unit <- polygon_feat_type @@ -1412,36 +1409,13 @@ plot_spat_image_layer_ggplot <- function( ... ) - bounds_dt <- .ext_to_dummy_df(e) - - # Assign region to plot - gg_obj <- gg_obj + geom_blank(data = bounds_dt, aes(sdimx, sdimy)) - # Assign image(s) to plot gg_obj <- gg_annotation_raster(ggobj = gg_obj, gimage = gimage, ext = e) - # if (!is.null(spatlocs)) { - # gg_obj <- gg_obj + - # geom_point( - # data = spatlocs, - # aes_string(sdimx, sdimy), - # alpha = 0.5, - # size = 0.4 - # ) - # } - return(gg_obj) } -# internal to convert a SpatExtent into a data.frame with x and y values that -# ggplot2 can use to determine bounds of placement -.ext_to_dummy_df <- function(x) { - data.frame( - sdimx = x[][c(1, 2)], - sdimy = x[][c(3, 4)], - row.names = NULL - ) -} + diff --git a/man/gg_annotation_raster.Rd b/man/gg_annotation_raster.Rd index 18e4bc3..fdff3c4 100644 --- a/man/gg_annotation_raster.Rd +++ b/man/gg_annotation_raster.Rd @@ -8,33 +8,39 @@ \alias{gg_annotation_raster,gg,giottoAffineImage-method} \title{Append image to ggplot as annotation_raster} \usage{ -\S4method{gg_annotation_raster}{gg,list}(ggobj, gimage, ...) +\S4method{gg_annotation_raster}{gg,list}(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) -\S4method{gg_annotation_raster}{gg,giottoImage}(ggobj, gimage, ...) +\S4method{gg_annotation_raster}{gg,giottoImage}(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) -\S4method{gg_annotation_raster}{gg,giottoLargeImage}(ggobj, gimage, ext = NULL, ...) +\S4method{gg_annotation_raster}{gg,giottoLargeImage}(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) -\S4method{gg_annotation_raster}{gg,giottoAffineImage}(ggobj, gimage, ext, ...) +\S4method{gg_annotation_raster}{gg,giottoAffineImage}(ggobj, gimage, ext = NULL, geom_blank = TRUE, ...) } \arguments{ \item{ggobj}{ggplot2 \code{gg} object} \item{gimage}{\code{giottoLargeImage}, \code{giottoImage} or \code{list} thereof} -\item{\dots}{additional params to pass} - \item{ext}{Object that responds to \code{ext()}. Defines the plot spatial ROI -that the image should be sampled for.} +This extent defines which portions of the image(s) will be plotted/should +be sampled for. The default is the same extent as the image.} + +\item{geom_blank}{logical. Whether to apply \verb{[ggplot2::geom_blank()]} to the +\code{gg} object so that the image can be plotted by itself.} + +\item{\dots}{additional params to pass} } \value{ \code{gg} object with images to plot appended as annotation rasters } \description{ -Append image to ggplot as annotation_raster +Add a spatially mapped image to a \emph{ggplot2} \code{gg} object. +For terra-based images, the image will be a cropped and sampled version +of the full size image on disk that has sufficient resolution for the size +of the plot requested. } \details{ No ... params are implemented for \code{giottoImage}. \cr ... params for \code{giottoLargeImage} passes to automated resampling params see \code{?auto_image_resample} for details } -\keyword{internal}