stratify_seurat: Given two spot groups, compute for each spot: (i) the...

View source: R/dist2border.R

stratify_seuratR Documentation

Given two spot groups, compute for each spot: (i) the distance of the closest spot in the other class.

Description

Given two spot groups, compute for each spot: (i) the distance of the closest spot in the other class.

Usage

stratify_seurat(
  seurat_obj,
  ident = NULL,
  colours = NULL,
  colours_stratum = NULL,
  pt_size = 4,
  breaks = 5,
  labels = NULL,
  diagnostic_plot = TRUE
)

Arguments

seurat_obj

A Seurat object.

ident

The classes of the spots (0/1). A named vector (name = spot name; value = classes).

colours

Colors for the spot classes.

colours_stratum

A set of colors for the stratum.

pt_size

The size of the points.

breaks

Either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of stratums in which spot are to be cut.

labels

Labels for the levels of the stratum. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.

diagnostic_plot

Whether to produce a diagnostic diagram. Highly recommanded to visually inspect the results.

Examples

library(Seurat)
library(ggplot2)
load_example_dataset("7870305/files/lymph_node_tiny_2")
Seurat::SpatialDimPlot(lymph_node_tiny_2)
identity <- Idents(lymph_node_tiny_2)
classes <- ifelse(Idents(lymph_node_tiny_2) == 7, 1, 0)
names(classes) <- names(identity)
h <- display_hull(lymph_node_tiny_2, ident=classes, color="black", delta=1, size_x=3.4, size_y=3)
plot_spatial(lymph_node_tiny_2, metadata = "seurat_clusters", pt_size = 6) + h
strat <- stratify_seurat(lymph_node_tiny_2, ident=classes)
strat[[1]]
strat[[2]] + ggplot2::coord_equal()
strat[[3]] + ggplot2::coord_equal()
strat[[4]] + ggplot2::coord_equal() 

dputhier/scigenex documentation built on May 31, 2024, 8:59 a.m.