From c513ddd7bb1bc55d2a5b978475472868c93893b0 Mon Sep 17 00:00:00 2001 From: jiajic <72078254+jiajic@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:47:38 -0400 Subject: [PATCH] GiottoVisuals semi-functional - Version bump - removed interactivity.R - reorganized scripts with a naming scheme - mostly passes R CMD check. Only some links in documentation remaining as errors. --- .Rbuildignore | 1 + DESCRIPTION | 52 +- NAMESPACE | 22 +- R/{defaults.R => aux_defaults.R} | 17 +- R/{plot_output.R => aux_output.R} | 56 +- R/{plot_save.R => aux_save.R} | 6 +- R/{auxilliary_visuals.R => aux_visuals.R} | 211 ++--- R/color_palettes.R | 2 +- R/dd.R | 151 +++- R/gg_info_layers.R | 9 +- R/image_visuals.R | 179 ---- R/interactivity.R | 477 ---------- R/package_imports.R | 1 + R/{aux_dendrogram.R => plot_dendrogram.R} | 108 ++- R/{aux_heatmap.R => plot_heatmap.R} | 644 +++++--------- R/{aux_scatterplot.R => plot_scatter.R} | 12 +- R/{aux_violinplot.R => plot_violin.R} | 13 +- ...atial_DE_visuals.R => spatialDE_visuals.R} | 0 R/{hvf_plots.R => vis_hvf.R} | 21 +- R/{pc_plots.R => vis_pc.R} | 44 +- R/{spatial_visuals.R => vis_spatial.R} | 818 ++++-------------- ...n_situ_visuals.R => vis_spatial_in_situ.R} | 127 ++- ...on_visuals.R => vis_spatial_interaction.R} | 382 +++----- R/viz_spatial_network.R | 317 +++++++ README.Rmd | 42 +- README.md | 39 +- man/FSV_show.Rd | 2 +- man/addPolygonCells.Rd | 55 -- man/aes_string2.Rd | 2 +- man/cellProximityBarplot.Rd | 10 +- man/cellProximityHeatmap.Rd | 10 +- man/cellProximityNetwork.Rd | 10 +- man/cellProximitySpatPlot.Rd | 27 +- man/cellProximitySpatPlot2D.Rd | 25 +- man/cellProximitySpatPlot3D.Rd | 21 +- man/cellProximityVisPlot.Rd | 2 +- man/cellProximityVisPlot_2D_ggplot.Rd | 2 +- man/cellProximityVisPlot_2D_plotly.Rd | 2 +- man/cellProximityVisPlot_3D_plotly.Rd | 2 +- man/compareCellAbundance.Rd | 34 - man/comparePolygonExpression.Rd | 40 - man/createHeatmap_DT.Rd | 19 +- man/create_cluster_dendrogram.Rd | 55 ++ man/create_jackstrawplot.Rd | 2 +- man/create_screeplot.Rd | 18 +- man/data_access_params.Rd | 4 +- man/decide_cluster_order.Rd | 5 +- man/dimCellPlot.Rd | 216 +++-- man/dimCellPlot2D.Rd | 172 ---- man/dimFeatPlot2D.Rd | 44 +- man/dimGenePlot3D.Rd | 8 +- man/dimPlot.Rd | 279 ++++-- man/dimPlot2D.Rd | 194 ----- man/dimPlot2D_single.Rd | 162 ---- man/dimPlot3D.Rd | 127 --- man/dimPlot_2D_plotly.Rd | 2 +- man/dimPlot_3D_plotly.Rd | 2 +- man/expand_feature_info.Rd | 2 +- man/filterInteractionChangedFeats.Rd | 50 ++ man/getCellsFromPolygon.Rd | 54 -- man/getColors.Rd | 2 +- man/gg_input.Rd | 17 + man/gg_simple_scatter.Rd | 10 +- man/giotto_point.Rd | 2 +- man/hvf_visualizations.Rd | 2 +- man/plotCCcomDotplot.Rd | 16 +- man/plotCCcomHeatmap.Rd | 16 +- man/plotCPF.Rd | 13 +- man/plotCPG.Rd | 36 - man/plotCellProximityFeats.Rd | 13 +- man/plotCellProximityGenes.Rd | 36 - man/plotCombineCCcom.Rd | 10 +- man/plotCombineCPG.Rd | 36 - man/plotCombineCellCellCommunication.Rd | 10 +- man/plotCombineCellProximityGenes.Rd | 36 - man/plotCombineICF.Rd | 10 +- man/plotCombineICG.Rd | 36 - man/plotCombineInteractionChangedFeats.Rd | 10 +- man/plotCombineInteractionChangedGenes.Rd | 36 - man/plotHeatmap.Rd | 42 +- man/plotICF.Rd | 13 +- man/plotICG.Rd | 31 - man/plotInteractionChangedFeats.Rd | 13 +- man/plotInteractionChangedGenes.Rd | 31 - man/plotInteractivePolygons.Rd | 21 - man/plotMetaDataCellsHeatmap.Rd | 20 +- man/plotMetaDataHeatmap.Rd | 47 +- man/plotPCA.Rd | 58 +- man/plotPCA_2D.Rd | 58 +- man/plotPCA_3D.Rd | 43 +- man/plotPolygons.Rd | 34 - man/plotRankSpatvsExpr.Rd | 18 +- man/plotRecovery.Rd | 12 +- man/plotRecovery_sub.Rd | 3 +- man/plotStatDelaunayNetwork.Rd | 67 ++ man/plotTSNE.Rd | 58 +- man/plotTSNE_2D.Rd | 58 +- man/plotTSNE_3D.Rd | 43 +- man/plotUMAP.Rd | 61 +- man/plotUMAP_2D.Rd | 58 +- man/plotUMAP_3D.Rd | 43 +- man/plot_auto_largeImage_resample.Rd | 81 -- man/plot_cell_params.Rd | 22 + man/plot_cow_params.Rd | 18 + man/plot_dimred_params.Rd | 30 + man/plot_feat_params.Rd | 14 + man/plot_image_params.Rd | 18 + man/plot_nn_net_params.Rd | 22 + man/plot_output_handler.Rd | 4 +- man/plot_output_params.Rd | 20 + man/plot_params.Rd | 60 +- man/plot_poly_params.Rd | 39 + man/plot_save.Rd | 4 +- man/plot_spatenr_params.Rd | 12 + man/plot_spatnet_params.Rd | 22 + man/plotly_axis_scale_2D.Rd | 2 +- man/plotly_axis_scale_3D.Rd | 2 +- man/plotly_grid.Rd | 2 +- man/plotly_network.Rd | 2 +- man/select_gimage.Rd | 21 - man/set_default_color_continuous.Rd | 2 +- man/showClusterDendrogram.Rd | 21 +- man/showClusterHeatmap.Rd | 98 ++- man/showColorInstructions.Rd | 2 +- man/showSaveParameters.Rd | 2 +- man/spatCellPlot.Rd | 252 ++++-- man/spatCellPlot2D.Rd | 199 ----- man/spatDeconvPlot.Rd | 17 +- man/spatDimCellPlot.Rd | 85 +- man/spatDimCellPlot2D.Rd | 56 +- man/spatDimFeatPlot2D.Rd | 58 +- man/spatDimGenePlot3D.Rd | 12 +- man/spatDimPlot.Rd | 344 ++++++-- man/spatDimPlot2D.Rd | 268 ------ man/spatDimPlot3D.Rd | 22 +- man/spatFeatPlot2D.Rd | 42 +- man/spatFeatPlot2D_single.Rd | 35 +- man/spatGenePlot3D.Rd | 22 +- man/spatInSituPlotDensity.Rd | 24 +- man/spatInSituPlotDensity_single.Rd | 2 +- man/spatInSituPlotHex.Rd | 24 +- man/spatInSituPlotHex_single.Rd | 2 +- man/spatInSituPlotPoints.Rd | 35 +- man/spatNetwDistributions.Rd | 58 ++ man/spatNetwDistributionsDistance.Rd | 49 ++ man/spatNetwDistributionsKneighbors.Rd | 43 + man/spatPlot.Rd | 341 ++++++-- man/spatPlot2D.Rd | 221 ----- man/spatPlot2D_single.Rd | 76 +- man/spatPlot3D.Rd | 130 --- man/spatPlot_2D_plotly.Rd | 2 +- man/spatPlot_3D_plotly.Rd | 2 +- man/violinPlot.Rd | 10 +- tests/testthat.R | 2 +- 154 files changed, 3979 insertions(+), 5563 deletions(-) rename R/{defaults.R => aux_defaults.R} (97%) rename R/{plot_output.R => aux_output.R} (55%) rename R/{plot_save.R => aux_save.R} (98%) rename R/{auxilliary_visuals.R => aux_visuals.R} (80%) delete mode 100644 R/image_visuals.R delete mode 100644 R/interactivity.R rename R/{aux_dendrogram.R => plot_dendrogram.R} (50%) rename R/{aux_heatmap.R => plot_heatmap.R} (74%) rename R/{aux_scatterplot.R => plot_scatter.R} (71%) rename R/{aux_violinplot.R => plot_violin.R} (90%) rename R/{spatial_DE_visuals.R => spatialDE_visuals.R} (100%) rename R/{hvf_plots.R => vis_hvf.R} (78%) rename R/{pc_plots.R => vis_pc.R} (74%) rename R/{spatial_visuals.R => vis_spatial.R} (91%) rename R/{spatial_in_situ_visuals.R => vis_spatial_in_situ.R} (90%) rename R/{spatial_interaction_visuals.R => vis_spatial_interaction.R} (92%) create mode 100644 R/viz_spatial_network.R delete mode 100644 man/addPolygonCells.Rd delete mode 100644 man/compareCellAbundance.Rd delete mode 100644 man/comparePolygonExpression.Rd create mode 100644 man/create_cluster_dendrogram.Rd delete mode 100644 man/dimCellPlot2D.Rd delete mode 100644 man/dimPlot2D.Rd delete mode 100644 man/dimPlot2D_single.Rd delete mode 100644 man/dimPlot3D.Rd create mode 100644 man/filterInteractionChangedFeats.Rd delete mode 100644 man/getCellsFromPolygon.Rd create mode 100644 man/gg_input.Rd delete mode 100644 man/plotCPG.Rd delete mode 100644 man/plotCellProximityGenes.Rd delete mode 100644 man/plotCombineCPG.Rd delete mode 100644 man/plotCombineCellProximityGenes.Rd delete mode 100644 man/plotCombineICG.Rd delete mode 100644 man/plotCombineInteractionChangedGenes.Rd delete mode 100644 man/plotICG.Rd delete mode 100644 man/plotInteractionChangedGenes.Rd delete mode 100644 man/plotInteractivePolygons.Rd delete mode 100644 man/plotPolygons.Rd create mode 100644 man/plotStatDelaunayNetwork.Rd delete mode 100644 man/plot_auto_largeImage_resample.Rd create mode 100644 man/plot_cell_params.Rd create mode 100644 man/plot_cow_params.Rd create mode 100644 man/plot_dimred_params.Rd create mode 100644 man/plot_feat_params.Rd create mode 100644 man/plot_image_params.Rd create mode 100644 man/plot_nn_net_params.Rd create mode 100644 man/plot_output_params.Rd create mode 100644 man/plot_poly_params.Rd create mode 100644 man/plot_spatenr_params.Rd create mode 100644 man/plot_spatnet_params.Rd delete mode 100644 man/select_gimage.Rd delete mode 100644 man/spatCellPlot2D.Rd delete mode 100644 man/spatDimPlot2D.Rd create mode 100644 man/spatNetwDistributions.Rd create mode 100644 man/spatNetwDistributionsDistance.Rd create mode 100644 man/spatNetwDistributionsKneighbors.Rd delete mode 100644 man/spatPlot2D.Rd delete mode 100644 man/spatPlot3D.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 8a6cd2c..13c4bd9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,3 +3,4 @@ ^LICENSE\.md$ ^README\.Rmd$ ^.github$ +^codecov.yml$ diff --git a/DESCRIPTION b/DESCRIPTION index 85a5a7b..6072a3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: GiottoVisuals Title: What the Package Does (One Line, Title Case) -Version: 0.0.0.9001 +Version: 0.0.0.9002 Authors@R: c( person("Ruben", "Dries", email = "rubendries@gmail.com", role = c("aut", "cre")), @@ -28,17 +28,21 @@ Depends: GiottoUtils, GiottoClass Imports: + checkmate, + colorRamp2, cowplot (>= 0.9.4), data.table, ggplot2 (>= 3.1.1), ggrepel, - graphics, + igraph (>= 1.2.4.1), methods, plotly, RColorBrewer (>= 1.1-2), + reshape2, scales (>= 1.0.0), scattermore, - stats + stats, + terra Suggests: ComplexHeatmap (>= 1.20.0), ggalluvial, @@ -47,41 +51,45 @@ Suggests: ggraph, ggsci, GiottoData, - networkd3, + htmlwidgets, + Matrix, + networkD3, NineteenEightyR, nord, palr, palettetown, + png, rcartocolor, - shiny, + remotes, + scatterpie, + tiff, viridis, viridisLite, wesanderson, - testthat (>= 3.0.0), + testthat (>= 3.0.0) Remotes: drieslab/GiottoUtils, drieslab/GiottoClass Config/testthat/edition: 3 Collate: - 'aux_dendrogram.R' - 'aux_heatmap.R' - 'aux_scatterplot.R' - 'aux_violinplot.R' - 'plot_save.R' - 'auxilliary_visuals.R' + 'aux_defaults.R' + 'aux_output.R' + 'aux_save.R' + 'aux_visuals.R' 'color_palettes.R' 'dd.R' - 'defaults.R' 'gg_info_layers.R' 'globals.R' - 'hvf_plots.R' - 'image_visuals.R' - 'interactivity.R' 'package_imports.R' - 'pc_plots.R' - 'plot_output.R' - 'spatial_DE_visuals.R' - 'spatial_in_situ_visuals.R' - 'spatial_interaction_visuals.R' - 'spatial_visuals.R' + 'plot_dendrogram.R' + 'plot_heatmap.R' + 'plot_scatter.R' + 'plot_violin.R' + 'spatialDE_visuals.R' + 'vis_hvf.R' + 'vis_pc.R' + 'vis_spatial.R' + 'vis_spatial_in_situ.R' + 'vis_spatial_interaction.R' + 'viz_spatial_network.R' 'zzz.R' diff --git a/NAMESPACE b/NAMESPACE index b433b96..9a0913d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand export(FSV_show) -export(addPolygonCells) export(cellProximityBarplot) export(cellProximityHeatmap) export(cellProximityNetwork) @@ -9,12 +8,12 @@ export(cellProximitySpatPlot) export(cellProximitySpatPlot2D) export(cellProximitySpatPlot3D) export(cellProximityVisPlot) -export(compareCellAbundance) -export(comparePolygonExpression) export(create_calc_var_HVF_plot) +export(create_cluster_dendrogram) export(create_cov_group_HVF_plot) export(create_cov_loess_HVF_plot) export(create_jackstrawplot) +export(create_screeplot) export(dimCellPlot) export(dimCellPlot2D) export(dimFeatPlot2D) @@ -23,37 +22,28 @@ export(dimPlot) export(dimPlot2D) export(dimPlot3D) export(expand_feature_info) -export(getCellsFromPolygon) export(getColors) export(getDistinctColors) export(gg_simple_scatter) export(plotCCcomDotplot) export(plotCCcomHeatmap) export(plotCPF) -export(plotCPG) export(plotCellProximityFeats) -export(plotCellProximityGenes) export(plotCombineCCcom) -export(plotCombineCPG) export(plotCombineCellCellCommunication) -export(plotCombineCellProximityGenes) export(plotCombineICF) export(plotCombineInteractionChangedFeats) -export(plotCombineInteractionChangedGenes) export(plotHeatmap) export(plotICF) -export(plotICG) export(plotInteractionChangedFeats) -export(plotInteractionChangedGenes) -export(plotInteractivePolygons) export(plotMetaDataCellsHeatmap) export(plotMetaDataHeatmap) export(plotPCA) export(plotPCA_2D) export(plotPCA_3D) -export(plotPolygons) export(plotRankSpatvsExpr) export(plotRecovery) +export(plotStatDelaunayNetwork) export(plotTSNE) export(plotTSNE_2D) export(plotTSNE_3D) @@ -61,7 +51,6 @@ export(plotUMAP) export(plotUMAP_2D) export(plotUMAP_3D) export(plot_output_handler) -export(select_gimage) export(showClusterDendrogram) export(showClusterHeatmap) export(showColorInstructions) @@ -82,6 +71,9 @@ export(spatGenePlot3D) export(spatInSituPlotDensity) export(spatInSituPlotHex) export(spatInSituPlotPoints) +export(spatNetwDistributions) +export(spatNetwDistributionsDistance) +export(spatNetwDistributionsKneighbors) export(spatPlot) export(spatPlot2D) export(spatPlot3D) @@ -91,6 +83,8 @@ import(GiottoUtils) import(ggplot2) import(utils) importClassesFrom(data.table,data.table) +importFrom(data.table,dcast) +importFrom(data.table,dcast.data.table) importFrom(methods,slot) importFrom(stats,cov) importFrom(stats,var) diff --git a/R/defaults.R b/R/aux_defaults.R similarity index 97% rename from R/defaults.R rename to R/aux_defaults.R index 080e36a..93a7873 100644 --- a/R/defaults.R +++ b/R/aux_defaults.R @@ -196,18 +196,18 @@ set_default_color_continuous <- function( # select gradient functions to use grad <- switch( type, - 'fill' = ggplot2::scale_fill_gradient(), - 'color' = ggplot2::scale_color_gradient() + 'fill' = ggplot2::scale_fill_gradient, + 'color' = ggplot2::scale_color_gradient ) gradn <- switch( type, - 'fill' = ggplot2::scale_fill_gradientn(), - 'color' = ggplot2::scale_color_gradientn() + 'fill' = ggplot2::scale_fill_gradientn, + 'color' = ggplot2::scale_color_gradientn ) grad2 <- switch( type, - 'fill' = ggplot2::scale_fill_gradient2(), - 'color' = ggplot2::scale_color_gradient2() + 'fill' = ggplot2::scale_fill_gradient2, + 'color' = ggplot2::scale_color_gradient2 ) # global giotto options @@ -243,6 +243,8 @@ set_default_color_continuous <- function( ...), 'sequential' = evaluate_color_gradient_sequential(colors = colors, reverse = reverse, + gradn = gradn, + grad = grad, ...) ) } @@ -461,6 +463,9 @@ set_default_color_continuous_CCcom_dotplot = function( #' @export showColorInstructions <- function() { + # DT vars + option = default = description = NULL + out = giotto_color_instructions[, paste( '\noption : ', color_blue(option), '\ndefault : ', default, diff --git a/R/plot_output.R b/R/aux_output.R similarity index 55% rename from R/plot_output.R rename to R/aux_output.R index aa957e3..40c897a 100644 --- a/R/plot_output.R +++ b/R/aux_output.R @@ -18,7 +18,7 @@ #' the plot in display device #' @param default_save_name default name to use (should be set by the specific #' plotting function. Users should not interact with this parameter) -#' @param save_param list of plot saving parameters see [showSaveParameters] +#' @param save_param list of plot saving parameters see [showSaveParameters()] #' @param else_return optional. What should be returned instead if the plot #' object is not returned #' @keywords internal @@ -62,13 +62,63 @@ plot_output_handler = function(gobject, ## return plot ## if(return_plot) { - invisible(return(plot_object)) + return(invisible(plot_object)) } else { - return(else_return) + return(invisible(else_return)) } } +# TODO split into two functions +#' plot_output_handler_read = function(gobject, +#' plot_object, +#' save_plot = NA, +#' return_plot = NA, +#' show_plot = NA, +#' default_save_name, +#' save_param, +#' else_return = NULL) { +#' checkmate::assert_class(gobject, 'giotto') +#' checkmate::assert_character(default_save_name) +#' checkmate::assert_list(save_param) +#' +#' instr = instructions(gobject) +#' +#' ## output settings detection ## +#' # IF setting is NA then the appropriate setting from gobject instructions will +#' # be checked and used. +#' # IF setting is NOT NA then the provided value will be used directly. +#' show_plot = ifelse(is.na(show_plot), readGiottoInstructions(instr, param = 'show_plot'), show_plot) +#' save_plot = ifelse(is.na(save_plot), readGiottoInstructions(instr, param = 'save_plot'), save_plot) +#' return_plot = ifelse(is.na(return_plot), readGiottoInstructions(instr, param = 'return_plot'), return_plot) +#' } +#' +#' +#' plot_output_handler_do = function(gplot_out) { +#' checkmate::assert_class(gplot_out, 'giottoPlotOutput') +#' +#' ## print plot ## +#' if(gplot_out$show_plot) { +#' print(gplot_out$plot_object) +#' } +#' +#' ## save plot ## +#' if(gplot_out$save_plot) { +#' do.call('all_plots_save_function', +#' c(list(gobject = instr, +#' plot_object = gplot_out$plot_object, +#' default_save_name = default_save_name), +#' save_param) +#' ) +#' } +#' +#' ## return plot ## +#' if(return_plot) { +#' invisible(return(plot_object)) +#' } else { +#' return(else_return) +#' } +#' } diff --git a/R/plot_save.R b/R/aux_save.R similarity index 98% rename from R/plot_save.R rename to R/aux_save.R index a4b136c..ceac936 100644 --- a/R/plot_save.R +++ b/R/aux_save.R @@ -2,6 +2,7 @@ #' @name plot_save #' @description #' Functions to automatically save plots to directory of interest +#' @param gobject giotto object or giottoInstructions #' @param plot_object ggplot object to plot #' @param save_dir directory to save to #' @param save_folder folder in save_dir to save to @@ -28,7 +29,6 @@ NULL #' @describeIn plot_save ggplot saving. ... passes to cowplot::save_plot -#' @inheritParams data_access_params #' @keywords internal ggplot_save_function = function(gobject, plot_object, @@ -61,7 +61,7 @@ ggplot_save_function = function(gobject, if(is.null(save_name)) { save_name = default_save_name save_name = paste0(plot_count,'-', save_name) - options('giotto.plot_count' = plot_count + 1) + options('giotto.plot_count' = plot_count + 1L) } if(is.null(save_format)) save_format = readGiottoInstructions(gobject, param = 'plot_format') if(is.null(dpi)) dpi = readGiottoInstructions(gobject, param = 'dpi') @@ -122,7 +122,6 @@ ggplot_save_function = function(gobject, #' @describeIn plot_save base and general saving. ... passes to grDevices png, tiff, pdf, svg -#' @inheritParams data_access_params #' @keywords internal general_save_function = function(gobject, plot_object, @@ -240,7 +239,6 @@ general_save_function = function(gobject, } #' @describeIn plot_save wrapper for ggplot and general saving. ... passes to the respective save function -#' @inheritParams data_access_params #' @keywords internal all_plots_save_function = function(gobject, plot_object, diff --git a/R/auxilliary_visuals.R b/R/aux_visuals.R similarity index 80% rename from R/auxilliary_visuals.R rename to R/aux_visuals.R index eb54682..d72b49b 100644 --- a/R/auxilliary_visuals.R +++ b/R/aux_visuals.R @@ -1,145 +1,16 @@ -#' @include plot_save.R +#' @include aux_save.R NULL - -# images #### -#' @title select_gimage -#' @name select_gimage -#' @description selects and (possibly resamples) giotto images for plotting -#' @keywords internal -#' @export -select_gimage = function(gobject, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - spat_unit = NULL, - spat_loc_name = NULL, - feat_type = NULL, - polygon_feat_type = NULL) { - - - if(!is.null(gimage)) gimage = gimage - - - else if(!is.null(image_name)) { - - if(length(image_name) == 1) { - gimage = gobject@images[[image_name]] - if(is.null(gimage)) warning('image_name: ', image_name, ' does not exists') - } else { - gimage = list() - for(gim in 1:length(image_name)) { - gimage[[gim]] = gobject@images[[gim]] - if(is.null(gimage[[gim]])) warning('image_name: ', gim, ' does not exists') - } - } - - } else if(!is.null(largeImage_name)) { - # If there is input to largeImage_name arg - - if(length(largeImage_name) == 1) { - gimage = plot_auto_largeImage_resample(gobject = gobject, - largeImage_name = largeImage_name, - spat_unit = spat_unit, - spat_loc_name = spat_loc_name, - polygon_feat_type = polygon_feat_type, - include_image_in_border = TRUE) - } else { - gimage = list() - for(gim in 1:length(largeImage_name)) { - gimage[[gim]] = plot_auto_largeImage_resample(gobject = gobject, - largeImage_name = largeImage_name[[gim]], - spat_unit = spat_unit, - spat_loc_name = spat_loc_name, - polygon_feat_type = polygon_feat_type, - include_image_in_border = TRUE) - } - } - - } else { - # Default to first image available in images if no input given to image_name or largeImage_name args - image_name = names(gobject@images)[1] - gimage = gobject@images[[image_name]] - - if(is.null(gimage)) warning('image_name: ', image_name, ' does not exist \n') - } - - return(gimage) - -} - - - - -# ggplot helper #### - -#' @title aes_string2 -#' @name aes_string2 -#' @param \dots aes_string parameters -#' @keywords internal -#' @description makes sure aes_string can also be used with names that start with numeric values -#' @keywords internal -aes_string2 <- function(...){ - args <- lapply(list(...), function(x) sprintf("`%s`", x)) - do.call(ggplot2::aes_string, args) -} - - - - - -# giotto point plotting #### - -#' @title giotto_point -#' @name giotto_point -#' @param \dots geom_point parameters -#' @keywords internal -#' @description uses ggplot::geom_point, scattermore::geom_scattermore or scattermore::geom_scattermost -giotto_point = function(plot_method = c('ggplot', 'scattermore', 'scattermost'), - size = 1, - scattermost_xy = NULL, - scattermost_color = NULL, - ...) { - - plot_method = match.arg(arg = plot_method, choices = c('ggplot', 'scattermore', 'scattermost')) - - if(plot_method == 'ggplot') { - ggplot2::geom_point(size = size, - ...) - } else if(plot_method == 'scattermore') { - package_check(pkg_name = "scattermore", - repository = 'CRAN') - scattermore::geom_scattermore(pointsize = size, - ...) - } else if(plot_method == 'scattermost') { - package_check(pkg_name = "scattermore", - repository = 'CRAN') - scattermore::geom_scattermost(xy = scattermost_xy, - color = scattermost_color, - pointsize = size) - } - -} - - - - - - -# heatmap helper #### - +# clusters #### #' @title decide_cluster_order #' @name decide_cluster_order #' @description creates order for clusters -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @inheritParams data_access_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param feats features to use (e.g. genes) -#' @param genes deprecated, use feats #' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") #' @param cluster_order method to determine cluster order (e.g. "size", "correlation", "custom") #' @param cluster_custom_order custom order for clusters @@ -153,18 +24,12 @@ decide_cluster_order = function(gobject, feat_type = NULL, expression_values = c('normalized', 'scaled', 'custom'), feats, - genes = NULL, cluster_column = NULL, cluster_order = c('size', 'correlation', 'custom'), cluster_custom_order = NULL, cor_method = 'pearson', hclust_method = 'ward.D') { - ## deprecated arguments - if(!is.null(genes)) { - feats = genes - } - # Set feat_type and spat_unit spat_unit = set_default_spat_unit(gobject = gobject, spat_unit = spat_unit) @@ -172,7 +37,7 @@ decide_cluster_order = function(gobject, spat_unit = spat_unit, feat_type = feat_type) - # epxression data + # expression data values = match.arg(expression_values, unique(c('normalized', 'scaled', 'custom', expression_values))) expr_values = get_expression_values(gobject = gobject, spat_unit = spat_unit, @@ -234,6 +99,74 @@ decide_cluster_order = function(gobject, +# ggplot helper #### + +#' @title aes_string2 +#' @name aes_string2 +#' @param \dots aes_string parameters +#' @keywords internal +#' @description makes sure aes_string can also be used with names that start with numeric values +#' @keywords internal +aes_string2 <- function(...){ + args <- lapply(list(...), function(x) sprintf("`%s`", x)) + do.call(ggplot2::aes_string, args) +} + + +#' @title gg_input +#' @name gg_input +#' @description modular handling of ggplot inputs for functions that may either +#' append additional information to a ggplot object or be where the ggobject is +#' first made. +#' @param ggobject ggplot object or NULL +#' @keywords internal +gg_input = function(ggobject) { + if(is.null(ggobject)) { + return(ggplot2::ggplot()) + } else { + checkmate::assert_class(ggobject, 'ggplot') + return(ggobject) + } +} + + +# giotto point plotting #### + +#' @title giotto_point +#' @name giotto_point +#' @param \dots geom_point parameters +#' @keywords internal +#' @description uses ggplot::geom_point, scattermore::geom_scattermore or scattermore::geom_scattermost +giotto_point = function(plot_method = c('ggplot', 'scattermore', 'scattermost'), + size = 1, + scattermost_xy = NULL, + scattermost_color = NULL, + ...) { + + plot_method = match.arg(arg = plot_method, choices = c('ggplot', 'scattermore', 'scattermost')) + + if(plot_method == 'ggplot') { + ggplot2::geom_point(size = size, + ...) + } else if(plot_method == 'scattermore') { + package_check(pkg_name = "scattermore", + repository = 'CRAN') + scattermore::geom_scattermore(pointsize = size, + ...) + } else if(plot_method == 'scattermost') { + package_check(pkg_name = "scattermore", + repository = 'CRAN') + scattermore::geom_scattermost(xy = scattermost_xy, + color = scattermost_color, + pointsize = size) + } + +} + + + + + # rescale values #### diff --git a/R/color_palettes.R b/R/color_palettes.R index b541865..cff0a38 100644 --- a/R/color_palettes.R +++ b/R/color_palettes.R @@ -22,7 +22,7 @@ #' @examples #' f <- system.file("ex/elev.tif", package="terra") #' r <- terra::rast(f) -#' terra::plot(r, col = getColors(100, 'Spectral')) +#' terra::plot(r, col = getColors(pal = 'Spectral', n = 100)) #' @export getColors <- function(pal = 'viridis', n = 100, diff --git a/R/dd.R b/R/dd.R index eff3361..266b419 100644 --- a/R/dd.R +++ b/R/dd.R @@ -17,12 +17,10 @@ - - # Data Access #### -#' data_access_params +#' Params documentation template: data_access_params #' #' @name data_access_params #' @param gobject giotto object @@ -35,31 +33,125 @@ NULL +# Plotting #### +#' Params documentation template: plot_cell_params +#' @name plot_cell_params +#' @param cell_color character. what to color cells by (e.g. metadata col or +#' spatial enrichment col) +#' @param color_as_factor logical. convert color column to factor. discrete colors +#' are used when this is TRUE. continuous colors when FALSE. +#' @param cell_color_code character. discrete colors to use. palette to use or +#' named vector of colors +#' @param cell_color_gradient character. continuous colors to use. palette to +#' use or vector of colors to use (minimum of 2). +#' @keywords internal +NULL +#' Params documentation template: plot_feat_params +#' @name plot_feat_params +#' @param feats_color_code code to color the provided features +#' @param feat_shape_code code to shape the provided feature types +#' @keywords internal +NULL +#' Params documentation template: plot_poly_params +#' @name plot_poly_params +#' @param show_polygon overlay polygon information (e.g. cell shape) +#' @param use_overlap use polygon and feature coordinates overlap results +#' @param polygon_feat_type feature type associated with polygon information +#' @param polygon_color color for polygon border +#' @param polygon_bg_color color for polygon background (overruled by polygon_fill) +#' @param polygon_fill character. what to color to fill polgyons by (e.g. metadata +#' col or spatial enrichment col) +#' @param polygon_fill_gradient polygon fill gradient colors given in order from low to high +#' @param polygon_fill_gradient_midpoint value to set as gradient midpoint (optional). If +#' left as \code{NULL}, the median value detected will be chosen +#' @param polygon_fill_gradient_style either 'divergent' (midpoint is used in +#' color scaling) or 'sequential' (scaled based on data range) +#' @param polygon_fill_as_factor is fill color a factor +#' @param polygon_fill_code code to color the fill column +#' @param polygon_alpha alpha of polygon +#' @param polygon_line_size line width of the polygon's outline +#' @keywords internal +NULL -# Plotting #### +#' Params documentation template: plot_dimred_params +#' @name plot_dimred_params +#' @param dim_reduction_to_use character. dimension reduction to use +#' @param dim_reduction_name character. dimension reduction name +#' @param dim1_to_use numeric. dimension to use on x-axis +#' @param dim2_to_use numeric. dimension to use on y-axis +#' @param dim3_to_use numeric. dimension to use on z-axis +#' @param dim_point_shape point with border or not (border or no_border) +#' @param dim_point_size size of points in dim. reduction space +#' @param dim_point_alpha transparancy of point in dim. reduction space +#' @param dim_point_border_col border color of points in dim. reduction space +#' @param dim_point_border_stroke border stroke of points in dim. reduction space +#' @keywords internal +NULL + +#' Params documentation template: plot_nn_net_params +#' @name plot_nn_net_params +#' @param show_NN_network logical. Show underlying NN network +#' @param nn_network_to_use character. type of NN network to use (kNN vs sNN) +#' @param network_name character. name of NN network to use, if show_NN_network = TRUE +#' @param nn_network_name character. name of NN network to use, if show_NN_network = TRUE +#' @param network_color color of NN network +#' @param nn_network_alpha column to use for alpha of the edges +#' @keywords internal +NULL + +#' Params documentation template: plot_spatnet_params +#' @name plot_spatnet_params +#' @param show_spatial_network show spatial network +#' @param spatial_network_name name of spatial network to use +#' @param spat_network_name name of spatial network to use +#' @param spat_network_color color of spatial network +#' @param spatial_network_color color of spatial network +#' @param spat_network_alpha alpha of spatial network +#' @keywords internal +NULL + +#' Params documentation template: plot_spatenr_params +#' @name plot_spatenr_params +#' @param spat_enr_names character. names of spatial enrichment results to include +#' @keywords internal +NULL +#' Params documentation template: plot_image_params +#' @name plot_image_params +#' @param show_image show a tissue background image +#' @param gimage a giotto image +#' @param image_name name of a giotto image or multiple images with group_by +#' @param largeImage_name name of a giottoLargeImage or multiple images with group_by +#' @keywords internal +NULL -#' plot_params + +#' Params documentation template: plot_params #' #' @name plot_params -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors -#' @param cell_color_gradient vector with 3 colors for numeric data #' -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits +#' @param group_by character. Create multiple plots based on cell annotation column +#' @param group_by_subset character. subset the group_by factor column +#' +#' @param gradient_midpoint numeric. midpoint for color gradient +#' @param gradient_style either 'divergent' (midpoint is used in color scaling) +#' or 'sequential' (scaled based on data range) +#' @param gradient_limits numeric vector with lower and upper limits +#' @param gradient_color character. continuous colors to use. palette to +#' use or vector of colors to use (minimum of 2). #' #' @param select_cell_groups select subset of cells/clusters based on cell_color parameter #' @param select_cells select subset of cells based on cell IDs #' #' @param show_other_cells display not selected cells #' @param other_cell_color color for not selected cells +#' @param other_cell_alpha (0 to 1) alpha for not selected cells +#' @param other_cells_alpha (0 to 1) alpha for not selected cells #' @param other_point_size point size for not selected cells #' #' @param show_cluster_center plot center of selected clusters @@ -69,17 +161,6 @@ NULL #' @param center_point_border_col border color of center points #' @param center_point_border_stroke border stroke size of center points #' -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' -#' @param spat_enr_names names of spatial enrichment results to include -#' -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE -#' #' @param label_size size of labels #' @param label_fontface font of labels #' @@ -90,23 +171,35 @@ NULL #' @param point_border_col color of border around points #' @param point_border_stroke stroke size of border around points #' -#' @param title title for plot, defaults to cell_color parameter -#' @param show_legend show legend +#' @param title character. title for plot, defaults to cell_color parameter +#' @param show_legend logical. show legend #' @param legend_text size of legend text #' @param legend_symbol_size size of legend symbols #' @param background_color color of plot background #' @param axis_text size of axis text #' @param axis_title size of axis title -#' +#' @keywords internal +NULL + + +#' Params documentation template: plot_cow_params +#' @name plot_cow_params #' @param cow_n_col cowplot param: how many columns #' @param cow_rel_h cowplot param: relative heights of rows (e.g. c(1,2)) #' @param cow_rel_w cowplot param: relative widths of columns (e.g. c(1,2)) #' @param cow_align cowplot param: how to align -#' -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] +#' @keywords internal +NULL + +#' Params documentation template: plot_output_params +#' @name plot_output_params +#' @param show_plot logical. show plot +#' @param return_plot logical. return ggplot object +#' @param save_plot logical. save the plot #' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} #' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @keywords internal NULL + + + diff --git a/R/gg_info_layers.R b/R/gg_info_layers.R index d512c3c..70c200e 100644 --- a/R/gg_info_layers.R +++ b/R/gg_info_layers.R @@ -815,15 +815,12 @@ plot_cell_polygon_layer = function(ggobject = NULL, alpha = 0.5, size = 2) { - # data.table variables - final_fill = NULL - # check fill column if(!is.null(fill)) { if(fill_as_factor == TRUE) { - polygon_dt[, final_fill := as.factor(get(fill))] + polygon_dt[, 'final_fill' := as.factor(get(fill))] } else { - polygon_dt[, final_fill := get(fill)] + polygon_dt[, 'final_fill' := get(fill)] } } @@ -927,7 +924,7 @@ plot_feature_points_layer = function(ggobject, plot_method = match.arg(arg = plot_method, choices = c('ggplot', 'scattermore', 'scattermost')) # data.table vars - feat_ID = NULL + feat_ID = x = y = NULL spatial_feat_info_subset = spatial_feat_info[feat_ID %in% unlist(feats)] diff --git a/R/image_visuals.R b/R/image_visuals.R deleted file mode 100644 index 44efac2..0000000 --- a/R/image_visuals.R +++ /dev/null @@ -1,179 +0,0 @@ -## ** image object compatibility #### - -#' @title Optimized largeImage resampling -#' @name plot_auto_largeImage_resample -#' @description Downsample \code{largeImage} for plotting. Uses \code{\link[terra]{spatSample}} -#' to load only a portion of the original image, speeding up plotting and lowering memory -#' footprint. -#' -#' Default behavior of \code{spatSample} is to crop if only a smaller ROI is needed for plotting -#' followed by the sampling process in order to reduce wasted sampling by focusing the -#' sample space. For very large ROIs, this crop can be time intensive and require -#' writing to disk. -#' -#' This function examines the ROI dimensions as defined through the limits of the spatial -#' locations to be plotted, and decides between the following two methods in order to -#' avoid this issue: -#' \itemize{ -#' \item{\strong{Method A.} First crop original image and then sample n values where -#' n = 500,000 to generate final image} -#' \item{\strong{Method B.} First oversample n values and then crop, where n = 500,000 -#' scaled by a value >1. Scaling factor increases the smaller the ROI is and -#' is defined by: original dimensions/crop dimensions where the larger ratio between -#' x and y dims is chosen. Scale factor is capped by \code{max_resample_scale}} -#' } -#' Control points for this function are set by \code{max_crop} which decides the max -#' ROI area after which switchover to method B happens in order to avoid laborious crops -#' and \code{max_resample_scale} which determines the maximum scale factor for number -#' of values to sample. Both values can be adjusted depending on system resources. -#' Additionally, \code{flex_resample} determines if this switching behavior happens. -#' When set to \code{FALSE}, only method A is used. -#' @param gobject \code{gobject} containing \code{largeImage} object -#' @param giottoLargeImage \code{largeImage} object to resample if not provided through -#' \code{gobject} and \code{largeImage_name} -#' @param largeImage_name name of \code{largeImage} in \code{gobject} -#' @param spat_unit spatial unit -#' @param spat_loc_name name of spatial locations to plot -#' @param polygon_feat_type name of polygon/spatial_info to plot -#' @param include_image_in_border [boolean] expand the extent sampled to also show image in -#' border regions not included in spatlocs. This prevents images in plots from -#' being sharply cut off around the furthest spatial locations. (default is \code{TRUE}) -#' @param flex_resample [boolean] Whether to allow automatic selection of sampling -#' workflow as defined in details sections. (default is \code{TRUE}) -#' @param max_crop maximum crop size allowed for \strong{method A} before switching to -#' \strong{method B} (see description) -#' @param max_resample_scale maximum cells allowed to resample to compensate for -#' decreased resolution when cropping after sampling -#' @return a \code{giottoLargeImage} cropped and resampled properly for plotting -#' @seealso \code{\link[terra]{spatSample}} -#' @keywords internal -plot_auto_largeImage_resample = function(gobject, - giottoLargeImage = NULL, - largeImage_name = NULL, - spat_unit = NULL, - spat_loc_name = NULL, - polygon_feat_type = NULL, - include_image_in_border = TRUE, - flex_resample = TRUE, - max_crop = 1e+08, - max_resample_scale = 100) { - - # If no giottoLargeImage, select specified giottoLargeImage. If none specified, select first one. - if(is.null(giottoLargeImage)) { - giottoLargeImage = get_giottoLargeImage(gobject = gobject, - name = largeImage_name) - } - - # Set spat_unit - spat_unit = set_default_spat_unit(gobject = gobject, - spat_unit = spat_unit) - - # Get spatial locations - cell_locations = get_spatial_locations(gobject = gobject, - spat_unit = spat_unit, - spat_loc_name = spat_loc_name, - output = 'data.table', - copy_obj = TRUE) - - # If no spatial locations are available, rely on first existing polygon extent - if(is.null(cell_locations)) { - sub_obj = get_polygon_info(gobject = gobject, - polygon_name = polygon_feat_type, - return_giottoPolygon = TRUE) - - # Find centroids then if there are more than 100, sample 30% - sub_obj = calculate_centroids_polygons(sub_obj) - sampleSize = ifelse(nrow(sub_obj) > 100, ceiling(0.3*nrow(sub_obj)), nrow(sub_obj)) - - centroid_sample_DT = slot(sub_obj, 'spatVectorCentroids') %>% - sample(., size = sampleSize) %>% - terra::geom() %>% - as.data.table() - - cell_locations = data.table::data.table(sdimx = c(centroid_sample_DT$x), - sdimy = c(centroid_sample_DT$y)) - - # sub_ext = terra::ext(sub_obj)[1:4] - # cell_locations = data.table::data.table(sdimx = c(sub_ext[['xmin']], sub_ext[['xmax']]), - # sdimy = c(sub_ext[['ymin']], sub_ext[['ymax']])) - } - - if(is.null(cell_locations)) stop('No spatial locations or polygons discovered.\n Cannot determine largeImage resample extent\n') - - # Get image extent minmax - im_minmax = terra::ext(giottoLargeImage@raster_object)[1:4] - # Determine crop - if(isTRUE(include_image_in_border)) { - # with crop padding - x_range = range(cell_locations$sdimx) - y_range = range(cell_locations$sdimy) - x_halfPaddedRange = diff(x_range)*0.625 - y_halfPaddedRange = diff(y_range)*0.625 - x_midpt = mean(x_range) - y_midpt = mean(y_range) - - xmax_crop = x_midpt + x_halfPaddedRange - xmin_crop = x_midpt - x_halfPaddedRange - ymax_crop = y_midpt + y_halfPaddedRange - ymin_crop = y_midpt - y_halfPaddedRange - - if(xmin_crop < im_minmax[['xmin']]) xmin_crop = im_minmax[['xmin']] - if(xmax_crop > im_minmax[['xmax']]) xmax_crop = im_minmax[['xmax']] - if(ymin_crop < im_minmax[['ymin']]) ymin_crop = im_minmax[['ymin']] - if(ymax_crop > im_minmax[['ymax']]) ymax_crop = im_minmax[['ymax']] - } else { - # no crop padding - x_range = range(cell_locations$sdimx) - y_range = range(cell_locations$sdimy) - xmin_crop = x_range[1] - xmax_crop = x_range[2] - ymin_crop = y_range[1] - ymax_crop = y_range[2] - } - - # setup crop extent object - crop_ext = terra::ext(xmin_crop, xmax_crop, - ymin_crop, ymax_crop) - - # zoom and resample giottoLargeImage - crop_xdim = abs(xmax_crop - xmin_crop) - crop_ydim = abs(ymax_crop - ymin_crop) - crop_area_px = crop_xdim * giottoLargeImage@scale_factor[['x']] * giottoLargeImage@scale_factor[['y']] * crop_ydim - im_xdim = abs(im_minmax[2] - im_minmax[1]) - im_ydim = abs(im_minmax[2] - im_minmax[1]) - crop_relative_scale = max(im_xdim/crop_xdim, im_ydim/crop_ydim) - - if(!isTRUE(flex_resample) | crop_area_px <= max_crop) { - # METHOD A: Crop if needed then resample to final image - if(!isTRUE(flex_resample) & crop_area_px > max_crop) { - warning('Plotting large regions with flex_resample == FALSE will be costly in time and drive space.') - } - # For ROIs with area smaller than max_crop OR if flex_resample is FALSE - crop_image = terra::crop(x = giottoLargeImage@raster_object, - y = crop_ext) - giottoLargeImage@raster_object = terra::spatSample(crop_image, - size = 500000, - method = 'regular', - as.raster = TRUE) - } else { - # METHOD B: Resample then crop to final image - # Sample n values where n = default val scaled by a value >1 - if(crop_relative_scale <= max_resample_scale) { - # Scale factor is fullsize image dim/crop dim. Larger of the two ratios is chosen - resample_image = terra::spatSample(giottoLargeImage@raster_object, - size = round(500000 * crop_relative_scale), - method = 'regular', - as.raster = TRUE) - } else { - # For scale factors that are too large, scaling is capped by max_resample_scale - resample_image = terra::spatSample(giottoLargeImage@raster_object, - size = 500000 * max_resample_scale, - method = 'regular', - as.raster = TRUE) - } - giottoLargeImage@raster_object = terra::crop(x = resample_image, - y = crop_ext) - } - - return(giottoLargeImage) -} diff --git a/R/interactivity.R b/R/interactivity.R deleted file mode 100644 index 7603d16..0000000 --- a/R/interactivity.R +++ /dev/null @@ -1,477 +0,0 @@ - -# ** interactive plotting #### - -#' Select image regions by plotting interactive polygons -#' -#' @description Plot interactive polygons on an image and retrieve the polygons coordinates. -#' @param x A `ggplot` or `rast` plot object to draw polygons on -#' @param width,height An integer, defining the width/height in pixels. -#' @param ... Graphical parameters passed on to `polygon` or `geom_point`. -#' -#' @return A `data.table` containing x,y coordinates from the plotted polygons. -#' -#' -#' @export -plotInteractivePolygons <- function(x, - width = "auto", - height = "auto", - ...) { - - package_check(pkg_name = 'miniUI', repository = 'CRAN') - package_check(pkg_name = 'shiny', repository = 'CRAN') - - # data.table variables - y = name = NULL - - if(is.null(x)) stop('plot object is empty') - - ## find min and max values for spatRaster image - if("SpatRaster" %in% class(x)) { - ui <- miniUI::miniPage( - miniUI::gadgetTitleBar("Plot Interactive Polygons"), - miniUI::miniContentPanel( - shiny::textInput("polygon_name", label = "Polygon name", value = "polygon 1"), - shiny::sliderInput("xrange", label = "x coordinates", - min = min(terra::ext(x))[1], - max = max(terra::ext(x))[1], - value = c(min(terra::ext(x))[1], - max(terra::ext(x))[1])) , - shiny::sliderInput("yrange", label = "y coordinates", - min = min(terra::ext(x))[2], - max = max(terra::ext(x))[2], - value = c(min(terra::ext(x))[2], - max(terra::ext(x))[2])) , - shiny::plotOutput("plot", click = "plot_click") - ) - ) - - } else { ## find min and max values for non-spatRaster image - ui <- miniUI::miniPage( - miniUI::gadgetTitleBar("Plot Interactive Polygons"), - miniUI::miniContentPanel( - shiny::textInput("polygon_name", label = "Polygon name", value = "polygon 1"), - shiny::sliderInput("xrange", label = "x coordinates", - min = min(x[["layers"]][[1]]$data$sdimx), - max = max(x[["layers"]][[1]]$data$sdimx), - value = c(min(x[["layers"]][[1]]$data$sdimx), - max(x[["layers"]][[1]]$data$sdimx))) , - shiny::sliderInput("yrange", label = "y coordinates", - min = min(x[["layers"]][[1]]$data$sdimy), - max = max(x[["layers"]][[1]]$data$sdimy), - value = c(min(x[["layers"]][[1]]$data$sdimy), - max(x[["layers"]][[1]]$data$sdimy))) , - shiny::plotOutput("plot", click = "plot_click") - ) - ) - } - - server <- function(input, output,session) { - output$plot <- shiny::renderPlot({ - if ("ggplot" %in% class(x)) { - x$coordinates$default <- TRUE - x + - geom_polygon(data = clicklist(), aes(x,y, color = name, fill = name), - alpha = 0, ...) + - coord_fixed(xlim = c(input$xrange[1], input$xrange[2]), - ylim = c(input$yrange[1], input$yrange[2])) + - theme(legend.position = 'none') - } else { - terra::plot(x) - lapply(split(clicklist(), by = "name"), function (x) graphics::polygon(x$x, x$y, ...) ) - } - }, res = 96, width = width, height = height) - - clicklist <- shiny::reactiveVal(data.table::data.table(x = numeric(), y = numeric(), name = character())) # empty table - shiny::observeEvent(input$plot_click, { - click_x <- input$plot_click$x - click_y <- input$plot_click$y - polygon_name <- input$polygon_name - temp <- clicklist() # get the table of past clicks - temp <- rbind(temp,data.table::data.table(x = click_x, y = click_y, name = polygon_name)) - clicklist(temp) - }) - - - output$info <- shiny::renderTable(clicklist()) - - shiny::observeEvent(input$done, { - returnValue <- clicklist() - shiny::stopApp(returnValue) - }) - } - shiny::runGadget(ui, server) -} - - -#' Get cells located within the polygons area -#' -#' @param gobject A Giotto object -#' @param polygon_name name of polygon selections -#' @param spat_unit spatial unit, default = 'cell' -#' @param spat_loc_name name of spatial locations to use, default = 'raw' -#' @param polygons character. A vector with polygon names to extract cells from. If NULL, cells from all polygons are retrieved -#' -#' @return A terra 'SpatVector' with cell ID, x y coordinates, and polygon ID where each cell is located in. -#' -#' @export -#' -#' @examples -#' -#' \dontrun{ -#' ## Plot interactive polygons -#' my_spatPlot <- spatPlot2D(gobject = my_giotto_object, -#' show_image = TRUE, -#' point_alpha = 0.75, -#' save_plot = FALSE) -#' my_polygon_coords <- plotInteractivePolygons(my_spatPlot) -#' -#' ## Add polygon coordinates to Giotto object -#' my_giotto_polygons <- createGiottoPolygonsFromDfr(my_polygon_coords) -#' my_giotto_object <- addGiottoPolygons(gobject = my_giotto_object, -#' gpolygons = list(my_giotto_polygons)) -#' -#' ## Get cells located within polygons area -#' getCellsFromPolygon(my_giotto_object) -#' -#' ## Get only cells from polygon 1 -#' getCellsFromPolygon(my_giotto_object, polygons = "polygon 1") -#' } -#' -getCellsFromPolygon <- function(gobject, - polygon_name = 'selections', - spat_unit = "cell", - spat_loc_name = 'raw', - polygons = NULL) { - - if (!inherits(gobject, "giotto")) { - stop("gobject needs to be a giotto object") - } - - ## get polygons spatial info - polygon_spatVector = get_polygon_info(gobject = gobject, - polygon_name = polygon_name, - return_giottoPolygon = FALSE) - # polygon_spatVector <- slot(slot(gobject, "spatial_info")[[spat_unit]], "spatVector") - - ## get cell spatial locations - spatial_locs <- get_spatial_locations(gobject = gobject, - spat_unit = spat_unit, - spat_loc_name = spat_loc_name, - output = 'data.table', - copy_obj = TRUE) - - ## convert cell spatial locations to spatVector - cells_spatVector <- terra::vect(as.matrix(spatial_locs[,1:2]), - type = "points", - atts = spatial_locs) - - polygonCells <- terra::intersect(cells_spatVector, polygon_spatVector) - - if(!is.null(polygons)) { - polygonCells <- terra::subset(polygonCells, polygonCells$poly_ID %in% polygons) - } - - return(polygonCells) -} - - -#' Add corresponding polygon IDs to cell metadata -#' -#' @param gobject A Giotto object -#' @param polygon_name name of polygon selections -#' @param feat_type feature name where metadata will be added -#' @param spat_unit spatial unit -#' @param spat_loc_name name of spatial locations to use -#' @param polygons polygon names to plot (e.g. 'polygon_1'). If NULL, plots all available polygons -#' @param na.label polygon label for cells located outside of polygons area. Default = "no_polygon" -#' -#' @return A Giotto object with a modified cell_metadata slot that includes the -#' polygon name where each cell is located or no_polygon label if the cell is not located -#' within a polygon area -#' -#' @export -#' -#' @examples -#' -#' \dontrun{ -#' ## Plot interactive polygons -#' my_polygon_coords <- plotInteractivePolygons(my_spatPlot) -#' -#' ## Add polygon coordinates to Giotto object -#' my_giotto_polygons <- createGiottoPolygonsFromDfr(my_polygon_coords) -#' my_giotto_object <- addGiottoPolygons(gobject = my_giotto_object, -#' gpolygons = list(my_giotto_polygons)) -#' -#' ## Add polygon IDs to cell metadata -#' my_giotto_object <- addPolygonCells(my_giotto_object) -#' } -#' -addPolygonCells <- function(gobject, - polygon_name = 'selections', - spat_unit = "cell", - spat_loc_name = 'raw', - feat_type = "rna", - polygons = NULL, - na.label = "no_polygon") { - - ## verify gobject - if (!inherits(gobject, "giotto")) { - stop("gobject needs to be a giotto object") - } - - ## get cells within each polygon - polygon_cells <- data.table::as.data.table(getCellsFromPolygon(gobject = gobject, - polygon_name = polygon_name, - spat_unit = spat_unit, - spat_loc_name = spat_loc_name, - polygons = polygons)) - data.table::setnames(polygon_cells, old = 'poly_ID', new = polygon_name) - - ## get original cell metadata - cell_metadata <- get_cell_metadata(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - output = 'data.table', - copy_obj = TRUE) - - - ## add polygon ID to cell metadata - polygon_cells = polygon_cells[,c("cell_ID", polygon_name), with = FALSE] - new_cell_metadata <- data.table::merge.data.table(x = cell_metadata, - y = polygon_cells, - by = "cell_ID", all.x = TRUE) - - ## assign a default ID to cells outside of polygons - selection_values = new_cell_metadata[[polygon_name]] - selection_values = ifelse(is.na(selection_values), na.label, selection_values) - new_cell_metadata[, c(polygon_name) := selection_values] - - #new_cell_metadata[is.na(new_cell_metadata$poly_ID), "poly_ID"] <- na.label - - ## keep original order of cells - new_cell_metadata <- new_cell_metadata[match(cell_metadata$cell_ID, - new_cell_metadata$cell_ID), ] - - gobject <- addCellMetadata(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - new_metadata = new_cell_metadata[,-1]) - - return(gobject) -} - - -#' Compare gene expression between polygon areas -#' -#' @param gobject A Giotto object -#' @param polygon_name name of polygon selections -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") -#' @param selected_feats vector of selected features to plot -#' @param expression_values gene expression values to use ("normalized", "scaled", "custom") -#' @param method method to use to detect differentially expressed feats ("scran", "gini", "mast") -#' @param \dots Arguments passed to \link[ComplexHeatmap]{Heatmap} -#' -#' @return A ComplexHeatmap::Heatmap object -#' @export -comparePolygonExpression <- function(gobject, - polygon_name = 'selections', - spat_unit = "cell", - feat_type = "rna", - selected_feats = "top_genes", - expression_values = "normalized", - method = "scran", - ...) { - - # verify gobject - if (!inherits(gobject, "giotto")) { - stop("gobject needs to be a giotto object") - } - - # get expression - my_expression = get_expression_values(gobject, - values = expression_values, - spat_unit = spat_unit, - feat_type = feat_type, - output = 'matrix') - - # get cell_ID and poly_ID from metadata - my_metadata = get_cell_metadata(gobject, - spat_unit = spat_unit, - feat_type = feat_type, - output = 'data.table', - copy_obj = TRUE) - - my_metadata = my_metadata[,c("cell_ID", polygon_name), with = FALSE] - - if (length(selected_feats) == 1 && selected_feats == "top_genes") { - # find top features - scran_results <- findMarkers_one_vs_all(gobject, - spat_unit = "cell", - feat_type = "rna", - method = method, - expression_values = "normalized", - cluster_column = polygon_name, - min_feats = 10) - - selected_feats <- scran_results[, head(.SD, 2), by = 'cluster']$feats - } - # select features - my_expression <- my_expression[selected_feats,] - - # convert to data frame - my_rownames <- rownames(my_expression) - - # calculate zscore - - my_zscores <- my_expression - - for (gene in my_rownames) { - mean_expression_gene <- mean(my_expression[gene,]) - sd_expression_gene <- stats::sd(my_expression[gene,]) - for (cell in colnames(my_expression)) { - my_zscores[gene, cell] <- (my_expression[gene, cell]-mean_expression_gene)/sd_expression_gene - } - - } - - # calculate mean zscore per polygon - my_zscores_mean <- data.table::data.table(feat_ID = my_rownames) - - for(i in unique(my_metadata[[polygon_name]])) { - my_cells <- my_metadata[my_metadata[[polygon_name]] == i, "cell_ID" ] - my_sub_zscores <- my_zscores[,my_cells$cell_ID] - mean_zscores <- Matrix::rowMeans(my_sub_zscores) - my_zscores_mean <- cbind(my_zscores_mean, mean_zscores) - } - - my_zscores_mean <- as.matrix(my_zscores_mean[,-1]) - colnames(my_zscores_mean) <- unique(my_metadata[[polygon_name]]) - rownames(my_zscores_mean) <- my_rownames - - # plot heatmap - my_heatmap <- ComplexHeatmap::Heatmap(my_zscores_mean, - heatmap_legend_param = list(title = "Normalized mean z score"), - cluster_rows = FALSE, - cluster_columns = FALSE, - column_order = sort(colnames(my_zscores_mean)), - ...) - return(my_heatmap) -} - -#' Compare cell types percent per polygon -#' -#' @param gobject A Giotto object -#' @param polygon_name name of polygon selections -#' @param spat_unit spatial unit. Default = "cell" -#' @param feat_type feature type. Default = "rna" -#' @param cell_type_column column name within the cell metadata table to use -#' @param ... Additional parameters passed to ComplexHeatmap::Heatmap -#' -#' @return A ComplexHeatmap::Heatmap -#' @export -compareCellAbundance <- function(gobject, - polygon_name = 'selections', - spat_unit = "cell", - feat_type = "rna", - cell_type_column = "leiden_clus", - ...) { - - # verify gobject - if (!inherits(gobject, "giotto")) { - stop("gobject needs to be a giotto object") - } - - # get poly_ID and cell_type from metadata - my_metadata <- get_cell_metadata(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - output = 'data.table', - copy_obj = TRUE) - columns_to_select = c(polygon_name, cell_type_column) - my_metadata <- my_metadata[, columns_to_select, with = FALSE] - - # count cell_type per polygon - my_cell_counts <- table(my_metadata) - - my_cell_percent <- 100*my_cell_counts/rowSums(my_cell_counts) - - # convert to matrix - my_matrix <- Matrix::as.matrix(my_cell_percent) - - rownames(my_matrix) <- rownames(my_cell_percent) - colnames(my_matrix) <- colnames(my_cell_percent) - - # plot heatmap - my_heatmap <- ComplexHeatmap::Heatmap(t_flex(my_matrix), - heatmap_legend_param = list(title = "Cell type percent\nper polygon"), - cluster_rows = FALSE, - cluster_columns = FALSE, - ...) - return(my_heatmap) -} - - -#' Plot stored polygons -#' -#' @param gobject A Giotto object with polygon coordinates -#' @param polygon_name name of polygon selections -#' @param x A ggplot2, spatPlot or terra::rast object -#' @param spat_unit spatial unit -#' @param polygons character. Vector of polygon names to plot. If NULL, all polygons are plotted -#' @param ... Additional parameters passed to ggplot2::geom_polygon() or graphics::polygon -#' @import ggplot2 -#' -#' @return A ggplot2 image -#' @export -#' -plotPolygons <- function(gobject, - polygon_name = 'selections', - x, - spat_unit = "cell", - polygons = NULL, - ...) { - - ## verify gobject - if (!inherits(gobject, "giotto")) { - stop("gobject must be a Giotto object") - } - - y = geom = NULL - - ## verify plot exists - if(is.null(x)) stop('A plot object must be provided') - - ## get polygons spatial info - polygon_spatVector <- get_polygon_info(gobject = gobject, - polygon_name = polygon_name, - return_giottoPolygon = FALSE) - - coordinates <- terra::geom(polygon_spatVector, df = TRUE) - - if(!is.null(polygons)) { - ## replace polygon names - for (i in 1:length(unlist(polygon_spatVector[["poly_ID"]])) ) { - coordinates$geom <- replace(coordinates$geom, - coordinates$geom == i, - unlist(polygon_spatVector[["poly_ID"]])[i]) - } - - coordinates <- coordinates[coordinates$geom %in% polygons,] - } - - ## plot over ggplot or spatPlot - if(inherits(x, "ggplot")) { - x + - geom_polygon(data = coordinates, - aes(x, y, colour = factor(geom), group = geom), - alpha = 0, show.legend = FALSE, ...) + - theme(legend.position = 'none') - } else { - terra::plot(x) - lapply(split(coordinates, by = "name"), - function (x) graphics::polygon(x$x, x$y, ...) ) - } - -} - diff --git a/R/package_imports.R b/R/package_imports.R index 575fa5d..a43d5cf 100644 --- a/R/package_imports.R +++ b/R/package_imports.R @@ -1,5 +1,6 @@ # data.table class import needed for DT dispatch to work properly #' @importClassesFrom data.table data.table +#' @importFrom data.table dcast dcast.data.table #' @importFrom stats cov var #' @importFrom methods slot #' @import GiottoUtils diff --git a/R/aux_dendrogram.R b/R/plot_dendrogram.R similarity index 50% rename from R/aux_dendrogram.R rename to R/plot_dendrogram.R index a2ff7c4..427b5e8 100644 --- a/R/aux_dendrogram.R +++ b/R/plot_dendrogram.R @@ -1,9 +1,8 @@ #' @title showClusterDendrogram #' @name showClusterDendrogram #' @description Creates dendrogram for selected clusters. -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") #' @param cor correlation score to calculate distance (e.g. "pearson", "spearman") @@ -11,12 +10,7 @@ #' @param h height of horizontal lines to plot #' @param h_color color of horizontal lines #' @param rotate rotate dendrogram 90 degrees -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @param ... additional parameters passed to \code{\link[ggdendro]{ggdendrogram}} +#' @inheritDotParams ggdendro::ggdendrogram #' @return ggplot #' @details Expression correlation dendrogram for selected clusters. #' @export @@ -33,15 +27,13 @@ showClusterDendrogram <- function(gobject, show_plot = NA, return_plot = NA, save_plot = NA, - save_param = list(), + save_param = list(), default_save_name = 'showClusterDendrogram', ...) { - # verify if optional package is installed package_check(pkg_name = "ggdendro", repository = "CRAN") - cor = match.arg(cor, c('pearson', 'spearman')) values = match.arg(expression_values, unique(c('normalized', 'scaled', 'custom', expression_values))) # Set feat_type and spat_unit @@ -56,41 +48,91 @@ showClusterDendrogram <- function(gobject, feat_type = feat_type, expression_values = values, metadata_cols = cluster_column) - dcast_metatable = data.table::dcast.data.table(metatable, formula = variable~uniq_ID, value.var = 'value') + + pl = create_cluster_dendrogram( + data = metatable, + clus_col = 'uniq_ID', + var_col = 'variable', + val_col = 'value', + cor = cor, + distance = distance, + h = h, + h_color = h_color, + rotate = rotate, + ... + ) + + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) +} + + +#' @name create_cluster_dendrogram +#' @title Create clustered expression dendrogram +#' @description Create a dendrogram based on a data.table with columns for +#' cluster ID, variables, and their values. If no specific values are provided +#' for the 'col' params then they will be assumed as 1. clus_col, 2. var_col, +#' 3. val_col +#' @param data data.table. Should include columns with clustering labels, variables +#' that are being clustered, and the values of those clusters. +#' @param clus_col character. name of column with clustering info +#' @param var_col character. name of column with variable name +#' @param val_col character. name of column with values info +#' @param cor correlation score to calculate distance (e.g. "pearson", "spearman") +#' @param distance distance method to use for hierarchical clustering, default to "ward.D" +#' @param h height of horizontal lines to plot +#' @param h_color color of horizontal lines +#' @param rotate rotate dendrogram 90 degrees +#' @inheritDotParams ggdendro::ggdendrogram +#' @export +create_cluster_dendrogram = function(data, + clus_col = names(data)[[1]], + var_col = names(data)[[2]], + val_col = names(data)[[3]], + cor = c('pearson', 'spearman'), + distance = 'ward.D', + h = NULL, + h_color = 'red', + rotate = FALSE, + ...) { + + checkmate::assert_data_table(data) + checkmate::assert_character(clus_col) + checkmate::assert_character(var_col) + checkmate::assert_character(val_col) + cor = match.arg(cor, c('pearson', 'spearman')) + + dcast_metatable = data.table::dcast.data.table( + data = data, + formula = paste0(var_col, '~', clus_col), + value.var = val_col + ) testmatrix = dt_to_matrix(x = dcast_metatable) # correlation cormatrix = cor_flex(x = testmatrix, method = cor) - cordist = stats::as.dist(1 - cormatrix, diag = T, upper = T) + cordist = stats::as.dist(1 - cormatrix, diag = TRUE, upper = TRUE) corclus = stats::hclust(d = cordist, method = distance) cordend = stats::as.dendrogram(object = corclus) # plot dendrogram - pl = ggdendro::ggdendrogram(cordend, rotate = rotate, ...) + pl = ggdendro::ggdendrogram(data = cordend, rotate = rotate, ...) # add horizontal or vertical lines if(!is.null(h)) { pl = pl + ggplot2::geom_hline(yintercept = h, col = h_color) } - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(pl) - } + pl +} - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } - ## return plot - if(return_plot == TRUE) { - return(pl) - } -} diff --git a/R/aux_heatmap.R b/R/plot_heatmap.R similarity index 74% rename from R/aux_heatmap.R rename to R/plot_heatmap.R index b37c76c..a13dc4e 100644 --- a/R/aux_heatmap.R +++ b/R/plot_heatmap.R @@ -1,21 +1,14 @@ #' @title showClusterHeatmap #' @name showClusterHeatmap #' @description Creates heatmap based on identified clusters -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param feats vector of features to use, default to 'all' -#' @param genes deprecated. Replaced by \code{feats} param #' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") #' @param cor correlation score to calculate distance (e.g. "pearson", "spearman") #' @param distance distance method to use for hierarchical clustering, default to "ward.D" -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @param ... additional parameters passed to \code{\link[ComplexHeatmap]{Heatmap}} function +#' @inheritDotParams ComplexHeatmap::Heatmap #' @return ggplot #' @details Correlation heatmap of selected clusters. #' @export @@ -37,7 +30,6 @@ showClusterHeatmap <- function(gobject, # package Check package_check(pkg_name = 'ComplexHeatmap', repository = 'Bioc') - # Set feat_type and spat_unit spat_unit = set_default_spat_unit(gobject = gobject, spat_unit = spat_unit) @@ -70,34 +62,26 @@ showClusterHeatmap <- function(gobject, # correlation cormatrix = cor_flex(x = testmatrix, method = cor) - cordist = stats::as.dist(1 - cormatrix, diag = T, upper = T) + cordist = stats::as.dist(1 - cormatrix, diag = TRUE, upper = TRUE) corclus = stats::hclust(d = cordist, method = distance) - hmap = ComplexHeatmap::Heatmap(matrix = cormatrix, - cluster_rows = corclus, - cluster_columns = corclus, - ...) - - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(hmap) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = hmap, default_save_name = default_save_name), save_param)) - } + hmap = ComplexHeatmap::Heatmap( + matrix = cormatrix, + cluster_rows = corclus, + cluster_columns = corclus, + ... + ) - ## return plot - if(return_plot == TRUE) { - return(hmap) - } + return(plot_output_handler( + gobject = gobject, + plot_object = hmap, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } @@ -106,186 +90,15 @@ showClusterHeatmap <- function(gobject, -#' @title createHeatmap_DT -#' @name createHeatmap_DT -#' @description creates order for clusters -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") -#' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") -#' @param feats features to use -#' @param genes deprecated, use feats -#' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") -#' @param cluster_order method to determine cluster order (e.g. "size", "correlation", "custom") -#' @param cluster_custom_order custom order for clusters -#' @param cluster_cor_method method for cluster correlation, default to "pearson" -#' @param cluster_hclust_method method for hierarchical clustering of clusters, default to "ward.D" -#' @param feat_order method to determine features order (e.g. "correlation", "custom") -#' @param gene_order deprecated, use feat_order in the future -#' @param feat_custom_order custom order for features -#' @param gene_custom_order deprecated, use feat_custom_order in the future -#' @param feat_cor_method method for features correlation, default to "pearson" -#' @param gene_cor_method deprecated, use feat_cor_method in the future -#' @param feat_hclust_method method for hierarchical clustering of features, default to "complete" -#' @param gene_hclust_method deprecated, use feat_hclust_method in the future -#' @return list -#' @details Creates input data.tables for plotHeatmap function. -#' @keywords internal -createHeatmap_DT = function(gobject, - spat_unit = NULL, - feat_type = NULL, - expression_values = c('normalized', 'scaled', 'custom'), - feats, - genes = NULL, - cluster_column = NULL, - cluster_order = c('size', 'correlation', 'custom'), - cluster_custom_order = NULL, - cluster_cor_method = 'pearson', - cluster_hclust_method = 'ward.D', - feat_order = c('correlation', 'custom'), - gene_order = NULL, - feat_custom_order = NULL, - gene_custom_order = NULL, - feat_cor_method = 'pearson', - gene_cor_method = NULL, - feat_hclust_method = 'complete', - gene_hclust_method = NULL) { - - - ## deprecated arguments - if(!is.null(genes)) { - feats = genes - warning('genes is deprecated, use feats in the future \n') - } - if(!is.null(gene_order)) { - feat_order = gene_order - warning('gene_order is deprecated, use feat_order in the future \n') - } - if(!is.null(gene_custom_order)) { - feat_custom_order = gene_custom_order - warning('gene_custom_order is deprecated, use feat_custom_order in the future \n') - } - if(!is.null(gene_cor_method)) { - feat_cor_method = gene_cor_method - warning('gene_cor_method is deprecated, use feat_cor_method in the future \n') - } - if(!is.null(gene_hclust_method)) { - feat_hclust_method = gene_hclust_method - warning('gene_hclust_method is deprecated, use feat_hclust_method in the future \n') - } - - - # Set feat_type and spat_unit - spat_unit = set_default_spat_unit(gobject = gobject, - spat_unit = spat_unit) - feat_type = set_default_feat_type(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type) - - - # epxression data - values = match.arg(expression_values, unique(c('normalized', 'scaled', 'custom', expression_values))) - expr_values = get_expression_values(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - values = values, - output = 'matrix') - - # subset expression data - detected_feats = feats[feats %in% rownames(expr_values)] - subset_values = expr_values[rownames(expr_values) %in% detected_feats, ] - - # metadata - cell_metadata = pDataDT(gobject, - spat_unit = spat_unit, - feat_type = feat_type) - - # feat order - feat_order = match.arg(feat_order, c('correlation', 'custom')) - - - ### cluster order ### - clus_sort_names = decide_cluster_order(gobject = gobject, - spat_unit = spat_unit, - feat_type = feat_type, - expression_values = expression_values, - feats = feats, - cluster_column = cluster_column, - cluster_order = cluster_order, - cluster_custom_order = cluster_custom_order, - cor_method = cluster_cor_method, - hclust_method = cluster_hclust_method) - - ## data.table ## - subset_values_DT <- data.table::as.data.table(reshape2::melt(as.matrix(subset_values), - varnames = c('feats', 'cells'), - value.name = 'expression', - as.is = TRUE)) - subset_values_DT <- merge(subset_values_DT, - by.x = 'cells', - cell_metadata[, c('cell_ID', cluster_column), with = F], - by.y = 'cell_ID') - subset_values_DT[[cluster_column]] <- factor(subset_values_DT[[cluster_column]], levels = clus_sort_names) - - # data.table variables - z_scores = scale_scores = V1 = cells = NULL - - subset_values_DT[, feats := factor(feats, unique(detected_feats))] - subset_values_DT[, z_scores := scale(expression), by = feats] - subset_values_DT[, scale_scores := scales::rescale(x = expression, to = c(0,1)), by = feats] - - - ## order cells by mean expression ## - cell_order_DT = subset_values_DT[, mean(expression), by = c('cells', cluster_column)] - cell_order_DT = cell_order_DT[order(get(cluster_column), V1)] - subset_values_DT[, cells := factor(cells, cell_order_DT$cells)] - - ## get x-coordines for vertical lines in heatmap - x_lines = cumsum(as.vector(table(cell_order_DT[[cluster_column]]))) - - ## order feats ## - if(feat_order == 'correlation') { - featsum_per_clus = subset_values_DT[, sum(expression), by = c('feats', cluster_column)] - - my_formula = paste0('feats~',cluster_column) - test_mat = data.table::dcast.data.table(data = featsum_per_clus, formula = my_formula, value.var = 'V1') - test_matrix = as.matrix(test_mat[,-1]); rownames(test_matrix) = test_mat$feats - - feat_dist = stats::as.dist(1 - cor_flex(t_flex(test_matrix), method = feat_cor_method)) - feat_clus = stats::hclust(feat_dist, method = feat_hclust_method) - - feat_labels = rownames(test_matrix) - feat_index = 1:length(feat_labels) - names(feat_index) = feat_labels - - final_feat_order = names(feat_index[match(feat_clus$order, feat_index)]) - subset_values_DT[, feats := factor(feats, final_feat_order)] - - } else if(feat_order == 'custom') { - - if(is.null(feat_custom_order)) { - stop('\n with custom feat order the feat_custom_order parameter needs to be provided \n') - } - subset_values_DT[, feats := factor(feats, feat_custom_order)] - - } - - cell_order_DT[['cells']] = factor(cell_order_DT[['cells']], levels = as.character(cell_order_DT[['cells']])) - - return(list(DT = subset_values_DT, x_lines = x_lines, cell_DT = cell_order_DT)) -} - - #' @title plotHeatmap #' @name plotHeatmap -#' @description Creates heatmap for genes and clusters. -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @description Creates heatmap for features and clusters. +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param feats features to use -#' @param genes deprecated, use feats #' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") #' @param cluster_order method to determine cluster order (e.g. "size", "correlation", "custom") #' @param cluster_custom_order custom order for clusters @@ -296,24 +109,14 @@ createHeatmap_DT = function(gobject, #' @param feat_custom_order custom order for features #' @param feat_cor_method method for features correlation, default to "pearson" #' @param feat_hclust_method method for hierarchical clustering of features, default to "complete" -#' @param gene_order deprecated, use feat_order -#' @param gene_custom_order deprecated, use feat_custom_order -#' @param gene_cor_method deprecated, use feat_cor_method -#' @param gene_hclust_method deprecated, use feat_hclust_method #' @param show_values which values to show on heatmap (e.g. "rescaled", "z-scaled", "original") #' @param size_vertical_lines sizes for vertical lines -#' @param gradient_colors colors for heatmap gradient +#' @param gradient_colors deprecated #' @param feat_label_selection subset of features to show on y-axis -#' @param gene_label_selection deprecated, use feat_label_selection #' @param axis_text_y_size size for y-axis text #' @param legend_nrows number of rows for the cluster legend -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name #' @return ggplot -#' @details If you want to display many genes there are 2 ways to proceed: +#' @details If you want to display many features there are 2 ways to proceed: #' \itemize{ #' \item{1. set axis_text_y_size to a really small value and show all features} #' \item{2. provide a subset of features to display to feat_label_selection} @@ -324,7 +127,6 @@ plotHeatmap <- function(gobject, feat_type = NULL, expression_values = c('normalized', 'scaled', 'custom'), feats, - genes = NULL, cluster_column = NULL, cluster_order = c('size', 'correlation', 'custom'), cluster_custom_order = NULL, @@ -332,20 +134,15 @@ plotHeatmap <- function(gobject, cluster_cor_method = 'pearson', cluster_hclust_method = 'ward.D', feat_order = c('correlation', 'custom'), - gene_order = NULL, feat_custom_order = NULL, - gene_custom_order = NULL, feat_cor_method = 'pearson', - gene_cor_method = NULL, feat_hclust_method = 'complete', - gene_hclust_method = NULL, show_values = c('rescaled', 'z-scaled', 'original'), size_vertical_lines = 1.1, - gradient_colors = NULL, + gradient_colors = deprecated(), gradient_color = NULL, gradient_style = c('divergent', 'sequential'), feat_label_selection = NULL, - gene_label_selection = NULL, axis_text_y_size = NULL, legend_nrows = 1, show_plot = NA, @@ -364,26 +161,20 @@ plotHeatmap <- function(gobject, show_values = match.arg(show_values, choices = c('rescaled', 'z-scaled', 'original')) - heatmap_data = createHeatmap_DT(gobject = gobject, spat_unit = spat_unit, feat_type = feat_type, expression_values = expression_values, feats = feats, - genes = genes, cluster_column = cluster_column, cluster_order = cluster_order, cluster_custom_order = cluster_custom_order, cluster_cor_method = cluster_cor_method, cluster_hclust_method = cluster_hclust_method, feat_order = feat_order, - gene_order = gene_order, feat_custom_order = feat_custom_order, - gene_custom_order = gene_custom_order, feat_cor_method = feat_cor_method, - gene_cor_method = gene_cor_method, - feat_hclust_method = feat_hclust_method, - gene_hclust_method = gene_hclust_method) + feat_hclust_method = feat_hclust_method) cell_order_DT = heatmap_data[['cell_DT']] subset_values_DT = heatmap_data[['DT']] @@ -395,7 +186,7 @@ plotHeatmap <- function(gobject, clus_colors = set_default_color_discrete_heatmap_clus(instrs = instructions(gobject))(n = length(clus_values)) names(clus_colors) = clus_values } else { - clus_colors = cluster_color_code + clus_colors = set_default_color_discrete(colors = cluster_color_code, NULL, NULL, 'interpolate')(n = length(unique(cell_order_DT[[cluster_column]]))) } ## bar on top ## @@ -435,7 +226,7 @@ plotHeatmap <- function(gobject, hmap <- hmap + ggplot2::geom_tile(data = subset_values_DT, aes_string(x = 'cells', y = 'feats', fill = value_column)) hmap <- hmap + ggplot2::geom_vline(xintercept = x_lines, color = 'white', size = size_vertical_lines) hmap <- hmap + set_default_color_continuous_heatmap( - color = gradient_color, + colors = gradient_color, instrs = instructions(gobject), midpoint = midpoint, style = gradient_style, @@ -452,32 +243,9 @@ plotHeatmap <- function(gobject, ## align and combine aligned <- cowplot::align_plots(clus_pl, empty, hmap + ggplot2::theme(legend.position = "none"), align = "v", axis = "l") aligned <- append(aligned, list(cowplot::get_legend(hmap))) - combplot = cowplot::plot_grid(plotlist = aligned, - ncol = 2, rel_widths = c(1, 0.2), - nrow = 2, rel_heights = c(0.2, 1)) - - - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(combplot) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = combplot, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(combplot) - } - + combplot <- cowplot::plot_grid(plotlist = aligned, + ncol = 2, rel_widths = c(1, 0.2), + nrow = 2, rel_heights = c(0.2, 1)) } else { @@ -490,7 +258,7 @@ plotHeatmap <- function(gobject, plot.margin = ggplot2::margin(0, 0, 5.5, 5.5, "pt")) ### axis ### featDT = subset_values_DT[,c('feats'), with = F] - featDT = unique(setorder(featDT, feats)) + featDT = unique(data.table::setorder(featDT, feats)) # data.table variables featOrder = subset_feats = NULL @@ -499,9 +267,10 @@ plotHeatmap <- function(gobject, featDT[, subset_feats := ifelse(feats %in% feat_label_selection, as.character(feats), '')] axis <- ggplot2::ggplot(data = featDT, aes(x = 0, y = featOrder, label = subset_feats)) - axis <- axis + ggrepel::geom_text_repel(min.segment.length = grid::unit(0, "pt"), - color = "grey30", ## ggplot2 theme_grey() axis text - size = axis_text_y_size ## default ggplot2 theme_grey() axis text + axis <- axis + ggrepel::geom_text_repel( + min.segment.length = grid::unit(0, "pt"), + color = "grey30", ## ggplot2 theme_grey() axis text + size = axis_text_y_size ## default ggplot2 theme_grey() axis text ) axis <- axis + ggplot2::scale_x_continuous(limits = c(0, 1), expand = c(0, 0), breaks = NULL, labels = NULL, name = NULL) @@ -510,40 +279,24 @@ plotHeatmap <- function(gobject, axis <- axis + ggplot2::theme(panel.background = ggplot2::element_blank(), plot.margin = ggplot2::margin(0, 0, 0, 0, "cm")) - - #return(list(hmap, clus_pl, axis, empty)) - ## align and combine aligned <- cowplot::align_plots(clus_pl, empty, empty, hmap + theme(legend.position = "none"), axis, align = "h", axis = "b") aligned <- append(aligned, list(cowplot::get_legend(hmap))) - combplot = cowplot::plot_grid(plotlist = aligned, - ncol = 3, rel_widths = c(1, 0.2, 0.1), - nrow = 2, rel_heights = c(0.2, 1)) - - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - - ## print plot - if(show_plot == TRUE) { - print(combplot) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = combplot, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(combplot) - } - - } - + combplot <- cowplot::plot_grid(plotlist = aligned, + ncol = 3, rel_widths = c(1, 0.2, 0.1), + nrow = 2, rel_heights = c(0.2, 1)) + } + + return(plot_output_handler( + gobject = gobject, + plot_object = combplot, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } @@ -553,14 +306,13 @@ plotHeatmap <- function(gobject, #' @title plotMetaDataHeatmap #' @name plotMetaDataHeatmap -#' @description Creates heatmap for genes within aggregated clusters. -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @description Creates heatmap for features within aggregated clusters. +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param metadata_cols annotation columns found in pDataDT(gobject) #' @param selected_feats subset of features to use -#' @param selected_genes deprecated. See \code{selected_feats} param #' @param first_meta_col if more than 1 metadata column, select the x-axis factor #' @param second_meta_col if more than 1 metadata column, select the facetting factor #' @param show_values which values to show on heatmap (e.g. "zscores", "original", "zscores_rescaled") @@ -568,28 +320,18 @@ plotHeatmap <- function(gobject, #' @param clus_cor_method correlation method for clusters, default to "pearson" #' @param clus_cluster_method hierarchical cluster method for the clusters, default to "complete" #' @param custom_feat_order custom feature order (default = NULL) -#' @param custom_gene_order deprecated. See \code{custom_feat_order} param #' @param feat_cor_method correlation method for features, default to "pearson" -#' @param gene_cor_method deprecated. See \code{feat_cor_method} param #' @param feat_cluster_method hierarchical cluster method for the features, default to "complete" -#' @param gene_cluster_method deprecated. See \code{feat_cluster_method} param -#' @param gradient_color vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits #' @param x_text_size size of x-axis text #' @param x_text_angle angle of x-axis text #' @param y_text_size size of y-axis text #' @param strip_text_size size of strip text -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name +#' @param plot_title deprecated. Use title param #' @return ggplot or data.table -#' @details Creates heatmap for the average expression of selected genes in the different annotation/cluster groups. -#' Calculation of cluster or gene order is done on the provided expression values, but visualization -#' is by default on the z-scores. Other options are the original values or z-scores rescaled per gene (-1 to 1). -#' @seealso \code{\link{plotMetaDataCellsHeatmap}} for numeric cell annotation instead of gene expression. +#' @details Creates heatmap for the average expression of selected features in the different annotation/cluster groups. +#' Calculation of cluster or feature order is done on the provided expression values, but visualization +#' is by default on the z-scores. Other options are the original values or z-scores rescaled per feature (-1 to 1). +#' @seealso \code{\link{plotMetaDataCellsHeatmap}} for numeric cell annotation instead of feature expression. #' @export plotMetaDataHeatmap = function(gobject, spat_unit = NULL, @@ -597,7 +339,6 @@ plotMetaDataHeatmap = function(gobject, expression_values = c("normalized", "scaled", "custom"), metadata_cols = NULL, selected_feats = NULL, - selected_genes = NULL, first_meta_col = NULL, second_meta_col = NULL, show_values = c('zscores', 'original', 'zscores_rescaled'), @@ -605,11 +346,8 @@ plotMetaDataHeatmap = function(gobject, clus_cor_method = 'pearson', clus_cluster_method = 'complete', custom_feat_order = NULL, - custom_gene_order = NULL, feat_cor_method = 'pearson', - gene_cor_method = NULL, feat_cluster_method = 'complete', - gene_cluster_method = NULL, gradient_color = NULL, gradient_midpoint = 0, gradient_style = c('divergent', 'sequential'), @@ -618,30 +356,20 @@ plotMetaDataHeatmap = function(gobject, x_text_angle = 45, y_text_size = 10, strip_text_size = 8, - plot_title = NULL, + title = NULL, + plot_title = deprecated(), show_plot = NA, return_plot = NA, save_plot = NA, save_param = list(), default_save_name = 'plotMetaDataHeatmap') { - - ## deprecated arguments - if(!is.null(selected_genes)) { - selected_feats = selected_genes - warning('selected_genes is deprecated, use selected_feats in the future \n') - } - if(!is.null(custom_gene_order)) { - custom_feat_order = custom_gene_order - warning('custom_gene_order is deprecated, use custom_feat_order in the future \n') - } - if(!is.null(gene_cor_method)) { - feat_cor_method = gene_cor_method - warning('gene_cor_method is deprecated, use feat_cor_method in the future \n') - } - if(!is.null(gene_cluster_method)) { - feat_cluster_method = gene_cluster_method - warning('gene_cluster_method is deprecated, use feat_cluster_method in the future \n') + # deprecate + if (GiottoUtils::is_present(plot_title)) { + deprecate_warn('0.0.0.9000', + 'GiottoVisuals::plotMetaDataHeatmap(plot_title = )', + 'GiottoVisuals::plotMetaDataHeatmap(title = )') + title <- plot_title } # Set feat_type and spat_unit @@ -659,10 +387,10 @@ plotMetaDataHeatmap = function(gobject, selected_feats = selected_feats) # data.table variables - zscores = value = zscores_rescaled_per_feat = NULL + zscores = value = NULL - metaDT[, zscores := scale(value), by = c('variable')] - metaDT[, zscores_rescaled_per_feat := scales::rescale(zscores, to = c(-1,1)), by = c('variable')] + metaDT[, 'zscores' := scale(value), by = c('variable')] + metaDT[, 'zscores_rescaled_per_feat' := scales::rescale(zscores, to = c(-1,1)), by = c('variable')] show_values = match.arg(show_values, choices = c('zscores', 'original', 'zscores_rescaled')) if(show_values == 'zscores') { @@ -684,10 +412,7 @@ plotMetaDataHeatmap = function(gobject, main_factor = ifelse(length(metadata_cols) == 1, metadata_cols, first_meta_col) testmain = metaDT[, mean(value), by = c('variable', main_factor)] - dfunction <- function(d, col_name1, col_name2, value.var) { - data.table::dcast.data.table(d, paste(col_name1, "~", col_name2), value.var = value.var) - } - testmain_matrix = dfunction(d = testmain, col_name1 = 'variable', col_name2 = main_factor, value.var = 'V1') + testmain_matrix <- dcast_dt_string(testmain, 'variable', main_factor, 'V1') testmain_mat = as.matrix(testmain_matrix[,-1]); rownames(testmain_mat) = testmain_matrix$variable # for clusters @@ -755,8 +480,8 @@ plotMetaDataHeatmap = function(gobject, legend.title = ggplot2::element_blank()) pl <- pl + ggplot2::labs(x = metadata_cols, y = 'feats') - if(!is.null(plot_title)) { - pl <- pl + ggplot2::ggtitle(plot_title) + + if(!is.null(title)) { + pl <- pl + ggplot2::ggtitle(title) + ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5)) } @@ -855,9 +580,10 @@ plotMetaDataHeatmap = function(gobject, #' @title plotMetaDataCellsHeatmap #' @name plotMetaDataCellsHeatmap #' @description Creates heatmap for numeric cell metadata within aggregated clusters. -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_params +#' @param midpoint deprecated. Use gradient_midpoint. #' @param metadata_cols annotation columns found in pDataDT(gobject) #' @param spat_enr_names spatial enrichment results to include #' @param value_cols value columns to use @@ -870,19 +596,13 @@ plotMetaDataHeatmap = function(gobject, #' @param custom_values_order custom values order (default = NULL) #' @param values_cor_method correlation method for values, default to "pearson" #' @param values_cluster_method hierarchical cluster method for the values, default to "complete" -#' @param gradient_midpoint midpoint of show_values #' @param x_text_size size of x-axis text #' @param x_text_angle angle of x-axis text #' @param y_text_size size of y-axis text #' @param strip_text_size size of strip text -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot or data.table #' @details Creates heatmap for the average values of selected value columns in the different annotation groups. -#' @seealso \code{\link{plotMetaDataHeatmap}} for gene expression instead of numeric cell annotation data. +#' @seealso \code{\link{plotMetaDataHeatmap}} for feature expression instead of numeric cell annotation data. #' @export plotMetaDataCellsHeatmap = function(gobject, spat_unit = NULL, @@ -929,10 +649,10 @@ plotMetaDataCellsHeatmap = function(gobject, spat_enr_names = spat_enr_names) # data.table variables - zscores = zscores_rescaled_per_gene = value = NULL + zscores = value = NULL - metaDT[, zscores := scale(value), by = c('variable')] - metaDT[, zscores_rescaled_per_gene := scales::rescale(zscores, to = c(-1,1)), by = c('variable')] + metaDT[, 'zscores' := scale(value), by = c('variable')] + metaDT[, 'zscores_rescaled_per_gene' := scales::rescale(zscores, to = c(-1,1)), by = c('variable')] show_values = match.arg(show_values, choices = c('zscores', 'original', 'zscores_rescaled')) if(show_values == 'zscores') { @@ -952,13 +672,10 @@ plotMetaDataCellsHeatmap = function(gobject, ## order of genes and clusters - main_factor = ifelse(length(metadata_cols) == 1, metadata_cols, first_meta_col) - testmain = metaDT[, mean(value), by = c('variable', main_factor)] - dfunction <- function(d, col_name1, col_name2, value.var) { - data.table::dcast.data.table(d, paste(col_name1, "~", col_name2), value.var = value.var) - } - testmain_matrix = dfunction(d = testmain, col_name1 = 'variable', col_name2 = main_factor, value.var = 'V1') - testmain_mat = as.matrix(testmain_matrix[,-1]); rownames(testmain_mat) = testmain_matrix$variable + main_factor <- ifelse(length(metadata_cols) == 1, metadata_cols, first_meta_col) + testmain <- metaDT[, mean(value), by = c('variable', main_factor)] + testmain_matrix <- dcast_dt_string(testmain, 'variable', main_factor, 'V1') + testmain_mat <- as.matrix(testmain_matrix[,-1]); rownames(testmain_mat) = testmain_matrix$variable # for clusters if(is.null(custom_cluster_order)) { @@ -1013,30 +730,7 @@ plotMetaDataCellsHeatmap = function(gobject, legend.title = ggplot2::element_blank()) pl <- pl + ggplot2::labs(x = metadata_cols, y = 'genes') - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(pl) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(pl) - } - } - - - else { + } else { if(is.null(first_meta_col) | is.null(second_meta_col)) { cat('\n both first_meta_col and second_meta_col need to be defined, return data.table \n') @@ -1065,30 +759,158 @@ plotMetaDataCellsHeatmap = function(gobject, strip.text = ggplot2::element_text(size = strip_text_size), legend.title = ggplot2::element_blank()) pl <- pl + ggplot2::labs(x = first_meta_col, y = 'genes', title = second_meta_col) + } + } + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) +} - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - ## print plot - if(show_plot == TRUE) { - print(pl) - } - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } +# helpers #### - ## return plot - if(return_plot == TRUE) { - return(pl) - } + + +#' @title createHeatmap_DT +#' @name createHeatmap_DT +#' @description creates order for clusters +#' @inheritParams data_access_params +#' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") +#' @param feats features to use +#' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") +#' @param cluster_order method to determine cluster order (e.g. "size", "correlation", "custom") +#' @param cluster_custom_order custom order for clusters +#' @param cluster_cor_method method for cluster correlation, default to "pearson" +#' @param cluster_hclust_method method for hierarchical clustering of clusters, default to "ward.D" +#' @param feat_order method to determine features order (e.g. "correlation", "custom") +#' @param feat_custom_order custom order for features +#' @param feat_cor_method method for features correlation, default to "pearson" +#' @param feat_hclust_method method for hierarchical clustering of features, default to "complete" +#' @return list +#' @details Creates input data.tables for plotHeatmap function. +#' @keywords internal +createHeatmap_DT = function(gobject, + spat_unit = NULL, + feat_type = NULL, + expression_values = c('normalized', 'scaled', 'custom'), + feats, + cluster_column = NULL, + cluster_order = c('size', 'correlation', 'custom'), + cluster_custom_order = NULL, + cluster_cor_method = 'pearson', + cluster_hclust_method = 'ward.D', + feat_order = c('correlation', 'custom'), + feat_custom_order = NULL, + feat_cor_method = 'pearson', + feat_hclust_method = 'complete') { + + + # Set feat_type and spat_unit + spat_unit = set_default_spat_unit(gobject = gobject, + spat_unit = spat_unit) + feat_type = set_default_feat_type(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type) + + + # epxression data + values = match.arg(expression_values, unique(c('normalized', 'scaled', 'custom', expression_values))) + expr_values = get_expression_values(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + values = values, + output = 'matrix') + + # subset expression data + detected_feats = feats[feats %in% rownames(expr_values)] + subset_values = expr_values[rownames(expr_values) %in% detected_feats, ] + + # metadata + cell_metadata = pDataDT(gobject, + spat_unit = spat_unit, + feat_type = feat_type) + + # feat order + feat_order = match.arg(feat_order, c('correlation', 'custom')) + + + ### cluster order ### + clus_sort_names = decide_cluster_order(gobject = gobject, + spat_unit = spat_unit, + feat_type = feat_type, + expression_values = expression_values, + feats = feats, + cluster_column = cluster_column, + cluster_order = cluster_order, + cluster_custom_order = cluster_custom_order, + cor_method = cluster_cor_method, + hclust_method = cluster_hclust_method) + + ## data.table ## + subset_values_DT <- data.table::as.data.table(reshape2::melt(as.matrix(subset_values), + varnames = c('feats', 'cells'), + value.name = 'expression', + as.is = TRUE)) + subset_values_DT <- merge(subset_values_DT, + by.x = 'cells', + cell_metadata[, c('cell_ID', cluster_column), with = F], + by.y = 'cell_ID') + subset_values_DT[, (cluster_column) := factor(x = get(cluster_column), levels = clus_sort_names)] + + # data.table variables + z_scores = scale_scores = V1 = cells = NULL + + subset_values_DT[, feats := factor(feats, unique(detected_feats))] + subset_values_DT[, z_scores := scale(expression), by = feats] + subset_values_DT[, scale_scores := scales::rescale(x = expression, to = c(0,1)), by = feats] + + + ## order cells by mean expression ## + cell_order_DT = subset_values_DT[, mean(expression), by = c('cells', cluster_column)] + cell_order_DT = cell_order_DT[order(get(cluster_column), V1)] + subset_values_DT[, cells := factor(cells, cell_order_DT$cells)] + + ## get x-coordines for vertical lines in heatmap + x_lines = cumsum(as.vector(table(cell_order_DT[[cluster_column]]))) + + ## order feats ## + if(feat_order == 'correlation') { + featsum_per_clus = subset_values_DT[, sum(expression), by = c('feats', cluster_column)] + + my_formula = paste0('feats~',cluster_column) + test_mat = data.table::dcast.data.table(data = featsum_per_clus, formula = my_formula, value.var = 'V1') + test_matrix = as.matrix(test_mat[,-1]); rownames(test_matrix) = test_mat$feats + + feat_dist = stats::as.dist(1 - cor_flex(t_flex(test_matrix), method = feat_cor_method)) + feat_clus = stats::hclust(feat_dist, method = feat_hclust_method) + + feat_labels = rownames(test_matrix) + feat_index = 1:length(feat_labels) + names(feat_index) = feat_labels + + final_feat_order = names(feat_index[match(feat_clus$order, feat_index)]) + subset_values_DT[, 'feats' := factor(feats, final_feat_order)] + + } else if(feat_order == 'custom') { + + if(is.null(feat_custom_order)) { + stop('\n with custom feat order the feat_custom_order parameter needs to be provided \n') } + subset_values_DT[, 'feats' := factor(feats, feat_custom_order)] } + cell_order_DT[['cells']] = factor(cell_order_DT[['cells']], levels = as.character(cell_order_DT[['cells']])) + + return(list(DT = subset_values_DT, x_lines = x_lines, cell_DT = cell_order_DT)) } diff --git a/R/aux_scatterplot.R b/R/plot_scatter.R similarity index 71% rename from R/aux_scatterplot.R rename to R/plot_scatter.R index fef89d0..1250597 100644 --- a/R/aux_scatterplot.R +++ b/R/plot_scatter.R @@ -9,21 +9,17 @@ #' @param xlab a title for the x axis #' @param ylab a title for the y axis #' @param main an overall title for the plot -#' @param ... additional params passed to ggplot2::aes() +#' @inheritDotParams ggplot2::aes #' @param return ggplot object #' @keywords internal #' @export -gg_simple_scatter = function(ggobject = NULL, data, x, y, xlab = 'x', ylab = 'y', main, ...) { - if(is.null(gg_obj)) { - pl <- ggplot2::ggplot() - } else { - pl <- gg_obj - } +gg_simple_scatter = function(ggobject = NULL, data, x, y, xlab = 'x', ylab = 'y', main = NULL, ...) { + pl <- gg_input(ggobject) aes_args_list = list(x = x, y = y, ...) pl <- pl + - ggplot2::geom_point(data = data, do.call(ggplot2::aes, lapply(aes_args_list, eval(as.name)))) + + ggplot2::geom_point(data = data, aes_string2(x, y, ...)) + ggplot2::theme_classic() + ggplot2::labs(x = xlab, y = ylab) diff --git a/R/aux_violinplot.R b/R/plot_violin.R similarity index 90% rename from R/aux_violinplot.R rename to R/plot_violin.R index 2e6dcc8..a011dfc 100644 --- a/R/aux_violinplot.R +++ b/R/plot_violin.R @@ -1,12 +1,10 @@ #' @title violinPlot #' @name violinPlot #' @description Creates violinplot for selected clusters -#' @param gobject giotto object -#' @param spat_unit spatial unit (e.g. "cell") -#' @param feat_type feature type (e.g. "rna", "dna", "protein") +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param expression_values expression values to use (e.g. "normalized", "scaled", "custom") #' @param feats features to plot -#' @param genes deprecated, use feats argument #' @param cluster_column name of column to use for clusters (e.g. "leiden_clus") #' @param color_violin color violin according to "genes" or "clusters" #' @param cluster_custom_order custom order of clusters @@ -15,11 +13,6 @@ #' @param strip_text size of strip text #' @param axis_text_x_size size of x-axis text #' @param axis_text_y_size size of y-axis text -#' @param show_plot show plot. TRUE or FALSE -#' @param return_plot return ggplot object. TRUE or FALSE -#' @param save_plot directly save the plot. TRUE or FALSE -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export violinPlot <- function(gobject, @@ -90,7 +83,7 @@ violinPlot <- function(gobject, if(length(feats) == 1) { metadata_expr <- cbind(metadata, t_subset_data) - setnames(metadata_expr, 'V1', feats) + data.table::setnames(metadata_expr, 'V1', feats) } else { metadata_expr <- cbind(metadata, t_subset_data) } diff --git a/R/spatial_DE_visuals.R b/R/spatialDE_visuals.R similarity index 100% rename from R/spatial_DE_visuals.R rename to R/spatialDE_visuals.R diff --git a/R/hvf_plots.R b/R/vis_hvf.R similarity index 78% rename from R/hvf_plots.R rename to R/vis_hvf.R index 1de047c..c7c37c5 100644 --- a/R/hvf_plots.R +++ b/R/vis_hvf.R @@ -11,18 +11,20 @@ NULL - - #' @rdname hvf_visualizations #' @export create_cov_group_HVF_plot = function(feat_in_cells_detected, nr_expression_groups) { pl <- ggplot2::ggplot() pl <- pl + ggplot2::theme_classic() + - ggplot2::theme(axis.title = ggplot2::element_text(size = 14), axis.text = ggplot2::element_text(size = 12)) - pl <- pl + ggplot2::geom_point(data = feat_in_cells_detected, ggplot2::aes(x = mean_expr, y = cov, color = selected)) - pl <- pl + ggplot2::scale_color_manual(values = c(no = 'lightgrey', yes = 'orange'), guide = ggplot2::guide_legend(title = 'HVF', override.aes = list(size=5))) + ggplot2::theme(axis.title = ggplot2::element_text(size = 14), + axis.text = ggplot2::element_text(size = 12)) + pl <- pl + ggplot2::geom_point(data = feat_in_cells_detected, ggplot2::aes_string(x = 'mean_expr', y = 'cov', color = 'selected')) + pl <- pl + ggplot2::scale_color_manual(values = c(no = 'lightgrey', yes = 'orange'), + guide = ggplot2::guide_legend(title = 'HVF', + override.aes = list(size=5))) pl <- pl + ggplot2::facet_wrap(~expr_groups, ncol = nr_expression_groups, scales = 'free_x') - pl <- pl + ggplot2::theme(axis.text.x = ggplot2::element_blank(), strip.text = ggplot2::element_text(size = 4)) + pl <- pl + ggplot2::theme(axis.text.x = ggplot2::element_blank(), + strip.text = ggplot2::element_text(size = 4)) pl <- pl + ggplot2::labs(x = 'expression groups', y = 'cov') pl } @@ -31,8 +33,9 @@ create_cov_group_HVF_plot = function(feat_in_cells_detected, nr_expression_group #' @export create_cov_loess_HVF_plot = function(feat_in_cells_detected, difference_in_cov, var_col) { pl <- ggplot2::ggplot() - pl <- pl + ggplot2::theme_classic() + ggplot2::theme(axis.title = ggplot2::element_text(size = 14), - axis.text = ggplot2::element_text(size = 12)) + pl <- pl + ggplot2::theme_classic() + + ggplot2::theme(axis.title = ggplot2::element_text(size = 14), + axis.text = ggplot2::element_text(size = 12)) pl <- pl + ggplot2::geom_point(data = feat_in_cells_detected, ggplot2::aes_string(x = 'log(mean_expr)', y = var_col, color = 'selected')) pl <- pl + ggplot2::geom_line(data = feat_in_cells_detected, ggplot2::aes_string(x = 'log(mean_expr)', y = 'pred_cov_feats'), color = 'blue') hvg_line = paste0('pred_cov_feats+',difference_in_cov) @@ -48,7 +51,7 @@ create_cov_loess_HVF_plot = function(feat_in_cells_detected, difference_in_cov, #' @export create_calc_var_HVF_plot = function(dt_res) { pl = ggplot2::ggplot() - pl = pl + ggplot2::geom_point(data = dt_res, aes(x = rank, y = var, color = selected)) + pl = pl + ggplot2::geom_point(data = dt_res, aes_string(x = 'rank', y = 'var', color = 'selected')) pl = pl + ggplot2::scale_x_reverse() pl = pl + ggplot2::theme_classic() + ggplot2::theme(axis.title = ggplot2::element_text(size = 14), axis.text = ggplot2::element_text(size = 12)) diff --git a/R/pc_plots.R b/R/vis_pc.R similarity index 74% rename from R/pc_plots.R rename to R/vis_pc.R index e1ebbb7..643292b 100644 --- a/R/pc_plots.R +++ b/R/vis_pc.R @@ -1,27 +1,32 @@ - - - - ## * PC estimates #### # ------------------ # #' @title create_screeplot #' @name create_screeplot #' @description create screeplot with ggplot -#' @param pca_obj pca dimension reduction object -#' @param ncp number of principal components to calculate -#' @param ylim y-axis limits on scree plot +#' @param eigs numeric. Vector of pca eigenvalues +#' @param ncp numeric. max number of principal components to plot +#' @param ylim numeric. y-axis limits on scree plot #' @return ggplot -#' @keywords internal -create_screeplot = function(pca_obj, ncp = 20, ylim = c(0, 20)) { +#' @examples +#' \dontrun{ +#' dr = GiottoData::loadSubObjectMini('dimObj') +#' scree = create_screeplot(methods::slot(dr, 'misc')$eigenvalues) +#' scree +#' } +#' @export +create_screeplot = function(eigs, ncp = 20, ylim = c(0, 20)) { + checkmate::assert_numeric(eigs) + checkmate::assert_numeric(ncp, len = 1L) + checkmate::assert_numeric(ylim, len = 2L) - # data.table: set global variable + # DT vars PC = NULL - eigs = slot(pca_obj, 'misc')$eigenvalues + eigs = sort(eigs, decreasing = TRUE) # variance explained var_expl = eigs/sum(eigs)*100 @@ -31,7 +36,7 @@ create_screeplot = function(pca_obj, ncp = 20, ylim = c(0, 20)) { screeDT = data.table::data.table('PC' = paste0('PC.', 1:length(var_expl)), 'var_expl' = var_expl, 'var_expl_cum' = var_expl_cum) - screeDT[, PC := factor(PC, levels = PC)] + screeDT[, 'PC' := factor(PC, levels = PC)] max_ncp = length(eigs) ncp = ifelse(ncp > max_ncp, max_ncp, ncp) @@ -59,7 +64,6 @@ create_screeplot = function(pca_obj, ncp = 20, ylim = c(0, 20)) { align = 'v') return(combo_plot) - } @@ -82,13 +86,19 @@ create_jackstrawplot = function(jackstraw_data, ylim = c(0, 1), threshold = 0.01) { + checkmate::assert_numeric(ncp, len = 1L) + checkmate::assert_numeric(ylim, len = 2L) + checkmate::assert_numeric(threshold, len = 1L) + # data.table variables PC = p.val = NULL - testDT = data.table::data.table(PC = paste0('PC.', 1:length(jackstraw_data)), - p.val = jackstraw_data) - testDT[, PC := factor(PC, levels = PC)] - testDT[, sign := ifelse(p.val <= threshold, 'sign', 'n.s.')] + testDT = data.table::data.table( + PC = paste0('PC.', 1:length(jackstraw_data)), + p.val = jackstraw_data + ) + testDT[, 'PC' := factor(PC, levels = PC)] + testDT[, 'sign' := ifelse(p.val <= threshold, 'sign', 'n.s.')] pl = ggplot2::ggplot() pl = pl + ggplot2::theme_bw() diff --git a/R/spatial_visuals.R b/R/vis_spatial.R similarity index 91% rename from R/spatial_visuals.R rename to R/vis_spatial.R index 5191d51..4567c38 100644 --- a/R/spatial_visuals.R +++ b/R/vis_spatial.R @@ -1,19 +1,12 @@ - - - - ## * #### ## 2-D ggplots #### ## ----------- ## - - - ## ** spatial plotting #### @@ -23,9 +16,11 @@ #' @title spatPlot2D_single #' @name spatPlot2D_single #' @description Visualize cells according to spatial coordinates -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_spatnet_params +#' @inheritParams plot_spatenr_params #' @param show_image show a tissue background image #' @param gimage a giotto image #' @param image_name name of a giotto image @@ -33,53 +28,19 @@ #' @param spat_loc_name name of spatial locations #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') -#' @param spat_enr_names names of spatial enrichment results to include -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param point_shape shape of points (border, no_border or voronoi) -#' @param point_size size of point (cell) -#' @param point_alpha transparancy of point -#' @param point_border_col color of border around points -#' @param point_border_stroke stroke size of border around points #' @param show_cluster_center plot center of selected clusters #' @param show_center_label plot label of selected clusters #' @param center_point_size size of center points -#' @param label_size size of labels -#' @param label_fontface font of labels -#' @param show_network show underlying spatial network -#' @param spatial_network_name name of spatial network to use #' @param network_color color of spatial network #' @param network_alpha alpha of spatial network #' @param show_grid show spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param grid_color color of spatial grid -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells -#' @param other_point_size point size of not selected cells -#' @param other_cells_alpha alpha of not selected cells #' @param coord_fix_ratio fix ratio between x and y-axis -#' @param title title of plot -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param legend_symbol_size size of legend symbols -#' @param background_color color of plot background #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' -#' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] +#' @param vor_alpha transparency of voronoi 'cells' #' @param verbose be verbose -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @keywords internal @@ -486,26 +447,16 @@ spatPlot2D_single = function(gobject, if(is.null(title)) title = cell_color pl <- pl + ggplot2::labs(x = 'x coordinates', y = 'y coordinates', title = title) - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(pl) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(pl) - } + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } @@ -514,26 +465,18 @@ spatPlot2D_single = function(gobject, -#' @title spatPlot2D -#' @name spatPlot2D -#' @description Visualize cells according to spatial coordinates -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image or multiple images with group_by -#' @param largeImage_name name of a giottoLargeImage or multiple images with group_by -#' @param group_by create multiple plots based on cell annotation column -#' @param group_by_subset subset the group_by factor column + +#' @rdname spatPlot +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_image_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_params #' @param spat_loc_name name of spatial locations #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') -#' @param spat_enr_names names of spatial enrichment results to include -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors -#' @param cell_color_gradient vector with 3 colors for numeric data #' @param gradient_midpoint midpoint for color gradient #' @param gradient_limits vector with lower and upper limits #' @param select_cell_groups select subset of cells/clusters based on cell_color parameter @@ -567,26 +510,11 @@ spatPlot2D_single = function(gobject, #' @param legend_text size of legend text #' @param legend_symbol_size size of legend symbols #' @param background_color color of plot background -#' @param vor_border_color border colorr for voronoi plot +#' @param vor_border_color border color for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' -#' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @return ggplot -#' @details Description of parameters. -#' coord_fix_ratio: set to NULL to use default ggplot parameters -#' @family spatial visualizations +#' @param vor_alpha transparency of voronoi 'cells' +#' @details coord_fix_ratio: set to NULL to use default ggplot parameters #' @export -#' @seealso \code{\link{spatPlot3D}} spatPlot2D = function(gobject, spat_unit = NULL, feat_type = NULL, @@ -894,9 +822,8 @@ spatPlot2D = function(gobject, #' @title spatPlot #' @name spatPlot #' @description Visualize cells according to spatial coordinates -#' @inheritDotParams spatPlot2D -#' @return ggplot -#' @details Description of parameters. +#' @param \dots spatPLot(...) passes to spatPlot2D +#' @return ggplot (2D), plotly (3D) #' @family spatial visualizations #' @export #' @seealso \code{\link{spatPlot3D}} @@ -919,9 +846,9 @@ spatPlot = function(...) { #' @title spatDeconvPlot #' @name spatDeconvPlot #' @description Visualize cell type enrichment / deconvolution results in a scatterpie -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param deconv_name name of deconvolution results to use #' @param show_image show a tissue background image #' @param gimage a giotto image @@ -930,7 +857,6 @@ spatPlot = function(...) { #' @param spat_loc_name name of spatial locations #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') -#' @param cell_color_code named vector with colors #' @param line_color color of line within pie charts #' @param radius radios of pie charts #' @param alpha alpha of pie charts @@ -941,11 +867,6 @@ spatPlot = function(...) { #' @param title title for plot (default = deconv_name) #' @param axis_text size of axis text #' @param axis_title size of axis title -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @export @@ -1138,13 +1059,8 @@ spatDeconvPlot = function(gobject, -#' @title dimPlot2D_single -#' @name dimPlot2D_single -#' @description Visualize cells according to dimension reduction coordinates -#' @inheritParams data_access_params -#' @inheritParams plot_params -#' @return ggplot -#' @details Description of parameters. For 3D plots see \code{\link{dimPlot3D}} +# Create a single 2D dimplot. This is looped through by dimPlot2D() if needed. +#' @noRd #' @keywords internal dimPlot2D_single <- function(gobject, spat_unit = NULL, @@ -1424,8 +1340,6 @@ dimPlot2D_single <- function(gobject, } - - ## add % variance explained to names of plot for PCA ## if(dim_reduction_to_use == 'pca') { @@ -1472,47 +1386,31 @@ dimPlot2D_single <- function(gobject, } } - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(pl) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(pl) - } - + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } -#' @title Plot dimension reduction 2D -#' @name dimPlot2D -#' @description Visualize cells according to dimension reduction coordinates + +#' @rdname dimPlot #' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_nn_net_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params #' @inheritParams plot_params -#' @param group_by create multiple plots based on cell annotation column -#' @param group_by_subset subset the group_by factor column -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' @param spat_enr_names names of spatial enrichment results to include -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE #' @return ggplot -#' @details Description of parameters. For 3D plots see \code{\link{dimPlot3D}} #' @family reduced dimension visualizations #' @export dimPlot2D = function(gobject, @@ -1767,15 +1665,11 @@ dimPlot2D = function(gobject, -#' @title dimPlot +#' @title Plot dimension reduction #' @name dimPlot +#' @param \dots dimPlot(...) passes to dimPlot2D() #' @description Visualize cells according to dimension reduction coordinates -#' @inheritDotParams dimPlot2D -#' @return ggplot -#' @details Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{dimPlot3D}} -#' @family reduced dimension visualizations #' @export - dimPlot = function(...) { dimPlot2D(...) @@ -1822,7 +1716,6 @@ plotUMAP_2D = function(gobject, #' @param default_save_name default save name of UMAP plot #' @inheritDotParams dimPlot2D -gobject -dim_reduction_to_use -dim_reduction_name -default_save_name #' @return ggplot -#' @details Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotUMAP_3D}} #' @family reduced dimension visualizations #' @export plotUMAP = function(gobject, @@ -1965,38 +1858,22 @@ plotPCA = function(gobject, ## ** spatial and dim reduction plotting #### -#' @title spatDimPlot2D -#' @name spatDimPlot2D +#' @title spatDimPlot +#' @name spatDimPlot #' @description Visualize cells according to spatial AND dimension reduction coordinates 2D -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_nn_net_params +#' @inheritParams plot_spatnet_params +#' @inheritParams plot_image_params +#' @inheritParams plot_params #' @param spat_loc_name name of spatial locations #' @param plot_alignment direction to align plot -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis #' @param sdimx = spatial dimension to use on x-axis #' @param sdimy = spatial dimension to use on y-axis -#' @param spat_enr_names names of spatial enrichment results to include -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param dim_point_shape point with border or not (border or no_border) -#' @param dim_point_size size of points in dim. reduction space -#' @param dim_point_alpha transparancy of point in dim. reduction space -#' @param dim_point_border_col border color of points in dim. reduction space -#' @param dim_point_border_stroke border stroke of points in dim. reduction space #' @param spat_point_shape shape of points (border, no_border or voronoi) #' @param spat_point_size size of spatial points #' @param spat_point_alpha transparancy of spatial points @@ -2016,14 +1893,6 @@ plotPCA = function(gobject, #' @param spat_center_point_border_stroke border strike size of spatial center points #' @param spat_label_size size of the center label #' @param spat_label_fontface font of the center label -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE -#' @param nn_network_alpha column to use for alpha of the edges -#' @param show_spatial_network show spatial network -#' @param spat_network_name name of spatial network to use -#' @param spat_network_color color of spatial network -#' @param spat_network_alpha alpha of spatial network #' @param show_spatial_grid show spatial grid #' @param spat_grid_name name of spatial grid to use #' @param spat_grid_color color of spatial grid @@ -2034,20 +1903,11 @@ plotPCA = function(gobject, #' @param spat_other_cells_alpha alpha of not selected spat cells #' @param dim_show_legend show legend of dimension reduction plot #' @param spat_show_legend show legend of spatial plot -#' @param legend_text size of legend text -#' @param legend_symbol_size size of legend symbols #' @param dim_background_color background color of points in dim. reduction space #' @param spat_background_color background color of spatial points -#' @param vor_border_color border colorr for voronoi plot +#' @param vor_border_color border color for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' -#' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param +#' @param vor_alpha transparency of voronoi 'cells' #' @return ggplot #' @details Description of parameters. #' @family spatial and dimension reduction visualizations @@ -2286,45 +2146,26 @@ spatDimPlot2D <- function(gobject, combo_plot = cowplot::plot_grid(dmpl, spl, ncol = ncol, nrow = nrow, rel_heights = c(1), rel_widths = c(1), align = 'h') } - - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(combo_plot) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = combo_plot, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(combo_plot) - } - + return(plot_output_handler( + gobject = gobject, + plot_object = combo_plot, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } -#' @title spatDimPlot -#' @name spatDimPlot -#' @description Visualize cells according to spatial AND dimension reduction coordinates 2D -#' @inheritDotParams spatDimPlot2D -#' @return ggplot -#' @details Description of parameters. -#' @family spatial and dimension reduction visualizations +#' @rdname spatDimPlot +#' @param \dots spatDimPlot(...) passes to spatDimPlot2D() #' @export -#' @seealso \code{\link{spatDimPlot2D}} and \code{\link{spatDimPlot3D}} for 3D visualization. -spatDimPlot = function(...) { - - spatDimPlot2D(...) - +spatDimPlot = function(gobject, ...) { + spatDimPlot2D(gobject, ...) } @@ -2334,23 +2175,19 @@ spatDimPlot = function(...) { #' @title spatFeatPlot2D_single #' @name spatFeatPlot2D_single #' @description Visualize cells and feature expression according to spatial coordinates -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_image_params +#' @inheritParams plot_params #' @param spat_loc_name name of spatial locations #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') +#' @param spat_enr_names names of spatial enrichment results to include #' @param expression_values gene expression values to use #' @param feats features to show #' @param order order points according to feature expression -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_style whether to use gradient as 'divergent' or 'sequential' -#' @param gradient_limits vector with lower and upper limits #' @param show_network show underlying spatial network #' @param network_color color of spatial network #' @param spatial_network_name name of spatial network to use @@ -2366,23 +2203,9 @@ spatDimPlot = function(...) { #' @param point_border_col color of border around points #' @param point_border_stroke stroke size of border around points #' @param coord_fix_ratio fix ratio between x and y-axis (default = 1) -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param background_color color of plot background #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' #' @param vor_alpha transparency of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family spatial feature expression visualizations @@ -2398,6 +2221,7 @@ spatFeatPlot2D_single <- function(gobject, spat_loc_name = 'raw', sdimx = 'sdimx', sdimy = 'sdimy', + spat_enr_names = NULL, expression_values = c('normalized', 'scaled', 'custom'), feats, order = TRUE, @@ -2840,56 +2664,34 @@ spatFeatPlot2D_single <- function(gobject, #' @title Plot data in physical space 2D #' @name spatFeatPlot2D #' @description Visualize cells and feature expression according to spatial coordinates -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image or multiple images if group_by -#' @param largeImage_name name of a giottoLargeImage or multiple images if group by +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_image_params +#' @inheritParams plot_params +#' @inheritParams plot_spatnet_params #' @param spat_loc_name name of spatial locations -#' @param group_by create multiple plots based on cell annotation column -#' @param group_by_subset subset the group_by factor column #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') #' @param expression_values gene expression values to use #' @param feats features to show #' @param order order points according to feature expression -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits #' @param show_network show underlying spatial network #' @param network_color color of spatial network -#' @param spatial_network_name name of spatial network to use #' @param edge_alpha alpha of edge #' @param show_grid show spatial grid #' @param grid_color color of spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param midpoint expression midpoint #' @param scale_alpha_with_expression scale expression with ggplot alpha parameter -#' @param point_shape shape of points (border, no_border or voronoi) -#' @param point_size size of point (cell) -#' @param point_alpha transparancy of points -#' @param point_border_col color of border around points -#' @param point_border_stroke stroke size of border around points #' @param coord_fix_ratio fix ratio between x and y-axis (default = 1) -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_legend show legend -#' @param legend_text size of legend text #' @param background_color color of plot background #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' -#' @param vor_alpha transparancy of voronoi 'cells' +#' @param vor_alpha transparency of voronoi 'cells' #' @param axis_text size of axis text #' @param axis_title size of axis title -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family spatial feature expression visualizations @@ -3156,44 +2958,17 @@ spatFeatPlot2D <- function(gobject, #' @title dimFeatPlot2D #' @name dimFeatPlot2D #' @description Visualize gene expression according to dimension reduction coordinates -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_nn_net_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_params #' @param expression_values gene expression values to use #' @param feats features to show #' @param order order points according to feature expression -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE -#' @param network_color color of NN network -#' @param edge_alpha column to use for alpha of the edges #' @param scale_alpha_with_expression scale expression with ggplot alpha parameter -#' @param point_shape point with border or not (border or no_border) -#' @param point_size size of point (cell) -#' @param point_alpha transparancy of points -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param point_border_col color of border around points -#' @param point_border_stroke stroke size of border around points -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param background_color color of plot background -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family dimension reduction feature expression visualizations @@ -3281,7 +3056,7 @@ dimFeatPlot2D <- function(gobject, # if(length(selected_feats) == 1) { subset_expr_data = expr_values[rownames(expr_values) %in% selected_feats, ] - t_sub_expr_data_DT = data.table('selected_feat' = subset_expr_data, 'cell_ID' = colnames(expr_values)) + t_sub_expr_data_DT = data.table::data.table('selected_feat' = subset_expr_data, 'cell_ID' = colnames(expr_values)) data.table::setnames(t_sub_expr_data_DT, 'selected_feat', selected_feats) } else { subset_expr_data = expr_values[rownames(expr_values) %in% selected_feats, ] @@ -3534,67 +3309,39 @@ dimFeatPlot2D <- function(gobject, #' @title spatDimFeatPlot2D #' @name spatDimFeatPlot2D #' @description Visualize cells according to spatial AND dimension reduction coordinates in ggplot mode -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_image_params +#' @inheritParams plot_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_spatnet_params +#' @inheritParams plot_nn_net_params #' @param expression_values feat expression values to use #' @param plot_alignment direction to align plot #' @param feats features to show #' @param order order points according to feature expression -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' @param dim_point_shape dim reduction points with border or not (border or no_border) -#' @param dim_point_size dim reduction plot: point size -#' @param dim_point_alpha transparancy of dim. reduction points -#' @param dim_point_border_col color of border around points -#' @param dim_point_border_stroke stroke size of border around points -#' @param show_NN_network show underlying NN network -#' @param show_spatial_network show underlying spatial netwok -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) #' @param network_name name of NN network to use, if show_NN_network = TRUE #' @param dim_network_color color of NN network #' @param dim_edge_alpha dim reduction plot: column to use for alpha of the edges #' @param scale_alpha_with_expression scale expression with ggplot alpha parameter #' @param sdimx spatial x-axis dimension name (default = 'sdimx') #' @param sdimy spatial y-axis dimension name (default = 'sdimy') -#' @param spatial_network_name name of spatial network to use -#' @param spatial_network_color color of spatial network #' @param show_spatial_grid show spatial grid #' @param grid_color color of spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param spat_point_shape spatial points with border or not (border or no_border) #' @param spat_point_size spatial plot: point size -#' @param spat_point_alpha transparancy of spatial points +#' @param spat_point_alpha transparency of spatial points #' @param spat_point_border_col color of border around points #' @param spat_point_border_stroke stroke size of border around points #' @param spat_edge_alpha edge alpha -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param show_legend show legend -#' @param legend_text size of legend text #' @param dim_background_color color of plot background for dimension plot #' @param spat_background_color color of plot background for spatial plot #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' #' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family spatial and dimension reduction feature expression visualizations @@ -3784,67 +3531,30 @@ spatDimFeatPlot2D <- function(gobject, -#' @title spatCellPlot2D -#' @name spatCellPlot2D +#' @title spatCellPlot +#' @name spatCellPlot #' @description Visualize cells according to spatial coordinates -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_image_params +#' @inheritParams plot_spatnet_params #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') -#' @param spat_enr_names names of spatial enrichment results to include #' @param cell_annotation_values numeric cell annotation columns -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param point_shape shape of points (border, no_border or voronoi) -#' @param point_size size of point (cell) -#' @param point_alpha transparancy of spatial points -#' @param point_border_col color of border around points -#' @param point_border_stroke stroke size of border around points -#' @param show_cluster_center plot center of selected clusters -#' @param show_center_label plot label of selected clusters -#' @param center_point_size size of center points -#' @param center_point_border_col border color of center points -#' @param center_point_border_stroke border stroke size of center points -#' @param label_size size of labels -#' @param label_fontface font of labels #' @param show_network show underlying spatial network -#' @param spatial_network_name name of spatial network to use #' @param network_color color of spatial network #' @param network_alpha alpha of spatial network #' @param show_grid show spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param grid_color color of spatial grid -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells -#' @param other_point_size point size of not selected cells -#' @param other_cells_alpha alpha of not selected cells #' @param coord_fix_ratio fix ratio between x and y-axis -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param legend_symbol_size size of legend symbols -#' @param background_color color of plot background #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' -#' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param +#' @param vor_alpha transparency of voronoi 'cells' #' @return ggplot #' @details Description of parameters. #' @family spatial cell annotation visualizations @@ -4024,13 +3734,8 @@ spatCellPlot2D = function(gobject, } -#' @title spatCellPlot -#' @name spatCellPlot -#' @description Visualize cells according to spatial coordinates -#' @inheritDotParams spatCellPlot2D -#' @return ggplot -#' @details Description of parameters. -#' @family spatial cell annotation visualizations +#' @rdname spatCellPlot +#' @param \dots spatCellPlot(...) passes to spatCellPlot2D() #' @export spatCellPlot = function(...) { @@ -4042,58 +3747,18 @@ spatCellPlot = function(...) { -#' @title dimCellPlot2D -#' @name dimCellPlot2D +#' @title dimCellPlot +#' @name dimCellPlot #' @description Visualize cells according to dimension reduction coordinates -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' @param spat_enr_names names of spatial enrichment results to include +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_nn_net_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_params #' @param cell_annotation_values numeric cell annotation columns -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE -#' @param cell_color_code named vector with colors for cell annotation values -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells -#' @param other_point_size size of not selected cells -#' @param show_cluster_center plot center of selected clusters -#' @param show_center_label plot label of selected clusters -#' @param center_point_size size of center points -#' @param center_point_border_col border color of center points -#' @param center_point_border_stroke border stroke size of center points -#' @param label_size size of labels -#' @param label_fontface font of labels -#' @param edge_alpha column to use for alpha of the edges -#' @param point_shape point with border or not (border or no_border) -#' @param point_size size of point (cell) -#' @param point_alpha transparancy of dim. reduction points -#' @param point_border_col color of border around points -#' @param point_border_stroke stroke size of border around points -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param legend_symbol_size size of legend symbols -#' @param background_color color of plot background -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. For 3D plots see \code{\link{dimPlot3D}} #' @family dimension reduction cell annotation visualizations @@ -4255,14 +3920,8 @@ dimCellPlot2D = function(gobject, -#' @title dimCellPlot -#' @name dimCellPlot -#' @description Visualize cells according to dimension reduction coordinates -#' @param gobject giotto object -#' @inheritDotParams dimCellPlot2D -gobject -#' @return ggplot -#' @details Description of parameters. For 3D plots see \code{\link{dimCellPlot2D}} -#' @family dimension reduction cell annotation visualizations +#' @rdname dimCellPlot +#' @param ... dimCellPlot(...) passes to dimCellPlot2D() #' @export dimCellPlot = function(gobject, ...) { @@ -4276,35 +3935,22 @@ dimCellPlot = function(gobject, ...) { #' @title spatDimCellPlot2D #' @name spatDimCellPlot2D #' @description Visualize numerical features of cells according to spatial AND dimension reduction coordinates in 2D -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_cow_params +#' @inheritParams plot_image_params +#' @inheritParams plot_spatenr_params +#' @inheritParams plot_dimred_params +#' @inheritParams plot_nn_net_params +#' @inheritParams plot_params #' @param plot_alignment direction to align plot -#' @param spat_enr_names names of spatial enrichment results to include #' @param cell_annotation_values numeric cell annotation columns -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis #' @param sdimx = spatial dimension to use on x-axis #' @param sdimy = spatial dimension to use on y-axis -#' @param cell_color_gradient vector with 3 colors for numeric data -#' @param gradient_midpoint midpoint for color gradient -#' @param gradient_limits vector with lower and upper limits -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param dim_point_shape dim reduction points with border or not (border or no_border) -#' @param dim_point_size size of points in dim. reduction space -#' @param dim_point_alpha transparancy of dim. reduction points -#' @param dim_point_border_col border color of points in dim. reduction space -#' @param dim_point_border_stroke border stroke of points in dim. reduction space #' @param spat_point_shape shape of points (border, no_border or voronoi) #' @param spat_point_size size of spatial points -#' @param spat_point_alpha transparancy of spatial points +#' @param spat_point_alpha transparency of spatial points #' @param spat_point_border_col border color of spatial points #' @param spat_point_border_stroke border stroke of spatial points #' @param dim_show_cluster_center show the center of each cluster @@ -4321,9 +3967,6 @@ dimCellPlot = function(gobject, ...) { #' @param spat_center_point_border_stroke stroke size of the spatial center points #' @param spat_label_size size of the center label #' @param spat_label_fontface font of the center label -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param nn_network_name name of NN network to use, if show_NN_network = TRUE #' @param dim_edge_alpha column to use for alpha of the edges #' @param spat_show_network show spatial network #' @param spatial_network_name name of spatial network to use @@ -4332,31 +3975,15 @@ dimCellPlot = function(gobject, ...) { #' @param spat_show_grid show spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param spat_grid_color color of spatial grid -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells #' @param dim_other_point_size size of not selected dim cells #' @param spat_other_point_size size of not selected spat cells #' @param spat_other_cells_alpha alpha of not selected spat cells #' @param coord_fix_ratio ratio for coordinates -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_legend show legend -#' @param legend_text size of legend text -#' @param legend_symbol_size size of legend symbols #' @param dim_background_color background color of points in dim. reduction space #' @param spat_background_color background color of spatial points #' @param vor_border_color border colorr for voronoi plot #' @param vor_max_radius maximum radius for voronoi 'cells' #' @param vor_alpha transparancy of voronoi 'cells' -#' @param axis_text size of axis text -#' @param axis_title size of axis title -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family spatial and dimension reduction cell annotation visualizations @@ -4661,7 +4288,7 @@ dimPlot_2D_plotly <- function(gobject, dim_dfr = dim_dfr[,c(dim1_to_use, dim2_to_use)] dim_names = colnames(dim_dfr) dim_DT = data.table::as.data.table(dim_dfr) - dim_DT[, cell_ID := rownames(dim_dfr)] + dim_DT[, 'cell_ID' := rownames(dim_dfr)] ## annotated cell metadata @@ -5151,43 +4778,9 @@ dimPlot_3D_plotly <- function(gobject, -#' @title dimPlot3D -#' @name dimPlot3D -#' @description Visualize cells according to dimension reduction coordinates -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param dim_reduction_to_use dimension reduction to use -#' @param dim_reduction_name dimension reduction name -#' @param dim1_to_use dimension to use on x-axis -#' @param dim2_to_use dimension to use on y-axis -#' @param dim3_to_use dimension to use on z-axis -#' @param spat_enr_names names of spatial enrichment results to include -#' @param show_NN_network show underlying NN network -#' @param nn_network_to_use type of NN network to use (kNN vs sNN) -#' @param network_name name of NN network to use, if show_NN_network = TRUE -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells -#' @param other_point_size size of not selected cells -#' @param show_cluster_center plot center of selected clusters -#' @param show_center_label plot label of selected clusters -#' @param center_point_size size of center points -#' @param label_size size of labels -#' @param edge_alpha column to use for alpha of the edges -#' @param point_size size of point (cell) -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @return plotly -#' @details Description of parameters. -#' @family reduced dimension visualizations + +#' @rdname dimPlot +#' @return plotly (dimplot3D only) #' @export dimPlot3D = function(gobject, spat_unit = NULL, @@ -5868,47 +5461,15 @@ spatPlot_3D_plotly = function(gobject, -#' @title spatPlot3D -#' @name spatPlot3D -#' @description Visualize cells according to spatial coordinates -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type -#' @param sdimx x-axis dimension name (default = 'sdimx') -#' @param sdimy y-axis dimension name (default = 'sdimy') + +#' @rdname spatPlot #' @param sdimz z-axis dimension name (default = 'sdimy') -#' @param spat_enr_names names of spatial enrichment results to include -#' @param point_size size of point (cell) -#' @param cell_color color for cells (see details) -#' @param cell_color_code named vector with colors -#' @param select_cell_groups select subset of cells/clusters based on cell_color parameter -#' @param select_cells select subset of cells based on cell IDs -#' @param show_other_cells display not selected cells -#' @param other_cell_color color of not selected cells -#' @param other_point_size size of not selected cells -#' @param other_cell_alpha alpha of not selected cells -#' @param show_network show underlying spatial network -#' @param network_color color of spatial network -#' @param network_alpha opacity of spatial network -#' @param spatial_network_name name of spatial network to use -#' @param show_grid show spatial grid -#' @param grid_color color of spatial grid #' @param grid_alpha opacity of spatial grid -#' @param spatial_grid_name name of spatial grid to use -#' @param title title of plot #' @param axis_scale the way to scale the axis #' @param custom_ratio customize the scale of the plot #' @param x_ticks set the number of ticks on the x-axis #' @param y_ticks set the number of ticks on the y-axis #' @param z_ticks set the number of ticks on the z-axis -#' @param show_legend show legend -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @return ggplot -#' @family spatial visualizations #' @export spatPlot3D = function(gobject, spat_unit = NULL, @@ -6046,9 +5607,9 @@ spatPlot3D = function(gobject, #' @title spatDimPlot3D #' @name spatDimPlot3D #' @description Visualize cells according to spatial AND dimension reduction coordinates in plotly mode -#' @param gobject giotto object -#' @param spat_unit spatial unit -#' @param feat_type feature type +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param plot_alignment direction to align plot #' @param dim_reduction_to_use dimension reduction to use #' @param dim_reduction_name dimension reduction name @@ -6069,9 +5630,6 @@ spatPlot3D = function(gobject, #' @param show_center_label provide a label for each cluster #' @param center_point_size size of the center point #' @param label_size size of the center label -#' @param cell_color color for cells (see details) -#' @param color_as_factor convert color column to factor -#' @param cell_color_code named vector with colors #' #' @param select_cell_groups select subset of cells/clusters based on cell_color parameter #' @param select_cells select subset of cells based on cell IDs @@ -6100,12 +5658,6 @@ spatPlot3D = function(gobject, #' @param y_ticks set the number of ticks on the y-axis #' @param z_ticks set the number of ticks on the z-axis #' @param legend_text_size size of legend -#' -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plotly #' @details Description of parameters. #' @family spatial and dimension reduction visualizations @@ -6863,12 +6415,13 @@ spatDimPlot3D <- function(gobject, #' @title spatGenePlot3D #' @name spatGenePlot3D #' @description Visualize cells and gene expression according to spatial coordinates -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param spat_loc_name name of spatial locations to use #' @param expression_values gene expression values to use -#' @param genes genes to show +#' @param genes deprecated +#' @param feats feats to show +#' @param spat_enr_names names of spatial enrichment results to include #' #' @param cluster_column cluster column to select groups #' @param select_cell_groups select subset of cells/clusters based on cell_color parameter @@ -6895,12 +6448,6 @@ spatDimPlot3D <- function(gobject, #' @param x_ticks set the number of ticks on the x-axis #' @param y_ticks set the number of ticks on the y-axis #' @param z_ticks set the number of ticks on the z-axis -#' -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family spatial gene expression visualizations @@ -6910,7 +6457,9 @@ spatGenePlot3D <- function(gobject, feat_type = NULL, spat_loc_name = NULL, expression_values = c('normalized', 'scaled', 'custom'), - genes, + genes = deprecated(), + feats, + spat_enr_names = NULL, show_network = FALSE, network_color = NULL, @@ -6944,6 +6493,14 @@ spatGenePlot3D <- function(gobject, save_param = list(), default_save_name = "spatGenePlot3D"){ + # deprecate + if (GiottoUtils::is_present(genes)) { + deprecate_warn('0.0.0.9000', + 'GiottoVisuals::spatGenePlot3D(genes = )', + 'GiottoVisuals::spatGenePlot3D(feats = )') + feats <- genes + } + # Set feat_type and spat_unit spat_unit = set_default_spat_unit(gobject = gobject, spat_unit = spat_unit) @@ -6954,7 +6511,7 @@ spatGenePlot3D <- function(gobject, # data.table variables cell_ID = NULL - selected_genes = genes + selected_genes = feats values = match.arg(expression_values, c('normalized', 'scaled', 'custom')) expr_values = get_expression_values(gobject = gobject, @@ -7248,6 +6805,7 @@ spatGenePlot3D <- function(gobject, #' @name dimGenePlot3D #' @description Visualize cells and gene expression according to dimension reduction coordinates #' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param expression_values gene expression values to use #' @param genes genes to show #' @param dim_reduction_to_use dimension reduction to use @@ -7276,11 +6834,6 @@ spatGenePlot3D <- function(gobject, #' @param genes_low_color color for low expression levels #' #' @param show_legend show legend -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @family dimension reduction gene expression visualizations @@ -7342,7 +6895,7 @@ dimGenePlot3D <- function(gobject, # if(length(selected_genes) == 1) { subset_expr_data = expr_values[rownames(expr_values) %in% selected_genes, ] - t_sub_expr_data_DT = data.table('selected_gene' = subset_expr_data, 'cell_ID' = colnames(expr_values)) + t_sub_expr_data_DT = data.table::data.table('selected_gene' = subset_expr_data, 'cell_ID' = colnames(expr_values)) data.table::setnames(t_sub_expr_data_DT, 'selected_gene', selected_genes) } else { subset_expr_data = expr_values[rownames(expr_values) %in% selected_genes, ] @@ -7581,9 +7134,8 @@ dimGenePlot3D <- function(gobject, #' @title spatDimGenePlot3D #' @name spatDimGenePlot3D #' @description Visualize cells according to spatial AND dimension reduction coordinates in ggplot mode -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param spat_loc_name name of spatial locations to use #' @param expression_values gene expression values to use #' @param plot_alignment direction to align plot @@ -7634,12 +7186,6 @@ dimGenePlot3D <- function(gobject, #' @param x_ticks set the number of ticks on the x-axis #' @param y_ticks set the number of ticks on the y-axis #' @param z_ticks set the number of ticks on the z-axis -#' -#' @param show_plot show plots -#' @param return_plot return plotly object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plotly #' @details Description of parameters. #' @family spatial and dimension reduction gene expression visualizations @@ -7732,7 +7278,7 @@ spatDimGenePlot3D <- function(gobject, # only keep genes that are in the dataset selected_genes = selected_genes[selected_genes %in% rownames(expr_values) ] subset_expr_data = expr_values[rownames(expr_values) %in% selected_genes, ] - t_sub_expr_data_DT = data.table('selected_gene' = subset_expr_data, 'cell_ID' = colnames(expr_values)) + t_sub_expr_data_DT = data.table::data.table('selected_gene' = subset_expr_data, 'cell_ID' = colnames(expr_values)) data.table::setnames(t_sub_expr_data_DT, 'selected_gene', selected_genes) diff --git a/R/spatial_in_situ_visuals.R b/R/vis_spatial_in_situ.R similarity index 90% rename from R/spatial_in_situ_visuals.R rename to R/vis_spatial_in_situ.R index 91fd9f6..931f2be 100644 --- a/R/spatial_in_situ_visuals.R +++ b/R/vis_spatial_in_situ.R @@ -14,37 +14,21 @@ #' @title spatInSituPlotPoints #' @name spatInSituPlotPoints #' @description Function to plot multiple features for multiple modalities at the spatial in situ level -#' @param gobject giotto object -#' @param show_image show a tissue background image -#' @param gimage a giotto image -#' @param image_name name of a giotto image -#' @param largeImage_name name of a giottoLargeImage -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_feat_params +#' @inheritParams plot_poly_params +#' @inheritParams plot_image_params #' @param spat_loc_name name of spatial locations -#' @param feats features to plot +#' @param feats named list of features to plot #' @param feat_type feature types of the feats -#' @param feats_color_code code to color the provided features -#' @param feat_shape_code code to shape the provided feature types #' @param sdimx spatial dimension x #' @param sdimy spatial dimension y #' @param point_size size of the points -#' @param line line size of point shapes +#' @param stroke stroke to apply to feature points #' @param expand_counts expand feature coordinate counts (see details) #' @param count_info_column column name with count information (if expand_counts = TRUE) #' @param jitter maximum x,y jitter provided as c(x, y) -#' @param show_polygon overlay polygon information (e.g. cell shape) -#' @param use_overlap use polygon and feature coordinates overlap results -#' @param polygon_feat_type feature type associated with polygon information -#' @param polygon_color color for polygon border -#' @param polygon_bg_color color for polygon background (overruled by polygon_fill) -#' @param polygon_fill fill color or column for polygon -#' @param polygon_fill_gradient polygon fill gradient colors given in order from low to high -#' @param polygon_fill_gradient_midpoint value to set as gradient midpoint (optional). If -#' left as \code{NULL}, the median value detected will be chosen -#' @param polygon_fill_as_factor is fill color a factor -#' @param polygon_fill_code code to color the fill column -#' @param polygon_alpha alpha of polygon -#' @param polygon_line_size line width of the polygon's outline #' @param axis_text axis text size #' @param axis_title title text size #' @param legend_text legend text size @@ -53,14 +37,23 @@ #' @param show_legend show legend #' @param plot_method method to plot points #' @param plot_last which layer to show on top of plot, polygons (default) or points. -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param -#' @param verbose verbosity +#' @param verbose be verbose #' @return ggplot -#' @details TODO +#' @examples +#' \dontrun{ +#' library(GiottoVisuals) +# g <- GiottoData::loadGiottoMini('viz') +# +# spatInSituPlotPoints( +# g, +# polygon_fill = 'nr_feats', +# polygon_fill_as_factor = FALSE, +# polygon_feat_type = 'aggregate', +# polygon_line_size = 0.1, +# polygon_alpha = 1 +# ) +#' } +#' #' @family In Situ visualizations #' @export spatInSituPlotPoints <- function(gobject, @@ -171,7 +164,7 @@ spatInSituPlotPoints <- function(gobject, sel_feats = feats) } - spatial_feat_info = rbindlist(spatial_feat_info, fill = TRUE) + spatial_feat_info = data.table::rbindlist(spatial_feat_info, fill = TRUE) plot = plot_feature_points_layer(ggobject = plot, instrs = instructions(gobject), @@ -216,7 +209,7 @@ spatInSituPlotPoints <- function(gobject, include_poly_info = TRUE, poly_info = polygon_feat_type) - polygon_dt = rbindlist(polygon_combo, fill = TRUE) + polygon_dt = data.table::rbindlist(polygon_combo, fill = TRUE) data.table::setnames(polygon_dt, old = 'cell_ID', new = 'poly_ID') @@ -267,7 +260,7 @@ spatInSituPlotPoints <- function(gobject, include_poly_info = TRUE, poly_info = polygon_feat_type) - polygon_dt = rbindlist(polygon_combo, fill = TRUE) + polygon_dt = data.table::rbindlist(polygon_combo, fill = TRUE) data.table::setnames(polygon_dt, old = 'cell_ID', new = 'poly_ID') @@ -495,7 +488,10 @@ spatInSituPlotHex_single = function(gobject, #' @title spatInSituPlotHex #' @name spatInSituPlotHex #' @description Function to plot hexbins for features for multiple modalities at the spatial in situ level -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_poly_params +#' @inheritParams plot_cow_params #' @param feats features to plot #' @param feat_type feature types of the feats #' @param sdimx spatial dimension x @@ -505,27 +501,12 @@ spatInSituPlotHex_single = function(gobject, #' @param min_axis_bins number of bins to create per range defined by minor axis. #' (default value is 10) #' @param alpha alpha of hexbin plot -#' @param show_polygon overlay polygon information (cell shape) -#' @param polygon_feat_type feature type associated with polygon information -#' @param polygon_color color for polygon border -#' @param polygon_fill fill color or column for polygon -#' @param polygon_fill_as_factor is fill color a factor -#' @param polygon_alpha alpha of polygon -#' @param polygon_size size of polygon border +#' @param polygon_size deprecated #' @param coord_fix_ratio fix ratio between x and y-axis #' @param axis_text axis text size #' @param axis_title title text size #' @param legend_text legend text size #' @param background_color background color -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details TODO #' @family In Situ visualizations @@ -544,7 +525,8 @@ spatInSituPlotHex = function(gobject, polygon_fill = NULL, polygon_fill_as_factor = NULL, polygon_alpha = 0.5, - polygon_size = 0.5, + polygon_size = deprecated(), + polygon_line_size = 0.5, coord_fix_ratio = 1, axis_text = 8, axis_title = 8, @@ -560,6 +542,14 @@ spatInSituPlotHex = function(gobject, save_param = list(), default_save_name = 'spatInSituPlotHex') { + # deprecate + if (GiottoUtils::is_present(polygon_size)) { + deprecate_warn('0.0.0.9000', + 'GiottoVisuals::spatInSituPlotHex(polygon_size = )', + 'GiottoVisuals::spatInSituPlotHex(polygon_size = )') + polygon_line_size <- polygon_size + } + if(is.null(feats)) { stop('You need to select features (feats) and modify feature types (feat_type) if needed \n') @@ -589,7 +579,7 @@ spatInSituPlotHex = function(gobject, polygon_fill = polygon_fill, polygon_fill_as_factor = polygon_fill_as_factor, polygon_alpha = polygon_alpha, - polygon_size = polygon_size, + polygon_size = polygon_line_size, coord_fix_ratio = coord_fix_ratio, axis_text = axis_text, axis_title = axis_title, @@ -749,33 +739,21 @@ spatInSituPlotDensity_single = function(gobject, #' @title spatInSituPlotDensity #' @name spatInSituPlotDensity #' @description Function for density plots for features for multiple modalities at the spatial in situ level -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_poly_params +#' @inheritParams plot_cow_params #' @param feats features to plot #' @param feat_type feature types of the feats #' @param sdimx spatial dimension x #' @param sdimy spatial dimension y #' @param alpha alpha of density plot -#' @param show_polygon overlay polygon information (cell shape) -#' @param polygon_feat_type feature type associated with polygon information -#' @param polygon_color color for polygon border -#' @param polygon_fill fill color or column for polygon -#' @param polygon_fill_as_factor is fill color a factor -#' @param polygon_alpha alpha of polygon -#' @param polygon_size size of polygon border +#' @param polygon_size deprecated #' @param coord_fix_ratio fix ratio between x and y-axis #' @param axis_text axis text size #' @param axis_title title text size #' @param legend_text legend text size #' @param background_color background color -#' @param cow_n_col cowplot param: how many columns -#' @param cow_rel_h cowplot param: relative height -#' @param cow_rel_w cowplot param: relative width -#' @param cow_align cowplot param: how to align -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters, see \code{\link{showSaveParameters}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details TODO #' @family In Situ visualizations @@ -792,7 +770,8 @@ spatInSituPlotDensity = function(gobject, polygon_fill = NULL, polygon_fill_as_factor = NULL, polygon_alpha = 0.5, - polygon_size = 0.5, + polygon_size = deprecated(), + polygon_line_size = 0.5, coord_fix_ratio = 1, axis_text = 8, axis_title = 8, @@ -808,6 +787,14 @@ spatInSituPlotDensity = function(gobject, save_param = list(), default_save_name = 'spatInSituPlotDensity') { + # deprecate + if (GiottoUtils::is_present(polygon_size)) { + deprecate_warn('0.0.0.9000', + 'GiottoVisuals::spatInSituPlotDensity(polygon_size = )', + 'GiottoVisuals::spatInSituPlotDensity(polygon_size = )') + polygon_line_size <- polygon_size + } + if(is.null(feats)) { stop('You need to select features (feat) and modify feature types (feat_type) if needed \n') diff --git a/R/spatial_interaction_visuals.R b/R/vis_spatial_interaction.R similarity index 92% rename from R/spatial_interaction_visuals.R rename to R/vis_spatial_interaction.R index fbe5308..ab8ed0c 100644 --- a/R/spatial_interaction_visuals.R +++ b/R/vis_spatial_interaction.R @@ -1,16 +1,12 @@ #' @title cellProximityBarplot #' @name cellProximityBarplot #' @description Create barplot from cell-cell proximity scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param CPscore CPscore, output from cellProximityEnrichment() #' @param min_orig_ints filter on minimum original cell-cell interactions #' @param min_sim_ints filter on minimum simulated cell-cell interactions #' @param p_val p-value -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot barplot #' @details This function creates a barplot that shows the spatial proximity #' enrichment or depletion of cell type pairs. @@ -79,17 +75,13 @@ cellProximityBarplot = function(gobject, #' @title cellProximityHeatmap #' @name cellProximityHeatmap #' @description Create heatmap from cell-cell proximity scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param CPscore CPscore, output from cellProximityEnrichment() #' @param scale scale cell-cell proximity interaction scores #' @param order_cell_types order cell types based on enrichment correlation #' @param color_breaks numerical vector of length 3 to represent min, mean and maximum #' @param color_names character color vector of length 3 -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot heatmap #' @details This function creates a heatmap that shows the spatial proximity #' enrichment or depletion of cell type pairs. @@ -165,7 +157,7 @@ cellProximityHeatmap = function(gobject, } heatm = ComplexHeatmap::Heatmap(matrix = final_matrix, cluster_rows = F, cluster_columns = F, - col = circlize::colorRamp2(breaks = color_breaks, colors = color_names)) + col = colorRamp2::colorRamp2(breaks = color_breaks, colors = color_names)) } else { heatm = ComplexHeatmap::Heatmap(matrix = final_matrix, cluster_rows = F, cluster_columns = F) } @@ -187,7 +179,8 @@ cellProximityHeatmap = function(gobject, #' @title cellProximityNetwork #' @name cellProximityNetwork #' @description Create network from cell-cell proximity scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param CPscore CPscore, output from cellProximityEnrichment() #' @param remove_self_edges remove enrichment/depletion edges with itself #' @param self_loop_strength size of self-loops @@ -202,11 +195,6 @@ cellProximityHeatmap = function(gobject, #' @param node_size size of nodes #' @param node_color_code color code for the nodes (e.g. cell labels) #' @param node_text_size size of node labels -#' @param show_plot show plot -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return igraph plot #' @details This function creates a network that shows the spatial proximity #' enrichment or depletion of cell type pairs. @@ -1108,25 +1096,15 @@ cellProximityVisPlot <- function(gobject, # * #### # NEW plots #### -#' @title plotCellProximityGenes -#' @name plotCellProximityGenes -#' @description Create visualization for cell proximity feature scores -#' @inheritDotParams plotCellProximityFeats -#' @export -plotCellProximityGenes <- function(...){ - - .Deprecated(new="plotCellProximityFeats") - - plotCellProximityFeats(...) - -} #' @title plotCellProximityFeats #' @name plotCellProximityFeats #' @description Create visualization for cell proximity feature scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param icfObject ICF (interaction changed feature) score object #' @param method plotting method to use #' @param min_cells minimum number of source cell type @@ -1139,12 +1117,6 @@ plotCellProximityGenes <- function(...){ #' @param min_zscore minimum z-score change #' @param zscores_column calculate z-scores over cell types or featuress #' @param direction differential expression directions to keep -#' @param cell_color_code vector of colors with cell types as names -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plot #' @export plotCellProximityFeats = function(gobject, @@ -1364,8 +1336,8 @@ plotCellProximityFeats = function(gobject, changed_feats_d = data.table::dcast.data.table(changed_feats, cell_type~int_cell_type, value.var = 'N', fill = 0) changed_feats_m = dt_to_matrix(changed_feats_d) - col_fun = circlize::colorRamp2(breaks = stats::quantile(log2(changed_feats_m+1)), - colors = c("white", 'white', "blue", "yellow", "red")) + col_fun = colorRamp2::colorRamp2(breaks = stats::quantile(log2(changed_feats_m+1)), + colors = c("white", 'white', "blue", "yellow", "red")) heatm = ComplexHeatmap::Heatmap(log2(changed_feats_m+1), col = col_fun, row_title = 'cell_type', column_title = 'int_cell_type', heatmap_legend_param = list(title = 'log2(# DEGs)')) @@ -1387,28 +1359,18 @@ plotCellProximityFeats = function(gobject, } - } -#' @title plotCPG -#' @name plotCPG -#' @description Create visualization for cell proximity feature scores -#' @inheritDotParams plotCellProximityFeats -#' @export -plotCPG <- function(...){ - - .Deprecated(new="plotCPF") - - plotCellProximityFeats(...) -} #' @title plotCPF #' @name plotCPF #' @description Create visualization for cell proximity feature scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param icfObject ICF (interaction changed feature) score object #' @param method plotting method to use #' @param min_cells minimum number of source cell type @@ -1421,12 +1383,6 @@ plotCPG <- function(...){ #' @param min_zscore minimum z-score change #' @param zscores_column calculate z-scores over cell types or features #' @param direction differential expression directions to keep -#' @param cell_color_code vector of colors with cell types as names -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plot #' @export plotCPF = function(gobject, @@ -1478,17 +1434,13 @@ plotCPF = function(gobject, #' @title Plot interaction changed features #' @name plotInteractionChangedFeats #' @description Create barplot to visualize interaction changed features -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param icfObject ICF (interaction changed feature) score object #' @param source_type cell type of the source cell #' @param source_markers markers for the source cell type #' @param ICF_feats named character vector of ICF features -#' @param cell_color_code cell color code for the interacting cell types -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plot #' @export plotInteractionChangedFeats = function(gobject, @@ -1580,35 +1532,19 @@ plotInteractionChangedFeats = function(gobject, -#' @title Plot interaction changed genes -#' @name plotInteractionChangedGenes -#' @description Create barplot to visualize interaction changed features -#' @inheritDotParams plotInteractionChangedFeats -#' @seealso \code{\link{plotInteractionChangedFeats}} -#' @export -plotInteractionChangedGenes = function(...) { - - .Deprecated(new="plotInteractionChangedFeats") - - plotInteractionChangedFeats(...) -} #' @title Plot interaction changed features #' @name plotICF #' @description Create barplot to visualize interaction changed features -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params #' @param icfObject ICF (interaction changed feature) score object #' @param source_type cell type of the source cell #' @param source_markers markers for the source cell type #' @param ICF_feats named character vector of ICF features -#' @param cell_color_code cell color code for the interacting cell types -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return plot #' @export plotICF = function(gobject, @@ -1641,26 +1577,15 @@ plotICF = function(gobject, -#' @title plotICG -#' @name plotICG -#' @description Create barplot to visualize interaction changed features -#' @inheritDotParams plotICF -#' @seealso \code{\link{plotICF}} -#' @export -plotICG = function(...) { - - .Deprecated(new="plotICF") - plotInteractionChangedFeats(...) - -} #' @title plotCombineInteractionChangedFeats #' @name plotCombineInteractionChangedFeats #' @description Create visualization for combined (pairwise) ICF scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param combIcfObject ICFscores, output from combineInteractionChangedFeats() #' @param selected_interactions interactions to show #' @param selected_feat_to_feat pairwise feature combinations to show @@ -1671,11 +1596,6 @@ plotICG = function(...) { #' @param facet_ncol ggplot facet ncol parameter #' @param facet_nrow ggplot facet nrow parameter #' @param colors vector with two colors to use -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotCombineInteractionChangedFeats <- function(gobject, @@ -1793,40 +1713,14 @@ plotCombineInteractionChangedFeats <- function(gobject, -#' @title plotCombineInteractionChangedGenes -#' @name plotCombineInteractionChangedGenes -#' @description Create visualization for combined (pairwise) ICF scores -#' @inheritDotParams plotCombineInteractionChangedFeats -#' @seealso \code{\link{plotCombineInteractionChangedFeats}} -#' @export -plotCombineInteractionChangedGenes <- function(...) { - - .Deprecated(new="plotCombineInteractionChangedFeats") - - plotCombineInteractionChangedFeats(...) - -} - - - -#' @title plotCombineCellProximityGenes -#' @description Create visualization for combined (pairwise) ICG scores -#' @inheritDotParams plotCombineInteractionChangedFeats -#' @seealso \code{\link{plotCombineInteractionChangedFeats}} -#' @export -plotCombineCellProximityGenes <- function(...) { - - .Deprecated(new = "plotCombineInteractionChangedFeats") - plotCombineInteractionChangedGenes(...) - -} #' @title plotCombineICF #' @name plotCombineICF #' @description Create visualization for combined (pairwise) ICF scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param combIcfObject ICFscores, output from combineInteractionChangedFeats() #' @param selected_interactions interactions to show #' @param selected_feat_to_feat pairwise feature combinations to show @@ -1837,11 +1731,6 @@ plotCombineCellProximityGenes <- function(...) { #' @param facet_ncol ggplot facet ncol parameter #' @param facet_nrow ggplot facet nrow parameter #' @param colors vector with two colors to use -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotCombineICF <- function(gobject, @@ -1880,44 +1769,100 @@ plotCombineICF <- function(gobject, -#' @title plotCombineICG -#' @name plotCombineICG -#' @description Create visualization for combined (pairwise) ICF scores -#' @inheritDotParams plotCombineICF -#' @seealso \code{\link{plotCombineICF}} -plotCombineICG <- function(...) { - .Deprecated(new = "plotCombineICF") - plotCombineICF(...) -} +## helper #### +# TODO +#' @title filterInteractionChangedFeats +#' @name filterInteractionChangedFeats +#' @description Filter Interaction Changed Feature scores. +#' @param icfObject ICF (interaction changed feature) score object +#' @param min_cells minimum number of source cell type +#' @param min_cells_expr minimum expression level for source cell type +#' @param min_int_cells minimum number of interacting neighbor cell type +#' @param min_int_cells_expr minimum expression level for interacting neighbor cell type +#' @param min_fdr minimum adjusted p-value +#' @param min_spat_diff minimum absolute spatial expression difference +#' @param min_log2_fc minimum log2 fold-change +#' @param min_zscore minimum z-score change +#' @param zscores_column calculate z-scores over cell types or genes +#' @param direction differential expression directions to keep +#' @return icfObject that contains the filtered differential feature scores +#' @keywords internal +filterInteractionChangedFeats = function(icfObject, + min_cells = 4, + min_cells_expr = 1, + min_int_cells = 4, + min_int_cells_expr = 1, + min_fdr = 0.1, + min_spat_diff = 0.2, + min_log2_fc = 0.2, + min_zscore = 2, + zscores_column = c('cell_type', 'feats'), + direction = c('both', 'up', 'down')) { -#' @title plotCombineCPG -#' @description Create visualization for combined (pairwise) ICF scores -#' @inheritDotParams plotCombineICF -#' @seealso \code{\link{plotCombineICF}} -#' @export -plotCombineCPG <- function(...) { + # data.table variables + nr_select = int_nr_select = zscores = log2fc = sel = other = p.adj = NULL + + if(!'icfObject' %in% class(icfObject)) { + stop('\n icfObject needs to be the output from findInteractionChangedFeats() or findICF() \n') + } + + zscores_column = match.arg(zscores_column, choices = c('cell_type', 'feats')) + + ICFscore = copy(icfObject[['ICFscores']]) - .Deprecated(new = "plotCombineICF") + # other parameters + direction = match.arg(direction, choices = c('both', 'up', 'down')) - plotCombineICF(...) + + ## sequential filter steps ## + # 1. minimum number of source and target cells + selection_scores = ICFscore[nr_select >= min_cells & int_nr_select >= min_int_cells] + + # 2. create z-scores for log2fc per cell type + selection_scores[, zscores := scale(log2fc), by = c(zscores_column)] + + # 3. filter based on z-scores and minimum levels + comb_DT = rbind(selection_scores[zscores >= min_zscore & abs(diff) >= min_spat_diff & log2fc >= min_log2_fc & sel >= min_cells_expr], + selection_scores[zscores <= -min_zscore & abs(diff) >= min_spat_diff & log2fc <= -min_log2_fc & other >= min_int_cells_expr]) + + # 4. filter based on adjusted p-value (fdr) + comb_DT = comb_DT[p.adj < min_fdr] + + + if(direction == 'both') { + selection_scores = selection_scores + } else if(direction == 'up') { + selection_scores = selection_scores[log2fc >= min_log2_fc] + } else if(direction == 'down') { + selection_scores = selection_scores[log2fc <= -min_log2_fc] + } + + + newobj = copy(icfObject) + newobj[['ICFscores']] = comb_DT + + return(newobj) } + + # * #### # cell communication plots #### #' @title plotCombineCellCellCommunication #' @name plotCombineCellCellCommunication #' @description Create visualization for combined (pairwise) cell proximity gene scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param combCCcom combined communcation scores, output from combCCcom() #' @param selected_LR selected ligand-receptor pair #' @param selected_cell_LR selected cell-cell interaction pair for ligand-receptor pair @@ -1928,11 +1873,6 @@ plotCombineCPG <- function(...) { #' @param facet_ncol ggplot facet ncol parameter #' @param facet_nrow ggplot facet nrow parameter #' @param colors vector with two colors to use -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotCombineCellCellCommunication <- function(gobject, @@ -2047,7 +1987,8 @@ plotCombineCellCellCommunication <- function(gobject, #' @title plotCombineCCcom #' @name plotCombineCCcom #' @description Create visualization for combined (pairwise) cell proximity gene scores -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param combCCcom combined communcation scores, output from combCCcom() #' @param selected_LR selected ligand-receptor pair #' @param selected_cell_LR selected cell-cell interaction pair for ligand-receptor pair @@ -2058,11 +1999,6 @@ plotCombineCellCellCommunication <- function(gobject, #' @param facet_ncol ggplot facet ncol parameter #' @param facet_nrow ggplot facet nrow parameter #' @param colors vector with two colors to use -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotCombineCCcom = function(gobject, @@ -2107,7 +2043,9 @@ plotCombineCCcom = function(gobject, #' @title plotCCcomHeatmap #' @name plotCCcomHeatmap #' @description Plots heatmap for ligand-receptor communication scores in cell-cell interactions -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_params #' @param comScores communinication scores from \code{\link{exprCellCellcom}} or \code{\link{spatCellCellcom}} #' @param selected_LR selected ligand-receptor combinations #' @param selected_cell_LR selected cell-cell combinations for ligand-receptor combinations @@ -2116,11 +2054,6 @@ plotCombineCCcom = function(gobject, #' @param show values to show on heatmap #' @param cor_method correlation method used for clustering #' @param aggl_method agglomeration method used by hclust -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot logical. directly save the plot -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotCCcomHeatmap = function(gobject, @@ -2220,7 +2153,9 @@ plotCCcomHeatmap = function(gobject, #' @title plotCCcomDotplot #' @name plotCCcomDotplot #' @description Plots dotplot for ligand-receptor communication scores in cell-cell interactions -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_params #' @param comScores communication scores from \code{\link{exprCellCellcom}} or \code{\link{spatCellCellcom}} #' @param selected_LR selected ligand-receptor combinations #' @param selected_cell_LR selected cell-cell combinations for ligand-receptor combinations @@ -2229,11 +2164,8 @@ plotCCcomHeatmap = function(gobject, #' @param cluster_on values to use for clustering of cell-cell and ligand-receptor pairs #' @param cor_method correlation method used for clustering #' @param aggl_method agglomeration method used by hclust -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot logical. directly save the plot -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param +#' @param dot_color_gradient character. continuous colors to use. palette to +#' use or vector of colors to use (minimum of 2). #' @return ggplot #' @export plotCCcomDotplot = function(gobject, @@ -2359,21 +2291,21 @@ plotCCcomDotplot = function(gobject, #' @title plotRankSpatvsExpr #' @name plotRankSpatvsExpr #' @description Plots dotplot to compare ligand-receptor rankings from spatial and expression information -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params #' @param combCC combined communication scores from \code{\link{combCCcom}} #' @param expr_rnk_column column with expression rank information to use #' @param spat_rnk_column column with spatial rank information to use -#' @param gradient_midpoint midpoint of colors +#' @param gradient_midpoint numeric. default = 10. midpoint of colors +#' @param dot_color_gradient character. continuous colors to use. palette to +#' use or vector of colors to use (minimum of 2). +#' @param gradient_style either 'divergent' (midpoint is used in color scaling) +#' or 'sequential' (scaled based on data range) #' @param midpoint deprecated #' @param size_range size ranges of dotplot #' @param xlims x-limits, numerical vector of 2 #' @param ylims y-limits, numerical vector of 2 #' @param selected_ranks numerical vector, will be used to print out the percentage of top spatial ranks are recovered -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotRankSpatvsExpr = function(gobject, @@ -2417,10 +2349,10 @@ plotRankSpatvsExpr = function(gobject, spt_list[[rnk]] = names(mytab) } - rnk_res = as.data.table(do.call('rbind', rnk_list)) + rnk_res = data.table::as.data.table(do.call('rbind', rnk_list)) rnk_res[, spt_rank := 1:total_rnks] - rnk_res_m = melt.data.table(rnk_res, id.vars = 'spt_rank') + rnk_res_m = data.table::melt.data.table(rnk_res, id.vars = 'spt_rank') rnk_res_m[, spt_rank := as.numeric(spt_rank)] rnk_res_m[, variable := as.numeric(variable)] @@ -2438,7 +2370,7 @@ plotRankSpatvsExpr = function(gobject, pl = pl + ggplot2::geom_point(data = rnk_res_m, ggplot2::aes(x = variable, y = spt_rank, size = value, color = value)) pl = pl + set_default_color_continuous_CCcom_dotplot( colors = dot_color_gradient, - instrs = instruction(gobject), + instrs = instructions(gobject), midpoint = gradient_midpoint, style = gradient_style, type = 'color', @@ -2458,7 +2390,6 @@ plotRankSpatvsExpr = function(gobject, pl = pl + ylim(ylims) } - return(plot_output_handler( gobject = gobject, plot_object = pl, @@ -2481,6 +2412,7 @@ plotRankSpatvsExpr = function(gobject, #' @param combCC combined communinication scores from \code{\link{combCCcom}} #' @param first_col first column to use #' @param second_col second column to use +#' @keywords internal plotRecovery_sub = function(combCC, first_col = 'LR_expr_rnk', second_col = 'LR_spat_rnk') { @@ -2535,16 +2467,12 @@ plotRecovery_sub = function(combCC, #' @title plotRecovery #' @name plotRecovery #' @description Plots recovery plot to compare ligand-receptor rankings from spatial and expression information -#' @param gobject giotto object -#' @param combCC combined communinication scores from \code{\link{combCCcom}} +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @param combCC combined communication scores from \code{\link{combCCcom}} #' @param expr_rnk_column column with expression rank information to use #' @param spat_rnk_column column with spatial rank information to use #' @param ground_truth what to consider as ground truth (default: spatial) -#' @param show_plot show plots -#' @param return_plot return plotting object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @export plotRecovery = function(gobject, @@ -2577,26 +2505,16 @@ plotRecovery = function(gobject, } - # print, return and save parameters - show_plot = ifelse(is.na(show_plot), readGiottoInstructions(gobject, param = 'show_plot'), show_plot) - save_plot = ifelse(is.na(save_plot), readGiottoInstructions(gobject, param = 'save_plot'), save_plot) - return_plot = ifelse(is.na(return_plot), readGiottoInstructions(gobject, param = 'return_plot'), return_plot) - - ## print plot - if(show_plot == TRUE) { - print(pl) - } - - ## save plot - if(save_plot == TRUE) { - do.call('all_plots_save_function', c(list(gobject = gobject, plot_object = pl, default_save_name = default_save_name), save_param)) - } - - ## return plot - if(return_plot == TRUE) { - return(pl) - } - + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) } @@ -2613,27 +2531,24 @@ plotRecovery = function(gobject, #' @title cellProximitySpatPlot2D #' @name cellProximitySpatPlot2D #' @description Visualize 2D cell-cell interactions according to spatial coordinates in ggplot mode -#' @param gobject giotto object -#' @param feat_type feature type -#' @param spat_unit spatial unit +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_spatnet_params +#' @inheritParams plot_params #' @param spat_loc_name spatial locations to use #' @param interaction_name cell-cell interaction name #' @param cluster_column cluster column with cell clusters #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') -#' @param cell_color color for cells (see details) -#' @param cell_color_code named vector with colors -#' @param color_as_factor convert color column to factor #' @param show_other_cells decide if show cells not in network #' @param show_network show spatial network of selected cells #' @param show_other_network show spatial network of not selected cells #' @param network_color color of spatial network -#' @param spatial_network_name name of spatial network to use #' @param show_grid show spatial grid #' @param grid_color color of spatial grid #' @param spatial_grid_name name of spatial grid to use #' @param coord_fix_ratio fix ratio between x and y-axis -#' @param show_legend show legend #' @param point_size_select size of selected points #' @param point_select_border_col border color of selected points #' @param point_select_border_stroke stroke size of selected points @@ -2641,11 +2556,6 @@ plotRecovery = function(gobject, #' @param point_alpha_other opacity of other points #' @param point_other_border_col border color of other points #' @param point_other_border_stroke stroke size of other points -#' @param show_plot show plots -#' @param return_plot return ggplot object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @return ggplot #' @details Description of parameters. #' @export @@ -2891,24 +2801,23 @@ cellProximitySpatPlot = function(gobject, ...) { #' @title cellProximitySpatPlot3D #' @name cellProximitySpatPlot3D #' @description Visualize 3D cell-cell interactions according to spatial coordinates in plotly mode -#' @param gobject giotto object +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @inheritParams plot_spatnet_params +#' @inheritParams plot_cell_params +#' @inheritParams plot_params #' @param interaction_name cell-cell interaction name #' @param cluster_column cluster column with cell clusters #' @param sdimx x-axis dimension name (default = 'sdimx') #' @param sdimy y-axis dimension name (default = 'sdimy') #' @param sdimz z-axis dimension name (default = 'sdimz') -#' @param cell_color color for cells (see details) -#' @param cell_color_code named vector with colors -#' @param color_as_factor convert color column to factor #' @param show_other_cells decide if show cells not in network #' @param show_network show spatial network of selected cells #' @param show_other_network show spatial network of not selected cells #' @param network_color color of spatial network -#' @param spatial_network_name name of spatial network to use #' @param show_grid show spatial grid #' @param grid_color color of spatial grid #' @param spatial_grid_name name of spatial grid to use -#' @param show_legend show legend #' @param point_size_select size of selected points #' @param point_size_other size of other points #' @param point_alpha_other opacity of other points @@ -2917,11 +2826,6 @@ cellProximitySpatPlot = function(gobject, ...) { #' @param y_ticks ticks on y-axis #' @param z_ticks ticks on z-axis #' @param custom_ratio custom ratio of axes -#' @param show_plot show plots -#' @param return_plot return plotly object -#' @param save_plot directly save the plot [boolean] -#' @param save_param list of saving parameters from \code{\link{all_plots_save_function}} -#' @param default_save_name default save name for saving, don't change, change save_name in save_param #' @param \dots additional parameters #' @return plotly #' @details Description of parameters. diff --git a/R/viz_spatial_network.R b/R/viz_spatial_network.R new file mode 100644 index 0000000..818bd5f --- /dev/null +++ b/R/viz_spatial_network.R @@ -0,0 +1,317 @@ +#' @title Plot spatial distance distribution +#' @name spatNetwDistributionsDistance +#' @description This function return histograms displaying the distance distribution for each spatial k-neighbor +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @param spatial_network_name name of spatial network +#' @param hist_bins number of binds to use for the histogram +#' @param test_distance_limit effect of different distance threshold on k-neighbors +#' @param ncol number of columns to visualize the histograms in +#' @return ggplot plot +#' @export +spatNetwDistributionsDistance <- function(gobject, + spat_unit = NULL, + spatial_network_name = 'spatial_network', + hist_bins = 30, + test_distance_limit = NULL, + ncol = 1, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = 'spatNetwDistributionsDistance') { + + # Set feat_type and spat_unit + spat_unit = set_default_spat_unit(gobject = gobject, + spat_unit = spat_unit) + + # data.table variables + distance = rank_int = status = label = keep = NULL + + ## spatial network + spatial_network = get_spatialNetwork(gobject, + spat_unit = spat_unit, + name = spatial_network_name, + output = 'networkDT') + + ## convert to full network with rank_int column + spatial_network = convert_to_full_spatial_network(spatial_network) + + if(is.null(spatial_network)) { + stop('spatial network ', spatial_network_name, ' was not found') + } + + if(!is.null(test_distance_limit)) { + removed_neighbors = spatial_network[distance > test_distance_limit, .N, by = rank_int] + removed_neighbors[, 'status' := 'remove'] + keep_neighbors = spatial_network[distance <= test_distance_limit, .N, by = rank_int] + keep_neighbors[, 'status' := 'keep'] + + dist_removal_dt = rbind(removed_neighbors, keep_neighbors) + data.table::setorder(dist_removal_dt, rank_int) + + dist_removal_dt_dcast = data.table::dcast.data.table(data = dist_removal_dt, rank_int~status, value.var = 'N', fill = 0) + dist_removal_dt_dcast[, label := paste0('keep:',keep, '\n remove:',remove)] + } + + # text location coordinates + middle_distance = max(spatial_network$distance)/(3/2) + freq_dt = spatial_network[, table(cut(distance, breaks = 30)), by = rank_int] + middle_height = max(freq_dt$V1)/(3/2) + + pl = ggplot2::ggplot() + pl = pl + ggplot2::labs(title = 'distance distribution per k-neighbor') + pl = pl + ggplot2::theme_classic() + pl = pl + ggplot2::geom_histogram(data = spatial_network, ggplot2::aes(x = distance), color = 'white', fill = 'black', bins = hist_bins) + pl = pl + ggplot2::facet_wrap(~rank_int, ncol = ncol) + if(!is.null(test_distance_limit)) { + pl = pl + ggplot2::geom_vline(xintercept = test_distance_limit, color = 'red') + pl = pl + ggplot2::geom_text(data = dist_removal_dt_dcast, ggplot2::aes(x = middle_distance, y = middle_height, label = label)) + } + + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) +} + + + + +#' @title spatNetwDistributionsKneighbors +#' @description This function returns a histogram displaying the number of k-neighbors distribution for each cell +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @param spatial_network_name name of spatial network +#' @param hist_bins number of binds to use for the histogram +#' @return ggplot plot +#' @export +spatNetwDistributionsKneighbors = function(gobject, + spat_unit = NULL, + spatial_network_name = 'spatial_network', + hist_bins = 30, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = 'spatNetwDistributionsKneighbors') { + + # Set feat_type and spat_unit + spat_unit = set_default_spat_unit(gobject = gobject, + spat_unit = spat_unit) + + # data.table variables + N = NULL + + ## spatial network + #spatial_network = gobject@spatial_network[[spatial_network_name]] + spatial_network = get_spatialNetwork(gobject, + spat_unit = spat_unit, + name = spatial_network_name, + output = 'networkDT') + + ## convert to full network with rank_int column + spatial_network = convert_to_full_spatial_network(spatial_network) + + if(is.null(spatial_network)) { + stop('spatial network ', spatial_network_name, ' was not found') + } + + spatial_network_dt = as.data.table(spatial_network[, table(source)]) + + pl = ggplot2::ggplot() + pl = pl + ggplot2::labs(title = 'k-neighbor distribution for all cells', x = 'k-neighbors/cell') + pl = pl + ggplot2::theme_classic() + pl = pl + ggplot2::geom_histogram(data = spatial_network_dt, ggplot2::aes(x = N), color = 'white', fill = 'black', bins = hist_bins) + + return(plot_output_handler( + gobject = gobject, + plot_object = pl, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) +} + + + +#' @title spatNetwDistributions +#' @name spatNetwDistributions +#' @description This function return histograms displaying the distance distribution for each spatial k-neighbor +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @param spatial_network_name name of spatial network +#' @param distribution show the distribution of cell-to-cell distance or number of k neighbors +#' @param hist_bins number of binds to use for the histogram +#' @param test_distance_limit effect of different distance threshold on k-neighbors +#' @param ncol number of columns to visualize the histograms in +#' @details The \strong{distance} option shows the spatial distance distribution for each nearest neighbor rank (1st, 2nd, 3th, ... neigbor). +#' With this option the user can also test the effect of a distance limit on the spatial network. This distance limit can be used to remove neigbor +#' cells that are considered to far away. \cr +#' The \strong{k_neighbors} option shows the number of k neighbors distribution over all cells. +#' @return ggplot plot +#' @export +spatNetwDistributions <- function(gobject, + spat_unit = NULL, + spatial_network_name = 'spatial_network', + distribution = c('distance', 'k_neighbors'), + hist_bins = 30, + test_distance_limit = NULL, + ncol = 1, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = 'spatNetwDistributions') { + + + # Set feat_type and spat_unit + spat_unit = set_default_spat_unit(gobject = gobject, + spat_unit = spat_unit) + + ## histogram to show + distribution = match.arg(distribution, choices = c('distance', 'k_neighbors')) + + ## spatial network + spatial_network = get_spatialNetwork(gobject, + spat_unit = spat_unit, + name = spatial_network_name, + output = 'networkDT') + if(is.null(spatial_network)) { + stop('spatial network ', spatial_network_name, ' was not found') + } + + switch( + distribution, + 'distance' = { + spatNetwDistributionsDistance(gobject = gobject, + spat_unit = spat_unit, + spatial_network_name = spatial_network_name, + hist_bins = hist_bins, + test_distance_limit = test_distance_limit, + ncol = ncol, + show_plot = show_plot, + return_plot = return_plot, + save_plot = save_plot, + save_param = save_param, + default_save_name = default_save_name) + }, + 'k_neighbors' = { + spatNetwDistributionsKneighbors(gobject = gobject, + spat_unit = spat_unit, + spatial_network_name = spatial_network_name, + hist_bins = hist_bins, + show_plot = show_plot, + return_plot = return_plot, + save_plot = save_plot, + save_param = save_param, + default_save_name = default_save_name) + } + ) + +} + + + + + + +#' @title plotStatDelaunayNetwork +#' @name plotStatDelaunayNetwork +#' @description Plots network statistics for a Delaunay network.. +#' @inheritParams data_access_params +#' @inheritParams plot_output_params +#' @param method package to use to create a Delaunay network +#' @param dimensions which spatial dimensions to use (maximum 2 dimensions) +#' @param maximum_distance distance cuttof for Delaunay neighbors to consider +#' @param minimum_k minimum neigbhours if maximum_distance != NULL +#' @param options (geometry) String containing extra control options for the underlying Qhull command; see the Qhull documentation (../doc/qhull/html/qdelaun.html) for the available options. (default = 'Pp', do not report precision problems) +#' @param Y (RTriangle) If TRUE prohibits the insertion of Steiner points on the mesh boundary. +#' @param j (RTriangle) If TRUE jettisons vertices that are not part of the final triangulation from the output. +#' @param S (RTriangle) Specifies the maximum number of added Steiner points. +#' @param \dots Other parameters +#' @return giotto object with updated spatial network slot +#' @export +plotStatDelaunayNetwork = function(gobject, + feat_type = NULL, + spat_unit = NULL, + method = c("deldir", "delaunayn_geometry", "RTriangle"), + dimensions = "all", + maximum_distance = "auto", # all + minimum_k = 0, # all + options = "Pp", # geometry + Y = TRUE, # RTriange + j = TRUE, # RTriange + S = 0, # RTriange + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = 'plotStatDelaunayNetwork', + ...) { + # data.table variables + distance = rank_int = N = NULL + + delaunay_network_DT = createSpatialDelaunayNetwork(gobject = gobject, + feat_type = feat_type, + spat_unit = spat_unit, + method = method, + dimensions = dimensions, + name = 'temp_network', + maximum_distance = maximum_distance, # all + minimum_k = minimum_k, # all + options = options, # geometry + Y = Y, # RTriange + j = j, # RTriange + S = S, # RTriange + return_gobject = FALSE, + output = 'data.table', + ...) + + delaunay_network_DT_c = convert_to_full_spatial_network(reduced_spatial_network_DT = delaunay_network_DT) + + ## create visuals + pl1 = ggplot2::ggplot(delaunay_network_DT, ggplot2::aes(x=factor(""), y=distance)) + pl1 = pl1 + ggplot2::theme_classic() + ggplot2::theme(plot.title = ggplot2::element_text(hjust=0.5)) + pl1 = pl1 + ggplot2::geom_boxplot(outlier.colour = "red", outlier.shape = 1) + pl1 = pl1 + ggplot2::labs(title = 'Delaunay network', y = 'cell-cell distances', x = '') + + pl2 = ggplot2::ggplot(delaunay_network_DT_c, ggplot2::aes(x=factor(rank_int), y=distance)) + pl2 = pl2 + ggplot2::theme_classic() + ggplot2::theme(plot.title = ggplot2::element_text(hjust=0.5)) + pl2 = pl2 + ggplot2::geom_boxplot(outlier.colour = "red", outlier.shape = 1) + pl2 = pl2 + ggplot2::labs(title = 'Delaunay network by neigbor ranking', y = 'cell-cell distances', x = '') + + neighbors = delaunay_network_DT_c[, .N, by = source] + pl3 = ggplot2::ggplot() + pl3 = pl3 + ggplot2::theme_classic() + ggplot2::theme(plot.title = ggplot2::element_text(hjust=0.5)) + pl3 = pl3 + ggplot2::geom_histogram(data = neighbors, ggplot2::aes(x = as.factor(N)), stat = 'count') + pl3 = pl3 + ggplot2::labs(title = 'Delaunay network neigbors per cell', y = 'count', x = '') + pl3 + + savelist = list(pl1, pl2, pl3) + + ## combine plots with cowplot + combo_plot <- cowplot::plot_grid(pl1, pl2, NULL, pl3, + ncol = 2, + rel_heights = c(1, 1), rel_widths = c(1, 2), align = 'v') + + return(plot_output_handler( + gobject = gobject, + plot_object = combo_plot, + save_plot = save_plot, + return_plot = return_plot, + show_plot = show_plot, + default_save_name = default_save_name, + save_param = save_param, + else_return = NULL + )) +} diff --git a/README.Rmd b/README.Rmd index a8a1d10..c6f5654 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,12 +17,11 @@ knitr::opts_chunk$set( ![Version](https://img.shields.io/github/r-package/v/drieslab/GiottoVisuals) -[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![Codecov test coverage](https://codecov.io/gh/jiajic/GiottoVisuals/branch/main/graph/badge.svg)](https://app.codecov.io/gh/jiajic/GiottoVisuals?branch=main) [![R-CMD-check](https://github.com/drieslab/GiottoVisuals/actions/workflows/R-CMD-check.yml/badge.svg)](https://github.com/drieslab/GiottoVisuals/actions/workflows/R-CMD-check.yml) [![GitHub issues](https://img.shields.io/github/issues/drieslab/Giotto)](https://github.com/drieslab/Giotto/issues) [![GitHub pulls](https://img.shields.io/github/issues-pr/drieslab/GiottoVisuals)](https://github.com/drieslab/GiottoVisuals/pulls) -[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) GiottoVisuals contains the main plotting functions of Giotto Suite @@ -32,7 +31,44 @@ GiottoVisuals contains the main plotting functions of Giotto Suite You can install the development version of GiottoVisuals like so: ``` r -library(devtools) +library(remotes) install_github('drieslab/GiottoVisuals') ``` +## Script Organization by Prefixes: + +`aux_` - auxilliary and meta functionality +- `aux_output.R` - plot output handling +- `aux_save.R` - plot saving +- `aux_defaults.R` - set plotting defaults +- `aux_visuals.R` - general auxilliary plotting functions + +`plot_` - general plotting functions organized by type of plot +- `plot_scatter.R` - scatter plots +- `plot_violin.R` - violin plots +- `plot_heatmap.R` - heatmaps +- `plot_dendrogram.R` - dendrograms + +`vis_` - specific plotting functions organized by topic +- `vis_hvf.R` - highly variable features plots +- `vis_pc.R` - principle components plots +- `vis_spatial.R` - +- `vis_spatial_in_situ.R` - + +`gg_` - ggplot2 related +- `gg_info_layers.R` - modular internals for plotting the different layers of information +- `` + +Other: +- `color_palettes.R` - color palettes and factory functions + + +- `vis_spatialDE.R` - + +Package: +- `package_imports.R` - all imports +- `globals.R` - global variables +- `dd.R` - dummy documentation for inheriting +- `zzz.R` - onloads + + diff --git a/README.md b/README.md index 3d99203..734fbeb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ![Version](https://img.shields.io/github/r-package/v/drieslab/GiottoVisuals) [![Lifecycle: -stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) +experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![Codecov test coverage](https://codecov.io/gh/jiajic/GiottoVisuals/branch/main/graph/badge.svg)](https://app.codecov.io/gh/jiajic/GiottoVisuals?branch=main) [![R-CMD-check](https://github.com/drieslab/GiottoVisuals/actions/workflows/R-CMD-check.yml/badge.svg)](https://github.com/drieslab/GiottoVisuals/actions/workflows/R-CMD-check.yml) @@ -24,6 +24,41 @@ GiottoVisuals contains the main plotting functions of Giotto Suite You can install the development version of GiottoVisuals like so: ``` r -library(devtools) +library(remotes) install_github('drieslab/GiottoVisuals') ``` + +## Script Organization by Prefixes: + +`aux_` - auxilliary and meta functionality +- `aux_output.R` - plot output handling +- `aux_save.R` - plot saving +- `aux_defaults.R` - set plotting defaults +- `aux_visuals.R` - general auxilliary plotting functions + +`plot_` - general plotting functions organized by type of plot +- `plot_scatter.R` - scatter plots +- `plot_violin.R` - violin plots +- `plot_heatmap.R` - heatmaps +- `plot_dendrogram.R` - dendrograms + +`vis_` - specific plotting functions organized by topic - `vis_hvf.R` - +highly variable features plots +- `vis_pc.R` - principle components plots +- `vis_spatial.R` - - `vis_spatial_in_situ.R` - + +`gg_` - ggplot2 related +- `gg_info_layers.R` - modular internals for plotting the different +layers of information +- \`\` + +Other: +- `color_palettes.R` - color palettes and factory functions + +- `vis_spatialDE.R` - + +Package: +- `package_imports.R` - all imports +- `globals.R` - global variables +- `dd.R` - dummy documentation for inheriting +- `zzz.R` - onloads diff --git a/man/FSV_show.Rd b/man/FSV_show.Rd index 779d22e..5c69f07 100644 --- a/man/FSV_show.Rd +++ b/man/FSV_show.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_DE_visuals.R +% Please edit documentation in R/spatialDE_visuals.R \name{FSV_show} \alias{FSV_show} \title{FSV_show} diff --git a/man/addPolygonCells.Rd b/man/addPolygonCells.Rd deleted file mode 100644 index 594d94b..0000000 --- a/man/addPolygonCells.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{addPolygonCells} -\alias{addPolygonCells} -\title{Add corresponding polygon IDs to cell metadata} -\usage{ -addPolygonCells( - gobject, - polygon_name = "selections", - spat_unit = "cell", - spat_loc_name = "raw", - feat_type = "rna", - polygons = NULL, - na.label = "no_polygon" -) -} -\arguments{ -\item{gobject}{A Giotto object} - -\item{polygon_name}{name of polygon selections} - -\item{spat_unit}{spatial unit} - -\item{spat_loc_name}{name of spatial locations to use} - -\item{feat_type}{feature name where metadata will be added} - -\item{polygons}{polygon names to plot (e.g. 'polygon_1'). If NULL, plots all available polygons} - -\item{na.label}{polygon label for cells located outside of polygons area. Default = "no_polygon"} -} -\value{ -A Giotto object with a modified cell_metadata slot that includes the -polygon name where each cell is located or no_polygon label if the cell is not located -within a polygon area -} -\description{ -Add corresponding polygon IDs to cell metadata -} -\examples{ - -\dontrun{ -## Plot interactive polygons -my_polygon_coords <- plotInteractivePolygons(my_spatPlot) - -## Add polygon coordinates to Giotto object -my_giotto_polygons <- createGiottoPolygonsFromDfr(my_polygon_coords) -my_giotto_object <- addGiottoPolygons(gobject = my_giotto_object, - gpolygons = list(my_giotto_polygons)) - -## Add polygon IDs to cell metadata -my_giotto_object <- addPolygonCells(my_giotto_object) -} - -} diff --git a/man/aes_string2.Rd b/man/aes_string2.Rd index 84018cc..9f31d21 100644 --- a/man/aes_string2.Rd +++ b/man/aes_string2.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{aes_string2} \alias{aes_string2} \title{aes_string2} diff --git a/man/cellProximityBarplot.Rd b/man/cellProximityBarplot.Rd index 05c0733..7abd4bf 100644 --- a/man/cellProximityBarplot.Rd +++ b/man/cellProximityBarplot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityBarplot} \alias{cellProximityBarplot} \title{cellProximityBarplot} @@ -28,13 +28,13 @@ cellProximityBarplot( \item{p_val}{p-value} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/cellProximityHeatmap.Rd b/man/cellProximityHeatmap.Rd index 344881f..db0181e 100644 --- a/man/cellProximityHeatmap.Rd +++ b/man/cellProximityHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityHeatmap} \alias{cellProximityHeatmap} \title{cellProximityHeatmap} @@ -31,13 +31,13 @@ cellProximityHeatmap( \item{color_names}{character color vector of length 3} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/cellProximityNetwork.Rd b/man/cellProximityNetwork.Rd index 8dc1eca..88b4784 100644 --- a/man/cellProximityNetwork.Rd +++ b/man/cellProximityNetwork.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityNetwork} \alias{cellProximityNetwork} \title{cellProximityNetwork} @@ -58,13 +58,13 @@ cellProximityNetwork( \item{node_text_size}{size of node labels} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/cellProximitySpatPlot.Rd b/man/cellProximitySpatPlot.Rd index 49b8982..5a86659 100644 --- a/man/cellProximitySpatPlot.Rd +++ b/man/cellProximitySpatPlot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximitySpatPlot} \alias{cellProximitySpatPlot} \title{cellProximitySpatPlot} @@ -12,26 +12,19 @@ cellProximitySpatPlot(gobject, ...) \item{...}{ Arguments passed on to \code{\link[=cellProximitySpatPlot2D]{cellProximitySpatPlot2D}} \describe{ - \item{\code{feat_type}}{feature type} - \item{\code{spat_unit}}{spatial unit} \item{\code{spat_loc_name}}{spatial locations to use} \item{\code{interaction_name}}{cell-cell interaction name} \item{\code{cluster_column}}{cluster column with cell clusters} \item{\code{sdimx}}{x-axis dimension name (default = 'sdimx')} \item{\code{sdimy}}{y-axis dimension name (default = 'sdimy')} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{color_as_factor}}{convert color column to factor} \item{\code{show_other_cells}}{decide if show cells not in network} \item{\code{show_network}}{show spatial network of selected cells} \item{\code{show_other_network}}{show spatial network of not selected cells} \item{\code{network_color}}{color of spatial network} - \item{\code{spatial_network_name}}{name of spatial network to use} \item{\code{show_grid}}{show spatial grid} \item{\code{grid_color}}{color of spatial grid} \item{\code{spatial_grid_name}}{name of spatial grid to use} \item{\code{coord_fix_ratio}}{fix ratio between x and y-axis} - \item{\code{show_legend}}{show legend} \item{\code{point_size_select}}{size of selected points} \item{\code{point_select_border_col}}{border color of selected points} \item{\code{point_select_border_stroke}}{stroke size of selected points} @@ -39,11 +32,21 @@ cellProximitySpatPlot(gobject, ...) \item{\code{point_alpha_other}}{opacity of other points} \item{\code{point_other_border_col}}{border color of other points} \item{\code{point_other_border_stroke}}{stroke size of other points} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} + \item{\code{spat_unit}}{spatial unit (e.g. "cell")} + \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{spatial_network_name}}{name of spatial network to use} + \item{\code{show_legend}}{logical. show legend} }} } \value{ diff --git a/man/cellProximitySpatPlot2D.Rd b/man/cellProximitySpatPlot2D.Rd index 546b42c..5e0fdcb 100644 --- a/man/cellProximitySpatPlot2D.Rd +++ b/man/cellProximitySpatPlot2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximitySpatPlot2D} \alias{cellProximitySpatPlot2D} \title{cellProximitySpatPlot2D} @@ -43,9 +43,9 @@ cellProximitySpatPlot2D( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{spat_loc_name}{spatial locations to use} @@ -57,11 +57,14 @@ cellProximitySpatPlot2D( \item{sdimy}{y-axis dimension name (default = 'sdimy')} -\item{cell_color}{color for cells (see details)} +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} -\item{cell_color_code}{named vector with colors} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{color_as_factor}{convert color column to factor} +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} \item{show_other_cells}{decide if show cells not in network} @@ -81,7 +84,7 @@ cellProximitySpatPlot2D( \item{coord_fix_ratio}{fix ratio between x and y-axis} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{point_size_select}{size of selected points} @@ -97,13 +100,13 @@ cellProximitySpatPlot2D( \item{point_other_border_stroke}{stroke size of other points} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/cellProximitySpatPlot3D.Rd b/man/cellProximitySpatPlot3D.Rd index ff679af..3057342 100644 --- a/man/cellProximitySpatPlot3D.Rd +++ b/man/cellProximitySpatPlot3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximitySpatPlot3D} \alias{cellProximitySpatPlot3D} \title{cellProximitySpatPlot3D} @@ -52,11 +52,14 @@ cellProximitySpatPlot3D( \item{sdimz}{z-axis dimension name (default = 'sdimz')} -\item{cell_color}{color for cells (see details)} +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} -\item{cell_color_code}{named vector with colors} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{color_as_factor}{convert color column to factor} +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} \item{show_other_cells}{decide if show cells not in network} @@ -74,7 +77,7 @@ cellProximitySpatPlot3D( \item{spatial_grid_name}{name of spatial grid to use} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{point_size_select}{size of selected points} @@ -92,13 +95,13 @@ cellProximitySpatPlot3D( \item{z_ticks}{ticks on z-axis} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotly object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} diff --git a/man/cellProximityVisPlot.Rd b/man/cellProximityVisPlot.Rd index 0ed1ade..fb0b484 100644 --- a/man/cellProximityVisPlot.Rd +++ b/man/cellProximityVisPlot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityVisPlot} \alias{cellProximityVisPlot} \title{cellProximityVisPlot} diff --git a/man/cellProximityVisPlot_2D_ggplot.Rd b/man/cellProximityVisPlot_2D_ggplot.Rd index d4da787..d666188 100644 --- a/man/cellProximityVisPlot_2D_ggplot.Rd +++ b/man/cellProximityVisPlot_2D_ggplot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityVisPlot_2D_ggplot} \alias{cellProximityVisPlot_2D_ggplot} \title{cellProximityVisPlot_2D_ggplot} diff --git a/man/cellProximityVisPlot_2D_plotly.Rd b/man/cellProximityVisPlot_2D_plotly.Rd index 3bd8bf4..10e5394 100644 --- a/man/cellProximityVisPlot_2D_plotly.Rd +++ b/man/cellProximityVisPlot_2D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityVisPlot_2D_plotly} \alias{cellProximityVisPlot_2D_plotly} \title{cellProximityVisPlot_2D_plotly} diff --git a/man/cellProximityVisPlot_3D_plotly.Rd b/man/cellProximityVisPlot_3D_plotly.Rd index ff9b367..8130f7e 100644 --- a/man/cellProximityVisPlot_3D_plotly.Rd +++ b/man/cellProximityVisPlot_3D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{cellProximityVisPlot_3D_plotly} \alias{cellProximityVisPlot_3D_plotly} \title{cellProximityVisPlot_3D_plotly} diff --git a/man/compareCellAbundance.Rd b/man/compareCellAbundance.Rd deleted file mode 100644 index 732ada7..0000000 --- a/man/compareCellAbundance.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{compareCellAbundance} -\alias{compareCellAbundance} -\title{Compare cell types percent per polygon} -\usage{ -compareCellAbundance( - gobject, - polygon_name = "selections", - spat_unit = "cell", - feat_type = "rna", - cell_type_column = "leiden_clus", - ... -) -} -\arguments{ -\item{gobject}{A Giotto object} - -\item{polygon_name}{name of polygon selections} - -\item{spat_unit}{spatial unit. Default = "cell"} - -\item{feat_type}{feature type. Default = "rna"} - -\item{cell_type_column}{column name within the cell metadata table to use} - -\item{...}{Additional parameters passed to ComplexHeatmap::Heatmap} -} -\value{ -A ComplexHeatmap::Heatmap -} -\description{ -Compare cell types percent per polygon -} diff --git a/man/comparePolygonExpression.Rd b/man/comparePolygonExpression.Rd deleted file mode 100644 index 6ba828d..0000000 --- a/man/comparePolygonExpression.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{comparePolygonExpression} -\alias{comparePolygonExpression} -\title{Compare gene expression between polygon areas} -\usage{ -comparePolygonExpression( - gobject, - polygon_name = "selections", - spat_unit = "cell", - feat_type = "rna", - selected_feats = "top_genes", - expression_values = "normalized", - method = "scran", - ... -) -} -\arguments{ -\item{gobject}{A Giotto object} - -\item{polygon_name}{name of polygon selections} - -\item{spat_unit}{spatial unit (e.g. "cell")} - -\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} - -\item{selected_feats}{vector of selected features to plot} - -\item{expression_values}{gene expression values to use ("normalized", "scaled", "custom")} - -\item{method}{method to use to detect differentially expressed feats ("scran", "gini", "mast")} - -\item{\dots}{Arguments passed to \link[ComplexHeatmap]{Heatmap}} -} -\value{ -A ComplexHeatmap::Heatmap object -} -\description{ -Compare gene expression between polygon areas -} diff --git a/man/createHeatmap_DT.Rd b/man/createHeatmap_DT.Rd index ea59f5e..bdfc154 100644 --- a/man/createHeatmap_DT.Rd +++ b/man/createHeatmap_DT.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_heatmap.R +% Please edit documentation in R/plot_heatmap.R \name{createHeatmap_DT} \alias{createHeatmap_DT} \title{createHeatmap_DT} @@ -10,20 +10,15 @@ createHeatmap_DT( feat_type = NULL, expression_values = c("normalized", "scaled", "custom"), feats, - genes = NULL, cluster_column = NULL, cluster_order = c("size", "correlation", "custom"), cluster_custom_order = NULL, cluster_cor_method = "pearson", cluster_hclust_method = "ward.D", feat_order = c("correlation", "custom"), - gene_order = NULL, feat_custom_order = NULL, - gene_custom_order = NULL, feat_cor_method = "pearson", - gene_cor_method = NULL, - feat_hclust_method = "complete", - gene_hclust_method = NULL + feat_hclust_method = "complete" ) } \arguments{ @@ -37,8 +32,6 @@ createHeatmap_DT( \item{feats}{features to use} -\item{genes}{deprecated, use feats} - \item{cluster_column}{name of column to use for clusters (e.g. "leiden_clus")} \item{cluster_order}{method to determine cluster order (e.g. "size", "correlation", "custom")} @@ -51,19 +44,11 @@ createHeatmap_DT( \item{feat_order}{method to determine features order (e.g. "correlation", "custom")} -\item{gene_order}{deprecated, use feat_order in the future} - \item{feat_custom_order}{custom order for features} -\item{gene_custom_order}{deprecated, use feat_custom_order in the future} - \item{feat_cor_method}{method for features correlation, default to "pearson"} -\item{gene_cor_method}{deprecated, use feat_cor_method in the future} - \item{feat_hclust_method}{method for hierarchical clustering of features, default to "complete"} - -\item{gene_hclust_method}{deprecated, use feat_hclust_method in the future} } \value{ list diff --git a/man/create_cluster_dendrogram.Rd b/man/create_cluster_dendrogram.Rd new file mode 100644 index 0000000..e90bf9c --- /dev/null +++ b/man/create_cluster_dendrogram.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_dendrogram.R +\name{create_cluster_dendrogram} +\alias{create_cluster_dendrogram} +\title{Create clustered expression dendrogram} +\usage{ +create_cluster_dendrogram( + data, + clus_col = names(data)[[1]], + var_col = names(data)[[2]], + val_col = names(data)[[3]], + cor = c("pearson", "spearman"), + distance = "ward.D", + h = NULL, + h_color = "red", + rotate = FALSE, + ... +) +} +\arguments{ +\item{data}{data.table. Should include columns with clustering labels, variables +that are being clustered, and the values of those clusters.} + +\item{clus_col}{character. name of column with clustering info} + +\item{var_col}{character. name of column with variable name} + +\item{val_col}{character. name of column with values info} + +\item{cor}{correlation score to calculate distance (e.g. "pearson", "spearman")} + +\item{distance}{distance method to use for hierarchical clustering, default to "ward.D"} + +\item{h}{height of horizontal lines to plot} + +\item{h_color}{color of horizontal lines} + +\item{rotate}{rotate dendrogram 90 degrees} + +\item{...}{ + Arguments passed on to \code{\link[ggdendro:ggdendrogram]{ggdendro::ggdendrogram}} + \describe{ + \item{\code{segments}}{If TRUE, show line segments} + \item{\code{labels}}{if TRUE, shows segment labels} + \item{\code{leaf_labels}}{if TRUE, shows leaf labels} + \item{\code{theme_dendro}}{if TRUE, applies a blank theme to plot (see +\code{\link[ggdendro:theme_dendro]{theme_dendro()}})} + }} +} +\description{ +Create a dendrogram based on a data.table with columns for +cluster ID, variables, and their values. If no specific values are provided +for the 'col' params then they will be assumed as 1. clus_col, 2. var_col, +3. val_col +} diff --git a/man/create_jackstrawplot.Rd b/man/create_jackstrawplot.Rd index d373390..c6eff45 100644 --- a/man/create_jackstrawplot.Rd +++ b/man/create_jackstrawplot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pc_plots.R +% Please edit documentation in R/vis_pc.R \name{create_jackstrawplot} \alias{create_jackstrawplot} \title{create_jackstrawplot} diff --git a/man/create_screeplot.Rd b/man/create_screeplot.Rd index 0c7c1f2..57b20e3 100644 --- a/man/create_screeplot.Rd +++ b/man/create_screeplot.Rd @@ -1,17 +1,17 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pc_plots.R +% Please edit documentation in R/vis_pc.R \name{create_screeplot} \alias{create_screeplot} \title{create_screeplot} \usage{ -create_screeplot(pca_obj, ncp = 20, ylim = c(0, 20)) +create_screeplot(eigs, ncp = 20, ylim = c(0, 20)) } \arguments{ -\item{pca_obj}{pca dimension reduction object} +\item{eigs}{numeric. Vector of pca eigenvalues} -\item{ncp}{number of principal components to calculate} +\item{ncp}{numeric. max number of principal components to plot} -\item{ylim}{y-axis limits on scree plot} +\item{ylim}{numeric. y-axis limits on scree plot} } \value{ ggplot @@ -19,4 +19,10 @@ ggplot \description{ create screeplot with ggplot } -\keyword{internal} +\examples{ +\dontrun{ +dr = GiottoData::loadSubObjectMini('dimObj') +scree = create_screeplot(methods::slot(dr, 'misc')$eigenvalues) +scree +} +} diff --git a/man/data_access_params.Rd b/man/data_access_params.Rd index 15d73ae..9c2846a 100644 --- a/man/data_access_params.Rd +++ b/man/data_access_params.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/dd.R \name{data_access_params} \alias{data_access_params} -\title{data_access_params} +\title{Params documentation template: data_access_params} \arguments{ \item{gobject}{giotto object} @@ -11,6 +11,6 @@ \item{feat_type}{feature type (e.g. "rna", "dna", "protein")} } \description{ -data_access_params +Params documentation template: data_access_params } \keyword{internal} diff --git a/man/decide_cluster_order.Rd b/man/decide_cluster_order.Rd index 9db689f..debe774 100644 --- a/man/decide_cluster_order.Rd +++ b/man/decide_cluster_order.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{decide_cluster_order} \alias{decide_cluster_order} \title{decide_cluster_order} @@ -10,7 +10,6 @@ decide_cluster_order( feat_type = NULL, expression_values = c("normalized", "scaled", "custom"), feats, - genes = NULL, cluster_column = NULL, cluster_order = c("size", "correlation", "custom"), cluster_custom_order = NULL, @@ -29,8 +28,6 @@ decide_cluster_order( \item{feats}{features to use (e.g. genes)} -\item{genes}{deprecated, use feats} - \item{cluster_column}{name of column to use for clusters (e.g. "leiden_clus")} \item{cluster_order}{method to determine cluster order (e.g. "size", "correlation", "custom")} diff --git a/man/dimCellPlot.Rd b/man/dimCellPlot.Rd index cc08888..114713f 100644 --- a/man/dimCellPlot.Rd +++ b/man/dimCellPlot.Rd @@ -1,66 +1,170 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{dimCellPlot} \alias{dimCellPlot} +\alias{dimCellPlot2D} \title{dimCellPlot} \usage{ +dimCellPlot2D( + gobject, + spat_unit = NULL, + feat_type = NULL, + dim_reduction_to_use = "umap", + dim_reduction_name = "umap", + dim1_to_use = 1, + dim2_to_use = 2, + spat_enr_names = NULL, + cell_annotation_values = NULL, + show_NN_network = F, + nn_network_to_use = "sNN", + network_name = "sNN.pca", + cell_color_code = NULL, + cell_color_gradient = NULL, + gradient_midpoint = NULL, + gradient_style = c("divergent", "sequential"), + gradient_limits = NULL, + select_cell_groups = NULL, + select_cells = NULL, + show_other_cells = TRUE, + other_cell_color = "lightgrey", + other_point_size = 0.5, + show_cluster_center = FALSE, + show_center_label = TRUE, + center_point_size = 4, + center_point_border_col = "black", + center_point_border_stroke = 0.1, + label_size = 4, + label_fontface = "bold", + edge_alpha = NULL, + point_shape = c("border", "no_border"), + point_size = 1, + point_alpha = 1, + point_border_col = "black", + point_border_stroke = 0.1, + show_legend = TRUE, + legend_text = 8, + legend_symbol_size = 1, + background_color = "white", + axis_text = 8, + axis_title = 8, + cow_n_col = NULL, + cow_rel_h = 1, + cow_rel_w = 1, + cow_align = "h", + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "dimCellPlot2D" +) + dimCellPlot(gobject, ...) } \arguments{ \item{gobject}{giotto object} -\item{...}{ - Arguments passed on to \code{\link[=dimCellPlot2D]{dimCellPlot2D}} - \describe{ - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{dim_reduction_to_use}}{dimension reduction to use} - \item{\code{dim_reduction_name}}{dimension reduction name} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{cell_annotation_values}}{numeric cell annotation columns} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{cell_color_code}}{named vector with colors for cell annotation values} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{size of not selected cells} - \item{\code{show_cluster_center}}{plot center of selected clusters} - \item{\code{show_center_label}}{plot label of selected clusters} - \item{\code{center_point_size}}{size of center points} - \item{\code{center_point_border_col}}{border color of center points} - \item{\code{center_point_border_stroke}}{border stroke size of center points} - \item{\code{label_size}}{size of labels} - \item{\code{label_fontface}}{font of labels} - \item{\code{edge_alpha}}{column to use for alpha of the edges} - \item{\code{point_shape}}{point with border or not (border or no_border)} - \item{\code{point_size}}{size of point (cell)} - \item{\code{point_alpha}}{transparancy of dim. reduction points} - \item{\code{point_border_col}}{color of border around points} - \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{show_legend}}{show legend} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} - \item{\code{background_color}}{color of plot background} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative height} - \item{\code{cow_rel_w}}{cowplot param: relative width} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{dim_reduction_to_use}{character. dimension reduction to use} + +\item{dim_reduction_name}{character. dimension reduction name} + +\item{dim1_to_use}{numeric. dimension to use on x-axis} + +\item{dim2_to_use}{numeric. dimension to use on y-axis} + +\item{spat_enr_names}{character. names of spatial enrichment results to include} + +\item{cell_annotation_values}{numeric cell annotation columns} + +\item{show_NN_network}{logical. Show underlying NN network} + +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} + +\item{network_name}{character. name of NN network to use, if show_NN_network = TRUE} + +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{numeric. midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} + +\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} + +\item{select_cells}{select subset of cells based on cell IDs} + +\item{show_other_cells}{display not selected cells} + +\item{other_cell_color}{color for not selected cells} + +\item{other_point_size}{point size for not selected cells} + +\item{show_cluster_center}{plot center of selected clusters} + +\item{show_center_label}{plot label of selected clusters} + +\item{center_point_size}{size of center points} + +\item{center_point_border_col}{border color of center points} + +\item{center_point_border_stroke}{border stroke size of center points} + +\item{label_size}{size of labels} + +\item{label_fontface}{font of labels} + +\item{edge_alpha}{column to use for alpha of the edges} + +\item{point_shape}{point with border or not (border or no_border)} + +\item{point_size}{size of point (cell)} + +\item{point_alpha}{transparency of points} + +\item{point_border_col}{color of border around points} + +\item{point_border_stroke}{stroke size of border around points} + +\item{show_legend}{logical. show legend} + +\item{legend_text}{size of legend text} + +\item{legend_symbol_size}{size of legend symbols} + +\item{background_color}{color of plot background} + +\item{axis_text}{size of axis text} + +\item{axis_title}{size of axis title} + +\item{cow_n_col}{cowplot param: how many columns} + +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} + +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} + +\item{cow_align}{cowplot param: how to align} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{...}{dimCellPlot(...) passes to dimCellPlot2D()} } \value{ ggplot @@ -69,10 +173,6 @@ ggplot Visualize cells according to dimension reduction coordinates } \details{ -Description of parameters. For 3D plots see \code{\link{dimCellPlot2D}} -} -\seealso{ -Other dimension reduction cell annotation visualizations: -\code{\link{dimCellPlot2D}()} +Description of parameters. For 3D plots see \code{\link{dimPlot3D}} } \concept{dimension reduction cell annotation visualizations} diff --git a/man/dimCellPlot2D.Rd b/man/dimCellPlot2D.Rd deleted file mode 100644 index 6eeda9f..0000000 --- a/man/dimCellPlot2D.Rd +++ /dev/null @@ -1,172 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{dimCellPlot2D} -\alias{dimCellPlot2D} -\title{dimCellPlot2D} -\usage{ -dimCellPlot2D( - gobject, - spat_unit = NULL, - feat_type = NULL, - dim_reduction_to_use = "umap", - dim_reduction_name = "umap", - dim1_to_use = 1, - dim2_to_use = 2, - spat_enr_names = NULL, - cell_annotation_values = NULL, - show_NN_network = F, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - cell_color_code = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = TRUE, - other_cell_color = "lightgrey", - other_point_size = 0.5, - show_cluster_center = FALSE, - show_center_label = TRUE, - center_point_size = 4, - center_point_border_col = "black", - center_point_border_stroke = 0.1, - label_size = 4, - label_fontface = "bold", - edge_alpha = NULL, - point_shape = c("border", "no_border"), - point_size = 1, - point_alpha = 1, - point_border_col = "black", - point_border_stroke = 0.1, - show_legend = TRUE, - legend_text = 8, - legend_symbol_size = 1, - background_color = "white", - axis_text = 8, - axis_title = 8, - cow_n_col = NULL, - cow_rel_h = 1, - cow_rel_w = 1, - cow_align = "h", - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "dimCellPlot2D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{cell_annotation_values}{numeric cell annotation columns} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - -\item{cell_color_code}{named vector with colors for cell annotation values} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{size of not selected cells} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{center_point_border_col}{border color of center points} - -\item{center_point_border_stroke}{border stroke size of center points} - -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{edge_alpha}{column to use for alpha of the edges} - -\item{point_shape}{point with border or not (border or no_border)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparancy of dim. reduction points} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{cow_n_col}{cowplot param: how many columns} - -\item{cow_rel_h}{cowplot param: relative height} - -\item{cow_rel_w}{cowplot param: relative width} - -\item{cow_align}{cowplot param: how to align} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to dimension reduction coordinates -} -\details{ -Description of parameters. For 3D plots see \code{\link{dimPlot3D}} -} -\seealso{ -Other dimension reduction cell annotation visualizations: -\code{\link{dimCellPlot}()} -} -\concept{dimension reduction cell annotation visualizations} diff --git a/man/dimFeatPlot2D.Rd b/man/dimFeatPlot2D.Rd index a6d78f6..b066095 100644 --- a/man/dimFeatPlot2D.Rd +++ b/man/dimFeatPlot2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{dimFeatPlot2D} \alias{dimFeatPlot2D} \title{dimFeatPlot2D} @@ -49,9 +49,9 @@ dimFeatPlot2D( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{expression_values}{gene expression values to use} @@ -59,19 +59,19 @@ dimFeatPlot2D( \item{order}{order points according to feature expression} -\item{dim_reduction_to_use}{dimension reduction to use} +\item{dim_reduction_to_use}{character. dimension reduction to use} -\item{dim_reduction_name}{dimension reduction name} +\item{dim_reduction_name}{character. dimension reduction name} -\item{dim1_to_use}{dimension to use on x-axis} +\item{dim1_to_use}{numeric. dimension to use on x-axis} -\item{dim2_to_use}{dimension to use on y-axis} +\item{dim2_to_use}{numeric. dimension to use on y-axis} -\item{show_NN_network}{show underlying NN network} +\item{show_NN_network}{logical. Show underlying NN network} -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} +\item{network_name}{character. name of NN network to use, if show_NN_network = TRUE} \item{network_color}{color of NN network} @@ -83,19 +83,23 @@ dimFeatPlot2D( \item{point_size}{size of point (cell)} -\item{point_alpha}{transparancy of points} +\item{point_alpha}{transparency of points} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} \item{point_border_col}{color of border around points} \item{point_border_stroke}{stroke size of border around points} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -107,17 +111,17 @@ dimFeatPlot2D( \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/dimGenePlot3D.Rd b/man/dimGenePlot3D.Rd index c1e6953..f68f839 100644 --- a/man/dimGenePlot3D.Rd +++ b/man/dimGenePlot3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{dimGenePlot3D} \alias{dimGenePlot3D} \title{dimGenePlot3D} @@ -91,11 +91,11 @@ dimGenePlot3D( \item{show_legend}{show legend} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/dimPlot.Rd b/man/dimPlot.Rd index a28ca16..10b3936 100644 --- a/man/dimPlot.Rd +++ b/man/dimPlot.Rd @@ -1,83 +1,232 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{dimPlot} +% Please edit documentation in R/vis_spatial.R +\name{dimPlot2D} +\alias{dimPlot2D} \alias{dimPlot} -\title{dimPlot} +\alias{dimPlot3D} +\title{Plot dimension reduction} \usage{ +dimPlot2D( + gobject, + spat_unit = NULL, + feat_type = NULL, + group_by = NULL, + group_by_subset = NULL, + dim_reduction_to_use = "umap", + dim_reduction_name = NULL, + dim1_to_use = 1, + dim2_to_use = 2, + spat_enr_names = NULL, + show_NN_network = FALSE, + nn_network_to_use = "sNN", + network_name = "sNN.pca", + cell_color = NULL, + color_as_factor = TRUE, + cell_color_code = NULL, + cell_color_gradient = NULL, + gradient_midpoint = NULL, + gradient_style = c("divergent", "sequential"), + gradient_limits = NULL, + select_cell_groups = NULL, + select_cells = NULL, + show_other_cells = TRUE, + other_cell_color = "lightgrey", + other_point_size = 0.5, + show_cluster_center = FALSE, + show_center_label = TRUE, + center_point_size = 4, + center_point_border_col = "black", + center_point_border_stroke = 0.1, + label_size = 4, + label_fontface = "bold", + edge_alpha = NULL, + point_shape = c("border", "no_border"), + point_size = 1, + point_alpha = 1, + point_border_col = "black", + point_border_stroke = 0.1, + title = NULL, + show_legend = TRUE, + legend_text = 10, + legend_symbol_size = 2, + background_color = "white", + axis_text = 8, + axis_title = 8, + cow_n_col = NULL, + cow_rel_h = 1, + cow_rel_w = 1, + cow_align = "h", + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "dimPlot2D" +) + dimPlot(...) + +dimPlot3D( + gobject, + spat_unit = NULL, + feat_type = NULL, + dim_reduction_to_use = "umap", + dim_reduction_name = "umap", + dim1_to_use = 1, + dim2_to_use = 2, + dim3_to_use = 3, + spat_enr_names = NULL, + select_cell_groups = NULL, + select_cells = NULL, + show_other_cells = T, + other_cell_color = "lightgrey", + other_point_size = 2, + show_NN_network = F, + nn_network_to_use = "sNN", + network_name = "sNN.pca", + color_as_factor = T, + cell_color = NULL, + cell_color_code = NULL, + show_cluster_center = F, + show_center_label = T, + center_point_size = 4, + label_size = 4, + edge_alpha = NULL, + point_size = 3, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "dim3D" +) } \arguments{ -\item{...}{ - Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} - \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim_reduction_to_use}}{dimension reduction to use} - \item{\code{dim_reduction_name}}{dimension reduction name} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{gobject}}{giotto object} - \item{\code{spat_unit}}{spatial unit (e.g. "cell")} - \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color for not selected cells} - \item{\code{other_point_size}}{point size for not selected cells} - \item{\code{show_cluster_center}}{plot center of selected clusters} - \item{\code{show_center_label}}{plot label of selected clusters} - \item{\code{center_point_size}}{size of center points} - \item{\code{center_point_border_col}}{border color of center points} - \item{\code{center_point_border_stroke}}{border stroke size of center points} - \item{\code{label_size}}{size of labels} - \item{\code{label_fontface}}{font of labels} - \item{\code{edge_alpha}}{column to use for alpha of the edges} - \item{\code{point_shape}}{point with border or not (border or no_border)} - \item{\code{point_size}}{size of point (cell)} - \item{\code{point_alpha}}{transparency of points} - \item{\code{point_border_col}}{color of border around points} - \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} - \item{\code{background_color}}{color of plot background} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{group_by}{character. Create multiple plots based on cell annotation column} + +\item{group_by_subset}{character. subset the group_by factor column} + +\item{dim_reduction_to_use}{character. dimension reduction to use} + +\item{dim_reduction_name}{character. dimension reduction name} + +\item{dim1_to_use}{numeric. dimension to use on x-axis} + +\item{dim2_to_use}{numeric. dimension to use on y-axis} + +\item{spat_enr_names}{character. names of spatial enrichment results to include} + +\item{show_NN_network}{logical. Show underlying NN network} + +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} + +\item{network_name}{character. name of NN network to use, if show_NN_network = TRUE} + +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{numeric. midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} + +\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} + +\item{select_cells}{select subset of cells based on cell IDs} + +\item{show_other_cells}{display not selected cells} + +\item{other_cell_color}{color for not selected cells} + +\item{other_point_size}{point size for not selected cells} + +\item{show_cluster_center}{plot center of selected clusters} + +\item{show_center_label}{plot label of selected clusters} + +\item{center_point_size}{size of center points} + +\item{center_point_border_col}{border color of center points} + +\item{center_point_border_stroke}{border stroke size of center points} + +\item{label_size}{size of labels} + +\item{label_fontface}{font of labels} + +\item{edge_alpha}{column to use for alpha of the edges} + +\item{point_shape}{point with border or not (border or no_border)} + +\item{point_size}{size of point (cell)} + +\item{point_alpha}{transparency of points} + +\item{point_border_col}{color of border around points} + +\item{point_border_stroke}{stroke size of border around points} + +\item{title}{character. title for plot, defaults to cell_color parameter} + +\item{show_legend}{logical. show legend} + +\item{legend_text}{size of legend text} + +\item{legend_symbol_size}{size of legend symbols} + +\item{background_color}{color of plot background} + +\item{axis_text}{size of axis text} + +\item{axis_title}{size of axis title} + +\item{cow_n_col}{cowplot param: how many columns} + +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} + +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} + +\item{cow_align}{cowplot param: how to align} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{\dots}{dimPlot(...) passes to dimPlot2D()} + +\item{dim3_to_use}{numeric. dimension to use on z-axis} } \value{ ggplot + +plotly (dimplot3D only) } \description{ Visualize cells according to dimension reduction coordinates } -\details{ -Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{dimPlot3D}} -} \seealso{ Other reduced dimension visualizations: -\code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/dimPlot2D.Rd b/man/dimPlot2D.Rd deleted file mode 100644 index 79c429d..0000000 --- a/man/dimPlot2D.Rd +++ /dev/null @@ -1,194 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{dimPlot2D} -\alias{dimPlot2D} -\title{Plot dimension reduction 2D} -\usage{ -dimPlot2D( - gobject, - spat_unit = NULL, - feat_type = NULL, - group_by = NULL, - group_by_subset = NULL, - dim_reduction_to_use = "umap", - dim_reduction_name = NULL, - dim1_to_use = 1, - dim2_to_use = 2, - spat_enr_names = NULL, - show_NN_network = FALSE, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - cell_color = NULL, - color_as_factor = TRUE, - cell_color_code = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = TRUE, - other_cell_color = "lightgrey", - other_point_size = 0.5, - show_cluster_center = FALSE, - show_center_label = TRUE, - center_point_size = 4, - center_point_border_col = "black", - center_point_border_stroke = 0.1, - label_size = 4, - label_fontface = "bold", - edge_alpha = NULL, - point_shape = c("border", "no_border"), - point_size = 1, - point_alpha = 1, - point_border_col = "black", - point_border_stroke = 0.1, - title = NULL, - show_legend = TRUE, - legend_text = 10, - legend_symbol_size = 2, - background_color = "white", - axis_text = 8, - axis_title = 8, - cow_n_col = NULL, - cow_rel_h = 1, - cow_rel_w = 1, - cow_align = "h", - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "dimPlot2D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit (e.g. "cell")} - -\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} - -\item{group_by}{create multiple plots based on cell annotation column} - -\item{group_by_subset}{subset the group_by factor column} - -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - -\item{cell_color}{color for cells (see details)} - -\item{color_as_factor}{convert color column to factor} - -\item{cell_color_code}{named vector with colors} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color for not selected cells} - -\item{other_point_size}{point size for not selected cells} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{center_point_border_col}{border color of center points} - -\item{center_point_border_stroke}{border stroke size of center points} - -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{edge_alpha}{column to use for alpha of the edges} - -\item{point_shape}{point with border or not (border or no_border)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparency of points} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} - -\item{title}{title for plot, defaults to cell_color parameter} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{cow_n_col}{cowplot param: how many columns} - -\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} - -\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} - -\item{cow_align}{cowplot param: how to align} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to dimension reduction coordinates -} -\details{ -Description of parameters. For 3D plots see \code{\link{dimPlot3D}} -} -\seealso{ -Other reduced dimension visualizations: -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, -\code{\link{plotPCA_2D}()}, -\code{\link{plotPCA_3D}()}, -\code{\link{plotPCA}()}, -\code{\link{plotTSNE_2D}()}, -\code{\link{plotTSNE_3D}()}, -\code{\link{plotTSNE}()}, -\code{\link{plotUMAP_2D}()}, -\code{\link{plotUMAP_3D}()}, -\code{\link{plotUMAP}()} -} -\concept{reduced dimension visualizations} diff --git a/man/dimPlot2D_single.Rd b/man/dimPlot2D_single.Rd deleted file mode 100644 index 3c1aa93..0000000 --- a/man/dimPlot2D_single.Rd +++ /dev/null @@ -1,162 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{dimPlot2D_single} -\alias{dimPlot2D_single} -\title{dimPlot2D_single} -\usage{ -dimPlot2D_single( - gobject, - spat_unit = NULL, - feat_type = NULL, - dim_reduction_to_use = "umap", - dim_reduction_name = NULL, - dim1_to_use = 1, - dim2_to_use = 2, - spat_enr_names = NULL, - show_NN_network = F, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - cell_color = NULL, - color_as_factor = T, - cell_color_code = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = T, - other_cell_color = "lightgrey", - other_point_size = 0.5, - show_cluster_center = F, - show_center_label = T, - center_point_size = 4, - center_point_border_col = "black", - center_point_border_stroke = 0.1, - label_size = 4, - label_fontface = "bold", - edge_alpha = NULL, - point_shape = c("border", "no_border"), - point_size = 1, - point_alpha = 1, - point_border_col = "black", - point_border_stroke = 0.1, - title = NULL, - show_legend = T, - legend_text = 8, - legend_symbol_size = 1, - background_color = "white", - axis_text = 8, - axis_title = 8, - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "dimPlot2D_single" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit (e.g. "cell")} - -\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} - -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - -\item{cell_color}{color for cells (see details)} - -\item{color_as_factor}{convert color column to factor} - -\item{cell_color_code}{named vector with colors} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color for not selected cells} - -\item{other_point_size}{point size for not selected cells} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{center_point_border_col}{border color of center points} - -\item{center_point_border_stroke}{border stroke size of center points} - -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{edge_alpha}{column to use for alpha of the edges} - -\item{point_shape}{point with border or not (border or no_border)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparency of points} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} - -\item{title}{title for plot, defaults to cell_color parameter} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to dimension reduction coordinates -} -\details{ -Description of parameters. For 3D plots see \code{\link{dimPlot3D}} -} -\keyword{internal} diff --git a/man/dimPlot3D.Rd b/man/dimPlot3D.Rd deleted file mode 100644 index a1352c7..0000000 --- a/man/dimPlot3D.Rd +++ /dev/null @@ -1,127 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{dimPlot3D} -\alias{dimPlot3D} -\title{dimPlot3D} -\usage{ -dimPlot3D( - gobject, - spat_unit = NULL, - feat_type = NULL, - dim_reduction_to_use = "umap", - dim_reduction_name = "umap", - dim1_to_use = 1, - dim2_to_use = 2, - dim3_to_use = 3, - spat_enr_names = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = T, - other_cell_color = "lightgrey", - other_point_size = 2, - show_NN_network = F, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - color_as_factor = T, - cell_color = NULL, - cell_color_code = NULL, - show_cluster_center = F, - show_center_label = T, - center_point_size = 4, - label_size = 4, - edge_alpha = NULL, - point_size = 3, - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "dim3D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{dim3_to_use}{dimension to use on z-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{size of not selected cells} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - -\item{color_as_factor}{convert color column to factor} - -\item{cell_color}{color for cells (see details)} - -\item{cell_color_code}{named vector with colors} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{label_size}{size of labels} - -\item{edge_alpha}{column to use for alpha of the edges} - -\item{point_size}{size of point (cell)} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -plotly -} -\description{ -Visualize cells according to dimension reduction coordinates -} -\details{ -Description of parameters. -} -\seealso{ -Other reduced dimension visualizations: -\code{\link{dimPlot2D}()}, -\code{\link{dimPlot}()}, -\code{\link{plotPCA_2D}()}, -\code{\link{plotPCA_3D}()}, -\code{\link{plotPCA}()}, -\code{\link{plotTSNE_2D}()}, -\code{\link{plotTSNE_3D}()}, -\code{\link{plotTSNE}()}, -\code{\link{plotUMAP_2D}()}, -\code{\link{plotUMAP_3D}()}, -\code{\link{plotUMAP}()} -} -\concept{reduced dimension visualizations} diff --git a/man/dimPlot_2D_plotly.Rd b/man/dimPlot_2D_plotly.Rd index 49a9724..9b8602d 100644 --- a/man/dimPlot_2D_plotly.Rd +++ b/man/dimPlot_2D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{dimPlot_2D_plotly} \alias{dimPlot_2D_plotly} \title{dimPlot_2D_plotly} diff --git a/man/dimPlot_3D_plotly.Rd b/man/dimPlot_3D_plotly.Rd index 4b0720c..4350427 100644 --- a/man/dimPlot_3D_plotly.Rd +++ b/man/dimPlot_3D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{dimPlot_3D_plotly} \alias{dimPlot_3D_plotly} \title{dimPlot_3D_plotly} diff --git a/man/expand_feature_info.Rd b/man/expand_feature_info.Rd index 8cb2f89..72a3e0c 100644 --- a/man/expand_feature_info.Rd +++ b/man/expand_feature_info.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{expand_feature_info} \alias{expand_feature_info} \title{expand_feature_info} diff --git a/man/filterInteractionChangedFeats.Rd b/man/filterInteractionChangedFeats.Rd new file mode 100644 index 0000000..ec4377f --- /dev/null +++ b/man/filterInteractionChangedFeats.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/vis_spatial_interaction.R +\name{filterInteractionChangedFeats} +\alias{filterInteractionChangedFeats} +\title{filterInteractionChangedFeats} +\usage{ +filterInteractionChangedFeats( + icfObject, + min_cells = 4, + min_cells_expr = 1, + min_int_cells = 4, + min_int_cells_expr = 1, + min_fdr = 0.1, + min_spat_diff = 0.2, + min_log2_fc = 0.2, + min_zscore = 2, + zscores_column = c("cell_type", "feats"), + direction = c("both", "up", "down") +) +} +\arguments{ +\item{icfObject}{ICF (interaction changed feature) score object} + +\item{min_cells}{minimum number of source cell type} + +\item{min_cells_expr}{minimum expression level for source cell type} + +\item{min_int_cells}{minimum number of interacting neighbor cell type} + +\item{min_int_cells_expr}{minimum expression level for interacting neighbor cell type} + +\item{min_fdr}{minimum adjusted p-value} + +\item{min_spat_diff}{minimum absolute spatial expression difference} + +\item{min_log2_fc}{minimum log2 fold-change} + +\item{min_zscore}{minimum z-score change} + +\item{zscores_column}{calculate z-scores over cell types or genes} + +\item{direction}{differential expression directions to keep} +} +\value{ +icfObject that contains the filtered differential feature scores +} +\description{ +Filter Interaction Changed Feature scores. +} +\keyword{internal} diff --git a/man/getCellsFromPolygon.Rd b/man/getCellsFromPolygon.Rd deleted file mode 100644 index 3dc91df..0000000 --- a/man/getCellsFromPolygon.Rd +++ /dev/null @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{getCellsFromPolygon} -\alias{getCellsFromPolygon} -\title{Get cells located within the polygons area} -\usage{ -getCellsFromPolygon( - gobject, - polygon_name = "selections", - spat_unit = "cell", - spat_loc_name = "raw", - polygons = NULL -) -} -\arguments{ -\item{gobject}{A Giotto object} - -\item{polygon_name}{name of polygon selections} - -\item{spat_unit}{spatial unit, default = 'cell'} - -\item{spat_loc_name}{name of spatial locations to use, default = 'raw'} - -\item{polygons}{character. A vector with polygon names to extract cells from. If NULL, cells from all polygons are retrieved} -} -\value{ -A terra 'SpatVector' with cell ID, x y coordinates, and polygon ID where each cell is located in. -} -\description{ -Get cells located within the polygons area -} -\examples{ - -\dontrun{ -## Plot interactive polygons -my_spatPlot <- spatPlot2D(gobject = my_giotto_object, - show_image = TRUE, - point_alpha = 0.75, - save_plot = FALSE) -my_polygon_coords <- plotInteractivePolygons(my_spatPlot) - -## Add polygon coordinates to Giotto object -my_giotto_polygons <- createGiottoPolygonsFromDfr(my_polygon_coords) -my_giotto_object <- addGiottoPolygons(gobject = my_giotto_object, - gpolygons = list(my_giotto_polygons)) - -## Get cells located within polygons area -getCellsFromPolygon(my_giotto_object) - -## Get only cells from polygon 1 -getCellsFromPolygon(my_giotto_object, polygons = "polygon 1") -} - -} diff --git a/man/getColors.Rd b/man/getColors.Rd index ffe350b..933f363 100644 --- a/man/getColors.Rd +++ b/man/getColors.Rd @@ -36,5 +36,5 @@ than exist then the palette will be made continuous\cr \examples{ f <- system.file("ex/elev.tif", package="terra") r <- terra::rast(f) -terra::plot(r, col = getColors(100, 'Spectral')) +terra::plot(r, col = getColors(pal = 'Spectral', n = 100)) } diff --git a/man/gg_input.Rd b/man/gg_input.Rd new file mode 100644 index 0000000..a0d8502 --- /dev/null +++ b/man/gg_input.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/aux_visuals.R +\name{gg_input} +\alias{gg_input} +\title{gg_input} +\usage{ +gg_input(ggobject) +} +\arguments{ +\item{ggobject}{ggplot object or NULL} +} +\description{ +modular handling of ggplot inputs for functions that may either +append additional information to a ggplot object or be where the ggobject is +first made. +} +\keyword{internal} diff --git a/man/gg_simple_scatter.Rd b/man/gg_simple_scatter.Rd index 75939cd..53c48b2 100644 --- a/man/gg_simple_scatter.Rd +++ b/man/gg_simple_scatter.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_scatterplot.R +% Please edit documentation in R/plot_scatter.R \name{gg_simple_scatter} \alias{gg_simple_scatter} \title{gg_simple_scatter} @@ -11,7 +11,7 @@ gg_simple_scatter( y, xlab = "x", ylab = "y", - main, + main = NULL, ... ) } @@ -30,7 +30,11 @@ gg_simple_scatter( \item{main}{an overall title for the plot} -\item{...}{additional params passed to ggplot2::aes()} +\item{...}{ + Arguments passed on to \code{\link[ggplot2:aes]{ggplot2::aes}} + \describe{ + \item{\code{}}{} + }} \item{return}{ggplot object} } diff --git a/man/giotto_point.Rd b/man/giotto_point.Rd index 69fb0aa..2cbc6d7 100644 --- a/man/giotto_point.Rd +++ b/man/giotto_point.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{giotto_point} \alias{giotto_point} \title{giotto_point} diff --git a/man/hvf_visualizations.Rd b/man/hvf_visualizations.Rd index 16f7431..deedff1 100644 --- a/man/hvf_visualizations.Rd +++ b/man/hvf_visualizations.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hvf_plots.R +% Please edit documentation in R/vis_hvf.R \name{hvf_visualizations} \alias{hvf_visualizations} \alias{create_cov_group_HVF_plot} diff --git a/man/plotCCcomDotplot.Rd b/man/plotCCcomDotplot.Rd index 51633ee..7e0b052 100644 --- a/man/plotCCcomDotplot.Rd +++ b/man/plotCCcomDotplot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCCcomDotplot} \alias{plotCCcomDotplot} \title{plotCCcomDotplot} @@ -43,13 +43,19 @@ plotCCcomDotplot( \item{aggl_method}{agglomeration method used by hclust} -\item{show_plot}{show plots} +\item{dot_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{return_plot}{return plotting object} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} -\item{save_plot}{logical. directly save the plot} +\item{show_plot}{logical. show plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCCcomHeatmap.Rd b/man/plotCCcomHeatmap.Rd index 8169d8e..818c888 100644 --- a/man/plotCCcomHeatmap.Rd +++ b/man/plotCCcomHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCCcomHeatmap} \alias{plotCCcomHeatmap} \title{plotCCcomHeatmap} @@ -43,13 +43,19 @@ plotCCcomHeatmap( \item{aggl_method}{agglomeration method used by hclust} -\item{show_plot}{show plots} +\item{gradient_color}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{return_plot}{return plotting object} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} -\item{save_plot}{logical. directly save the plot} +\item{show_plot}{logical. show plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCPF.Rd b/man/plotCPF.Rd index e8084b0..056e504 100644 --- a/man/plotCPF.Rd +++ b/man/plotCPF.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCPF} \alias{plotCPF} \title{plotCPF} @@ -53,15 +53,16 @@ plotCPF( \item{direction}{differential expression directions to keep} -\item{cell_color_code}{vector of colors with cell types as names} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCPG.Rd b/man/plotCPG.Rd deleted file mode 100644 index cf90b3c..0000000 --- a/man/plotCPG.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCPG} -\alias{plotCPG} -\title{plotCPG} -\usage{ -plotCPG(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCellProximityFeats]{plotCellProximityFeats}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{icfObject}}{ICF (interaction changed feature) score object} - \item{\code{method}}{plotting method to use} - \item{\code{min_cells}}{minimum number of source cell type} - \item{\code{min_cells_expr}}{minimum expression level for source cell type} - \item{\code{min_int_cells}}{minimum number of interacting neighbor cell type} - \item{\code{min_int_cells_expr}}{minimum expression level for interacting neighbor cell type} - \item{\code{min_fdr}}{minimum adjusted p-value} - \item{\code{min_spat_diff}}{minimum absolute spatial expression difference} - \item{\code{min_log2_fc}}{minimum log2 fold-change} - \item{\code{min_zscore}}{minimum z-score change} - \item{\code{zscores_column}}{calculate z-scores over cell types or featuress} - \item{\code{direction}}{differential expression directions to keep} - \item{\code{cell_color_code}}{vector of colors with cell types as names} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for cell proximity feature scores -} diff --git a/man/plotCellProximityFeats.Rd b/man/plotCellProximityFeats.Rd index 7b9c336..dacbfa6 100644 --- a/man/plotCellProximityFeats.Rd +++ b/man/plotCellProximityFeats.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCellProximityFeats} \alias{plotCellProximityFeats} \title{plotCellProximityFeats} @@ -53,15 +53,16 @@ plotCellProximityFeats( \item{direction}{differential expression directions to keep} -\item{cell_color_code}{vector of colors with cell types as names} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCellProximityGenes.Rd b/man/plotCellProximityGenes.Rd deleted file mode 100644 index 702c57a..0000000 --- a/man/plotCellProximityGenes.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCellProximityGenes} -\alias{plotCellProximityGenes} -\title{plotCellProximityGenes} -\usage{ -plotCellProximityGenes(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCellProximityFeats]{plotCellProximityFeats}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{icfObject}}{ICF (interaction changed feature) score object} - \item{\code{method}}{plotting method to use} - \item{\code{min_cells}}{minimum number of source cell type} - \item{\code{min_cells_expr}}{minimum expression level for source cell type} - \item{\code{min_int_cells}}{minimum number of interacting neighbor cell type} - \item{\code{min_int_cells_expr}}{minimum expression level for interacting neighbor cell type} - \item{\code{min_fdr}}{minimum adjusted p-value} - \item{\code{min_spat_diff}}{minimum absolute spatial expression difference} - \item{\code{min_log2_fc}}{minimum log2 fold-change} - \item{\code{min_zscore}}{minimum z-score change} - \item{\code{zscores_column}}{calculate z-scores over cell types or featuress} - \item{\code{direction}}{differential expression directions to keep} - \item{\code{cell_color_code}}{vector of colors with cell types as names} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for cell proximity feature scores -} diff --git a/man/plotCombineCCcom.Rd b/man/plotCombineCCcom.Rd index f3d82fb..a920f31 100644 --- a/man/plotCombineCCcom.Rd +++ b/man/plotCombineCCcom.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCombineCCcom} \alias{plotCombineCCcom} \title{plotCombineCCcom} @@ -46,13 +46,13 @@ plotCombineCCcom( \item{colors}{vector with two colors to use} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCombineCPG.Rd b/man/plotCombineCPG.Rd deleted file mode 100644 index 9da1404..0000000 --- a/man/plotCombineCPG.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCombineCPG} -\alias{plotCombineCPG} -\title{plotCombineCPG} -\usage{ -plotCombineCPG(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCombineICF]{plotCombineICF}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{combIcfObject}}{ICFscores, output from combineInteractionChangedFeats()} - \item{\code{selected_interactions}}{interactions to show} - \item{\code{selected_feat_to_feat}}{pairwise feature combinations to show} - \item{\code{detail_plot}}{show detailed info in both interacting cell types} - \item{\code{simple_plot}}{show a simplified plot} - \item{\code{simple_plot_facet}}{facet on interactions or feats with simple plot} - \item{\code{facet_scales}}{ggplot facet scales paramter} - \item{\code{facet_ncol}}{ggplot facet ncol parameter} - \item{\code{facet_nrow}}{ggplot facet nrow parameter} - \item{\code{colors}}{vector with two colors to use} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for combined (pairwise) ICF scores -} -\seealso{ -\code{\link{plotCombineICF}} -} diff --git a/man/plotCombineCellCellCommunication.Rd b/man/plotCombineCellCellCommunication.Rd index 9560701..6b97824 100644 --- a/man/plotCombineCellCellCommunication.Rd +++ b/man/plotCombineCellCellCommunication.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCombineCellCellCommunication} \alias{plotCombineCellCellCommunication} \title{plotCombineCellCellCommunication} @@ -46,13 +46,13 @@ plotCombineCellCellCommunication( \item{colors}{vector with two colors to use} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCombineCellProximityGenes.Rd b/man/plotCombineCellProximityGenes.Rd deleted file mode 100644 index 92a26f0..0000000 --- a/man/plotCombineCellProximityGenes.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCombineCellProximityGenes} -\alias{plotCombineCellProximityGenes} -\title{plotCombineCellProximityGenes} -\usage{ -plotCombineCellProximityGenes(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCombineInteractionChangedFeats]{plotCombineInteractionChangedFeats}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{combIcfObject}}{ICFscores, output from combineInteractionChangedFeats()} - \item{\code{selected_interactions}}{interactions to show} - \item{\code{selected_feat_to_feat}}{pairwise feature combinations to show} - \item{\code{detail_plot}}{show detailed info in both interacting cell types} - \item{\code{simple_plot}}{show a simplified plot} - \item{\code{simple_plot_facet}}{facet on interactions or feats with simple plot} - \item{\code{facet_scales}}{ggplot facet scales paramter} - \item{\code{facet_ncol}}{ggplot facet ncol parameter} - \item{\code{facet_nrow}}{ggplot facet nrow parameter} - \item{\code{colors}}{vector with two colors to use} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for combined (pairwise) ICG scores -} -\seealso{ -\code{\link{plotCombineInteractionChangedFeats}} -} diff --git a/man/plotCombineICF.Rd b/man/plotCombineICF.Rd index 71f0b54..8f550a2 100644 --- a/man/plotCombineICF.Rd +++ b/man/plotCombineICF.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCombineICF} \alias{plotCombineICF} \title{plotCombineICF} @@ -46,13 +46,13 @@ plotCombineICF( \item{colors}{vector with two colors to use} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCombineICG.Rd b/man/plotCombineICG.Rd deleted file mode 100644 index e1ddb5b..0000000 --- a/man/plotCombineICG.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCombineICG} -\alias{plotCombineICG} -\title{plotCombineICG} -\usage{ -plotCombineICG(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCombineICF]{plotCombineICF}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{combIcfObject}}{ICFscores, output from combineInteractionChangedFeats()} - \item{\code{selected_interactions}}{interactions to show} - \item{\code{selected_feat_to_feat}}{pairwise feature combinations to show} - \item{\code{detail_plot}}{show detailed info in both interacting cell types} - \item{\code{simple_plot}}{show a simplified plot} - \item{\code{simple_plot_facet}}{facet on interactions or feats with simple plot} - \item{\code{facet_scales}}{ggplot facet scales paramter} - \item{\code{facet_ncol}}{ggplot facet ncol parameter} - \item{\code{facet_nrow}}{ggplot facet nrow parameter} - \item{\code{colors}}{vector with two colors to use} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for combined (pairwise) ICF scores -} -\seealso{ -\code{\link{plotCombineICF}} -} diff --git a/man/plotCombineInteractionChangedFeats.Rd b/man/plotCombineInteractionChangedFeats.Rd index 8cc183b..c3561d1 100644 --- a/man/plotCombineInteractionChangedFeats.Rd +++ b/man/plotCombineInteractionChangedFeats.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotCombineInteractionChangedFeats} \alias{plotCombineInteractionChangedFeats} \title{plotCombineInteractionChangedFeats} @@ -46,13 +46,13 @@ plotCombineInteractionChangedFeats( \item{colors}{vector with two colors to use} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotCombineInteractionChangedGenes.Rd b/man/plotCombineInteractionChangedGenes.Rd deleted file mode 100644 index 0824fdb..0000000 --- a/man/plotCombineInteractionChangedGenes.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotCombineInteractionChangedGenes} -\alias{plotCombineInteractionChangedGenes} -\title{plotCombineInteractionChangedGenes} -\usage{ -plotCombineInteractionChangedGenes(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotCombineInteractionChangedFeats]{plotCombineInteractionChangedFeats}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{combIcfObject}}{ICFscores, output from combineInteractionChangedFeats()} - \item{\code{selected_interactions}}{interactions to show} - \item{\code{selected_feat_to_feat}}{pairwise feature combinations to show} - \item{\code{detail_plot}}{show detailed info in both interacting cell types} - \item{\code{simple_plot}}{show a simplified plot} - \item{\code{simple_plot_facet}}{facet on interactions or feats with simple plot} - \item{\code{facet_scales}}{ggplot facet scales paramter} - \item{\code{facet_ncol}}{ggplot facet ncol parameter} - \item{\code{facet_nrow}}{ggplot facet nrow parameter} - \item{\code{colors}}{vector with two colors to use} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create visualization for combined (pairwise) ICF scores -} -\seealso{ -\code{\link{plotCombineInteractionChangedFeats}} -} diff --git a/man/plotHeatmap.Rd b/man/plotHeatmap.Rd index 4889645..8eb1787 100644 --- a/man/plotHeatmap.Rd +++ b/man/plotHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_heatmap.R +% Please edit documentation in R/plot_heatmap.R \name{plotHeatmap} \alias{plotHeatmap} \title{plotHeatmap} @@ -10,7 +10,6 @@ plotHeatmap( feat_type = NULL, expression_values = c("normalized", "scaled", "custom"), feats, - genes = NULL, cluster_column = NULL, cluster_order = c("size", "correlation", "custom"), cluster_custom_order = NULL, @@ -18,20 +17,15 @@ plotHeatmap( cluster_cor_method = "pearson", cluster_hclust_method = "ward.D", feat_order = c("correlation", "custom"), - gene_order = NULL, feat_custom_order = NULL, - gene_custom_order = NULL, feat_cor_method = "pearson", - gene_cor_method = NULL, feat_hclust_method = "complete", - gene_hclust_method = NULL, show_values = c("rescaled", "z-scaled", "original"), size_vertical_lines = 1.1, - gradient_colors = NULL, + gradient_colors = deprecated(), gradient_color = NULL, gradient_style = c("divergent", "sequential"), feat_label_selection = NULL, - gene_label_selection = NULL, axis_text_y_size = NULL, legend_nrows = 1, show_plot = NA, @@ -52,8 +46,6 @@ plotHeatmap( \item{feats}{features to use} -\item{genes}{deprecated, use feats} - \item{cluster_column}{name of column to use for clusters (e.g. "leiden_clus")} \item{cluster_order}{method to determine cluster order (e.g. "size", "correlation", "custom")} @@ -68,52 +60,48 @@ plotHeatmap( \item{feat_order}{method to determine features order (e.g. "correlation", "custom")} -\item{gene_order}{deprecated, use feat_order} - \item{feat_custom_order}{custom order for features} -\item{gene_custom_order}{deprecated, use feat_custom_order} - \item{feat_cor_method}{method for features correlation, default to "pearson"} -\item{gene_cor_method}{deprecated, use feat_cor_method} - \item{feat_hclust_method}{method for hierarchical clustering of features, default to "complete"} -\item{gene_hclust_method}{deprecated, use feat_hclust_method} - \item{show_values}{which values to show on heatmap (e.g. "rescaled", "z-scaled", "original")} \item{size_vertical_lines}{sizes for vertical lines} -\item{gradient_colors}{colors for heatmap gradient} +\item{gradient_colors}{deprecated} -\item{feat_label_selection}{subset of features to show on y-axis} +\item{gradient_color}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gene_label_selection}{deprecated, use feat_label_selection} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{feat_label_selection}{subset of features to show on y-axis} \item{axis_text_y_size}{size for y-axis text} \item{legend_nrows}{number of rows for the cluster legend} -\item{show_plot}{show plot. TRUE or FALSE} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} -\item{default_save_name}{default save name} +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } \value{ ggplot } \description{ -Creates heatmap for genes and clusters. +Creates heatmap for features and clusters. } \details{ -If you want to display many genes there are 2 ways to proceed: +If you want to display many features there are 2 ways to proceed: \itemize{ \item{1. set axis_text_y_size to a really small value and show all features} \item{2. provide a subset of features to display to feat_label_selection} diff --git a/man/plotICF.Rd b/man/plotICF.Rd index 20c8ca3..8c8d79b 100644 --- a/man/plotICF.Rd +++ b/man/plotICF.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotICF} \alias{plotICF} \title{Plot interaction changed features} @@ -29,15 +29,16 @@ plotICF( \item{ICF_feats}{named character vector of ICF features} -\item{cell_color_code}{cell color code for the interacting cell types} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotICG.Rd b/man/plotICG.Rd deleted file mode 100644 index b0c5f46..0000000 --- a/man/plotICG.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotICG} -\alias{plotICG} -\title{plotICG} -\usage{ -plotICG(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotICF]{plotICF}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{icfObject}}{ICF (interaction changed feature) score object} - \item{\code{source_type}}{cell type of the source cell} - \item{\code{source_markers}}{markers for the source cell type} - \item{\code{ICF_feats}}{named character vector of ICF features} - \item{\code{cell_color_code}}{cell color code for the interacting cell types} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create barplot to visualize interaction changed features -} -\seealso{ -\code{\link{plotICF}} -} diff --git a/man/plotInteractionChangedFeats.Rd b/man/plotInteractionChangedFeats.Rd index f84a27d..2f7dbfe 100644 --- a/man/plotInteractionChangedFeats.Rd +++ b/man/plotInteractionChangedFeats.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotInteractionChangedFeats} \alias{plotInteractionChangedFeats} \title{Plot interaction changed features} @@ -29,15 +29,16 @@ plotInteractionChangedFeats( \item{ICF_feats}{named character vector of ICF features} -\item{cell_color_code}{cell color code for the interacting cell types} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotInteractionChangedGenes.Rd b/man/plotInteractionChangedGenes.Rd deleted file mode 100644 index 79a0b05..0000000 --- a/man/plotInteractionChangedGenes.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R -\name{plotInteractionChangedGenes} -\alias{plotInteractionChangedGenes} -\title{Plot interaction changed genes} -\usage{ -plotInteractionChangedGenes(...) -} -\arguments{ -\item{...}{ - Arguments passed on to \code{\link[=plotInteractionChangedFeats]{plotInteractionChangedFeats}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{icfObject}}{ICF (interaction changed feature) score object} - \item{\code{source_type}}{cell type of the source cell} - \item{\code{source_markers}}{markers for the source cell type} - \item{\code{ICF_feats}}{named character vector of ICF features} - \item{\code{cell_color_code}}{cell color code for the interacting cell types} - \item{\code{show_plot}}{show plots} - \item{\code{return_plot}}{return plotting object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters from \code{\link{all_plots_save_function}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} -} -\description{ -Create barplot to visualize interaction changed features -} -\seealso{ -\code{\link{plotInteractionChangedFeats}} -} diff --git a/man/plotInteractivePolygons.Rd b/man/plotInteractivePolygons.Rd deleted file mode 100644 index fcbf136..0000000 --- a/man/plotInteractivePolygons.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{plotInteractivePolygons} -\alias{plotInteractivePolygons} -\title{Select image regions by plotting interactive polygons} -\usage{ -plotInteractivePolygons(x, width = "auto", height = "auto", ...) -} -\arguments{ -\item{x}{A \code{ggplot} or \code{rast} plot object to draw polygons on} - -\item{width, height}{An integer, defining the width/height in pixels.} - -\item{...}{Graphical parameters passed on to \code{polygon} or \code{geom_point}.} -} -\value{ -A \code{data.table} containing x,y coordinates from the plotted polygons. -} -\description{ -Plot interactive polygons on an image and retrieve the polygons coordinates. -} diff --git a/man/plotMetaDataCellsHeatmap.Rd b/man/plotMetaDataCellsHeatmap.Rd index d9b772b..d5e5bd7 100644 --- a/man/plotMetaDataCellsHeatmap.Rd +++ b/man/plotMetaDataCellsHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_heatmap.R +% Please edit documentation in R/plot_heatmap.R \name{plotMetaDataCellsHeatmap} \alias{plotMetaDataCellsHeatmap} \title{plotMetaDataCellsHeatmap} @@ -66,7 +66,15 @@ plotMetaDataCellsHeatmap( \item{values_cluster_method}{hierarchical cluster method for the values, default to "complete"} -\item{gradient_midpoint}{midpoint of show_values} +\item{gradient_color}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{numeric. midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{midpoint}{deprecated. Use gradient_midpoint.} \item{x_text_size}{size of x-axis text} @@ -76,11 +84,11 @@ plotMetaDataCellsHeatmap( \item{strip_text_size}{size of strip text} -\item{show_plot}{show plot. TRUE or FALSE} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} @@ -96,5 +104,5 @@ Creates heatmap for numeric cell metadata within aggregated clusters. Creates heatmap for the average values of selected value columns in the different annotation groups. } \seealso{ -\code{\link{plotMetaDataHeatmap}} for gene expression instead of numeric cell annotation data. +\code{\link{plotMetaDataHeatmap}} for feature expression instead of numeric cell annotation data. } diff --git a/man/plotMetaDataHeatmap.Rd b/man/plotMetaDataHeatmap.Rd index f302125..6d167f9 100644 --- a/man/plotMetaDataHeatmap.Rd +++ b/man/plotMetaDataHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_heatmap.R +% Please edit documentation in R/plot_heatmap.R \name{plotMetaDataHeatmap} \alias{plotMetaDataHeatmap} \title{plotMetaDataHeatmap} @@ -11,7 +11,6 @@ plotMetaDataHeatmap( expression_values = c("normalized", "scaled", "custom"), metadata_cols = NULL, selected_feats = NULL, - selected_genes = NULL, first_meta_col = NULL, second_meta_col = NULL, show_values = c("zscores", "original", "zscores_rescaled"), @@ -19,11 +18,8 @@ plotMetaDataHeatmap( clus_cor_method = "pearson", clus_cluster_method = "complete", custom_feat_order = NULL, - custom_gene_order = NULL, feat_cor_method = "pearson", - gene_cor_method = NULL, feat_cluster_method = "complete", - gene_cluster_method = NULL, gradient_color = NULL, gradient_midpoint = 0, gradient_style = c("divergent", "sequential"), @@ -32,7 +28,8 @@ plotMetaDataHeatmap( x_text_angle = 45, y_text_size = 10, strip_text_size = 8, - plot_title = NULL, + title = NULL, + plot_title = deprecated(), show_plot = NA, return_plot = NA, save_plot = NA, @@ -53,8 +50,6 @@ plotMetaDataHeatmap( \item{selected_feats}{subset of features to use} -\item{selected_genes}{deprecated. See \code{selected_feats} param} - \item{first_meta_col}{if more than 1 metadata column, select the x-axis factor} \item{second_meta_col}{if more than 1 metadata column, select the facetting factor} @@ -69,21 +64,19 @@ plotMetaDataHeatmap( \item{custom_feat_order}{custom feature order (default = NULL)} -\item{custom_gene_order}{deprecated. See \code{custom_feat_order} param} - \item{feat_cor_method}{correlation method for features, default to "pearson"} -\item{gene_cor_method}{deprecated. See \code{feat_cor_method} param} - \item{feat_cluster_method}{hierarchical cluster method for the features, default to "complete"} -\item{gene_cluster_method}{deprecated. See \code{feat_cluster_method} param} +\item{gradient_color}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_color}{vector with 3 colors for numeric data} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_limits}{numeric vector with lower and upper limits} \item{x_text_size}{size of x-axis text} @@ -93,27 +86,31 @@ plotMetaDataHeatmap( \item{strip_text_size}{size of strip text} -\item{show_plot}{show plot. TRUE or FALSE} +\item{title}{character. title for plot, defaults to cell_color parameter} + +\item{plot_title}{deprecated. Use title param} + +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} -\item{default_save_name}{default save name} +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } \value{ ggplot or data.table } \description{ -Creates heatmap for genes within aggregated clusters. +Creates heatmap for features within aggregated clusters. } \details{ -Creates heatmap for the average expression of selected genes in the different annotation/cluster groups. -Calculation of cluster or gene order is done on the provided expression values, but visualization -is by default on the z-scores. Other options are the original values or z-scores rescaled per gene (-1 to 1). +Creates heatmap for the average expression of selected features in the different annotation/cluster groups. +Calculation of cluster or feature order is done on the provided expression values, but visualization +is by default on the z-scores. Other options are the original values or z-scores rescaled per feature (-1 to 1). } \seealso{ -\code{\link{plotMetaDataCellsHeatmap}} for numeric cell annotation instead of gene expression. +\code{\link{plotMetaDataCellsHeatmap}} for numeric cell annotation instead of feature expression. } diff --git a/man/plotPCA.Rd b/man/plotPCA.Rd index 8f1a55f..e5d04a8 100644 --- a/man/plotPCA.Rd +++ b/man/plotPCA.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotPCA} \alias{plotPCA} \title{plotPCA} @@ -16,22 +16,36 @@ plotPCA(gobject, dim_reduction_name = NULL, default_save_name = "PCA", ...) \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -50,21 +64,13 @@ plotPCA(gobject, dim_reduction_name = NULL, default_save_name = "PCA", ...) \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -79,8 +85,6 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\ \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotTSNE_2D}()}, diff --git a/man/plotPCA_2D.Rd b/man/plotPCA_2D.Rd index 0e5944a..54a6f92 100644 --- a/man/plotPCA_2D.Rd +++ b/man/plotPCA_2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotPCA_2D} \alias{plotPCA_2D} \title{plotPCA_2D} @@ -21,22 +21,36 @@ plotPCA_2D( \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -55,21 +69,13 @@ plotPCA_2D( \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -84,8 +90,6 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\ \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, \code{\link{plotTSNE_2D}()}, diff --git a/man/plotPCA_3D.Rd b/man/plotPCA_3D.Rd index 92d4e74..cee17c7 100644 --- a/man/plotPCA_3D.Rd +++ b/man/plotPCA_3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotPCA_3D} \alias{plotPCA_3D} \title{plotPCA_3D} @@ -21,33 +21,36 @@ plotPCA_3D( \item{...}{ Arguments passed on to \code{\link[=dimPlot3D]{dimPlot3D}} \describe{ - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{dim3_to_use}}{dimension to use on z-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} + \item{\code{spat_unit}}{spatial unit (e.g. "cell")} + \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{dim3_to_use}}{numeric. dimension to use on z-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{size of not selected cells} + \item{\code{other_cell_color}}{color for not selected cells} + \item{\code{other_point_size}}{point size for not selected cells} \item{\code{show_cluster_center}}{plot center of selected clusters} \item{\code{show_center_label}}{plot label of selected clusters} \item{\code{center_point_size}}{size of center points} \item{\code{label_size}}{size of labels} \item{\code{edge_alpha}}{column to use for alpha of the edges} \item{\code{point_size}}{size of point (cell)} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -62,8 +65,6 @@ Description of parameters. \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA}()}, \code{\link{plotTSNE_2D}()}, diff --git a/man/plotPolygons.Rd b/man/plotPolygons.Rd deleted file mode 100644 index 55bd1ff..0000000 --- a/man/plotPolygons.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/interactivity.R -\name{plotPolygons} -\alias{plotPolygons} -\title{Plot stored polygons} -\usage{ -plotPolygons( - gobject, - polygon_name = "selections", - x, - spat_unit = "cell", - polygons = NULL, - ... -) -} -\arguments{ -\item{gobject}{A Giotto object with polygon coordinates} - -\item{polygon_name}{name of polygon selections} - -\item{x}{A ggplot2, spatPlot or terra::rast object} - -\item{spat_unit}{spatial unit} - -\item{polygons}{character. Vector of polygon names to plot. If NULL, all polygons are plotted} - -\item{...}{Additional parameters passed to ggplot2::geom_polygon() or graphics::polygon} -} -\value{ -A ggplot2 image -} -\description{ -Plot stored polygons -} diff --git a/man/plotRankSpatvsExpr.Rd b/man/plotRankSpatvsExpr.Rd index 5b9c46b..55dd56b 100644 --- a/man/plotRankSpatvsExpr.Rd +++ b/man/plotRankSpatvsExpr.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotRankSpatvsExpr} \alias{plotRankSpatvsExpr} \title{plotRankSpatvsExpr} @@ -33,9 +33,15 @@ plotRankSpatvsExpr( \item{spat_rnk_column}{column with spatial rank information to use} +\item{dot_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{midpoint}{deprecated} -\item{gradient_midpoint}{midpoint of colors} +\item{gradient_midpoint}{numeric. default = 10. midpoint of colors} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} \item{size_range}{size ranges of dotplot} @@ -45,13 +51,13 @@ plotRankSpatvsExpr( \item{selected_ranks}{numerical vector, will be used to print out the percentage of top spatial ranks are recovered} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotRecovery.Rd b/man/plotRecovery.Rd index 2efe61a..b77090a 100644 --- a/man/plotRecovery.Rd +++ b/man/plotRecovery.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotRecovery} \alias{plotRecovery} \title{plotRecovery} @@ -20,7 +20,7 @@ plotRecovery( \arguments{ \item{gobject}{giotto object} -\item{combCC}{combined communinication scores from \code{\link{combCCcom}}} +\item{combCC}{combined communication scores from \code{\link{combCCcom}}} \item{expr_rnk_column}{column with expression rank information to use} @@ -28,13 +28,13 @@ plotRecovery( \item{ground_truth}{what to consider as ground truth (default: spatial)} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotting object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/plotRecovery_sub.Rd b/man/plotRecovery_sub.Rd index b34b178..6b1688e 100644 --- a/man/plotRecovery_sub.Rd +++ b/man/plotRecovery_sub.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_interaction_visuals.R +% Please edit documentation in R/vis_spatial_interaction.R \name{plotRecovery_sub} \alias{plotRecovery_sub} \title{plotRecovery_sub} @@ -16,3 +16,4 @@ plotRecovery_sub(combCC, first_col = "LR_expr_rnk", second_col = "LR_spat_rnk") \description{ Plots recovery plot to compare ligand-receptor rankings from spatial and expression information } +\keyword{internal} diff --git a/man/plotStatDelaunayNetwork.Rd b/man/plotStatDelaunayNetwork.Rd new file mode 100644 index 0000000..f69ba81 --- /dev/null +++ b/man/plotStatDelaunayNetwork.Rd @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/viz_spatial_network.R +\name{plotStatDelaunayNetwork} +\alias{plotStatDelaunayNetwork} +\title{plotStatDelaunayNetwork} +\usage{ +plotStatDelaunayNetwork( + gobject, + feat_type = NULL, + spat_unit = NULL, + method = c("deldir", "delaunayn_geometry", "RTriangle"), + dimensions = "all", + maximum_distance = "auto", + minimum_k = 0, + options = "Pp", + Y = TRUE, + j = TRUE, + S = 0, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "plotStatDelaunayNetwork", + ... +) +} +\arguments{ +\item{gobject}{giotto object} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{method}{package to use to create a Delaunay network} + +\item{dimensions}{which spatial dimensions to use (maximum 2 dimensions)} + +\item{maximum_distance}{distance cuttof for Delaunay neighbors to consider} + +\item{minimum_k}{minimum neigbhours if maximum_distance != NULL} + +\item{options}{(geometry) String containing extra control options for the underlying Qhull command; see the Qhull documentation (../doc/qhull/html/qdelaun.html) for the available options. (default = 'Pp', do not report precision problems)} + +\item{Y}{(RTriangle) If TRUE prohibits the insertion of Steiner points on the mesh boundary.} + +\item{j}{(RTriangle) If TRUE jettisons vertices that are not part of the final triangulation from the output.} + +\item{S}{(RTriangle) Specifies the maximum number of added Steiner points.} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{\dots}{Other parameters} +} +\value{ +giotto object with updated spatial network slot +} +\description{ +Plots network statistics for a Delaunay network.. +} diff --git a/man/plotTSNE.Rd b/man/plotTSNE.Rd index d7754e3..10245f9 100644 --- a/man/plotTSNE.Rd +++ b/man/plotTSNE.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotTSNE} \alias{plotTSNE} \title{plotTSNE} @@ -16,22 +16,36 @@ plotTSNE(gobject, dim_reduction_name = NULL, default_save_name = "tSNE", ...) \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -50,21 +64,13 @@ plotTSNE(gobject, dim_reduction_name = NULL, default_save_name = "tSNE", ...) \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -79,8 +85,6 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\ \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plotTSNE_2D.Rd b/man/plotTSNE_2D.Rd index 0824589..1a3fa12 100644 --- a/man/plotTSNE_2D.Rd +++ b/man/plotTSNE_2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotTSNE_2D} \alias{plotTSNE_2D} \title{plotTSNE_2D} @@ -21,22 +21,36 @@ plotTSNE_2D( \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -55,21 +69,13 @@ plotTSNE_2D( \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -84,8 +90,6 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\ \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plotTSNE_3D.Rd b/man/plotTSNE_3D.Rd index 6a08dcc..0923783 100644 --- a/man/plotTSNE_3D.Rd +++ b/man/plotTSNE_3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotTSNE_3D} \alias{plotTSNE_3D} \title{plotTSNE_3D} @@ -21,33 +21,36 @@ plotTSNE_3D( \item{...}{ Arguments passed on to \code{\link[=dimPlot3D]{dimPlot3D}} \describe{ - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{dim3_to_use}}{dimension to use on z-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} + \item{\code{spat_unit}}{spatial unit (e.g. "cell")} + \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{dim3_to_use}}{numeric. dimension to use on z-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{size of not selected cells} + \item{\code{other_cell_color}}{color for not selected cells} + \item{\code{other_point_size}}{point size for not selected cells} \item{\code{show_cluster_center}}{plot center of selected clusters} \item{\code{show_center_label}}{plot label of selected clusters} \item{\code{center_point_size}}{size of center points} \item{\code{label_size}}{size of labels} \item{\code{edge_alpha}}{column to use for alpha of the edges} \item{\code{point_size}}{size of point (cell)} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -62,8 +65,6 @@ Description of parameters. \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plotUMAP.Rd b/man/plotUMAP.Rd index 104e5f6..4fb04cd 100644 --- a/man/plotUMAP.Rd +++ b/man/plotUMAP.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotUMAP} \alias{plotUMAP} \title{plotUMAP} @@ -16,22 +16,36 @@ plotUMAP(gobject, dim_reduction_name = NULL, default_save_name = "UMAP", ...) \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -50,21 +64,13 @@ plotUMAP(gobject, dim_reduction_name = NULL, default_save_name = "UMAP", ...) \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -73,14 +79,9 @@ ggplot \description{ Short wrapper for UMAP visualization } -\details{ -Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\link{plotUMAP_3D}} -} \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plotUMAP_2D.Rd b/man/plotUMAP_2D.Rd index 1b8cc0e..fd4b252 100644 --- a/man/plotUMAP_2D.Rd +++ b/man/plotUMAP_2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotUMAP_2D} \alias{plotUMAP_2D} \title{plotUMAP_2D} @@ -21,22 +21,36 @@ plotUMAP_2D( \item{...}{ Arguments passed on to \code{\link[=dimPlot2D]{dimPlot2D}} \describe{ - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{spat_unit}}{spatial unit (e.g. "cell")} \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{group_by}}{character. Create multiple plots based on cell annotation column} + \item{\code{group_by_subset}}{character. subset the group_by factor column} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} @@ -55,21 +69,13 @@ plotUMAP_2D( \item{\code{point_alpha}}{transparency of points} \item{\code{point_border_col}}{color of border around points} \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{title}}{title for plot, defaults to cell_color parameter} - \item{\code{show_legend}}{show legend} + \item{\code{title}}{character. title for plot, defaults to cell_color parameter} + \item{\code{show_legend}}{logical. show legend} \item{\code{legend_text}}{size of legend text} \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{background_color}}{color of plot background} \item{\code{axis_text}}{size of axis text} \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} - \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -84,8 +90,6 @@ Description of parameters, see \code{\link{dimPlot2D}}. For 3D plots see \code{\ \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plotUMAP_3D.Rd b/man/plotUMAP_3D.Rd index b570e98..3bbe987 100644 --- a/man/plotUMAP_3D.Rd +++ b/man/plotUMAP_3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{plotUMAP_3D} \alias{plotUMAP_3D} \title{plotUMAP_3D} @@ -21,33 +21,36 @@ plotUMAP_3D( \item{...}{ Arguments passed on to \code{\link[=dimPlot3D]{dimPlot3D}} \describe{ - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{dim3_to_use}}{dimension to use on z-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} + \item{\code{spat_unit}}{spatial unit (e.g. "cell")} + \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} + \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{dim3_to_use}}{numeric. dimension to use on z-axis} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{cell_color}}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + \item{\code{color_as_factor}}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + \item{\code{cell_color_code}}{character. discrete colors to use. palette to use or +named vector of colors} \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} \item{\code{select_cells}}{select subset of cells based on cell IDs} \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{size of not selected cells} + \item{\code{other_cell_color}}{color for not selected cells} + \item{\code{other_point_size}}{point size for not selected cells} \item{\code{show_cluster_center}}{plot center of selected clusters} \item{\code{show_center_label}}{plot label of selected clusters} \item{\code{center_point_size}}{size of center points} \item{\code{label_size}}{size of labels} \item{\code{edge_alpha}}{column to use for alpha of the edges} \item{\code{point_size}}{size of point (cell)} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} }} } \value{ @@ -62,8 +65,6 @@ Description of parameters. \seealso{ Other reduced dimension visualizations: \code{\link{dimPlot2D}()}, -\code{\link{dimPlot3D}()}, -\code{\link{dimPlot}()}, \code{\link{plotPCA_2D}()}, \code{\link{plotPCA_3D}()}, \code{\link{plotPCA}()}, diff --git a/man/plot_auto_largeImage_resample.Rd b/man/plot_auto_largeImage_resample.Rd deleted file mode 100644 index 95f86cd..0000000 --- a/man/plot_auto_largeImage_resample.Rd +++ /dev/null @@ -1,81 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/image_visuals.R -\name{plot_auto_largeImage_resample} -\alias{plot_auto_largeImage_resample} -\title{Optimized largeImage resampling} -\usage{ -plot_auto_largeImage_resample( - gobject, - giottoLargeImage = NULL, - largeImage_name = NULL, - spat_unit = NULL, - spat_loc_name = NULL, - polygon_feat_type = NULL, - include_image_in_border = TRUE, - flex_resample = TRUE, - max_crop = 1e+08, - max_resample_scale = 100 -) -} -\arguments{ -\item{gobject}{\code{gobject} containing \code{largeImage} object} - -\item{giottoLargeImage}{\code{largeImage} object to resample if not provided through -\code{gobject} and \code{largeImage_name}} - -\item{largeImage_name}{name of \code{largeImage} in \code{gobject}} - -\item{spat_unit}{spatial unit} - -\item{spat_loc_name}{name of spatial locations to plot} - -\item{polygon_feat_type}{name of polygon/spatial_info to plot} - -\item{include_image_in_border}{\link{boolean} expand the extent sampled to also show image in -border regions not included in spatlocs. This prevents images in plots from -being sharply cut off around the furthest spatial locations. (default is \code{TRUE})} - -\item{flex_resample}{\link{boolean} Whether to allow automatic selection of sampling -workflow as defined in details sections. (default is \code{TRUE})} - -\item{max_crop}{maximum crop size allowed for \strong{method A} before switching to -\strong{method B} (see description)} - -\item{max_resample_scale}{maximum cells allowed to resample to compensate for -decreased resolution when cropping after sampling} -} -\value{ -a \code{giottoLargeImage} cropped and resampled properly for plotting -} -\description{ -Downsample \code{largeImage} for plotting. Uses \code{\link[terra]{spatSample}} -to load only a portion of the original image, speeding up plotting and lowering memory -footprint. - -Default behavior of \code{spatSample} is to crop if only a smaller ROI is needed for plotting -followed by the sampling process in order to reduce wasted sampling by focusing the -sample space. For very large ROIs, this crop can be time intensive and require -writing to disk. - -This function examines the ROI dimensions as defined through the limits of the spatial -locations to be plotted, and decides between the following two methods in order to -avoid this issue: -\itemize{ -\item{\strong{Method A.} First crop original image and then sample n values where -n = 500,000 to generate final image} -\item{\strong{Method B.} First oversample n values and then crop, where n = 500,000 -scaled by a value >1. Scaling factor increases the smaller the ROI is and -is defined by: original dimensions/crop dimensions where the larger ratio between -x and y dims is chosen. Scale factor is capped by \code{max_resample_scale}} -} -Control points for this function are set by \code{max_crop} which decides the max -ROI area after which switchover to method B happens in order to avoid laborious crops -and \code{max_resample_scale} which determines the maximum scale factor for number -of values to sample. Both values can be adjusted depending on system resources. -Additionally, \code{flex_resample} determines if this switching behavior happens. -When set to \code{FALSE}, only method A is used. -} -\seealso{ -\code{\link[terra]{spatSample}} -} -\keyword{internal} diff --git a/man/plot_cell_params.Rd b/man/plot_cell_params.Rd new file mode 100644 index 0000000..67b1406 --- /dev/null +++ b/man/plot_cell_params.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_cell_params} +\alias{plot_cell_params} +\title{Params documentation template: plot_cell_params} +\arguments{ +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} +} +\description{ +Params documentation template: plot_cell_params +} +\keyword{internal} diff --git a/man/plot_cow_params.Rd b/man/plot_cow_params.Rd new file mode 100644 index 0000000..c9627e9 --- /dev/null +++ b/man/plot_cow_params.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_cow_params} +\alias{plot_cow_params} +\title{Params documentation template: plot_cow_params} +\arguments{ +\item{cow_n_col}{cowplot param: how many columns} + +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} + +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} + +\item{cow_align}{cowplot param: how to align} +} +\description{ +Params documentation template: plot_cow_params +} +\keyword{internal} diff --git a/man/plot_dimred_params.Rd b/man/plot_dimred_params.Rd new file mode 100644 index 0000000..ba7c690 --- /dev/null +++ b/man/plot_dimred_params.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_dimred_params} +\alias{plot_dimred_params} +\title{Params documentation template: plot_dimred_params} +\arguments{ +\item{dim_reduction_to_use}{character. dimension reduction to use} + +\item{dim_reduction_name}{character. dimension reduction name} + +\item{dim1_to_use}{numeric. dimension to use on x-axis} + +\item{dim2_to_use}{numeric. dimension to use on y-axis} + +\item{dim3_to_use}{numeric. dimension to use on z-axis} + +\item{dim_point_shape}{point with border or not (border or no_border)} + +\item{dim_point_size}{size of points in dim. reduction space} + +\item{dim_point_alpha}{transparancy of point in dim. reduction space} + +\item{dim_point_border_col}{border color of points in dim. reduction space} + +\item{dim_point_border_stroke}{border stroke of points in dim. reduction space} +} +\description{ +Params documentation template: plot_dimred_params +} +\keyword{internal} diff --git a/man/plot_feat_params.Rd b/man/plot_feat_params.Rd new file mode 100644 index 0000000..8a9a85c --- /dev/null +++ b/man/plot_feat_params.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_feat_params} +\alias{plot_feat_params} +\title{Params documentation template: plot_feat_params} +\arguments{ +\item{feats_color_code}{code to color the provided features} + +\item{feat_shape_code}{code to shape the provided feature types} +} +\description{ +Params documentation template: plot_feat_params +} +\keyword{internal} diff --git a/man/plot_image_params.Rd b/man/plot_image_params.Rd new file mode 100644 index 0000000..78e4145 --- /dev/null +++ b/man/plot_image_params.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_image_params} +\alias{plot_image_params} +\title{Params documentation template: plot_image_params} +\arguments{ +\item{show_image}{show a tissue background image} + +\item{gimage}{a giotto image} + +\item{image_name}{name of a giotto image or multiple images with group_by} + +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} +} +\description{ +Params documentation template: plot_image_params +} +\keyword{internal} diff --git a/man/plot_nn_net_params.Rd b/man/plot_nn_net_params.Rd new file mode 100644 index 0000000..5bda323 --- /dev/null +++ b/man/plot_nn_net_params.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_nn_net_params} +\alias{plot_nn_net_params} +\title{Params documentation template: plot_nn_net_params} +\arguments{ +\item{show_NN_network}{logical. Show underlying NN network} + +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} + +\item{network_name}{character. name of NN network to use, if show_NN_network = TRUE} + +\item{nn_network_name}{character. name of NN network to use, if show_NN_network = TRUE} + +\item{network_color}{color of NN network} + +\item{nn_network_alpha}{column to use for alpha of the edges} +} +\description{ +Params documentation template: plot_nn_net_params +} +\keyword{internal} diff --git a/man/plot_output_handler.Rd b/man/plot_output_handler.Rd index 3e9058a..e0df000 100644 --- a/man/plot_output_handler.Rd +++ b/man/plot_output_handler.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_output.R +% Please edit documentation in R/aux_output.R \name{plot_output_handler} \alias{plot_output_handler} \title{Plotting output handler} @@ -32,7 +32,7 @@ the plot in display device} \item{default_save_name}{default name to use (should be set by the specific plotting function. Users should not interact with this parameter)} -\item{save_param}{list of plot saving parameters see \link{showSaveParameters}} +\item{save_param}{list of plot saving parameters see \code{\link[=showSaveParameters]{showSaveParameters()}}} \item{else_return}{optional. What should be returned instead if the plot object is not returned} diff --git a/man/plot_output_params.Rd b/man/plot_output_params.Rd new file mode 100644 index 0000000..62e4aa5 --- /dev/null +++ b/man/plot_output_params.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_output_params} +\alias{plot_output_params} +\title{Params documentation template: plot_output_params} +\arguments{ +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} +} +\description{ +Params documentation template: plot_output_params +} +\keyword{internal} diff --git a/man/plot_params.Rd b/man/plot_params.Rd index 564fa16..243b347 100644 --- a/man/plot_params.Rd +++ b/man/plot_params.Rd @@ -2,19 +2,21 @@ % Please edit documentation in R/dd.R \name{plot_params} \alias{plot_params} -\title{plot_params} +\title{Params documentation template: plot_params} \arguments{ -\item{cell_color}{color for cells (see details)} +\item{group_by}{character. Create multiple plots based on cell annotation column} -\item{color_as_factor}{convert color column to factor} +\item{group_by_subset}{character. subset the group_by factor column} -\item{cell_color_code}{named vector with colors} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_limits}{numeric vector with lower and upper limits} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_color}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} \item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} @@ -24,6 +26,10 @@ \item{other_cell_color}{color for not selected cells} +\item{other_cell_alpha}{(0 to 1) alpha for not selected cells} + +\item{other_cells_alpha}{(0 to 1) alpha for not selected cells} + \item{other_point_size}{point size for not selected cells} \item{show_cluster_center}{plot center of selected clusters} @@ -36,22 +42,6 @@ \item{center_point_border_stroke}{border stroke size of center points} -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - \item{label_size}{size of labels} \item{label_fontface}{font of labels} @@ -68,9 +58,9 @@ \item{point_border_stroke}{stroke size of border around points} -\item{title}{title for plot, defaults to cell_color parameter} +\item{title}{character. title for plot, defaults to cell_color parameter} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -81,26 +71,8 @@ \item{axis_text}{size of axis text} \item{axis_title}{size of axis title} - -\item{cow_n_col}{cowplot param: how many columns} - -\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} - -\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} - -\item{cow_align}{cowplot param: how to align} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } \description{ -plot_params +Params documentation template: plot_params } \keyword{internal} diff --git a/man/plot_poly_params.Rd b/man/plot_poly_params.Rd new file mode 100644 index 0000000..5eec0d9 --- /dev/null +++ b/man/plot_poly_params.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_poly_params} +\alias{plot_poly_params} +\title{Params documentation template: plot_poly_params} +\arguments{ +\item{show_polygon}{overlay polygon information (e.g. cell shape)} + +\item{use_overlap}{use polygon and feature coordinates overlap results} + +\item{polygon_feat_type}{feature type associated with polygon information} + +\item{polygon_color}{color for polygon border} + +\item{polygon_bg_color}{color for polygon background (overruled by polygon_fill)} + +\item{polygon_fill}{character. what to color to fill polgyons by (e.g. metadata +col or spatial enrichment col)} + +\item{polygon_fill_gradient}{polygon fill gradient colors given in order from low to high} + +\item{polygon_fill_gradient_midpoint}{value to set as gradient midpoint (optional). If +left as \code{NULL}, the median value detected will be chosen} + +\item{polygon_fill_gradient_style}{either 'divergent' (midpoint is used in +color scaling) or 'sequential' (scaled based on data range)} + +\item{polygon_fill_as_factor}{is fill color a factor} + +\item{polygon_fill_code}{code to color the fill column} + +\item{polygon_alpha}{alpha of polygon} + +\item{polygon_line_size}{line width of the polygon's outline} +} +\description{ +Params documentation template: plot_poly_params +} +\keyword{internal} diff --git a/man/plot_save.Rd b/man/plot_save.Rd index ceab324..3065523 100644 --- a/man/plot_save.Rd +++ b/man/plot_save.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_save.R +% Please edit documentation in R/aux_save.R \name{plot_save} \alias{plot_save} \alias{ggplot_save_function} @@ -70,7 +70,7 @@ all_plots_save_function( ) } \arguments{ -\item{gobject}{giotto object} +\item{gobject}{giotto object or giottoInstructions} \item{plot_object}{ggplot object to plot} diff --git a/man/plot_spatenr_params.Rd b/man/plot_spatenr_params.Rd new file mode 100644 index 0000000..2b80d50 --- /dev/null +++ b/man/plot_spatenr_params.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_spatenr_params} +\alias{plot_spatenr_params} +\title{Params documentation template: plot_spatenr_params} +\arguments{ +\item{spat_enr_names}{character. names of spatial enrichment results to include} +} +\description{ +Params documentation template: plot_spatenr_params +} +\keyword{internal} diff --git a/man/plot_spatnet_params.Rd b/man/plot_spatnet_params.Rd new file mode 100644 index 0000000..752985d --- /dev/null +++ b/man/plot_spatnet_params.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dd.R +\name{plot_spatnet_params} +\alias{plot_spatnet_params} +\title{Params documentation template: plot_spatnet_params} +\arguments{ +\item{show_spatial_network}{show spatial network} + +\item{spatial_network_name}{name of spatial network to use} + +\item{spat_network_name}{name of spatial network to use} + +\item{spat_network_color}{color of spatial network} + +\item{spatial_network_color}{color of spatial network} + +\item{spat_network_alpha}{alpha of spatial network} +} +\description{ +Params documentation template: plot_spatnet_params +} +\keyword{internal} diff --git a/man/plotly_axis_scale_2D.Rd b/man/plotly_axis_scale_2D.Rd index 6aa2d53..a041dde 100644 --- a/man/plotly_axis_scale_2D.Rd +++ b/man/plotly_axis_scale_2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{plotly_axis_scale_2D} \alias{plotly_axis_scale_2D} \title{plotly_axis_scale_2D} diff --git a/man/plotly_axis_scale_3D.Rd b/man/plotly_axis_scale_3D.Rd index 6a7f2fd..c3f42aa 100644 --- a/man/plotly_axis_scale_3D.Rd +++ b/man/plotly_axis_scale_3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{plotly_axis_scale_3D} \alias{plotly_axis_scale_3D} \title{plotly_axis_scale_3D} diff --git a/man/plotly_grid.Rd b/man/plotly_grid.Rd index a67bb8e..5a879f0 100644 --- a/man/plotly_grid.Rd +++ b/man/plotly_grid.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{plotly_grid} \alias{plotly_grid} \title{plotly_grid} diff --git a/man/plotly_network.Rd b/man/plotly_network.Rd index 34f4e60..03b80c0 100644 --- a/man/plotly_network.Rd +++ b/man/plotly_network.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R +% Please edit documentation in R/aux_visuals.R \name{plotly_network} \alias{plotly_network} \title{plotly_network} diff --git a/man/select_gimage.Rd b/man/select_gimage.Rd deleted file mode 100644 index c22d5db..0000000 --- a/man/select_gimage.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/auxilliary_visuals.R -\name{select_gimage} -\alias{select_gimage} -\title{select_gimage} -\usage{ -select_gimage( - gobject, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - spat_unit = NULL, - spat_loc_name = NULL, - feat_type = NULL, - polygon_feat_type = NULL -) -} -\description{ -selects and (possibly resamples) giotto images for plotting -} -\keyword{internal} diff --git a/man/set_default_color_continuous.Rd b/man/set_default_color_continuous.Rd index d39fefa..09c6e1d 100644 --- a/man/set_default_color_continuous.Rd +++ b/man/set_default_color_continuous.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/defaults.R +% Please edit documentation in R/aux_defaults.R \name{set_default_color_continuous} \alias{set_default_color_continuous} \title{Set a default color for continuous values} diff --git a/man/showClusterDendrogram.Rd b/man/showClusterDendrogram.Rd index 821547b..d3cc412 100644 --- a/man/showClusterDendrogram.Rd +++ b/man/showClusterDendrogram.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_dendrogram.R +% Please edit documentation in R/plot_dendrogram.R \name{showClusterDendrogram} \alias{showClusterDendrogram} \title{showClusterDendrogram} @@ -44,17 +44,28 @@ showClusterDendrogram( \item{rotate}{rotate dendrogram 90 degrees} -\item{show_plot}{show plot. TRUE or FALSE} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -\item{...}{additional parameters passed to \code{\link[ggdendro]{ggdendrogram}}} +\item{...}{ + Arguments passed on to \code{\link[ggdendro:ggdendrogram]{ggdendro::ggdendrogram}} + \describe{ + \item{\code{data}}{Either a dendro object or an object that can be coerced to class +dendro using the \code{\link[ggdendro:dendro_data]{dendro_data()}} function, i.e. objects of class +dendrogram, hclust or tree} + \item{\code{segments}}{If TRUE, show line segments} + \item{\code{labels}}{if TRUE, shows segment labels} + \item{\code{leaf_labels}}{if TRUE, shows leaf labels} + \item{\code{theme_dendro}}{if TRUE, applies a blank theme to plot (see +\code{\link[ggdendro:theme_dendro]{theme_dendro()}})} + }} } \value{ ggplot diff --git a/man/showClusterHeatmap.Rd b/man/showClusterHeatmap.Rd index 8105bc6..b05fd33 100644 --- a/man/showClusterHeatmap.Rd +++ b/man/showClusterHeatmap.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_heatmap.R +% Please edit documentation in R/plot_heatmap.R \name{showClusterHeatmap} \alias{showClusterHeatmap} \title{showClusterHeatmap} @@ -38,19 +38,103 @@ showClusterHeatmap( \item{distance}{distance method to use for hierarchical clustering, default to "ward.D"} -\item{show_plot}{show plot. TRUE or FALSE} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -\item{...}{additional parameters passed to \code{\link[ComplexHeatmap]{Heatmap}} function} - -\item{genes}{deprecated. Replaced by \code{feats} param} +\item{...}{ + Arguments passed on to \code{\link[ComplexHeatmap:Heatmap]{ComplexHeatmap::Heatmap}} + \describe{ + \item{\code{matrix}}{A matrix. Either numeric or character. If it is a simple vector, it will be converted to a one-column matrix.} + \item{\code{col}}{A vector of colors if the color mapping is discrete or a color mapping function if the matrix is continuous numbers (should be generated by \code{\link[circlize]{colorRamp2}}). If the matrix is continuous, the value can also be a vector of colors so that colors can be interpolated. Pass to \code{\link[ComplexHeatmap]{ColorMapping}}. For more details and examples, please refer to \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#colors} .} + \item{\code{name}}{Name of the heatmap. By default the heatmap name is used as the title of the heatmap legend.} + \item{\code{na_col}}{Color for \code{NA} values.} + \item{\code{rect_gp}}{Graphic parameters for drawing rectangles (for heatmap body). The value should be specified by \code{\link[grid]{gpar}} and \code{fill} parameter is ignored.} + \item{\code{color_space}}{The color space in which colors are interpolated. Only used if \code{matrix} is numeric and \code{col} is a vector of colors. Pass to \code{\link[circlize]{colorRamp2}}.} + \item{\code{border}}{Whether draw border. The value can be logical or a string of color.} + \item{\code{border_gp}}{Graphic parameters for the borders. If you want to set different parameters for different heatmap slices, please consider to use \code{\link[ComplexHeatmap]{decorate_heatmap_body}}.} + \item{\code{cell_fun}}{Self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{j}, \code{i}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are column index, row index in \code{matrix}, coordinate of the cell, the width and height of the cell and the filled color. \code{x}, \code{y}, \code{width} and \code{height} are all \code{\link[grid]{unit}} objects.} + \item{\code{layer_fun}}{Similar as \code{cell_fun}, but is vectorized. Check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#customize-the-heatmap-body} .} + \item{\code{jitter}}{Random shifts added to the matrix. The value can be logical or a single numeric value. It it is \code{TRUE}, random values from uniform distribution between 0 and 1e-10 are generated. If it is a numeric value, the range for the uniform distribution is (0, \code{jitter}). It is mainly to solve the problem of "Error: node stack overflow" when there are too many identical rows/columns for plotting the dendrograms. ADD: From version 2.5.6, the error of node stack overflow has been fixed, now this argument is ignored.} + \item{\code{row_title}}{Title on the row.} + \item{\code{row_title_side}}{Will the title be put on the left or right of the heatmap?} + \item{\code{row_title_gp}}{Graphic parameters for row title.} + \item{\code{row_title_rot}}{Rotation of row title.} + \item{\code{column_title}}{Title on the column.} + \item{\code{column_title_side}}{Will the title be put on the top or bottom of the heatmap?} + \item{\code{column_title_gp}}{Graphic parameters for column title.} + \item{\code{column_title_rot}}{Rotation of column titles.} + \item{\code{cluster_rows}}{If the value is a logical, it controls whether to make cluster on rows. The value can also be a \code{\link[stats]{hclust}} or a \code{\link[stats]{dendrogram}} which already contains clustering. Check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#clustering} .} + \item{\code{cluster_row_slices}}{If rows are split into slices, whether perform clustering on the slice means?} + \item{\code{clustering_distance_rows}}{It can be a pre-defined character which is in ("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski", "pearson", "spearman", "kendall"). It can also be a function. If the function has one argument, the input argument should be a matrix and the returned value should be a \code{\link[stats]{dist}} object. If the function has two arguments, the input arguments are two vectors and the function calculates distance between these two vectors.} + \item{\code{clustering_method_rows}}{Method to perform hierarchical clustering, pass to \code{\link[stats]{hclust}}.} + \item{\code{row_dend_side}}{Should the row dendrogram be put on the left or right of the heatmap?} + \item{\code{row_dend_width}}{Width of the row dendrogram, should be a \code{\link[grid]{unit}} object.} + \item{\code{show_row_dend}}{Whether show row dendrogram?} + \item{\code{row_dend_gp}}{Graphic parameters for the dendrogram segments. If users already provide a \code{\link[stats]{dendrogram}} object with edges rendered, this argument will be ignored.} + \item{\code{row_dend_reorder}}{Apply reordering on row dendrograms. The value can be a logical value or a vector which contains weight which is used to reorder rows. The reordering is applied by \code{\link[stats]{reorder.dendrogram}}.} + \item{\code{cluster_columns}}{Whether make cluster on columns? Same settings as \code{cluster_rows}.} + \item{\code{cluster_column_slices}}{If columns are split into slices, whether perform clustering on the slice means?} + \item{\code{clustering_distance_columns}}{Same setting as \code{clustering_distance_rows}.} + \item{\code{clustering_method_columns}}{Method to perform hierarchical clustering, pass to \code{\link[stats]{hclust}}.} + \item{\code{column_dend_side}}{Should the column dendrogram be put on the top or bottom of the heatmap?} + \item{\code{column_dend_height}}{height of the column cluster, should be a \code{\link[grid]{unit}} object.} + \item{\code{show_column_dend}}{Whether show column dendrogram?} + \item{\code{column_dend_gp}}{Graphic parameters for dendrogram segments. Same settings as \code{row_dend_gp}.} + \item{\code{column_dend_reorder}}{Apply reordering on column dendrograms. Same settings as \code{row_dend_reorder}.} + \item{\code{row_order}}{Order of rows. Manually setting row order turns off clustering.} + \item{\code{column_order}}{Order of column.} + \item{\code{row_labels}}{Optional row labels which are put as row names in the heatmap.} + \item{\code{row_names_side}}{Should the row names be put on the left or right of the heatmap?} + \item{\code{show_row_names}}{Whether show row names.} + \item{\code{row_names_max_width}}{Maximum width of row names viewport.} + \item{\code{row_names_gp}}{Graphic parameters for row names.} + \item{\code{row_names_rot}}{Rotation of row names.} + \item{\code{row_names_centered}}{Should row names put centered?} + \item{\code{column_labels}}{Optional column labels which are put as column names in the heatmap.} + \item{\code{column_names_side}}{Should the column names be put on the top or bottom of the heatmap?} + \item{\code{column_names_max_height}}{Maximum height of column names viewport.} + \item{\code{show_column_names}}{Whether show column names.} + \item{\code{column_names_gp}}{Graphic parameters for drawing text.} + \item{\code{column_names_rot}}{Rotation of column names.} + \item{\code{column_names_centered}}{Should column names put centered?} + \item{\code{top_annotation}}{A \code{\link[ComplexHeatmap]{HeatmapAnnotation}} object.} + \item{\code{bottom_annotation}}{A \code{\link[ComplexHeatmap]{HeatmapAnnotation}} object.} + \item{\code{left_annotation}}{It should be specified by \code{\link[ComplexHeatmap]{rowAnnotation}}.} + \item{\code{right_annotation}}{it should be specified by \code{\link[ComplexHeatmap]{rowAnnotation}}.} + \item{\code{km}}{Apply k-means clustering on rows. If the value is larger than 1, the heatmap will be split by rows according to the k-means clustering. For each row slice, hierarchical clustering is still applied with parameters above.} + \item{\code{split}}{A vector or a data frame by which the rows are split. But if \code{cluster_rows} is a clustering object, \code{split} can be a single number indicating to split the dendrogram by \code{\link[stats]{cutree}}.} + \item{\code{row_km}}{Same as \code{km}.} + \item{\code{row_km_repeats}}{Number of k-means runs to get a consensus k-means clustering. Note if \code{row_km_repeats} is set to more than one, the final number of groups might be smaller than \code{row_km}, but this might means the original \code{row_km} is not a good choice.} + \item{\code{row_split}}{Same as \code{split}.} + \item{\code{column_km}}{K-means clustering on columns.} + \item{\code{column_km_repeats}}{Number of k-means runs to get a consensus k-means clustering. Similar as \code{row_km_repeats}.} + \item{\code{column_split}}{Split on columns. For heatmap splitting, please refer to \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#heatmap-split} .} + \item{\code{gap}}{Gap between row slices if the heatmap is split by rows. The value should be a \code{\link[grid]{unit}} object.} + \item{\code{row_gap}}{Same as \code{gap}.} + \item{\code{column_gap}}{Gap between column slices.} + \item{\code{show_parent_dend_line}}{When heatmap is split, whether to add a dashed line to mark parent dendrogram and children dendrograms?} + \item{\code{width}}{Width of the heatmap body.} + \item{\code{height}}{Height of the heatmap body.} + \item{\code{heatmap_width}}{Width of the whole heatmap (including heatmap components)} + \item{\code{heatmap_height}}{Height of the whole heatmap (including heatmap components). Check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#size-of-the-heatmap} .} + \item{\code{show_heatmap_legend}}{Whether show heatmap legend?} + \item{\code{heatmap_legend_param}}{A list contains parameters for the heatmap legends. See \code{\link[ComplexHeatmap]{color_mapping_legend,ColorMapping-method}} for all available parameters.} + \item{\code{use_raster}}{Whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge. If number of rows or columns is more than 2000, it is by default turned on. Note if \code{cell_fun} is set, \code{use_raster} is enforced to be \code{FALSE}.} + \item{\code{raster_device}}{Graphic device which is used to generate the raster image.} + \item{\code{raster_quality}}{A value larger than 1.} + \item{\code{raster_device_param}}{A list of further parameters for the selected graphic device. For raster image support, please check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#heatmap-as-raster-image} .} + \item{\code{raster_resize_mat}}{Whether resize the matrix to let the dimension of the matrix the same as the dimension of the raster image? The value can be logical. If it is \code{TRUE}, \code{\link[base]{mean}} is used to summarize the sub matrix which corresponds to a single pixel. The value can also be a summary function, e.g. \code{\link[base:Extremes]{max}}.} + \item{\code{raster_by_magick}}{Whether to use \code{\link[magick:transform]{image_resize}} to scale the image.} + \item{\code{raster_magick_filter}}{Pass to \code{filter} argument of \code{\link[magick:transform]{image_resize}}. A character scalar and all possible values are in \code{\link[magick:options]{filter_types}}. The default is \code{"Lanczos"}.} + \item{\code{post_fun}}{A function which will be executed after the heatmap list is drawn.} + }} } \value{ ggplot diff --git a/man/showColorInstructions.Rd b/man/showColorInstructions.Rd index a2689c6..e4e1c58 100644 --- a/man/showColorInstructions.Rd +++ b/man/showColorInstructions.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/defaults.R +% Please edit documentation in R/aux_defaults.R \name{showColorInstructions} \alias{showColorInstructions} \title{Show Giotto color instructions} diff --git a/man/showSaveParameters.Rd b/man/showSaveParameters.Rd index 0c3e35f..3787853 100644 --- a/man/showSaveParameters.Rd +++ b/man/showSaveParameters.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_save.R +% Please edit documentation in R/aux_save.R \name{showSaveParameters} \alias{showSaveParameters} \title{showSaveParameters} diff --git a/man/spatCellPlot.Rd b/man/spatCellPlot.Rd index 6139c1b..ebbd9aa 100644 --- a/man/spatCellPlot.Rd +++ b/man/spatCellPlot.Rd @@ -1,74 +1,196 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatCellPlot} \alias{spatCellPlot} +\alias{spatCellPlot2D} \title{spatCellPlot} \usage{ +spatCellPlot2D( + gobject, + spat_unit = NULL, + feat_type = NULL, + show_image = F, + gimage = NULL, + image_name = NULL, + largeImage_name = NULL, + sdimx = "sdimx", + sdimy = "sdimy", + spat_enr_names = NULL, + cell_annotation_values = NULL, + cell_color_gradient = NULL, + gradient_midpoint = NULL, + gradient_style = c("divergent", "sequential"), + gradient_limits = NULL, + select_cell_groups = NULL, + select_cells = NULL, + point_shape = c("border", "no_border", "voronoi"), + point_size = 3, + point_alpha = 1, + point_border_col = "black", + point_border_stroke = 0.1, + show_cluster_center = F, + show_center_label = F, + center_point_size = 4, + center_point_border_col = "black", + center_point_border_stroke = 0.1, + label_size = 4, + label_fontface = "bold", + show_network = F, + spatial_network_name = "Delaunay_network", + network_color = NULL, + network_alpha = 1, + show_grid = F, + spatial_grid_name = "spatial_grid", + grid_color = NULL, + show_other_cells = T, + other_cell_color = "lightgrey", + other_point_size = 1, + other_cells_alpha = 0.1, + coord_fix_ratio = 1, + show_legend = T, + legend_text = 8, + legend_symbol_size = 1, + background_color = "white", + vor_border_color = "white", + vor_max_radius = 200, + vor_alpha = 1, + axis_text = 8, + axis_title = 8, + cow_n_col = NULL, + cow_rel_h = 1, + cow_rel_w = 1, + cow_align = "h", + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatCellPlot2D" +) + spatCellPlot(...) } \arguments{ -\item{...}{ - Arguments passed on to \code{\link[=spatCellPlot2D]{spatCellPlot2D}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{feat_type}}{feature type} - \item{\code{spat_unit}}{spatial unit} - \item{\code{show_image}}{show a tissue background image} - \item{\code{gimage}}{a giotto image} - \item{\code{image_name}}{name of a giotto image} - \item{\code{largeImage_name}}{name of a giottoLargeImage} - \item{\code{sdimx}}{x-axis dimension name (default = 'sdimx')} - \item{\code{sdimy}}{y-axis dimension name (default = 'sdimy')} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{cell_annotation_values}}{numeric cell annotation columns} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{point_shape}}{shape of points (border, no_border or voronoi)} - \item{\code{point_size}}{size of point (cell)} - \item{\code{point_alpha}}{transparancy of spatial points} - \item{\code{point_border_col}}{color of border around points} - \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{show_cluster_center}}{plot center of selected clusters} - \item{\code{show_center_label}}{plot label of selected clusters} - \item{\code{center_point_size}}{size of center points} - \item{\code{center_point_border_col}}{border color of center points} - \item{\code{center_point_border_stroke}}{border stroke size of center points} - \item{\code{label_size}}{size of labels} - \item{\code{label_fontface}}{font of labels} - \item{\code{show_network}}{show underlying spatial network} - \item{\code{spatial_network_name}}{name of spatial network to use} - \item{\code{network_color}}{color of spatial network} - \item{\code{network_alpha}}{alpha of spatial network} - \item{\code{show_grid}}{show spatial grid} - \item{\code{spatial_grid_name}}{name of spatial grid to use} - \item{\code{grid_color}}{color of spatial grid} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{point size of not selected cells} - \item{\code{other_cells_alpha}}{alpha of not selected cells} - \item{\code{coord_fix_ratio}}{fix ratio between x and y-axis} - \item{\code{show_legend}}{show legend} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} - \item{\code{background_color}}{color of plot background} - \item{\code{vor_border_color}}{border colorr for voronoi plot} - \item{\code{vor_max_radius}}{maximum radius for voronoi 'cells'} - \item{\code{vor_alpha}}{transparancy of voronoi 'cells'} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative height} - \item{\code{cow_rel_w}}{cowplot param: relative width} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{show_image}{show a tissue background image} + +\item{gimage}{a giotto image} + +\item{image_name}{name of a giotto image or multiple images with group_by} + +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} + +\item{sdimx}{x-axis dimension name (default = 'sdimx')} + +\item{sdimy}{y-axis dimension name (default = 'sdimy')} + +\item{spat_enr_names}{character. names of spatial enrichment results to include} + +\item{cell_annotation_values}{numeric cell annotation columns} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{numeric. midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} + +\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} + +\item{select_cells}{select subset of cells based on cell IDs} + +\item{point_shape}{point with border or not (border or no_border)} + +\item{point_size}{size of point (cell)} + +\item{point_alpha}{transparency of points} + +\item{point_border_col}{color of border around points} + +\item{point_border_stroke}{stroke size of border around points} + +\item{show_cluster_center}{plot center of selected clusters} + +\item{show_center_label}{plot label of selected clusters} + +\item{center_point_size}{size of center points} + +\item{center_point_border_col}{border color of center points} + +\item{center_point_border_stroke}{border stroke size of center points} + +\item{label_size}{size of labels} + +\item{label_fontface}{font of labels} + +\item{show_network}{show underlying spatial network} + +\item{spatial_network_name}{name of spatial network to use} + +\item{network_color}{color of spatial network} + +\item{network_alpha}{alpha of spatial network} + +\item{show_grid}{show spatial grid} + +\item{spatial_grid_name}{name of spatial grid to use} + +\item{grid_color}{color of spatial grid} + +\item{show_other_cells}{display not selected cells} + +\item{other_cell_color}{color for not selected cells} + +\item{other_point_size}{point size for not selected cells} + +\item{other_cells_alpha}{(0 to 1) alpha for not selected cells} + +\item{coord_fix_ratio}{fix ratio between x and y-axis} + +\item{show_legend}{logical. show legend} + +\item{legend_text}{size of legend text} + +\item{legend_symbol_size}{size of legend symbols} + +\item{background_color}{color of plot background} + +\item{vor_border_color}{border colorr for voronoi plot} + +\item{vor_max_radius}{maximum radius for voronoi 'cells'} + +\item{vor_alpha}{transparency of voronoi 'cells'} + +\item{axis_text}{size of axis text} + +\item{axis_title}{size of axis title} + +\item{cow_n_col}{cowplot param: how many columns} + +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} + +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} + +\item{cow_align}{cowplot param: how to align} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{\dots}{spatCellPlot(...) passes to spatCellPlot2D()} } \value{ ggplot @@ -79,8 +201,4 @@ Visualize cells according to spatial coordinates \details{ Description of parameters. } -\seealso{ -Other spatial cell annotation visualizations: -\code{\link{spatCellPlot2D}()} -} \concept{spatial cell annotation visualizations} diff --git a/man/spatCellPlot2D.Rd b/man/spatCellPlot2D.Rd deleted file mode 100644 index 9157b2f..0000000 --- a/man/spatCellPlot2D.Rd +++ /dev/null @@ -1,199 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{spatCellPlot2D} -\alias{spatCellPlot2D} -\title{spatCellPlot2D} -\usage{ -spatCellPlot2D( - gobject, - spat_unit = NULL, - feat_type = NULL, - show_image = F, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - sdimx = "sdimx", - sdimy = "sdimy", - spat_enr_names = NULL, - cell_annotation_values = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - point_shape = c("border", "no_border", "voronoi"), - point_size = 3, - point_alpha = 1, - point_border_col = "black", - point_border_stroke = 0.1, - show_cluster_center = F, - show_center_label = F, - center_point_size = 4, - center_point_border_col = "black", - center_point_border_stroke = 0.1, - label_size = 4, - label_fontface = "bold", - show_network = F, - spatial_network_name = "Delaunay_network", - network_color = NULL, - network_alpha = 1, - show_grid = F, - spatial_grid_name = "spatial_grid", - grid_color = NULL, - show_other_cells = T, - other_cell_color = "lightgrey", - other_point_size = 1, - other_cells_alpha = 0.1, - coord_fix_ratio = 1, - show_legend = T, - legend_text = 8, - legend_symbol_size = 1, - background_color = "white", - vor_border_color = "white", - vor_max_radius = 200, - vor_alpha = 1, - axis_text = 8, - axis_title = 8, - cow_n_col = NULL, - cow_rel_h = 1, - cow_rel_w = 1, - cow_align = "h", - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "spatCellPlot2D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{show_image}{show a tissue background image} - -\item{gimage}{a giotto image} - -\item{image_name}{name of a giotto image} - -\item{largeImage_name}{name of a giottoLargeImage} - -\item{sdimx}{x-axis dimension name (default = 'sdimx')} - -\item{sdimy}{y-axis dimension name (default = 'sdimy')} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{cell_annotation_values}{numeric cell annotation columns} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{point_shape}{shape of points (border, no_border or voronoi)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparancy of spatial points} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{center_point_border_col}{border color of center points} - -\item{center_point_border_stroke}{border stroke size of center points} - -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{show_network}{show underlying spatial network} - -\item{spatial_network_name}{name of spatial network to use} - -\item{network_color}{color of spatial network} - -\item{network_alpha}{alpha of spatial network} - -\item{show_grid}{show spatial grid} - -\item{spatial_grid_name}{name of spatial grid to use} - -\item{grid_color}{color of spatial grid} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{point size of not selected cells} - -\item{other_cells_alpha}{alpha of not selected cells} - -\item{coord_fix_ratio}{fix ratio between x and y-axis} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - -\item{vor_border_color}{border colorr for voronoi plot} - -\item{vor_max_radius}{maximum radius for voronoi 'cells'} - -\item{vor_alpha}{transparancy of voronoi 'cells'} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{cow_n_col}{cowplot param: how many columns} - -\item{cow_rel_h}{cowplot param: relative height} - -\item{cow_rel_w}{cowplot param: relative width} - -\item{cow_align}{cowplot param: how to align} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to spatial coordinates -} -\details{ -Description of parameters. -} -\seealso{ -Other spatial cell annotation visualizations: -\code{\link{spatCellPlot}()} -} -\concept{spatial cell annotation visualizations} diff --git a/man/spatDeconvPlot.Rd b/man/spatDeconvPlot.Rd index 8fed2a5..1f41441 100644 --- a/man/spatDeconvPlot.Rd +++ b/man/spatDeconvPlot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDeconvPlot} \alias{spatDeconvPlot} \title{spatDeconvPlot} @@ -36,9 +36,9 @@ spatDeconvPlot( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{deconv_name}{name of deconvolution results to use} @@ -56,7 +56,8 @@ spatDeconvPlot( \item{sdimy}{y-axis dimension name (default = 'sdimy')} -\item{cell_color_code}{named vector with colors} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} \item{line_color}{color of line within pie charts} @@ -76,13 +77,13 @@ spatDeconvPlot( \item{coord_fix_ratio}{fix ratio between x and y-axis} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/spatDimCellPlot.Rd b/man/spatDimCellPlot.Rd index 5a767a0..076049d 100644 --- a/man/spatDimCellPlot.Rd +++ b/man/spatDimCellPlot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimCellPlot} \alias{spatDimCellPlot} \title{spatDimCellPlot} @@ -10,35 +10,13 @@ spatDimCellPlot(...) \item{...}{ Arguments passed on to \code{\link[=spatDimCellPlot2D]{spatDimCellPlot2D}} \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{show_image}}{show a tissue background image} - \item{\code{gimage}}{a giotto image} - \item{\code{image_name}}{name of a giotto image} - \item{\code{largeImage_name}}{name of a giottoLargeImage} \item{\code{plot_alignment}}{direction to align plot} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} \item{\code{cell_annotation_values}}{numeric cell annotation columns} - \item{\code{dim_reduction_to_use}}{dimension reduction to use} - \item{\code{dim_reduction_name}}{dimension reduction name} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} \item{\code{sdimx}}{= spatial dimension to use on x-axis} \item{\code{sdimy}}{= spatial dimension to use on y-axis} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{dim_point_shape}}{dim reduction points with border or not (border or no_border)} - \item{\code{dim_point_size}}{size of points in dim. reduction space} - \item{\code{dim_point_alpha}}{transparancy of dim. reduction points} - \item{\code{dim_point_border_col}}{border color of points in dim. reduction space} - \item{\code{dim_point_border_stroke}}{border stroke of points in dim. reduction space} \item{\code{spat_point_shape}}{shape of points (border, no_border or voronoi)} \item{\code{spat_point_size}}{size of spatial points} - \item{\code{spat_point_alpha}}{transparancy of spatial points} + \item{\code{spat_point_alpha}}{transparency of spatial points} \item{\code{spat_point_border_col}}{border color of spatial points} \item{\code{spat_point_border_stroke}}{border stroke of spatial points} \item{\code{dim_show_cluster_center}}{show the center of each cluster} @@ -55,9 +33,6 @@ spatDimCellPlot(...) \item{\code{spat_center_point_border_stroke}}{stroke size of the spatial center points} \item{\code{spat_label_size}}{size of the center label} \item{\code{spat_label_fontface}}{font of the center label} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{nn_network_name}}{name of NN network to use, if show_NN_network = TRUE} \item{\code{dim_edge_alpha}}{column to use for alpha of the edges} \item{\code{spat_show_network}}{show spatial network} \item{\code{spatial_network_name}}{name of spatial network to use} @@ -66,31 +41,59 @@ spatDimCellPlot(...) \item{\code{spat_show_grid}}{show spatial grid} \item{\code{spatial_grid_name}}{name of spatial grid to use} \item{\code{spat_grid_color}}{color of spatial grid} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} \item{\code{dim_other_point_size}}{size of not selected dim cells} \item{\code{spat_other_point_size}}{size of not selected spat cells} \item{\code{spat_other_cells_alpha}}{alpha of not selected spat cells} \item{\code{coord_fix_ratio}}{ratio for coordinates} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative height} - \item{\code{cow_rel_w}}{cowplot param: relative width} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_legend}}{show legend} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} \item{\code{dim_background_color}}{background color of points in dim. reduction space} \item{\code{spat_background_color}}{background color of spatial points} \item{\code{vor_border_color}}{border colorr for voronoi plot} \item{\code{vor_max_radius}}{maximum radius for voronoi 'cells'} \item{\code{vor_alpha}}{transparancy of voronoi 'cells'} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} + \item{\code{gobject}}{giotto object} + \item{\code{spat_unit}}{spatial unit (e.g. "cell")} + \item{\code{feat_type}}{feature type (e.g. "rna", "dna", "protein")} + \item{\code{show_plot}}{logical. show plot} + \item{\code{return_plot}}{logical. return ggplot object} + \item{\code{save_plot}}{logical. save the plot} \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} + \item{\code{cell_color_gradient}}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + \item{\code{cow_n_col}}{cowplot param: how many columns} + \item{\code{cow_rel_h}}{cowplot param: relative heights of rows (e.g. c(1,2))} + \item{\code{cow_rel_w}}{cowplot param: relative widths of columns (e.g. c(1,2))} + \item{\code{cow_align}}{cowplot param: how to align} + \item{\code{show_image}}{show a tissue background image} + \item{\code{gimage}}{a giotto image} + \item{\code{image_name}}{name of a giotto image or multiple images with group_by} + \item{\code{largeImage_name}}{name of a giottoLargeImage or multiple images with group_by} + \item{\code{spat_enr_names}}{character. names of spatial enrichment results to include} + \item{\code{dim_reduction_to_use}}{character. dimension reduction to use} + \item{\code{dim_reduction_name}}{character. dimension reduction name} + \item{\code{dim1_to_use}}{numeric. dimension to use on x-axis} + \item{\code{dim2_to_use}}{numeric. dimension to use on y-axis} + \item{\code{dim_point_shape}}{point with border or not (border or no_border)} + \item{\code{dim_point_size}}{size of points in dim. reduction space} + \item{\code{dim_point_alpha}}{transparancy of point in dim. reduction space} + \item{\code{dim_point_border_col}}{border color of points in dim. reduction space} + \item{\code{dim_point_border_stroke}}{border stroke of points in dim. reduction space} + \item{\code{show_NN_network}}{logical. Show underlying NN network} + \item{\code{nn_network_to_use}}{character. type of NN network to use (kNN vs sNN)} + \item{\code{nn_network_name}}{character. name of NN network to use, if show_NN_network = TRUE} + \item{\code{gradient_midpoint}}{numeric. midpoint for color gradient} + \item{\code{gradient_style}}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + \item{\code{gradient_limits}}{numeric vector with lower and upper limits} + \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} + \item{\code{select_cells}}{select subset of cells based on cell IDs} + \item{\code{show_other_cells}}{display not selected cells} + \item{\code{other_cell_color}}{color for not selected cells} + \item{\code{show_legend}}{logical. show legend} + \item{\code{legend_text}}{size of legend text} + \item{\code{legend_symbol_size}}{size of legend symbols} + \item{\code{axis_text}}{size of axis text} + \item{\code{axis_title}}{size of axis title} }} } \value{ diff --git a/man/spatDimCellPlot2D.Rd b/man/spatDimCellPlot2D.Rd index 14a389d..395a358 100644 --- a/man/spatDimCellPlot2D.Rd +++ b/man/spatDimCellPlot2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimCellPlot2D} \alias{spatDimCellPlot2D} \title{spatDimCellPlot2D} @@ -92,51 +92,55 @@ spatDimCellPlot2D( \arguments{ \item{gobject}{giotto object} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} \item{show_image}{show a tissue background image} \item{gimage}{a giotto image} -\item{image_name}{name of a giotto image} +\item{image_name}{name of a giotto image or multiple images with group_by} -\item{largeImage_name}{name of a giottoLargeImage} +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} \item{plot_alignment}{direction to align plot} -\item{spat_enr_names}{names of spatial enrichment results to include} +\item{spat_enr_names}{character. names of spatial enrichment results to include} \item{cell_annotation_values}{numeric cell annotation columns} -\item{dim_reduction_to_use}{dimension reduction to use} +\item{dim_reduction_to_use}{character. dimension reduction to use} -\item{dim_reduction_name}{dimension reduction name} +\item{dim_reduction_name}{character. dimension reduction name} -\item{dim1_to_use}{dimension to use on x-axis} +\item{dim1_to_use}{numeric. dimension to use on x-axis} -\item{dim2_to_use}{dimension to use on y-axis} +\item{dim2_to_use}{numeric. dimension to use on y-axis} \item{sdimx}{= spatial dimension to use on x-axis} \item{sdimy}{= spatial dimension to use on y-axis} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} \item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} \item{select_cells}{select subset of cells based on cell IDs} -\item{dim_point_shape}{dim reduction points with border or not (border or no_border)} +\item{dim_point_shape}{point with border or not (border or no_border)} \item{dim_point_size}{size of points in dim. reduction space} -\item{dim_point_alpha}{transparancy of dim. reduction points} +\item{dim_point_alpha}{transparancy of point in dim. reduction space} \item{dim_point_border_col}{border color of points in dim. reduction space} @@ -146,7 +150,7 @@ spatDimCellPlot2D( \item{spat_point_size}{size of spatial points} -\item{spat_point_alpha}{transparancy of spatial points} +\item{spat_point_alpha}{transparency of spatial points} \item{spat_point_border_col}{border color of spatial points} @@ -180,11 +184,11 @@ spatDimCellPlot2D( \item{spat_label_fontface}{font of the center label} -\item{show_NN_network}{show underlying NN network} +\item{show_NN_network}{logical. Show underlying NN network} -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} -\item{nn_network_name}{name of NN network to use, if show_NN_network = TRUE} +\item{nn_network_name}{character. name of NN network to use, if show_NN_network = TRUE} \item{dim_edge_alpha}{column to use for alpha of the edges} @@ -204,7 +208,7 @@ spatDimCellPlot2D( \item{show_other_cells}{display not selected cells} -\item{other_cell_color}{color of not selected cells} +\item{other_cell_color}{color for not selected cells} \item{dim_other_point_size}{size of not selected dim cells} @@ -212,7 +216,7 @@ spatDimCellPlot2D( \item{spat_other_cells_alpha}{alpha of not selected spat cells} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -236,17 +240,17 @@ spatDimCellPlot2D( \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatDimFeatPlot2D.Rd b/man/spatDimFeatPlot2D.Rd index 9a49350..42efa99 100644 --- a/man/spatDimFeatPlot2D.Rd +++ b/man/spatDimFeatPlot2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimFeatPlot2D} \alias{spatDimFeatPlot2D} \title{spatDimFeatPlot2D} @@ -72,17 +72,17 @@ spatDimFeatPlot2D( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{show_image}{show a tissue background image} \item{gimage}{a giotto image} -\item{image_name}{name of a giotto image} +\item{image_name}{name of a giotto image or multiple images with group_by} -\item{largeImage_name}{name of a giottoLargeImage} +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} \item{expression_values}{feat expression values to use} @@ -92,31 +92,31 @@ spatDimFeatPlot2D( \item{order}{order points according to feature expression} -\item{dim_reduction_to_use}{dimension reduction to use} +\item{dim_reduction_to_use}{character. dimension reduction to use} -\item{dim_reduction_name}{dimension reduction name} +\item{dim_reduction_name}{character. dimension reduction name} -\item{dim1_to_use}{dimension to use on x-axis} +\item{dim1_to_use}{numeric. dimension to use on x-axis} -\item{dim2_to_use}{dimension to use on y-axis} +\item{dim2_to_use}{numeric. dimension to use on y-axis} -\item{dim_point_shape}{dim reduction points with border or not (border or no_border)} +\item{dim_point_shape}{point with border or not (border or no_border)} -\item{dim_point_size}{dim reduction plot: point size} +\item{dim_point_size}{size of points in dim. reduction space} -\item{dim_point_alpha}{transparancy of dim. reduction points} +\item{dim_point_alpha}{transparancy of point in dim. reduction space} -\item{dim_point_border_col}{color of border around points} +\item{dim_point_border_col}{border color of points in dim. reduction space} -\item{dim_point_border_stroke}{stroke size of border around points} +\item{dim_point_border_stroke}{border stroke of points in dim. reduction space} -\item{show_NN_network}{show underlying NN network} +\item{show_NN_network}{logical. Show underlying NN network} -\item{show_spatial_network}{show underlying spatial netwok} +\item{show_spatial_network}{show spatial network} \item{dim_network_color}{color of NN network} -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} \item{network_name}{name of NN network to use, if show_NN_network = TRUE} @@ -142,7 +142,7 @@ spatDimFeatPlot2D( \item{spat_point_size}{spatial plot: point size} -\item{spat_point_alpha}{transparancy of spatial points} +\item{spat_point_alpha}{transparency of spatial points} \item{spat_point_border_col}{color of border around points} @@ -150,21 +150,25 @@ spatDimFeatPlot2D( \item{spat_edge_alpha}{edge alpha} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -182,11 +186,11 @@ spatDimFeatPlot2D( \item{axis_title}{size of axis title} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatDimGenePlot3D.Rd b/man/spatDimGenePlot3D.Rd index 49ed3c8..f11e75a 100644 --- a/man/spatDimGenePlot3D.Rd +++ b/man/spatDimGenePlot3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimGenePlot3D} \alias{spatDimGenePlot3D} \title{spatDimGenePlot3D} @@ -61,9 +61,9 @@ spatDimGenePlot3D( \arguments{ \item{gobject}{giotto object} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} \item{spat_loc_name}{name of spatial locations to use} @@ -151,11 +151,11 @@ spatDimGenePlot3D( \item{z_ticks}{set the number of ticks on the z-axis} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return plotly object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatDimPlot.Rd b/man/spatDimPlot.Rd index 7bce2fd..f40b78c 100644 --- a/man/spatDimPlot.Rd +++ b/man/spatDimPlot.Rd @@ -1,96 +1,265 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimPlot} \alias{spatDimPlot} +\alias{spatDimPlot2D} \title{spatDimPlot} \usage{ -spatDimPlot(...) +spatDimPlot2D( + gobject, + spat_unit = NULL, + feat_type = NULL, + show_image = F, + gimage = NULL, + image_name = NULL, + largeImage_name = NULL, + spat_loc_name = NULL, + plot_alignment = c("vertical", "horizontal"), + dim_reduction_to_use = "umap", + dim_reduction_name = NULL, + dim1_to_use = 1, + dim2_to_use = 2, + sdimx = "sdimx", + sdimy = "sdimy", + spat_enr_names = NULL, + cell_color = NULL, + color_as_factor = T, + cell_color_code = NULL, + cell_color_gradient = NULL, + gradient_midpoint = NULL, + gradient_style = c("divergent", "sequential"), + gradient_limits = NULL, + select_cell_groups = NULL, + select_cells = NULL, + dim_point_shape = c("border", "no_border"), + dim_point_size = 1, + dim_point_alpha = 1, + dim_point_border_col = "black", + dim_point_border_stroke = 0.1, + spat_point_shape = c("border", "no_border", "voronoi"), + spat_point_size = 1, + spat_point_alpha = 1, + spat_point_border_col = "black", + spat_point_border_stroke = 0.1, + dim_show_cluster_center = F, + dim_show_center_label = T, + dim_center_point_size = 4, + dim_center_point_border_col = "black", + dim_center_point_border_stroke = 0.1, + dim_label_size = 4, + dim_label_fontface = "bold", + spat_show_cluster_center = F, + spat_show_center_label = F, + spat_center_point_size = 4, + spat_center_point_border_col = "blue", + spat_center_point_border_stroke = 0.1, + spat_label_size = 4, + spat_label_fontface = "bold", + show_NN_network = F, + nn_network_to_use = "sNN", + network_name = "sNN.pca", + nn_network_alpha = 0.05, + show_spatial_network = F, + spat_network_name = "Delaunay_network", + spat_network_color = "blue", + spat_network_alpha = 0.5, + show_spatial_grid = F, + spat_grid_name = "spatial_grid", + spat_grid_color = "blue", + show_other_cells = T, + other_cell_color = "lightgrey", + dim_other_point_size = 1, + spat_other_point_size = 1, + spat_other_cells_alpha = 0.5, + dim_show_legend = F, + spat_show_legend = F, + legend_text = 10, + legend_symbol_size = 2, + dim_background_color = "white", + spat_background_color = "white", + vor_border_color = "white", + vor_max_radius = 200, + vor_alpha = 1, + axis_text = 8, + axis_title = 8, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatDimPlot2D" +) + +spatDimPlot(gobject, ...) } \arguments{ -\item{...}{ - Arguments passed on to \code{\link[=spatDimPlot2D]{spatDimPlot2D}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{show_image}}{show a tissue background image} - \item{\code{gimage}}{a giotto image} - \item{\code{image_name}}{name of a giotto image} - \item{\code{largeImage_name}}{name of a giottoLargeImage} - \item{\code{spat_loc_name}}{name of spatial locations} - \item{\code{plot_alignment}}{direction to align plot} - \item{\code{dim_reduction_to_use}}{dimension reduction to use} - \item{\code{dim_reduction_name}}{dimension reduction name} - \item{\code{dim1_to_use}}{dimension to use on x-axis} - \item{\code{dim2_to_use}}{dimension to use on y-axis} - \item{\code{sdimx}}{= spatial dimension to use on x-axis} - \item{\code{sdimy}}{= spatial dimension to use on y-axis} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{dim_point_shape}}{point with border or not (border or no_border)} - \item{\code{dim_point_size}}{size of points in dim. reduction space} - \item{\code{dim_point_alpha}}{transparancy of point in dim. reduction space} - \item{\code{dim_point_border_col}}{border color of points in dim. reduction space} - \item{\code{dim_point_border_stroke}}{border stroke of points in dim. reduction space} - \item{\code{spat_point_shape}}{shape of points (border, no_border or voronoi)} - \item{\code{spat_point_size}}{size of spatial points} - \item{\code{spat_point_alpha}}{transparancy of spatial points} - \item{\code{spat_point_border_col}}{border color of spatial points} - \item{\code{spat_point_border_stroke}}{border stroke of spatial points} - \item{\code{dim_show_cluster_center}}{show the center of each cluster} - \item{\code{dim_show_center_label}}{provide a label for each cluster} - \item{\code{dim_center_point_size}}{size of the center point} - \item{\code{dim_center_point_border_col}}{border color of center point} - \item{\code{dim_center_point_border_stroke}}{stroke size of center point} - \item{\code{dim_label_size}}{size of the center label} - \item{\code{dim_label_fontface}}{font of the center label} - \item{\code{spat_show_cluster_center}}{show the center of each cluster} - \item{\code{spat_show_center_label}}{provide a label for each cluster} - \item{\code{spat_center_point_size}}{size of the center point} - \item{\code{spat_center_point_border_col}}{border color of spatial center points} - \item{\code{spat_center_point_border_stroke}}{border strike size of spatial center points} - \item{\code{spat_label_size}}{size of the center label} - \item{\code{spat_label_fontface}}{font of the center label} - \item{\code{show_NN_network}}{show underlying NN network} - \item{\code{nn_network_to_use}}{type of NN network to use (kNN vs sNN)} - \item{\code{network_name}}{name of NN network to use, if show_NN_network = TRUE} - \item{\code{nn_network_alpha}}{column to use for alpha of the edges} - \item{\code{show_spatial_network}}{show spatial network} - \item{\code{spat_network_name}}{name of spatial network to use} - \item{\code{spat_network_color}}{color of spatial network} - \item{\code{spat_network_alpha}}{alpha of spatial network} - \item{\code{show_spatial_grid}}{show spatial grid} - \item{\code{spat_grid_name}}{name of spatial grid to use} - \item{\code{spat_grid_color}}{color of spatial grid} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{dim_other_point_size}}{size of not selected dim cells} - \item{\code{spat_other_point_size}}{size of not selected spat cells} - \item{\code{spat_other_cells_alpha}}{alpha of not selected spat cells} - \item{\code{dim_show_legend}}{show legend of dimension reduction plot} - \item{\code{spat_show_legend}}{show legend of spatial plot} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} - \item{\code{dim_background_color}}{background color of points in dim. reduction space} - \item{\code{spat_background_color}}{background color of spatial points} - \item{\code{vor_border_color}}{border colorr for voronoi plot} - \item{\code{vor_max_radius}}{maximum radius for voronoi 'cells'} - \item{\code{vor_alpha}}{transparancy of voronoi 'cells'} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{show_image}{show a tissue background image} + +\item{gimage}{a giotto image} + +\item{image_name}{name of a giotto image or multiple images with group_by} + +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} + +\item{spat_loc_name}{name of spatial locations} + +\item{plot_alignment}{direction to align plot} + +\item{dim_reduction_to_use}{character. dimension reduction to use} + +\item{dim_reduction_name}{character. dimension reduction name} + +\item{dim1_to_use}{numeric. dimension to use on x-axis} + +\item{dim2_to_use}{numeric. dimension to use on y-axis} + +\item{sdimx}{= spatial dimension to use on x-axis} + +\item{sdimy}{= spatial dimension to use on y-axis} + +\item{spat_enr_names}{character. names of spatial enrichment results to include} + +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{numeric. midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} + +\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} + +\item{select_cells}{select subset of cells based on cell IDs} + +\item{dim_point_shape}{point with border or not (border or no_border)} + +\item{dim_point_size}{size of points in dim. reduction space} + +\item{dim_point_alpha}{transparancy of point in dim. reduction space} + +\item{dim_point_border_col}{border color of points in dim. reduction space} + +\item{dim_point_border_stroke}{border stroke of points in dim. reduction space} + +\item{spat_point_shape}{shape of points (border, no_border or voronoi)} + +\item{spat_point_size}{size of spatial points} + +\item{spat_point_alpha}{transparancy of spatial points} + +\item{spat_point_border_col}{border color of spatial points} + +\item{spat_point_border_stroke}{border stroke of spatial points} + +\item{dim_show_cluster_center}{show the center of each cluster} + +\item{dim_show_center_label}{provide a label for each cluster} + +\item{dim_center_point_size}{size of the center point} + +\item{dim_center_point_border_col}{border color of center point} + +\item{dim_center_point_border_stroke}{stroke size of center point} + +\item{dim_label_size}{size of the center label} + +\item{dim_label_fontface}{font of the center label} + +\item{spat_show_cluster_center}{show the center of each cluster} + +\item{spat_show_center_label}{provide a label for each cluster} + +\item{spat_center_point_size}{size of the center point} + +\item{spat_center_point_border_col}{border color of spatial center points} + +\item{spat_center_point_border_stroke}{border strike size of spatial center points} + +\item{spat_label_size}{size of the center label} + +\item{spat_label_fontface}{font of the center label} + +\item{show_NN_network}{logical. Show underlying NN network} + +\item{nn_network_to_use}{character. type of NN network to use (kNN vs sNN)} + +\item{network_name}{character. name of NN network to use, if show_NN_network = TRUE} + +\item{nn_network_alpha}{column to use for alpha of the edges} + +\item{show_spatial_network}{show spatial network} + +\item{spat_network_name}{name of spatial network to use} + +\item{spat_network_color}{color of spatial network} + +\item{spat_network_alpha}{alpha of spatial network} + +\item{show_spatial_grid}{show spatial grid} + +\item{spat_grid_name}{name of spatial grid to use} + +\item{spat_grid_color}{color of spatial grid} + +\item{show_other_cells}{display not selected cells} + +\item{other_cell_color}{color of not selected cells} + +\item{dim_other_point_size}{size of not selected dim cells} + +\item{spat_other_point_size}{size of not selected spat cells} + +\item{spat_other_cells_alpha}{alpha of not selected spat cells} + +\item{dim_show_legend}{show legend of dimension reduction plot} + +\item{spat_show_legend}{show legend of spatial plot} + +\item{legend_text}{size of legend text} + +\item{legend_symbol_size}{size of legend symbols} + +\item{dim_background_color}{background color of points in dim. reduction space} + +\item{spat_background_color}{background color of spatial points} + +\item{vor_border_color}{border color for voronoi plot} + +\item{vor_max_radius}{maximum radius for voronoi 'cells'} + +\item{vor_alpha}{transparency of voronoi 'cells'} + +\item{axis_text}{size of axis text} + +\item{axis_title}{size of axis title} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{\dots}{spatDimPlot(...) passes to spatDimPlot2D()} } \value{ ggplot @@ -102,10 +271,9 @@ Visualize cells according to spatial AND dimension reduction coordinates 2D Description of parameters. } \seealso{ -\code{\link{spatDimPlot2D}} and \code{\link{spatDimPlot3D}} for 3D visualization. +\code{\link{spatDimPlot3D}} Other spatial and dimension reduction visualizations: -\code{\link{spatDimPlot2D}()}, \code{\link{spatDimPlot3D}()} } \concept{spatial and dimension reduction visualizations} diff --git a/man/spatDimPlot2D.Rd b/man/spatDimPlot2D.Rd deleted file mode 100644 index 9b7a027..0000000 --- a/man/spatDimPlot2D.Rd +++ /dev/null @@ -1,268 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{spatDimPlot2D} -\alias{spatDimPlot2D} -\title{spatDimPlot2D} -\usage{ -spatDimPlot2D( - gobject, - spat_unit = NULL, - feat_type = NULL, - show_image = F, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - spat_loc_name = NULL, - plot_alignment = c("vertical", "horizontal"), - dim_reduction_to_use = "umap", - dim_reduction_name = NULL, - dim1_to_use = 1, - dim2_to_use = 2, - sdimx = "sdimx", - sdimy = "sdimy", - spat_enr_names = NULL, - cell_color = NULL, - color_as_factor = T, - cell_color_code = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - dim_point_shape = c("border", "no_border"), - dim_point_size = 1, - dim_point_alpha = 1, - dim_point_border_col = "black", - dim_point_border_stroke = 0.1, - spat_point_shape = c("border", "no_border", "voronoi"), - spat_point_size = 1, - spat_point_alpha = 1, - spat_point_border_col = "black", - spat_point_border_stroke = 0.1, - dim_show_cluster_center = F, - dim_show_center_label = T, - dim_center_point_size = 4, - dim_center_point_border_col = "black", - dim_center_point_border_stroke = 0.1, - dim_label_size = 4, - dim_label_fontface = "bold", - spat_show_cluster_center = F, - spat_show_center_label = F, - spat_center_point_size = 4, - spat_center_point_border_col = "blue", - spat_center_point_border_stroke = 0.1, - spat_label_size = 4, - spat_label_fontface = "bold", - show_NN_network = F, - nn_network_to_use = "sNN", - network_name = "sNN.pca", - nn_network_alpha = 0.05, - show_spatial_network = F, - spat_network_name = "Delaunay_network", - spat_network_color = "blue", - spat_network_alpha = 0.5, - show_spatial_grid = F, - spat_grid_name = "spatial_grid", - spat_grid_color = "blue", - show_other_cells = T, - other_cell_color = "lightgrey", - dim_other_point_size = 1, - spat_other_point_size = 1, - spat_other_cells_alpha = 0.5, - dim_show_legend = F, - spat_show_legend = F, - legend_text = 10, - legend_symbol_size = 2, - dim_background_color = "white", - spat_background_color = "white", - vor_border_color = "white", - vor_max_radius = 200, - vor_alpha = 1, - axis_text = 8, - axis_title = 8, - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "spatDimPlot2D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{show_image}{show a tissue background image} - -\item{gimage}{a giotto image} - -\item{image_name}{name of a giotto image} - -\item{largeImage_name}{name of a giottoLargeImage} - -\item{spat_loc_name}{name of spatial locations} - -\item{plot_alignment}{direction to align plot} - -\item{dim_reduction_to_use}{dimension reduction to use} - -\item{dim_reduction_name}{dimension reduction name} - -\item{dim1_to_use}{dimension to use on x-axis} - -\item{dim2_to_use}{dimension to use on y-axis} - -\item{sdimx}{= spatial dimension to use on x-axis} - -\item{sdimy}{= spatial dimension to use on y-axis} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{cell_color}{color for cells (see details)} - -\item{color_as_factor}{convert color column to factor} - -\item{cell_color_code}{named vector with colors} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{dim_point_shape}{point with border or not (border or no_border)} - -\item{dim_point_size}{size of points in dim. reduction space} - -\item{dim_point_alpha}{transparancy of point in dim. reduction space} - -\item{dim_point_border_col}{border color of points in dim. reduction space} - -\item{dim_point_border_stroke}{border stroke of points in dim. reduction space} - -\item{spat_point_shape}{shape of points (border, no_border or voronoi)} - -\item{spat_point_size}{size of spatial points} - -\item{spat_point_alpha}{transparancy of spatial points} - -\item{spat_point_border_col}{border color of spatial points} - -\item{spat_point_border_stroke}{border stroke of spatial points} - -\item{dim_show_cluster_center}{show the center of each cluster} - -\item{dim_show_center_label}{provide a label for each cluster} - -\item{dim_center_point_size}{size of the center point} - -\item{dim_center_point_border_col}{border color of center point} - -\item{dim_center_point_border_stroke}{stroke size of center point} - -\item{dim_label_size}{size of the center label} - -\item{dim_label_fontface}{font of the center label} - -\item{spat_show_cluster_center}{show the center of each cluster} - -\item{spat_show_center_label}{provide a label for each cluster} - -\item{spat_center_point_size}{size of the center point} - -\item{spat_center_point_border_col}{border color of spatial center points} - -\item{spat_center_point_border_stroke}{border strike size of spatial center points} - -\item{spat_label_size}{size of the center label} - -\item{spat_label_fontface}{font of the center label} - -\item{show_NN_network}{show underlying NN network} - -\item{nn_network_to_use}{type of NN network to use (kNN vs sNN)} - -\item{network_name}{name of NN network to use, if show_NN_network = TRUE} - -\item{nn_network_alpha}{column to use for alpha of the edges} - -\item{show_spatial_network}{show spatial network} - -\item{spat_network_name}{name of spatial network to use} - -\item{spat_network_color}{color of spatial network} - -\item{spat_network_alpha}{alpha of spatial network} - -\item{show_spatial_grid}{show spatial grid} - -\item{spat_grid_name}{name of spatial grid to use} - -\item{spat_grid_color}{color of spatial grid} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{dim_other_point_size}{size of not selected dim cells} - -\item{spat_other_point_size}{size of not selected spat cells} - -\item{spat_other_cells_alpha}{alpha of not selected spat cells} - -\item{dim_show_legend}{show legend of dimension reduction plot} - -\item{spat_show_legend}{show legend of spatial plot} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{dim_background_color}{background color of points in dim. reduction space} - -\item{spat_background_color}{background color of spatial points} - -\item{vor_border_color}{border colorr for voronoi plot} - -\item{vor_max_radius}{maximum radius for voronoi 'cells'} - -\item{vor_alpha}{transparancy of voronoi 'cells'} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to spatial AND dimension reduction coordinates 2D -} -\details{ -Description of parameters. -} -\seealso{ -\code{\link{spatDimPlot3D}} - -Other spatial and dimension reduction visualizations: -\code{\link{spatDimPlot3D}()}, -\code{\link{spatDimPlot}()} -} -\concept{spatial and dimension reduction visualizations} diff --git a/man/spatDimPlot3D.Rd b/man/spatDimPlot3D.Rd index 444774b..934f32a 100644 --- a/man/spatDimPlot3D.Rd +++ b/man/spatDimPlot3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatDimPlot3D} \alias{spatDimPlot3D} \title{spatDimPlot3D} @@ -62,9 +62,9 @@ spatDimPlot3D( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{plot_alignment}{direction to align plot} @@ -116,11 +116,14 @@ spatDimPlot3D( \item{other_point_size}{size of not selected cells} -\item{cell_color}{color for cells (see details)} +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} -\item{color_as_factor}{convert color column to factor} +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} -\item{cell_color_code}{named vector with colors} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} \item{dim_point_size}{size of points in dim. reduction space} @@ -154,11 +157,11 @@ spatDimPlot3D( \item{legend_text_size}{size of legend} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} @@ -175,7 +178,6 @@ Description of parameters. } \seealso{ Other spatial and dimension reduction visualizations: -\code{\link{spatDimPlot2D}()}, \code{\link{spatDimPlot}()} } \concept{spatial and dimension reduction visualizations} diff --git a/man/spatFeatPlot2D.Rd b/man/spatFeatPlot2D.Rd index 4714082..7d9c447 100644 --- a/man/spatFeatPlot2D.Rd +++ b/man/spatFeatPlot2D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatFeatPlot2D} \alias{spatFeatPlot2D} \title{Plot data in physical space 2D} @@ -61,23 +61,23 @@ spatFeatPlot2D( \arguments{ \item{gobject}{giotto object} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} \item{show_image}{show a tissue background image} \item{gimage}{a giotto image} -\item{image_name}{name of a giotto image or multiple images if group_by} +\item{image_name}{name of a giotto image or multiple images with group_by} -\item{largeImage_name}{name of a giottoLargeImage or multiple images if group by} +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} \item{spat_loc_name}{name of spatial locations} -\item{group_by}{create multiple plots based on cell annotation column} +\item{group_by}{character. Create multiple plots based on cell annotation column} -\item{group_by_subset}{subset the group_by factor column} +\item{group_by_subset}{character. subset the group_by factor column} \item{sdimx}{x-axis dimension name (default = 'sdimx')} @@ -89,11 +89,15 @@ spatFeatPlot2D( \item{order}{order points according to feature expression} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{numeric vector with lower and upper limits} \item{show_network}{show underlying spatial network} @@ -113,11 +117,11 @@ spatFeatPlot2D( \item{scale_alpha_with_expression}{scale expression with ggplot alpha parameter} -\item{point_shape}{shape of points (border, no_border or voronoi)} +\item{point_shape}{point with border or not (border or no_border)} \item{point_size}{size of point (cell)} -\item{point_alpha}{transparancy of points} +\item{point_alpha}{transparency of points} \item{point_border_col}{color of border around points} @@ -125,7 +129,7 @@ spatFeatPlot2D( \item{coord_fix_ratio}{fix ratio between x and y-axis (default = 1)} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -133,7 +137,7 @@ spatFeatPlot2D( \item{vor_border_color}{border colorr for voronoi plot} -\item{vor_alpha}{transparancy of voronoi 'cells'} +\item{vor_alpha}{transparency of voronoi 'cells'} \item{vor_max_radius}{maximum radius for voronoi 'cells'} @@ -143,17 +147,17 @@ spatFeatPlot2D( \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatFeatPlot2D_single.Rd b/man/spatFeatPlot2D_single.Rd index 90e4e7f..b480e6f 100644 --- a/man/spatFeatPlot2D_single.Rd +++ b/man/spatFeatPlot2D_single.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatFeatPlot2D_single} \alias{spatFeatPlot2D_single} \title{spatFeatPlot2D_single} @@ -15,6 +15,7 @@ spatFeatPlot2D_single( spat_loc_name = "raw", sdimx = "sdimx", sdimy = "sdimy", + spat_enr_names = NULL, expression_values = c("normalized", "scaled", "custom"), feats, order = TRUE, @@ -59,17 +60,17 @@ spatFeatPlot2D_single( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{show_image}{show a tissue background image} \item{gimage}{a giotto image} -\item{image_name}{name of a giotto image} +\item{image_name}{name of a giotto image or multiple images with group_by} -\item{largeImage_name}{name of a giottoLargeImage} +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} \item{spat_loc_name}{name of spatial locations} @@ -77,19 +78,23 @@ spatFeatPlot2D_single( \item{sdimy}{y-axis dimension name (default = 'sdimy')} +\item{spat_enr_names}{names of spatial enrichment results to include} + \item{expression_values}{gene expression values to use} \item{feats}{features to show} \item{order}{order points according to feature expression} -\item{cell_color_gradient}{vector with 3 colors for numeric data} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} -\item{gradient_midpoint}{midpoint for color gradient} +\item{gradient_midpoint}{numeric. midpoint for color gradient} -\item{gradient_style}{whether to use gradient as 'divergent' or 'sequential'} +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} -\item{gradient_limits}{vector with lower and upper limits} +\item{gradient_limits}{numeric vector with lower and upper limits} \item{show_network}{show underlying spatial network} @@ -121,7 +126,7 @@ spatFeatPlot2D_single( \item{coord_fix_ratio}{fix ratio between x and y-axis (default = 1)} -\item{show_legend}{show legend} +\item{show_legend}{logical. show legend} \item{legend_text}{size of legend text} @@ -139,17 +144,17 @@ spatFeatPlot2D_single( \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatGenePlot3D.Rd b/man/spatGenePlot3D.Rd index 85efc66..d23c025 100644 --- a/man/spatGenePlot3D.Rd +++ b/man/spatGenePlot3D.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatGenePlot3D} \alias{spatGenePlot3D} \title{spatGenePlot3D} @@ -10,7 +10,9 @@ spatGenePlot3D( feat_type = NULL, spat_loc_name = NULL, expression_values = c("normalized", "scaled", "custom"), - genes, + genes = deprecated(), + feats, + spat_enr_names = NULL, show_network = FALSE, network_color = NULL, spatial_network_name = "Delaunay_network", @@ -43,15 +45,19 @@ spatGenePlot3D( \arguments{ \item{gobject}{giotto object} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} \item{spat_loc_name}{name of spatial locations to use} \item{expression_values}{gene expression values to use} -\item{genes}{genes to show} +\item{genes}{deprecated} + +\item{feats}{feats to show} + +\item{spat_enr_names}{names of spatial enrichment results to include} \item{show_network}{show underlying spatial network} @@ -97,11 +103,11 @@ spatGenePlot3D( \item{z_ticks}{set the number of ticks on the z-axis} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatInSituPlotDensity.Rd b/man/spatInSituPlotDensity.Rd index 49f4280..47faee8 100644 --- a/man/spatInSituPlotDensity.Rd +++ b/man/spatInSituPlotDensity.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{spatInSituPlotDensity} \alias{spatInSituPlotDensity} \title{spatInSituPlotDensity} @@ -17,7 +17,8 @@ spatInSituPlotDensity( polygon_fill = NULL, polygon_fill_as_factor = NULL, polygon_alpha = 0.5, - polygon_size = 0.5, + polygon_size = deprecated(), + polygon_line_size = 0.5, coord_fix_ratio = 1, axis_text = 8, axis_title = 8, @@ -47,19 +48,22 @@ spatInSituPlotDensity( \item{alpha}{alpha of density plot} -\item{show_polygon}{overlay polygon information (cell shape)} +\item{show_polygon}{overlay polygon information (e.g. cell shape)} \item{polygon_feat_type}{feature type associated with polygon information} \item{polygon_color}{color for polygon border} -\item{polygon_fill}{fill color or column for polygon} +\item{polygon_fill}{character. what to color to fill polgyons by (e.g. metadata +col or spatial enrichment col)} \item{polygon_fill_as_factor}{is fill color a factor} \item{polygon_alpha}{alpha of polygon} -\item{polygon_size}{size of polygon border} +\item{polygon_size}{deprecated} + +\item{polygon_line_size}{line width of the polygon's outline} \item{coord_fix_ratio}{fix ratio between x and y-axis} @@ -73,17 +77,17 @@ spatInSituPlotDensity( \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatInSituPlotDensity_single.Rd b/man/spatInSituPlotDensity_single.Rd index d037e7e..41c0593 100644 --- a/man/spatInSituPlotDensity_single.Rd +++ b/man/spatInSituPlotDensity_single.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{spatInSituPlotDensity_single} \alias{spatInSituPlotDensity_single} \title{spatInSituPlotDensity_single} diff --git a/man/spatInSituPlotHex.Rd b/man/spatInSituPlotHex.Rd index c480ad3..d95e7ec 100644 --- a/man/spatInSituPlotHex.Rd +++ b/man/spatInSituPlotHex.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{spatInSituPlotHex} \alias{spatInSituPlotHex} \title{spatInSituPlotHex} @@ -19,7 +19,8 @@ spatInSituPlotHex( polygon_fill = NULL, polygon_fill_as_factor = NULL, polygon_alpha = 0.5, - polygon_size = 0.5, + polygon_size = deprecated(), + polygon_line_size = 0.5, coord_fix_ratio = 1, axis_text = 8, axis_title = 8, @@ -55,19 +56,22 @@ range/10, where the 10 is from \code{min_axis_bins})} \item{alpha}{alpha of hexbin plot} -\item{show_polygon}{overlay polygon information (cell shape)} +\item{show_polygon}{overlay polygon information (e.g. cell shape)} \item{polygon_feat_type}{feature type associated with polygon information} \item{polygon_color}{color for polygon border} -\item{polygon_fill}{fill color or column for polygon} +\item{polygon_fill}{character. what to color to fill polgyons by (e.g. metadata +col or spatial enrichment col)} \item{polygon_fill_as_factor}{is fill color a factor} \item{polygon_alpha}{alpha of polygon} -\item{polygon_size}{size of polygon border} +\item{polygon_size}{deprecated} + +\item{polygon_line_size}{line width of the polygon's outline} \item{coord_fix_ratio}{fix ratio between x and y-axis} @@ -81,17 +85,17 @@ range/10, where the 10 is from \code{min_axis_bins})} \item{cow_n_col}{cowplot param: how many columns} -\item{cow_rel_h}{cowplot param: relative height} +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} -\item{cow_rel_w}{cowplot param: relative width} +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} \item{cow_align}{cowplot param: how to align} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} diff --git a/man/spatInSituPlotHex_single.Rd b/man/spatInSituPlotHex_single.Rd index 5e9e398..d41c773 100644 --- a/man/spatInSituPlotHex_single.Rd +++ b/man/spatInSituPlotHex_single.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{spatInSituPlotHex_single} \alias{spatInSituPlotHex_single} \title{spatInSituPlotHex_single} diff --git a/man/spatInSituPlotPoints.Rd b/man/spatInSituPlotPoints.Rd index 21fe941..dd1367b 100644 --- a/man/spatInSituPlotPoints.Rd +++ b/man/spatInSituPlotPoints.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_in_situ_visuals.R +% Please edit documentation in R/vis_spatial_in_situ.R \name{spatInSituPlotPoints} \alias{spatInSituPlotPoints} \title{spatInSituPlotPoints} @@ -59,15 +59,15 @@ spatInSituPlotPoints( \item{gimage}{a giotto image} -\item{image_name}{name of a giotto image} +\item{image_name}{name of a giotto image or multiple images with group_by} -\item{largeImage_name}{name of a giottoLargeImage} +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} \item{spat_loc_name}{name of spatial locations} -\item{feats}{features to plot} +\item{feats}{named list of features to plot} \item{feat_type}{feature types of the feats} @@ -81,6 +81,8 @@ spatInSituPlotPoints( \item{point_size}{size of the points} +\item{stroke}{stroke to apply to feature points} + \item{expand_counts}{expand feature coordinate counts (see details)} \item{count_info_column}{column name with count information (if expand_counts = TRUE)} @@ -97,13 +99,17 @@ spatInSituPlotPoints( \item{polygon_bg_color}{color for polygon background (overruled by polygon_fill)} -\item{polygon_fill}{fill color or column for polygon} +\item{polygon_fill}{character. what to color to fill polgyons by (e.g. metadata +col or spatial enrichment col)} \item{polygon_fill_gradient}{polygon fill gradient colors given in order from low to high} \item{polygon_fill_gradient_midpoint}{value to set as gradient midpoint (optional). If left as \code{NULL}, the median value detected will be chosen} +\item{polygon_fill_gradient_style}{either 'divergent' (midpoint is used in +color scaling) or 'sequential' (scaled based on data range)} + \item{polygon_fill_as_factor}{is fill color a factor} \item{polygon_fill_code}{code to color the fill column} @@ -128,19 +134,17 @@ left as \code{NULL}, the median value detected will be chosen} \item{plot_last}{which layer to show on top of plot, polygons (default) or points.} -\item{show_plot}{show plots} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -\item{verbose}{verbosity} - -\item{line}{line size of point shapes} +\item{verbose}{be verbose} } \value{ ggplot @@ -148,8 +152,11 @@ ggplot \description{ Function to plot multiple features for multiple modalities at the spatial in situ level } -\details{ -TODO +\examples{ +\dontrun{ +library(GiottoVisuals) +} + } \seealso{ Other In Situ visualizations: diff --git a/man/spatNetwDistributions.Rd b/man/spatNetwDistributions.Rd new file mode 100644 index 0000000..cfe30cb --- /dev/null +++ b/man/spatNetwDistributions.Rd @@ -0,0 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/viz_spatial_network.R +\name{spatNetwDistributions} +\alias{spatNetwDistributions} +\title{spatNetwDistributions} +\usage{ +spatNetwDistributions( + gobject, + spat_unit = NULL, + spatial_network_name = "spatial_network", + distribution = c("distance", "k_neighbors"), + hist_bins = 30, + test_distance_limit = NULL, + ncol = 1, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatNetwDistributions" +) +} +\arguments{ +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{spatial_network_name}{name of spatial network} + +\item{distribution}{show the distribution of cell-to-cell distance or number of k neighbors} + +\item{hist_bins}{number of binds to use for the histogram} + +\item{test_distance_limit}{effect of different distance threshold on k-neighbors} + +\item{ncol}{number of columns to visualize the histograms in} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} +} +\value{ +ggplot plot +} +\description{ +This function return histograms displaying the distance distribution for each spatial k-neighbor +} +\details{ +The \strong{distance} option shows the spatial distance distribution for each nearest neighbor rank (1st, 2nd, 3th, ... neigbor). +With this option the user can also test the effect of a distance limit on the spatial network. This distance limit can be used to remove neigbor +cells that are considered to far away. \cr +The \strong{k_neighbors} option shows the number of k neighbors distribution over all cells. +} diff --git a/man/spatNetwDistributionsDistance.Rd b/man/spatNetwDistributionsDistance.Rd new file mode 100644 index 0000000..1a16181 --- /dev/null +++ b/man/spatNetwDistributionsDistance.Rd @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/viz_spatial_network.R +\name{spatNetwDistributionsDistance} +\alias{spatNetwDistributionsDistance} +\title{Plot spatial distance distribution} +\usage{ +spatNetwDistributionsDistance( + gobject, + spat_unit = NULL, + spatial_network_name = "spatial_network", + hist_bins = 30, + test_distance_limit = NULL, + ncol = 1, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatNetwDistributionsDistance" +) +} +\arguments{ +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{spatial_network_name}{name of spatial network} + +\item{hist_bins}{number of binds to use for the histogram} + +\item{test_distance_limit}{effect of different distance threshold on k-neighbors} + +\item{ncol}{number of columns to visualize the histograms in} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} +} +\value{ +ggplot plot +} +\description{ +This function return histograms displaying the distance distribution for each spatial k-neighbor +} diff --git a/man/spatNetwDistributionsKneighbors.Rd b/man/spatNetwDistributionsKneighbors.Rd new file mode 100644 index 0000000..8ab70ad --- /dev/null +++ b/man/spatNetwDistributionsKneighbors.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/viz_spatial_network.R +\name{spatNetwDistributionsKneighbors} +\alias{spatNetwDistributionsKneighbors} +\title{spatNetwDistributionsKneighbors} +\usage{ +spatNetwDistributionsKneighbors( + gobject, + spat_unit = NULL, + spatial_network_name = "spatial_network", + hist_bins = 30, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatNetwDistributionsKneighbors" +) +} +\arguments{ +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{spatial_network_name}{name of spatial network} + +\item{hist_bins}{number of binds to use for the histogram} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} +} +\value{ +ggplot plot +} +\description{ +This function returns a histogram displaying the number of k-neighbors distribution for each cell +} diff --git a/man/spatPlot.Rd b/man/spatPlot.Rd index ee10343..80d3205 100644 --- a/man/spatPlot.Rd +++ b/man/spatPlot.Rd @@ -1,95 +1,284 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{spatPlot} +% Please edit documentation in R/vis_spatial.R +\name{spatPlot2D} +\alias{spatPlot2D} \alias{spatPlot} +\alias{spatPlot3D} \title{spatPlot} \usage{ +spatPlot2D( + gobject, + spat_unit = NULL, + feat_type = NULL, + show_image = F, + gimage = NULL, + image_name = NULL, + largeImage_name = NULL, + group_by = NULL, + group_by_subset = NULL, + spat_loc_name = NULL, + sdimx = "sdimx", + sdimy = "sdimy", + spat_enr_names = NULL, + cell_color = NULL, + color_as_factor = T, + cell_color_code = NULL, + cell_color_gradient = NULL, + gradient_midpoint = NULL, + gradient_style = c("divergent", "sequential"), + gradient_limits = NULL, + select_cell_groups = NULL, + select_cells = NULL, + point_shape = c("border", "no_border", "voronoi"), + point_size = 3, + point_alpha = 1, + point_border_col = "black", + point_border_stroke = 0.1, + show_cluster_center = F, + show_center_label = F, + center_point_size = 4, + center_point_border_col = "black", + center_point_border_stroke = 0.1, + label_size = 4, + label_fontface = "bold", + show_network = F, + spatial_network_name = "Delaunay_network", + network_color = NULL, + network_alpha = 1, + show_grid = F, + spatial_grid_name = "spatial_grid", + grid_color = NULL, + show_other_cells = T, + other_cell_color = "lightgrey", + other_point_size = 1, + other_cells_alpha = 0.1, + coord_fix_ratio = 1, + title = NULL, + show_legend = T, + legend_text = 10, + legend_symbol_size = 2, + background_color = "white", + vor_border_color = "white", + vor_max_radius = 200, + vor_alpha = 1, + axis_text = 8, + axis_title = 8, + cow_n_col = NULL, + cow_rel_h = 1, + cow_rel_w = 1, + cow_align = "h", + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spatPlot2D" +) + spatPlot(...) + +spatPlot3D( + gobject, + spat_unit = NULL, + feat_type = NULL, + sdimx = "sdimx", + sdimy = "sdimy", + sdimz = "sdimz", + spat_enr_names = NULL, + point_size = 3, + cell_color = NULL, + cell_color_code = NULL, + select_cell_groups = NULL, + select_cells = NULL, + show_other_cells = T, + other_cell_color = "lightgrey", + other_point_size = 0.5, + other_cell_alpha = 0.5, + show_network = F, + spatial_network_name = "Delaunay_network", + network_color = NULL, + network_alpha = 1, + show_grid = F, + spatial_grid_name = "spatial_grid", + grid_color = NULL, + grid_alpha = 1, + title = "", + show_legend = T, + axis_scale = c("cube", "real", "custom"), + custom_ratio = NULL, + x_ticks = NULL, + y_ticks = NULL, + z_ticks = NULL, + show_plot = NA, + return_plot = NA, + save_plot = NA, + save_param = list(), + default_save_name = "spat3D" +) } \arguments{ -\item{...}{ - Arguments passed on to \code{\link[=spatPlot2D]{spatPlot2D}} - \describe{ - \item{\code{gobject}}{giotto object} - \item{\code{spat_unit}}{spatial unit} - \item{\code{feat_type}}{feature type} - \item{\code{show_image}}{show a tissue background image} - \item{\code{gimage}}{a giotto image} - \item{\code{image_name}}{name of a giotto image or multiple images with group_by} - \item{\code{largeImage_name}}{name of a giottoLargeImage or multiple images with group_by} - \item{\code{group_by}}{create multiple plots based on cell annotation column} - \item{\code{group_by_subset}}{subset the group_by factor column} - \item{\code{spat_loc_name}}{name of spatial locations} - \item{\code{sdimx}}{x-axis dimension name (default = 'sdimx')} - \item{\code{sdimy}}{y-axis dimension name (default = 'sdimy')} - \item{\code{spat_enr_names}}{names of spatial enrichment results to include} - \item{\code{cell_color}}{color for cells (see details)} - \item{\code{color_as_factor}}{convert color column to factor} - \item{\code{cell_color_code}}{named vector with colors} - \item{\code{cell_color_gradient}}{vector with 3 colors for numeric data} - \item{\code{gradient_midpoint}}{midpoint for color gradient} - \item{\code{gradient_limits}}{vector with lower and upper limits} - \item{\code{select_cell_groups}}{select subset of cells/clusters based on cell_color parameter} - \item{\code{select_cells}}{select subset of cells based on cell IDs} - \item{\code{point_shape}}{shape of points (border, no_border or voronoi)} - \item{\code{point_size}}{size of point (cell)} - \item{\code{point_alpha}}{transparancy of point} - \item{\code{point_border_col}}{color of border around points} - \item{\code{point_border_stroke}}{stroke size of border around points} - \item{\code{show_cluster_center}}{plot center of selected clusters} - \item{\code{show_center_label}}{plot label of selected clusters} - \item{\code{center_point_size}}{size of center points} - \item{\code{center_point_border_col}}{border color of center points} - \item{\code{center_point_border_stroke}}{border stroke size of center points} - \item{\code{label_size}}{size of labels} - \item{\code{label_fontface}}{font of labels} - \item{\code{show_network}}{show underlying spatial network} - \item{\code{spatial_network_name}}{name of spatial network to use} - \item{\code{network_color}}{color of spatial network} - \item{\code{network_alpha}}{alpha of spatial network} - \item{\code{show_grid}}{show spatial grid} - \item{\code{spatial_grid_name}}{name of spatial grid to use} - \item{\code{grid_color}}{color of spatial grid} - \item{\code{show_other_cells}}{display not selected cells} - \item{\code{other_cell_color}}{color of not selected cells} - \item{\code{other_point_size}}{point size of not selected cells} - \item{\code{other_cells_alpha}}{alpha of not selected cells} - \item{\code{coord_fix_ratio}}{fix ratio between x and y-axis (default = 1)} - \item{\code{title}}{title of plot} - \item{\code{show_legend}}{show legend} - \item{\code{legend_text}}{size of legend text} - \item{\code{legend_symbol_size}}{size of legend symbols} - \item{\code{background_color}}{color of plot background} - \item{\code{vor_border_color}}{border colorr for voronoi plot} - \item{\code{vor_max_radius}}{maximum radius for voronoi 'cells'} - \item{\code{vor_alpha}}{transparancy of voronoi 'cells'} - \item{\code{axis_text}}{size of axis text} - \item{\code{axis_title}}{size of axis title} - \item{\code{cow_n_col}}{cowplot param: how many columns} - \item{\code{cow_rel_h}}{cowplot param: relative height} - \item{\code{cow_rel_w}}{cowplot param: relative width} - \item{\code{cow_align}}{cowplot param: how to align} - \item{\code{show_plot}}{show plot} - \item{\code{return_plot}}{return ggplot object} - \item{\code{save_plot}}{directly save the plot \link{boolean}} - \item{\code{save_param}}{list of saving parameters, see \code{\link{showSaveParameters}}} - \item{\code{default_save_name}}{default save name for saving, don't change, change save_name in save_param} - }} +\item{gobject}{giotto object} + +\item{spat_unit}{spatial unit (e.g. "cell")} + +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} + +\item{show_image}{show a tissue background image} + +\item{gimage}{a giotto image} + +\item{image_name}{name of a giotto image or multiple images with group_by} + +\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} + +\item{group_by}{character. Create multiple plots based on cell annotation column} + +\item{group_by_subset}{character. subset the group_by factor column} + +\item{spat_loc_name}{name of spatial locations} + +\item{sdimx}{x-axis dimension name (default = 'sdimx')} + +\item{sdimy}{y-axis dimension name (default = 'sdimy')} + +\item{spat_enr_names}{character. names of spatial enrichment results to include} + +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} + +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} + +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} + +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} + +\item{gradient_midpoint}{midpoint for color gradient} + +\item{gradient_style}{either 'divergent' (midpoint is used in color scaling) +or 'sequential' (scaled based on data range)} + +\item{gradient_limits}{vector with lower and upper limits} + +\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} + +\item{select_cells}{select subset of cells based on cell IDs} + +\item{point_shape}{shape of points (border, no_border or voronoi)} + +\item{point_size}{size of point (cell)} + +\item{point_alpha}{transparancy of point} + +\item{point_border_col}{color of border around points} + +\item{point_border_stroke}{stroke size of border around points} + +\item{show_cluster_center}{plot center of selected clusters} + +\item{show_center_label}{plot label of selected clusters} + +\item{center_point_size}{size of center points} + +\item{center_point_border_col}{border color of center points} + +\item{center_point_border_stroke}{border stroke size of center points} + +\item{label_size}{size of labels} + +\item{label_fontface}{font of labels} + +\item{show_network}{show underlying spatial network} + +\item{spatial_network_name}{name of spatial network to use} + +\item{network_color}{color of spatial network} + +\item{network_alpha}{alpha of spatial network} + +\item{show_grid}{show spatial grid} + +\item{spatial_grid_name}{name of spatial grid to use} + +\item{grid_color}{color of spatial grid} + +\item{show_other_cells}{display not selected cells} + +\item{other_cell_color}{color of not selected cells} + +\item{other_point_size}{point size of not selected cells} + +\item{other_cells_alpha}{alpha of not selected cells} + +\item{coord_fix_ratio}{fix ratio between x and y-axis (default = 1)} + +\item{title}{title of plot} + +\item{show_legend}{show legend} + +\item{legend_text}{size of legend text} + +\item{legend_symbol_size}{size of legend symbols} + +\item{background_color}{color of plot background} + +\item{vor_border_color}{border color for voronoi plot} + +\item{vor_max_radius}{maximum radius for voronoi 'cells'} + +\item{vor_alpha}{transparency of voronoi 'cells'} + +\item{axis_text}{size of axis text} + +\item{axis_title}{size of axis title} + +\item{cow_n_col}{cowplot param: how many columns} + +\item{cow_rel_h}{cowplot param: relative heights of rows (e.g. c(1,2))} + +\item{cow_rel_w}{cowplot param: relative widths of columns (e.g. c(1,2))} + +\item{cow_align}{cowplot param: how to align} + +\item{show_plot}{logical. show plot} + +\item{return_plot}{logical. return ggplot object} + +\item{save_plot}{logical. save the plot} + +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} + +\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} + +\item{\dots}{spatPLot(...) passes to spatPlot2D} + +\item{sdimz}{z-axis dimension name (default = 'sdimy')} + +\item{other_cell_alpha}{(0 to 1) alpha for not selected cells} + +\item{grid_alpha}{opacity of spatial grid} + +\item{axis_scale}{the way to scale the axis} + +\item{custom_ratio}{customize the scale of the plot} + +\item{x_ticks}{set the number of ticks on the x-axis} + +\item{y_ticks}{set the number of ticks on the y-axis} + +\item{z_ticks}{set the number of ticks on the z-axis} } \value{ -ggplot +ggplot (2D), plotly (3D) } \description{ Visualize cells according to spatial coordinates } \details{ -Description of parameters. +coord_fix_ratio: set to NULL to use default ggplot parameters } \seealso{ \code{\link{spatPlot3D}} - -Other spatial visualizations: -\code{\link{spatPlot2D}()}, -\code{\link{spatPlot3D}()} } \concept{spatial visualizations} diff --git a/man/spatPlot2D.Rd b/man/spatPlot2D.Rd deleted file mode 100644 index 01d0626..0000000 --- a/man/spatPlot2D.Rd +++ /dev/null @@ -1,221 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{spatPlot2D} -\alias{spatPlot2D} -\title{spatPlot2D} -\usage{ -spatPlot2D( - gobject, - spat_unit = NULL, - feat_type = NULL, - show_image = F, - gimage = NULL, - image_name = NULL, - largeImage_name = NULL, - group_by = NULL, - group_by_subset = NULL, - spat_loc_name = NULL, - sdimx = "sdimx", - sdimy = "sdimy", - spat_enr_names = NULL, - cell_color = NULL, - color_as_factor = T, - cell_color_code = NULL, - cell_color_gradient = NULL, - gradient_midpoint = NULL, - gradient_style = c("divergent", "sequential"), - gradient_limits = NULL, - select_cell_groups = NULL, - select_cells = NULL, - point_shape = c("border", "no_border", "voronoi"), - point_size = 3, - point_alpha = 1, - point_border_col = "black", - point_border_stroke = 0.1, - show_cluster_center = F, - show_center_label = F, - center_point_size = 4, - center_point_border_col = "black", - center_point_border_stroke = 0.1, - label_size = 4, - label_fontface = "bold", - show_network = F, - spatial_network_name = "Delaunay_network", - network_color = NULL, - network_alpha = 1, - show_grid = F, - spatial_grid_name = "spatial_grid", - grid_color = NULL, - show_other_cells = T, - other_cell_color = "lightgrey", - other_point_size = 1, - other_cells_alpha = 0.1, - coord_fix_ratio = 1, - title = NULL, - show_legend = T, - legend_text = 10, - legend_symbol_size = 2, - background_color = "white", - vor_border_color = "white", - vor_max_radius = 200, - vor_alpha = 1, - axis_text = 8, - axis_title = 8, - cow_n_col = NULL, - cow_rel_h = 1, - cow_rel_w = 1, - cow_align = "h", - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "spatPlot2D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{show_image}{show a tissue background image} - -\item{gimage}{a giotto image} - -\item{image_name}{name of a giotto image or multiple images with group_by} - -\item{largeImage_name}{name of a giottoLargeImage or multiple images with group_by} - -\item{group_by}{create multiple plots based on cell annotation column} - -\item{group_by_subset}{subset the group_by factor column} - -\item{spat_loc_name}{name of spatial locations} - -\item{sdimx}{x-axis dimension name (default = 'sdimx')} - -\item{sdimy}{y-axis dimension name (default = 'sdimy')} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{cell_color}{color for cells (see details)} - -\item{color_as_factor}{convert color column to factor} - -\item{cell_color_code}{named vector with colors} - -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{point_shape}{shape of points (border, no_border or voronoi)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparancy of point} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} - -\item{show_cluster_center}{plot center of selected clusters} - -\item{show_center_label}{plot label of selected clusters} - -\item{center_point_size}{size of center points} - -\item{center_point_border_col}{border color of center points} - -\item{center_point_border_stroke}{border stroke size of center points} - -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{show_network}{show underlying spatial network} - -\item{spatial_network_name}{name of spatial network to use} - -\item{network_color}{color of spatial network} - -\item{network_alpha}{alpha of spatial network} - -\item{show_grid}{show spatial grid} - -\item{spatial_grid_name}{name of spatial grid to use} - -\item{grid_color}{color of spatial grid} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{point size of not selected cells} - -\item{other_cells_alpha}{alpha of not selected cells} - -\item{coord_fix_ratio}{fix ratio between x and y-axis (default = 1)} - -\item{title}{title of plot} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - -\item{vor_border_color}{border colorr for voronoi plot} - -\item{vor_max_radius}{maximum radius for voronoi 'cells'} - -\item{vor_alpha}{transparancy of voronoi 'cells'} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} - -\item{cow_n_col}{cowplot param: how many columns} - -\item{cow_rel_h}{cowplot param: relative height} - -\item{cow_rel_w}{cowplot param: relative width} - -\item{cow_align}{cowplot param: how to align} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to spatial coordinates -} -\details{ -Description of parameters. -coord_fix_ratio: set to NULL to use default ggplot parameters -} -\seealso{ -\code{\link{spatPlot3D}} - -Other spatial visualizations: -\code{\link{spatPlot3D}()}, -\code{\link{spatPlot}()} -} -\concept{spatial visualizations} diff --git a/man/spatPlot2D_single.Rd b/man/spatPlot2D_single.Rd index 49de5c0..0a16d15 100644 --- a/man/spatPlot2D_single.Rd +++ b/man/spatPlot2D_single.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatPlot2D_single} \alias{spatPlot2D_single} \title{spatPlot2D_single} @@ -70,9 +70,9 @@ spatPlot2D_single( \arguments{ \item{gobject}{giotto object} -\item{feat_type}{feature type} +\item{feat_type}{feature type (e.g. "rna", "dna", "protein")} -\item{spat_unit}{spatial unit} +\item{spat_unit}{spatial unit (e.g. "cell")} \item{show_image}{show a tissue background image} @@ -88,33 +88,19 @@ spatPlot2D_single( \item{sdimy}{y-axis dimension name (default = 'sdimy')} -\item{spat_enr_names}{names of spatial enrichment results to include} +\item{spat_enr_names}{character. names of spatial enrichment results to include} -\item{cell_color}{color for cells (see details)} +\item{cell_color}{character. what to color cells by (e.g. metadata col or +spatial enrichment col)} -\item{color_as_factor}{convert color column to factor} +\item{color_as_factor}{logical. convert color column to factor. discrete colors +are used when this is TRUE. continuous colors when FALSE.} -\item{cell_color_code}{named vector with colors} +\item{cell_color_code}{character. discrete colors to use. palette to use or +named vector of colors} -\item{cell_color_gradient}{vector with 3 colors for numeric data} - -\item{gradient_midpoint}{midpoint for color gradient} - -\item{gradient_limits}{vector with lower and upper limits} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{point_shape}{shape of points (border, no_border or voronoi)} - -\item{point_size}{size of point (cell)} - -\item{point_alpha}{transparancy of point} - -\item{point_border_col}{color of border around points} - -\item{point_border_stroke}{stroke size of border around points} +\item{cell_color_gradient}{character. continuous colors to use. palette to +use or vector of colors to use (minimum of 2).} \item{show_cluster_center}{plot center of selected clusters} @@ -122,12 +108,6 @@ spatPlot2D_single( \item{center_point_size}{size of center points} -\item{label_size}{size of labels} - -\item{label_fontface}{font of labels} - -\item{show_network}{show underlying spatial network} - \item{spatial_network_name}{name of spatial network to use} \item{network_color}{color of spatial network} @@ -140,45 +120,23 @@ spatPlot2D_single( \item{grid_color}{color of spatial grid} -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{point size of not selected cells} - -\item{other_cells_alpha}{alpha of not selected cells} - \item{coord_fix_ratio}{fix ratio between x and y-axis} -\item{title}{title of plot} - -\item{show_legend}{show legend} - -\item{legend_text}{size of legend text} - -\item{legend_symbol_size}{size of legend symbols} - -\item{background_color}{color of plot background} - \item{vor_border_color}{border colorr for voronoi plot} \item{vor_max_radius}{maximum radius for voronoi 'cells'} -\item{vor_alpha}{transparancy of voronoi 'cells'} - -\item{axis_text}{size of axis text} - -\item{axis_title}{size of axis title} +\item{vor_alpha}{transparency of voronoi 'cells'} -\item{show_plot}{show plot} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot \link{boolean}} +\item{save_plot}{logical. save the plot} \item{verbose}{be verbose} -\item{save_param}{list of saving parameters from \code{\link{all_plots_save_function}}} +\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} } diff --git a/man/spatPlot3D.Rd b/man/spatPlot3D.Rd deleted file mode 100644 index 8e70999..0000000 --- a/man/spatPlot3D.Rd +++ /dev/null @@ -1,130 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R -\name{spatPlot3D} -\alias{spatPlot3D} -\title{spatPlot3D} -\usage{ -spatPlot3D( - gobject, - spat_unit = NULL, - feat_type = NULL, - sdimx = "sdimx", - sdimy = "sdimy", - sdimz = "sdimz", - spat_enr_names = NULL, - point_size = 3, - cell_color = NULL, - cell_color_code = NULL, - select_cell_groups = NULL, - select_cells = NULL, - show_other_cells = T, - other_cell_color = "lightgrey", - other_point_size = 0.5, - other_cell_alpha = 0.5, - show_network = F, - spatial_network_name = "Delaunay_network", - network_color = NULL, - network_alpha = 1, - show_grid = F, - spatial_grid_name = "spatial_grid", - grid_color = NULL, - grid_alpha = 1, - title = "", - show_legend = T, - axis_scale = c("cube", "real", "custom"), - custom_ratio = NULL, - x_ticks = NULL, - y_ticks = NULL, - z_ticks = NULL, - show_plot = NA, - return_plot = NA, - save_plot = NA, - save_param = list(), - default_save_name = "spat3D" -) -} -\arguments{ -\item{gobject}{giotto object} - -\item{spat_unit}{spatial unit} - -\item{feat_type}{feature type} - -\item{sdimx}{x-axis dimension name (default = 'sdimx')} - -\item{sdimy}{y-axis dimension name (default = 'sdimy')} - -\item{sdimz}{z-axis dimension name (default = 'sdimy')} - -\item{spat_enr_names}{names of spatial enrichment results to include} - -\item{point_size}{size of point (cell)} - -\item{cell_color}{color for cells (see details)} - -\item{cell_color_code}{named vector with colors} - -\item{select_cell_groups}{select subset of cells/clusters based on cell_color parameter} - -\item{select_cells}{select subset of cells based on cell IDs} - -\item{show_other_cells}{display not selected cells} - -\item{other_cell_color}{color of not selected cells} - -\item{other_point_size}{size of not selected cells} - -\item{other_cell_alpha}{alpha of not selected cells} - -\item{show_network}{show underlying spatial network} - -\item{spatial_network_name}{name of spatial network to use} - -\item{network_color}{color of spatial network} - -\item{network_alpha}{opacity of spatial network} - -\item{show_grid}{show spatial grid} - -\item{spatial_grid_name}{name of spatial grid to use} - -\item{grid_color}{color of spatial grid} - -\item{grid_alpha}{opacity of spatial grid} - -\item{title}{title of plot} - -\item{show_legend}{show legend} - -\item{axis_scale}{the way to scale the axis} - -\item{custom_ratio}{customize the scale of the plot} - -\item{x_ticks}{set the number of ticks on the x-axis} - -\item{y_ticks}{set the number of ticks on the y-axis} - -\item{z_ticks}{set the number of ticks on the z-axis} - -\item{show_plot}{show plot} - -\item{return_plot}{return ggplot object} - -\item{save_plot}{directly save the plot \link{boolean}} - -\item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} - -\item{default_save_name}{default save name for saving, don't change, change save_name in save_param} -} -\value{ -ggplot -} -\description{ -Visualize cells according to spatial coordinates -} -\seealso{ -Other spatial visualizations: -\code{\link{spatPlot2D}()}, -\code{\link{spatPlot}()} -} -\concept{spatial visualizations} diff --git a/man/spatPlot_2D_plotly.Rd b/man/spatPlot_2D_plotly.Rd index edac96c..0d64d87 100644 --- a/man/spatPlot_2D_plotly.Rd +++ b/man/spatPlot_2D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatPlot_2D_plotly} \alias{spatPlot_2D_plotly} \title{spatPlot_2D_plotly} diff --git a/man/spatPlot_3D_plotly.Rd b/man/spatPlot_3D_plotly.Rd index bc1d391..cacfe41 100644 --- a/man/spatPlot_3D_plotly.Rd +++ b/man/spatPlot_3D_plotly.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/spatial_visuals.R +% Please edit documentation in R/vis_spatial.R \name{spatPlot_3D_plotly} \alias{spatPlot_3D_plotly} \title{spatPlot_3D_plotly} diff --git a/man/violinPlot.Rd b/man/violinPlot.Rd index a253baf..84d896b 100644 --- a/man/violinPlot.Rd +++ b/man/violinPlot.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aux_violinplot.R +% Please edit documentation in R/plot_violin.R \name{violinPlot} \alias{violinPlot} \title{violinPlot} @@ -52,17 +52,15 @@ violinPlot( \item{axis_text_y_size}{size of y-axis text} -\item{show_plot}{show plot. TRUE or FALSE} +\item{show_plot}{logical. show plot} -\item{return_plot}{return ggplot object. TRUE or FALSE} +\item{return_plot}{logical. return ggplot object} -\item{save_plot}{directly save the plot. TRUE or FALSE} +\item{save_plot}{logical. save the plot} \item{save_param}{list of saving parameters, see \code{\link{showSaveParameters}}} \item{default_save_name}{default save name for saving, don't change, change save_name in save_param} - -\item{genes}{deprecated, use feats argument} } \value{ ggplot diff --git a/tests/testthat.R b/tests/testthat.R index 738eee1..d8aadfb 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -9,6 +9,6 @@ library(testthat) library(GiottoVisuals) -devtools::install_github('drieslab/GiottoUtils') +remotes::install_github('drieslab/GiottoUtils') test_check("GiottoVisuals")