HSVOverlay: Overlay HSV encoded features on HE images

HSVOverlayR Documentation

Overlay HSV encoded features on HE images

Description

Graphs the selected features as a HSVplot on a 2D grid of spots overlaid on top of an HE images. Only numerical features are accepted, e.g. genes or dimensionality reduction output vectors. If you want to draw dimentionality reduction vectors you need to specify the whole names of the vectors, e.g. 'features = c("factor_1", "factor_2")' for the two first NMF factors.

Usage

HSVOverlay(
  object,
  features,
  sampleids = 1,
  rescale = TRUE,
  spots = NULL,
  ncols.features = NULL,
  ncols.samples = NULL,
  type = NULL,
  min.cutoff = NA,
  max.cutoff = NA,
  slot = "data",
  pt.size = 2,
  pt.alpha = 1,
  add.alpha = FALSE,
  palette = NULL,
  cols = NULL,
  split.hsv = FALSE,
  dark.theme = FALSE,
  sample.label = TRUE,
  show.sb = TRUE,
  verbose = FALSE,
  ...
)

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")

sampleids

Names of samples to plot

rescale

Rescale each feature column separately from 0 to 1 range. If set to FALSE, all feature columns will be scaled together from 0 to 1 and preserve the relative differencies

spots

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

ncols.features

Number of columns passed to FeatureOverlay. For example, if you are plotting 4 features, 'ncols.features = 2' will arrange the FeatureOverlay plots into a 2x2 grid [default: 'length(features)']. (see Arrange plots* for a detailed description)

ncols.samples

Number of columns in the layout grid for the samples. For example, if you are plotting 4 samples, 'ncols.samples = 2' will arrange the plots obtained from FeatureOverlay plots into a 2x2 grid [default: '1']. (see Arrange plots* for a detailed description)

type

Image type to plot on. Here you can specify any of the images available in your Seurat object. To get this list you can run the rasterlists function on your Seurat object. If the type is not specified, the images will be prioritized in the following order if they are available; "processed", "masked" and "raw".

min.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]

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 expression data from? [dafault: 'data']

pt.size

Point size of each ST spot [default: 1]

pt.alpha

Opacity of each ST spot [default: 1]

add.alpha

Scale spot opacity by selected feature. Higher values get more opaque while lower values make spots transparent.

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.

split.hsv

Should the HSV colored features be split into separate plots? [default: FALSE]

dark.theme

Switches color of scalebar to 'white'

sample.label

Should the sample label be included in the image? [default: TRUE]

show.sb

Should a scalebar be drawn? [default: TRUE]

verbose

Print messages

...

Parameters passed to DimOverlay

Details

NOTE that this function draws sample 1 as default, but can take multiple samples as well using the 'sampleids argument'.

It is typically difficult to explore details in the HE image when diplaying multiple samples side by side, so we recommend to draw the plots for one sample at the time. If you have higher resolution images, it could also take significant time to draw the plots.

Arrange plots

The 'ncols.features' argument will determine how each subplot called using DimOverlay is arranged and will by default put all dims in 1 row, i.e. 'ncols.features = length(features)'. The 'ncols.samples' argument will determine how these subplots are arranged and will by default use 1 column, meaning that each subplot is put in its own row. The output layout matrix would then have the dimensions 'length(samples)xlength(features)'

The 'ncols.features' argument will determine how each subplot is arranged and will by default put all features in 1 row, i.e. 'ncols.features = length(features)'. The 'ncols.samples' argument will determine how these subplots are arranged and will by default use 1 column, meaning that each subplot is put in its own row. The output layout matrix would then have the dimensions 'length(samples)xlength(features)'

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.

Examples

## Not run: 
# Load images
se <- se %>% SCTransfrom() %>% LoadImages() %>% RunNMF()

# Overlay first two NMF factors on the first two tissue sections
HSVPlot(se, features = c("factor_1", "factor_2"), sampleids = 1:2)

## End(Not run)


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