Specificity

Regulon specificity scores and candidate enhancers per topic.

rustscenic.specificity

Regulon specificity scores (RSS) and topic-based candidate enhancers.

Two small downstream pieces SCENIC+ ships that rustscenic was missing.

Public API rustscenic.specificity.regulon_specificity_scores(auc, cell_groups) -> pd.DataFrame rustscenic.specificity.candidate_enhancers_per_topic(topic_peak, top_n=2000) -> dict

RSS measures how cluster-specific each regulon's activity is. Implemented as Jensen-Shannon divergence between (a) the regulon's per-group mean AUC distribution and (b) the cluster-membership distribution - the same formula pyscenic ships in pyscenic.binarization.regulon_specificity_scores.

Topic candidate enhancers turn the topics-fit output (a topic-peak weight matrix) into per-topic ranked peak lists, the bridge that pycisTopic uses between topic modelling and motif enrichment.

CandidateEnhancers

Bases: dict

dict subclass carrying backend provenance for ranked topic peaks.

rust_backend instance-attribute

rust_backend: dict

regulon_specificity_scores

regulon_specificity_scores(
    auc: DataFrame, cell_groups: Series | Sequence
) -> pd.DataFrame

Per-(group, regulon) Jensen-Shannon-based specificity score.

Parameters:

Name Type Description Default
auc DataFrame

AUCell output: cells × regulons. Index = cell barcodes, columns = regulon names. From rustscenic.aucell.score.

required
cell_groups Series | Sequence

Cluster / cell-type label per cell (length == auc.n_obs). Pandas Series indexed by barcode, or any sequence aligned to auc.index.

required

Returns:

Type Description
pandas.DataFrame indexed by group, columns = regulons. Values in
[0, 1]; higher = more group-specific. Same orientation as
``pyscenic.binarization.regulon_specificity_scores``.

candidate_enhancers_per_topic

candidate_enhancers_per_topic(
    topic_peak: ndarray | DataFrame,
    peak_names: Sequence[str] | None = None,
    top_n: int = 2000,
) -> dict[str, list[str]]

Top-ranked peaks per topic - pycisTopic's "candidate enhancers".

Topic models on scATAC give a (topic × peak) weight matrix. Per-topic, the highest-weight peaks are the topic's candidate enhancers - used downstream to query motif enrichment region-by-region.

Parameters:

Name Type Description Default
topic_peak ndarray | DataFrame

Either a (n_topics × n_peaks) numpy array, or a DataFrame indexed by topic with peaks as columns. From rustscenic.topics.fit.

required
peak_names Sequence[str] | None

Peak ID per column when topic_peak is a numpy array. Ignored for DataFrame input.

None
top_n int

Number of top-weighted peaks per topic.

2000

Returns:

Type Description
dict mapping ``topic_name -> [peak_ids ranked by descending weight]``.