ST.FeaturePlot: Feature plot on ST coordinates

ST.FeaturePlotR Documentation

Feature plot on ST coordinates

Description

Graphs selected features on a 2D grid of spots, for example raw gene counts, normalized gene counts or cluster labels.

Usage

ST.FeaturePlot(
  object,
  features,
  split.labels = FALSE,
  indices = NULL,
  spots = NULL,
  plot.type = "spots",
  min.cutoff = NA,
  max.cutoff = NA,
  slot = "data",
  blend = FALSE,
  pt.size = 1,
  pt.alpha = 1,
  pt.border = FALSE,
  palette = NULL,
  cols = NULL,
  dark.theme = FALSE,
  highlight.edges = TRUE,
  ncol = NULL,
  grid.ncol = NULL,
  center.zero = FALSE,
  channels.use = NULL,
  center.tissue = FALSE,
  verbose = FALSE,
  sb.size = 2.5,
  show.sb = TRUE,
  value.scale = c("samplewise", "all"),
  label.by = NULL,
  ...
)

Arguments

object

Seurat object

features
  • An Assay feature (e.g. a gene name - "MS4A1")

  • A column name from meta.data (e.g. mitochondrial percentage - "percent.mito")

split.labels

Only works if the features are specified by character vectors. The plot will be split into one plot for each group label, highlighting the labelled spots.

indices

Integer vector specifying sample indices to include in the plot [default: show all samples]

spots

Character vector with spot IDs to plot [default: all spots]

plot.type

Specify the type of plot to use [default: "spots"]. Available options are; "spots" (a "smooth" options will be added soon)

min.cutoff, max.cutoff

Vector of minimum and maximum cutoff values for each feature, may specify quantile in the form of 'q##' where '##' is the quantile (eg, 'q1', 'q10'). This can be useful if you have outlier values that skew the colorscale in the plot. For example, if you specify 'q1', you will trim of values below the 1st percentile. [default: no cuttoffs]

slot

Which slot to pull the data from? [default: 'data']

blend

Scale and blend expression values to visualize coexpression of two features (this options will override other coloring parameters). See 'Blending values' below for a more thourough description.

pt.size

Adjust point size for plotting [default: 1]

pt.alpha

Adjust point opacity for plotting [default: 1]

pt.border

Should a border be drawn around the spots? [default: TRUE]

palette

Color palette used for spatial heatmap (see palette.select(info = T) for available options). Disabled if a color vector is provided (see cols below).

cols

A vector of colors to use for colorscale, e.g. cols = c("blue", "white", "red") will create a gradient color scale going from blue to white to red. This options will deactivate the palette option.

dark.theme

Switches color of scalebar to 'white'

highlight.edges

Should edges be highlighted? [default: TRUE]

ncol

Number of columns to arrange the samples into. This can for example be useful to adjust if you want to visualize the samples in just in one row or one column.

grid.ncol

Number of columns for display when combining plots. This option will only have an effect on the sample level structure.

center.zero

Specifies whther or not the colorscale should be centered around 0. For some values, such as Principal Component vectors, the distribution of values is centered at 0 and in that case it can be appropriate to use a divergent colorscale with a predefined value for 0. If this parameter is set to TRUE, the ggplot2 function scale_color_gradient2 will be used to control the coloring instead of scale_color_gradientn. If center.zero is set to FALSE, the colorscale will simply map the values in equally spaced intervals which could skew the interpretaion of the output plot.

channels.use

Color channels to use for blending. Has to be a character vector of length 2 or 3 with "red", "green" and "blue" color names specified [default: c("red", "green", "blue)]

center.tissue

Adjust coordinates so that the center of the tissue is in the middle of the array along the y-axis. This can be useful if your samples have been placed in very different parts of the capture area and you want to center the plots in the middle. This is however unnecessary if you have already aligned the sample data (see AlignImages, WarpImages and ManualAlignImages)

verbose

Print messages

sb.size

Size of scalebar [default: 2.5]

show.sb

Should a scalebar be drawn? [default: TRUE]

value.scale

Defines how the dimensionality reduction values should be mapped to the colorbar. 'value.scale = "samplewise"' will scale each feature independantly while 'value.scale = "all"' will use the same value range for all vectors

label.by

Feature to relabel facets by. By default, facets are given a unique section number ranging grom 1 to the number of sections available in the 'Staffli' object. If you want to relabel these facets you can pass the name of a column that keeps the labels that you want to use. For example, if you wish to rename the facets to use labels defined by a charcater vector in column "section_id" in your meta.data slot, you can pass 'label.by = "section_id"' to relabel the facets. Only works for categorical group variables with where the number of groups is less than or equal to the number of tissue sections in your Staffli object.

...

Extra parameters passed on to t

Details

Note that you can only graph one specific class of features at the same time. This function does not support mixing of numeric and character vectors for example.

Value

A ggplot object

Splitting categorical features

If you are plotting a categorical feature, e.g.cluster labels, you have the option to split each label into facets using split.labels=TRUE. This is very useful if you have many different labels which can make it difficult to distinguish the different colors. However, splitting only works for one sample at the time which has to be specified by the indices argument.

Blending values

The blend option can be useful if you wish to visualize multiple features simultaneuosly and works for two or three vectors. Each of the selected vectors are rescaled from 0 to 1 and are used as RGB color channels to produce mixed color for each spot. This can be particularly useful when looking at overlapping value vectors. For example, if you are looking at two overlapping features "A" and "B" and use the blend option, the "A" values will be encoded in the "red" channel and the "B" values in the "green" channel. If a spot is purely "A" the color will be red and if it is purely "B" it will green. Any mixture of "A" and "B" will produce a color between red and green where a 50/50 mixture gives yellow color. The amplitude if the values will also determine the brightness of the color.

See Also

ST.DimPlot for how to plot dimensionality reduction output, FeatureOverlay and DimOverlay for how to overlay plots on the HE images.

Examples

## Not run: 
# Plot the number of unique genes and the number of UMIs per spot
ST.featurePlot(se, features = c("nFeature_RNA", "nCount_RNA"))

# Plot selected genes
ST.featurePlot(se, features = c("Cck", "Dcn"))

# Plot normalized values
se <- SCTransform(se)
ST.featurePlot(se, features = c("Cck", "Dcn"))

# Change to scaled data
ST.featurePlot(se, features = c("Cck", "Dcn"), slot = "scale.data", center.zero = TRUE)

# Cluster spots and plot cluster labels
se <- se %>% RunPCA()
   FindNeighbors(dims = 1:10, reduction = "pca") %>%
   FindClusters()
ST.featurePlot(se, features = "seurat_clusters")
# Split cluster labels into facets
ST.featurePlot(se, features = "seurat_clusters", split.labels = TRUE)

## End(Not run)


jbergenstrahle/STUtility documentation built on March 14, 2023, 7:15 a.m.