Skip to contents

Add a giotto image to a spatial ggplot object post creation

Usage

addGiottoImageToSpatPlot(
  spatpl = NULL,
  gimage = NULL,
  layer = c("bg", "overlay"),
  alpha = NULL
)

Arguments

spatpl

a spatial ggplot object

gimage

a giotto image, see createGiottoImage

layer

numeric layer on which to add the giotto image. OR takes 'bg' or 'overlay' as input to designate last (bottom/background) or first (top/overlay)

alpha

(optional) add giotto image to plot with transparency. Numeric. From 0 (transparent) to 1 (fully visible)

Value

an updated spatial ggplot object

Examples

g <- GiottoData::loadGiottoMini("visium", verbose = FALSE)
#> 
#> 1. use installGiottoEnvironment() to install
#>  a local miniconda python environment along with required modules
#> 
#> 2. provide an existing python path to
#>  python_path to use your own python path which has all modules
#>  installed
#> Set options("giotto.use_conda" = FALSE) if
#>  python functionalities are not needed
#> Warning: Some of Giotto's expected python module(s) were not found:
#> pandas, igraph, leidenalg, community, networkx, sklearn
#> 
#> ** Python path used: "/usr/bin/python3"
#> (This is fine if python-based functions are not needed)

my_giottoimage <- GiottoClass::createGiottoImage(g,
mg_object = system.file("image.png", package = "GiottoVisuals"),
name = 'image')
#> Warning: `get_adj_rescale_img()` was deprecated in GiottoClass 0.3.1.
#>  this is too specific to the inner workings of `giottoImage`
#>  We can simply use `ext<-` to set a new extent instead of this.
#>  The deprecated feature was likely used in the GiottoClass package.
#>   Please report the issue at <https://github.com/drieslab/Giotto/issues>.

my_spatplot <- spatPlot2D(g, return_plot = TRUE)


addGiottoImageToSpatPlot(spatpl = my_spatplot, gimage = my_giottoimage)