Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/satijalab/seurat-wrappers/llms.txt

Use this file to discover all available pages before exploring further.

RunPaCMAP() runs the PaCMAP algorithm on a Seurat object, producing a low-dimensional embedding suitable for visualization. PaCMAP uses three types of cell pairs (neighbors, mid-near, and further pairs) to preserve both local and global structure.

Syntax

# From PCA embeddings
RunPaCMAP(
  object,
  reduction = "pca",
  dims = NULL,
  features = NULL,
  assay = NULL,
  layer = "data",
  n_components = 2,
  n.neighbors = NULL,
  MN_ratio = 0.5,
  FP_ratio = 2,
  distance_method = "euclidean",
  lr = 1,
  num_iters = 250L,
  apply_pca = TRUE,
  init = "random",
  reduction.name = "pacmap",
  reduction.key = "PaCMAP_",
  verbose = TRUE,
  seed.use = 11L,
  ...
)

Parameters

object
Seurat
required
A Seurat object.
reduction
character
default:"pca"
Name of the existing reduction to use as input when dims is specified.
dims
integer vector
default:"NULL"
Dimensions from reduction to use as input. Specify either dims or features, not both.
features
character vector
default:"NULL"
Gene features to use as direct input. Specify either dims or features, not both.
layer
character
default:"data"
Layer to pull feature values from when features is specified.
n_components
integer
default:"2"
Number of PaCMAP output dimensions.
n.neighbors
integer
default:"NULL"
Number of neighbors for the kNN graph. Defaults to 10 for datasets smaller than 10,000 cells; scales with log10(n) for larger datasets.
MN_ratio
numeric
default:"0.5"
Ratio of mid-near pairs to neighbors.
FP_ratio
numeric
default:"2"
Ratio of further pairs to neighbors.
distance_method
character
default:"euclidean"
Distance metric for neighbor computation. Passed to PaCMAP’s distance parameter.
lr
numeric
default:"1"
Learning rate for the AdaGrad optimizer.
num_iters
integer
default:"250"
Number of optimization iterations.
apply_pca
logical
default:"TRUE"
Whether to apply PCA preprocessing before constructing the kNN graph.
init
character
default:"random"
Initialization method for the embedding. One of "pca" or "random".
reduction.name
character
default:"pacmap"
Name for the resulting DimReduc object.
reduction.key
character
default:"PaCMAP_"
Prefix for PaCMAP embedding column names.
seed.use
integer
default:"11"
Random seed for reproducibility.

Returns

A Seurat object with a new DimReduc object stored under reduction.name containing the PaCMAP embedding.
PaCMAP requires Python with the pacmap package installed and reticulate configured.

Examples

library(SeuratWrappers)
library(reticulate)
use_condaenv("r-pacmap")

# Run from PCA dims
object <- RunPaCMAP(object = seurat_obj, reduction = "pca", dims = 1:30)

# Run from variable features
object <- RunPaCMAP(object = seurat_obj, features = VariableFeatures(seurat_obj))

# Visualize
DimPlot(object, reduction = "pacmap")

See Also

Build docs developers (and LLMs) love