Different Ways to Visualize Spatial Data

This section delves into the multiple different ways that Giotto provides to visualize your spatial data.

Tip

Check out the different dataset examples to see the wide range of visualization options.

1. Task/Analysis Specific Functions

  • plotHeatmap

  • plotMetadataHeatmap

  • violinPlot

2. Functions that use the Spatial Coordinates of a Cell/Spot

Note

These functions generally start with spatXXX

  • spatPlot(), to plot cell annotation information (e.g. cluster or cell type)

  • spatGenePlot(), to overlay (multiple) gene expression values

  • spatCellPlot(), to overlay (multiple) numerical cell values (e.g. spatial enrichment)

3. Functions that use the Dimension Reduction Coordinates of a Cell/Spot

Note

These functions generally start with dimXXX

4. Functions for co-visualization that combine spat (2) and dim (3)

  • spatDimPlot() <spatDimPlot>`_, to plot cell annotation information (e.g. cluster or cell type)

  • spatDimGenePlot(), to overlay (multiple) gene expression values

  • spatDimCellPlot(), to overlay (multiple) numerical cell values (e.g. spatial enrichment)

5. Both in 2D and 3D

Most functions both have a 2D and 3D version, like spatDimPlot2D() and spatDimPlot3D(). In those cases the spatDimPlot2D() is the same as spatDimPlot(). So only in case you want to plot your spatial or dimension reduction data in 3D, you need to specifically say so.

6. Ways to Save Plots

See also

Giotto Tips and Tricks: How to visualize and save plots in Giotto? for more information.

All parameters available to save_param() are found on the help page of ?Giotto::all_plots_save_function

7. Hypothetical Example

# 1. standard R way
pl = spatPlot(mygobject, cell_color = 'cell_types')
pdf(file = 'path/to/save/to/plot.pdf')
print(pl)
dev.off()

# 2. indicate to save plot, this will save the plot according to Giotto instructions file
# If the instruction file is not provided in the beginning, it uses the defaults (e.g. working directory)
spatPlot(mygobject, cell_color = 'cell_types', save_plot = TRUE)

# 3. indicate to save plot and specifiy specific saving parameters by providing a list to save_param
# they will overrule the giotto instructions
spatPlot(mygobject, cell_color = 'cell_types', save_plot = TRUE,
 save_param = list(save_folder = 'my_subfolder', save_name = 'my_name', save_format = 'png', units = 'in'))

# 4. don't save or return plot, but just view plot
# defaults are: save_plot = F, return_plot = T and show_plot = T
# this can be changed in the instructions file or at each specific plotting function
spatPlot(mygobject, cell_color = 'cell_types', save_plot = F, return_plot = F show_plot = T)