grassp.ds.gene_sets_compartments

grassp.ds.gene_sets_compartments#

gene_sets_compartments(species='hsap', *, min_genes=None)[source]#

COMPARTMENTS curated subcellular localisation, 874 terms for human.

COMPARTMENTS (Binder et al. 2014, https://compartments.jensenlab.org) integrates localisation evidence from several channels; this is the knowledge channel, the curated one – manually assigned GO cellular-component terms carrying a 1-5 star confidence, already propagated over the ontology. Kept at confidence >= 3 and >= 5 genes, with generic and non-locational terms removed (whole-cell aggregators, topology qualifiers, “region of” groupings, the extracellular-exosome dump) and near-duplicate gene sets collapsed at Jaccard >= 0.8, keeping the canonical organelle name.

Sits between gene_sets_curated() and gene_sets_go_cc() in granularity. Term labels are upper-case, as in both published grassp analyses; the GO id is in the GMT’s description column.

Vendored build: 2026-09-24. COMPARTMENTS publishes no versioned archive, only a rolling download, so this build date is the only version this vocabulary has – quote it when reporting results. grassp.datasets.gene_sets.provenance() returns the full record, and marker_curation/fetch_compartments.py rebuilds it.

Parameters:
species Literal['hsap', 'mmus', 'scer'] (default: 'hsap')

Only "hsap" is bundled; the knowledge channel for other species is not curated to a comparable standard.

min_genes int | None (default: None)

Drop terms with fewer than this many genes. The build already applies a floor of 5; raising it further is worthwhile for enrichment testing.

Return type:

dict[str, list[str]]

Returns:

dict[str, list[str]] Mapping of upper-case compartment name to gene symbols.

See also

gene_sets_curated

the coarse, experiment-resolvable compartments to start from.

gene_sets_go_cc

the finer GO cellular-component vocabulary.

Examples

>>> import grassp as gr
>>> sets = gr.ds.gene_sets_compartments()
>>> len(sets)
874
>>> len(gr.ds.gene_sets_compartments(min_genes=20))
404

Notes

13 term names contain /, which h5ad rejects as an obsm column name; annotators fall back to uns[f"{key}_probabilities_categories" for those.