plotQC {ggspavis}R Documentation

plotQC

Description

Quality control (QC) plots for spatially resolved transcriptomics data.

Usage

plotQC(
  spe,
  type = c("bar", "scatter", "spots"),
  x_coord = "x",
  y_coord = "y",
  in_tissue = "in_tissue",
  metric_x = "cell_count",
  metric_y = "sum",
  discard = "discard",
  highlight_zeros = TRUE,
  threshold_x = NULL,
  threshold_y = NULL,
  trend = TRUE,
  marginal = TRUE,
  y_reverse = TRUE
)

Arguments

spe

(SpatialExperiment) Input data, assumed to be a SpatialExperiment object.

type

(character) Type of QC plot. Options are "bar", "scatter", and "spots". See details in description.

x_coord

(character) Name of column in spatialCoords containing x-coordinates. Default = "x". Required for spot-based plots.

y_coord

(character) Name of column in spatialCoords containing y-coordinates. Default = "y". Required for spot-based plots.

in_tissue

(character) Name of column in spatialData identifying spots over tissue, e.g. "in_tissue" for 10x Genomics Visium data. If this argument is provided, only spots over tissue will be shown. Alternatively, set to NULL to display all spots. Default = "in_tissue".

metric_x

(character) Name of column in colData containing QC metric to plot on x-axis (e.g. "cell_count" for number of cells per spot). Default = "cell_count". Required for barplots and scatterplots.

metric_y

(character) Name of column in colData containing QC metric to plot on y-axis (e.g. "sum" for number of detected transcripts, or "detected" for number of detected genes). Default = "sum". Required for scatterplots.

discard

(character) Name of column in colData identifying discarded spots that do not meet filtering thresholds, which will be highlighted on a spot-based plot. Default = "discard". Optional for spot-based plots.

highlight_zeros

(logical) Whether to highlight bar for x = 0 (e.g. zero cells per spot). Default = TRUE. Optional for barplots.

threshold_x

(numeric) Filtering threshold for QC metric on x-axis, which will be highlighted with a vertical bar. Default = NULL. Optional for scatterplots.

threshold_y

(numeric) Filtering threshold for QC metric on y-axis, which will be highlighted with a horizontal bar. Default = NULL. Optional for scatterplots.

trend

(logical) Whether to display a smoothed trend (loess) for scatterplots. Default = TRUE. Optional for scatterplots.

marginal

(logical) Whether to display marginal histograms for scatterplots. Default = TRUE. Optional for scatterplots.

y_reverse

(logical) Whether to reverse y coordinates, which is often required for 10x Genomics Visium data. Default = TRUE.

Details

Function to generate plots for quality control (QC) purposes for spatially resolved transcriptomics data.

The following types of QC plots are available:

- Barplot (type = "bar") for a single QC metric, e.g. number of cells per spot. For number of cells per spot, the barplot highlights spots with zero cells. - Scatterplot (type = "scatter") comparing two QC metrics, e.g. number of detected features vs. number of cells per spot, with optional vertical and horizontal lines highlighting QC filtering thresholds. - Spots (type = "spots") i.e. spots in spatial (x-y) coordinates, highlighting discarded spots that do not meet filtering thresholds.

Value

Returns a ggplot object. Additional plot elements can be added as ggplot elements (e.g. title, labels, formatting, etc).

Examples

library(STexampleData)
spe <- Visium_humanDLPFC()
plotQC(spe, type = "bar", metric_x = "cell_count")
colData(spe)$sum <- colSums(counts(spe))
plotQC(spe, type = "scatter", metric_x = "cell_count", metric_y = "sum")


[Package ggspavis version 1.0.0 Index]