Skip to content

patcon/valency-anndata

Repository files navigation

diagram of one workflow of valencyann-data

valency-anndata

Experimental tooling to support notebook analysis of polislike data.

✨ Inspired by scanpy and the scverse ecosystem! ❤️

Installation

pip install valency-anndata

Usage

Loading Polis Data

import valency_anndata as val

adata = val.datasets.polis.load("https://pol.is/report/r29kkytnipymd3exbynkd")
val.viz.schematic_diagram(adata, diff_from=None)
Screenshot 2025-12-23 at 12 00 16 AM

Running Polis Pipelines

with val.viz.schematic_diagram(diff_from=adata):
    val.tools.recipe_polis(adata, key_added_pca="X_pca_polis")
Screenshot 2025-12-23 at 12 57 42 AM
val.viz.embedding(adata, basis="pca_polis", color="kmeans_polis")
Screenshot 2025-12-23 at 12 00 59 AM

Exploring Polis Pipelines

val.viz.schematic_diagram(diff_from=adata):
    val.preprocessing.calculate_qc_metrics(pacmap_adata, inplace=True)
Screenshot 2025-12-23 at 12 58 18 AM
val.viz.embedding(adata, basis="pca_polis",
    color=["kmeans_polis", "pct_seen", "pct_agree", "pct_pass"],
)
Screenshot 2025-12-23 at 12 58 50 AM

Running & Exploring Alternative Pipelines

from valency_anndata.tools._polis import _zero_mask, _cluster_mask

with val.viz.schematic_diagram(diff_from=adata):
    _zero_mask(adata)
    val.preprocessing.impute(
        adata,
        strategy="mean",
        source_layer="X_masked",
        target_layer="X_masked_imputed_mean",
    )
    val.tools.pacmap(
        adata,
        key_added="X_pacmap",
        layer="X_masked_imputed_mean",
    )
    _cluster_mask(adata)
    val.tools.kmeans(
        adata,
        k_bounds=(2, 9),
        use_rep="X_pacmap",
        mask_obs="cluster_mask",
        key_added="kmeans_pacmap",
    )
Screenshot 2025-12-23 at 12 58 59 AM
val.viz.embedding(adata, basis="pacmap",
    color=["kmeans_pacmap", "pct_seen", "pct_agree", "pct_pass"],
)
Screenshot 2025-12-23 at 12 59 09 AM

For full examples and planned features, see: kitchen-sink.ipynb

AI-Assisted Exploration (Claude Code Skill)

This repo includes a Claude Code skill that guides you through loading and exploring Polis conversations interactively. It will prompt you for which projections and annotations to visualize, then run the full pipeline for you.

Contributing

We are maintaining a custom CONTRIBUTING.md with specific links and a compiled list of entry tasks!

About

Experimental tooling to support notebook analysis of polislike data.

Resources

Contributing

Stars

Watchers

Forks

Contributors