User guide#
This page summarizes the usual campmc workflow and what each CAMP method does. For full signatures, see the API reference.
Typical workflow#
Prepare embeddings — either use an object that already has
obsm['X_pca'](e.g. Scanpy’s reduced PBMC datasets), or runcampmc.preprocess()on raw counts.Partition — call
campmc.partition()with a method and compression factorgamma(target cells per metacell).Evaluate — use
campmc.mt.quality()(and optionallycampmc.mt.recovery_scores()) against reference labels.
See Partition PBMC 68k (reduced) for a runnable walkthrough, or the API pages for executable examples on each function.
import campmc as cp
import scanpy as sc
adata = sc.datasets.pbmc68k_reduced()
cp.partition(adata, method="camp3", gamma=25, random_state=0)
cp.mt.quality(adata, partition_key="camp", label_key="louvain")[["metacell_id", "size", "purity"]].head()
| metacell_id | size | purity | |
|---|---|---|---|
| 0 | seed0-25-__all__ | 57 | 1.000000 |
| 1 | seed1-25-__all__ | 34 | 0.911765 |
| 2 | seed10-25-__all__ | 2 | 1.000000 |
| 3 | seed11-25-__all__ | 42 | 0.857143 |
| 4 | seed12-25-__all__ | 25 | 0.840000 |
Choosing gamma#
gamma is the target number of cells per metacell. The coreset size is
m ≈ n / gamma:
|
Effect |
|---|---|
Smaller (e.g. 10–25) |
More metacells, finer resolution |
Larger (e.g. 50–100) |
Fewer metacells, stronger compression |
Pass gammas=[10, 25, 50] instead of gamma to store several partitions on
the same object (columns camp_10, camp_25, …).
CAMP methods#
All methods share the same coreset seed sampling; they differ in how cells are assigned to seeds:
Method |
Assignment idea |
Notes |
|---|---|---|
|
Short k-means initialized at seeds |
Fast baseline |
|
Cosine nearest seed + one centroid update |
Good default for speed |
|
Adaptive RBF weights over seed distances |
Often a strong default |
|
SEACells kernel graph from seeds |
Slower; needs SEACells |
Use method="camp3" unless you have a reason to compare variants.
AnnData keys#
After a single-gamma run with default key_added="camp":
Location |
Contents |
|---|---|
|
Metacell label per cell |
|
Whether the cell was a coreset seed |
|
Run metadata (method, gamma, …) |
With batch_key, partitioning is performed independently inside each batch
and labels include the batch annotation.