mkt.databases.cancer_hotspots.CancerHotspots
- class mkt.databases.cancer_hotspots.CancerHotspots[source]
Bases:
objectHarmonize cancerhotspots.org publication tiers into one annotated table.
Combines the Chang (
v2) and Bandlamudi 2026 (v3) queries and, becausev2is a strict subset ofv3, builds a single DataFrame (_df) from thev3superset with a row-levelTIER_COLUMNannotation: each record is labelledHotspotTier.CHANGif its(hugoSymbol, residue)also appears inv2, otherwiseHotspotTier.BANDLAMUDI. This is the main entry point; the per-versionCancerHotspotsQueryobjects remain available viaquery_chang/query_bandlamudifor provenance (query_datetime/from_cache).The row-level annotation is residue-keyed, so the Bandlamudi 2026 tier holds the 164
(gene, residue)pairs reported by cancerhotspots.org. For a position-keyed collapse (e.g. coloring a lollipop x-axis), usefirst_occurrence_map(), which yields 161 — see its docstring.- __init__(*args: Any, **kwargs: Any) None
Methods
__eq__(other)Return self==value.
__post_init__()Annotate the v3 superset with a row-level publication tier.
first_occurrence_map([single_residue_only])Map
(hugoSymbol, positionStart)to the earliest hotspot tier.from_csv(path)Build a client from a CSV written by
to_csv(), without querying.from_dataframe(df)Build a client from an already-harmonized table without querying the API.
get_gene(hugo_symbol)Return tier-annotated hotspot records for a single gene.
read_csv(path)Read a harmonized table written by
to_csv()back into a DataFrame.to_csv(path)Write the harmonized table to CSV, json-encoding dict-valued columns.
Attributes
__dataclass_fields____dataclass_params____match_args____pydantic_config__Harmonized, tier-annotated DataFrame (one row per
v3record).- property df: DataFrame | None
Harmonized, tier-annotated DataFrame (one row per
v3record).
- first_occurrence_map(single_residue_only: bool = False) dict[tuple[str, int], str][source]
Map
(hugoSymbol, positionStart)to the earliest hotspot tier.Collapses the residue-level
dfto one label per residue position:HotspotTier.CHANGif any record at that position is in the Chang tier, otherwiseHotspotTier.BANDLAMUDI. Positions absent from both tiers are simply not keyed (treat as “not a hotspot”).This keys on position rather than the full
residuestring because the downstream lollipop colors residue positions on its x-axis. As a result the Bandlamudi 2026 tier holds 161 positions, not the 164 new(gene, residue)pairs indf: three v3-only residues (FOXA1 D249, MTOR Y1450, TP53 E224) sit at positions already called in v2, so they collapse into existing Chang positions. Usedf(residue level) if you need the headline 164.- Parameters:
single_residue_only (bool, optional) – If True, exclude in-frame indel records (
type != "single residue") before collapsing, so the map only covers single-residue hotspots. Default False (all records).- Returns:
Mapping of
(hugoSymbol, positionStart)to aHotspotTiervalue; empty if the harmonized table is unavailable.- Return type:
dict[tuple[str, int], str]
- classmethod from_csv(path: str) CancerHotspots[source]
Build a client from a CSV written by
to_csv(), without querying.- Parameters:
path (str) – Path to a CSV previously written by
to_csv().- Returns:
Instance backed by the cached table.
- Return type:
- classmethod from_dataframe(df: DataFrame) CancerHotspots[source]
Build a client from an already-harmonized table without querying the API.
Bypasses
__post_init__(which would issue the per-tier network queries) viaobject.__new__and sets_dfdirectly, so cached data can be reloaded offline. The per-tier provenance objects (query_chang/query_bandlamudi) are set to None.- Parameters:
df (pd.DataFrame) – Tier-annotated table (e.g. from
read_csv()ordf).- Returns:
Instance backed by
df;get_gene()andfirst_occurrence_map()work as usual.- Return type:
- get_gene(hugo_symbol: str) DataFrame[source]
Return tier-annotated hotspot records for a single gene.
- Parameters:
hugo_symbol (str) – HGNC gene symbol to filter on (e.g.
"BRAF").- Returns:
Rows of
dfwhosehugoSymbolmatches; empty if none.- Return type:
pd.DataFrame