Skip to content

Commit

Permalink
Merge pull request #2 from jiajic/main
Browse files Browse the repository at this point in the history
GiottoVisuals semi-functional
  • Loading branch information
jiajic authored Aug 28, 2023
2 parents 207c789 + c513ddd commit 328d973
Show file tree
Hide file tree
Showing 154 changed files with 3,979 additions and 5,563 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
^LICENSE\.md$
^README\.Rmd$
^.github$
^codecov.yml$
52 changes: 30 additions & 22 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
role = c("aut", "cre")),
Expand Down Expand Up @@ -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,
Expand All @@ -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'
22 changes: 8 additions & 14 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# Generated by roxygen2: do not edit by hand

export(FSV_show)
export(addPolygonCells)
export(cellProximityBarplot)
export(cellProximityHeatmap)
export(cellProximityNetwork)
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)
Expand All @@ -23,45 +22,35 @@ 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)
export(plotUMAP)
export(plotUMAP_2D)
export(plotUMAP_3D)
export(plot_output_handler)
export(select_gimage)
export(showClusterDendrogram)
export(showClusterHeatmap)
export(showColorInstructions)
Expand All @@ -82,6 +71,9 @@ export(spatGenePlot3D)
export(spatInSituPlotDensity)
export(spatInSituPlotHex)
export(spatInSituPlotPoints)
export(spatNetwDistributions)
export(spatNetwDistributionsDistance)
export(spatNetwDistributionsKneighbors)
export(spatPlot)
export(spatPlot2D)
export(spatPlot3D)
Expand All @@ -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)
17 changes: 11 additions & 6 deletions R/defaults.R → R/aux_defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -243,6 +243,8 @@ set_default_color_continuous <- function(
...),
'sequential' = evaluate_color_gradient_sequential(colors = colors,
reverse = reverse,
gradn = gradn,
grad = grad,
...)
)
}
Expand Down Expand Up @@ -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,
Expand Down
56 changes: 53 additions & 3 deletions R/plot_output.R → R/aux_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
#' }
#' }



Expand Down
6 changes: 2 additions & 4 deletions R/plot_save.R → R/aux_save.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 328d973

Please sign in to comment.