spacr.localisation

Protein-localization metadata for compartment-aware figure colouring.

Interactive volcano plots can highlight genes from one selected LOPIT compartment while leaving the remaining genes grey.

Figures highlight one selected compartment against grey to keep the comparison legible. Coefficient feature names are resolved to bare gene identifiers with spacr.hits.gene_of() before joining the bundled TAGM/LOPIT table.

Functions

mask(frame, compartment, *[, key_column])

A boolean Series: which rows are in compartment.

of(frame, *[, key_column])

The compartment of each row of frame, as a Series aligned to it.

present(→ List[str])

The compartments this screen actually has, commonest first.

table(→ Dict[str, str])

{gene number: compartment} from the bundled TAGM/LOPIT table.

Module Contents

spacr.localisation.mask(frame, compartment: str | None, *, key_column: str = 'feature')[source]

A boolean Series: which rows are in compartment.

Parameters:
  • frame – table whose feature names are classified and whose index is preserved on the returned boolean Series.

  • compartmentNone or "" selects nothing, which is the right answer for “no compartment chosen” and lets a caller pass the menu’s state straight through without a branch.

spacr.localisation.of(frame, *, key_column: str = 'feature')[source]

The compartment of each row of frame, as a Series aligned to it.

Parameters:

frame – result frame whose feature identifiers are to be looked up.

Returns:

a pandas Series of compartment names, empty string where the gene is not in the table.

Joined through spacr.hits.gene_of(), which is the one place that knows how a design term names a gene. Both the per-gene and the per-guide rows resolve, because a guide’s gene is where its protein lives too.

spacr.localisation.present(frame, *, key_column: str = 'feature', minimum: int = MIN_GENES) List[str][source]

The compartments this screen actually has, commonest first.

Parameters:

frame – result frame whose represented compartments are to be counted.

NOT ALL 27. A menu listing every compartment in the reference table offers the user 22 choices that would colour nothing, and a choice that colours nothing is indistinguishable from a broken one.

spacr.localisation.table() Dict[str, str][source]

{gene number: compartment} from the bundled TAGM/LOPIT table.

Cached: the file is 3,832 rows and is read to build a right-click menu, which happens on the GUI thread every time the user opens one.

Returns:

an empty dict when the table is missing, never raising – a volcano is still a volcano without compartment colouring, and a screen of a different organism has no reason to carry this file.