Seuratmap2ref

From pwwang/immunopipe · View interactive version

Seuratmap2ref is an AI agent skill from the GitHub repository pwwang/immunopipe. Maintain existing [SeuratMap2Ref] configurations and troubleshoot legacy reference mapping. For new configurations, use the celltypeannotation skill with tool = "mapquery".

How to use this skill

Skill file

SeuratMap2Ref Process Configuration

Deprecated: For new configurations, use the celltypeannotation skill with tool = "mapquery". This skill documents the still-supported legacy [SeuratMap2Ref] process.

Purpose

Map query single-cell datasets to high-quality reference atlases using Seurat's reference mapping workflow. Performs label transfer, UMAP projection, and integration with reference annotations without modifying query expression data. Enables transfer learning from curated atlases like Azimuth PBMC or custom tissue-specific references.

When to Use

Configuration Structure

Process Enablement

[SeuratMap2Ref]
cache = true

Input Specification

[SeuratMap2Ref.in]
srtobj = ["SeuratClustering"]

Environment Variables

[SeuratMap2Ref.envs]
# REQUIRED
ref = "/path/to/reference.rds"  # Reference Seurat object (RDS/h5seurat)
use = "celltype"               # Reference metadata column to transfer
ident = "seurat_clusters"      # Name for transferred labels in query

# NORMALIZATION
refnorm = "auto"               # "LogNormalize", "SCTransform", "auto"
skip_if_normalized = true       # Skip if query already normalized

# PERFORMANCE
ncores = 1                     # Cores for parallelization
cache = "/tmp"                 # Cache intermediate results

# LARGE DATASETS
split_by = "sample"            # Split query by metadata column

# ANCHOR FINDING
[SeuratMap2Ref.envs.FindTransferAnchors]
normalization.method = "auto"
reference.reduction = "pca"
dims = "1:30"
k.anchor = 5

# MAPPING
[SeuratMap2Ref.envs.MapQuery]
reference.reduction = "pca"
reduction.model = "umap"
refdata = {}

# NORMALIZATION
[SeuratMap2Ref.envs.SCTransform]
do.center = true
[SeuratMap2Ref.envs.NormalizeData]
normalization.method = "LogNormalize"

External References

Seurat Functions

Configuration Examples

Minimal (Azimuth PBMC)

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
ref = "/path/to/pbmc_reference.rds"
use = "celltype.l1"

Custom with Multi-Level Transfer

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
ref = "/path/to/pancreas_atlas.rds"
use = "celltype.l2"
refdata = {celltype = "celltype", donor = "orig.ident"}
ident = "ref_celltype"

Large Dataset with Splitting

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
split_by = "sample"
ncores = 4
refnorm = "SCTransform"

Common Patterns

Pattern 1: Azimuth PBMC Reference

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
ref = "/data/azimuth/pbmc_reference.rds"
use = "celltype.l1"
refdata = {celltype = "celltype.l1", celltype.l2 = "celltype.l2"}

Pattern 2: Human Cell Atlas Reference

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
ref = "/data/hca/bone_marrow_reference.rds"
use = "cell_type"
refnorm = "SCTransform"
FindTransferAnchors.dims = "1:30"

Pattern 3: Multi-Label with Confidence Scores

[SeuratMap2Ref]
[SeuratMap2Ref.envs]
refdata = {
  "l1_celltype" = "celltype.l1",
  "l2_celltype" = "celltype.l2",
  "l1_score" = "celltype.l1.score",
  "l2_score" = "celltype.l2.score"
}

Available References

Azimuth References

Human Cell Atlas (HCA)

SeuratData References

library(SeuratData)
InstallData("pbmc3k")  # PBMC dataset
InstallData("bmcite")  # Bone marrow
InstallData("panc8")   # Pancreas islets

Dependencies

Validation Rules

Reference Format Requirements

Compatibility Checks

Troubleshooting

Dimension Mismatch

Problem: Reference has 30 PCs but query has 50

Solution: Set FindTransferAnchors.dims = "1:30"

Poor Anchor Quality

Problem: Low prediction scores or failed transfer

Solutions:

Out-of-Memory Errors

Problem: Large query dataset causes memory overflow

Solutions:

UMAP Projection Failure

Problem: ref.umap not found in query object

Solutions:

Cache Issues

Problem: Unexpected results after parameter changes

Solution: Delete cached files <signature>.<kind>.RDS or set cache = false

Label Column Overwrites

Problem: Multiple annotation processes overwrite each other

Solution: Set unique ident for each process

Normalization Method Mismatch

Problem: Query is SCTransform but reference is LogNormalize

Solutions:

Output

Files Generated

Metadata Added

Visualization

DimPlot(seurat_obj, reduction = "ref.umap", group.by = "predicted_celltype")

Related Processes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.