> ## 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()

> Pairwise Controlled Manifold Approximation for dimensionality reduction and visualization

`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

```r theme={null}
# 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

<ParamField path="object" type="Seurat" required>
  A Seurat object.
</ParamField>

<ParamField path="reduction" type="character" default="pca">
  Name of the existing reduction to use as input when `dims` is specified.
</ParamField>

<ParamField path="dims" type="integer vector" default="NULL">
  Dimensions from `reduction` to use as input. Specify either `dims` or `features`, not both.
</ParamField>

<ParamField path="features" type="character vector" default="NULL">
  Gene features to use as direct input. Specify either `dims` or `features`, not both.
</ParamField>

<ParamField path="layer" type="character" default="data">
  Layer to pull feature values from when `features` is specified.
</ParamField>

<ParamField path="n_components" type="integer" default="2">
  Number of PaCMAP output dimensions.
</ParamField>

<ParamField path="n.neighbors" type="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.
</ParamField>

<ParamField path="MN_ratio" type="numeric" default="0.5">
  Ratio of mid-near pairs to neighbors.
</ParamField>

<ParamField path="FP_ratio" type="numeric" default="2">
  Ratio of further pairs to neighbors.
</ParamField>

<ParamField path="distance_method" type="character" default="euclidean">
  Distance metric for neighbor computation. Passed to PaCMAP's `distance` parameter.
</ParamField>

<ParamField path="lr" type="numeric" default="1">
  Learning rate for the AdaGrad optimizer.
</ParamField>

<ParamField path="num_iters" type="integer" default="250">
  Number of optimization iterations.
</ParamField>

<ParamField path="apply_pca" type="logical" default="TRUE">
  Whether to apply PCA preprocessing before constructing the kNN graph.
</ParamField>

<ParamField path="init" type="character" default="random">
  Initialization method for the embedding. One of `"pca"` or `"random"`.
</ParamField>

<ParamField path="reduction.name" type="character" default="pacmap">
  Name for the resulting DimReduc object.
</ParamField>

<ParamField path="reduction.key" type="character" default="PaCMAP_">
  Prefix for PaCMAP embedding column names.
</ParamField>

<ParamField path="seed.use" type="integer" default="11">
  Random seed for reproducibility.
</ParamField>

## Returns

A Seurat object with a new DimReduc object stored under `reduction.name` containing the PaCMAP embedding.

<Note>
  PaCMAP requires Python with the `pacmap` package installed and `reticulate` configured.
</Note>

## Examples

```r theme={null}
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

* [PaCMAP method guide](/methods/pacmap)
