plotSpatialScatterpie: Spatial scatterpie

View source: R/plotSpatialScatterpie.R

plotSpatialScatterpieR Documentation

Spatial scatterpie

Description

This function takes in the coordinates of the spots and the proportions of the cell types within each spot. It returns a plot where each spot is a piechart showing proportions of the cell type composition.

Usage

plotSpatialScatterpie(
  x,
  y,
  cell_types = colnames(y),
  img = FALSE,
  slice = NULL,
  scatterpie_alpha = 1,
  pie_scale = 0.4,
  degrees = NULL,
  axis = NULL,
  ...
)

Arguments

x

Object containing the spots coordinates, it can be an object of class SpatialExperiment, dataframe or matrix. For the latter two rownames should have the spot barcodes to match x. If a matrix it has to of dimensions nrow(y) x 2 where the columns are the x and y coordinates in that order.

y

Matrix or dataframe containing the deconvoluted spots. rownames need to be the spot barcodes to match to x.

cell_types

Vector of cell type names to plot. By default uses the column names of y.

img

Logical TRUE or FALSE indicating whether to plot the image or not. Objects of classes accepted by plotImage can also be passed and that image will be used. By default FALSE.

slice

Character string indicating which slice to plot if img is TRUE. By default uses the first image.

scatterpie_alpha

Numeric scalar to set the alpha of the pie charts. By default 1.

pie_scale

Numeric scalar to set the size of the pie charts. By default 0.4.

degrees

From SpatialExperiment rotateImg. For clockwise (degrees > 0) and counter-clockwise (degrees < 0) rotation. By default NULL.

axis

From SpatialExperiment mirrorImg. When a SpatialExperiment object is passed as the image return the mirror image. For horizontal (axis = "h") and vertical (axis = "v") mirroring. By default NULL.

...

additional parameters to geom_scatterpie

Value

ggplot object

Author(s)

Marc Elosua Bayes & Helena L Crowell

Examples

set.seed(321)

# Coordinates
x <- replicate(2, rnorm(100))
rownames(x) <- paste0("spot", seq_len(nrow(x)))
colnames(x) <- c("imagecol", "imagerow")

# Proportions
y <- replicate(m <- 5, runif(nrow(x), 0, 1))
y <- prop.table(y, 1)

rownames(y) <- paste0("spot", seq_len(nrow(y)))
colnames(y) <- paste0("type", seq_len(ncol(y)))

(plt <- plotSpatialScatterpie(x = x, y = y))

MarcElosua/SPOTlight documentation built on March 7, 2024, 4:58 p.m.