Models and the store
models
Installed model names ('breast/SBS3/msk', 'experimental/prost/SBS3/op'), optionally filtered; root_dir reads another store.
sg2.models(tumor_type=None, soi=None, seq_type=None, root_dir=None) -> list[str]
| Parameter | Description | Default |
|---|---|---|
| tumor_typestr | Keep the models of this tumor type. | None |
| soistr | Keep the models of this signature. | None |
| seq_typestr | Keep the models of this platform. | None |
| root_dirstr | A store of your own to list instead of the data directory's. | None |
Returns A list of installed model names, tumor_type/soi/seq_type, with experimental/ in front of a withheld cell.
import sigma2 as sg2
from sigma2 import classifiers
# Card(tumor_type, classifier, seq_type, kind, status, verified, trained, snv_cutoff)
cards = classifiers.cards(tumor_type="breast")
released = [c for c in cards if c.kind == "signature" and c.status != "experimental"]
names = sg2.models(tumor_type="breast", seq_type="msk")
covered = sg2.hrd_model("msk").covered_tumor_types()
platforms = classifiers.mmrd_platforms()
# ['fo', 'msk', 'op', 'seqcap', 'tcga_mc3']
tumor_types = sg2.get("indices/tumor_types")
seq_types = sg2.SeqType.options()
Used in For AI agents, Manage models and the store
model
Load a classifier by name or by parts.
sg2.model(name=None, root_dir=None, tumor_type=None, soi=None, seq_type=None) -> GBMModel
| Parameter | Description | Default |
|---|---|---|
| namestr | The cell as <tumor_type>/<soi>/<seq_type>, in any case; or give the three parts as keywords. | None |
| root_dirstr | A store of your own to load from instead of the data directory's. | None |
| tumor_typestr | The tumor type, when the cell is given as parts. | None |
| soistr | The signature, when the cell is given as parts. | None |
| seq_typestr | The platform, when the cell is given as parts. | None |
Returns A GBMModel: name, path, config (the card as a dict), meta (the tuner's record), centroids; pass it as run(model=).
A GBMModel has name, path, config (the card as a dict), meta (the tuner's record) and centroids; pass it as run(model=...).
m = sg2.model("breast/SBS3/msk")
out = sg2.run(
input="test_mutations_50sample.maf",
ref_genome="hg19",
tumor_type="breast",
seq_type="msk",
soi="SBS3",
model=m,
)
Used in 2. Detect a signature (SBS3, APOBEC, any other), Train a classifier, Worked example: train on your own genomes, Manage models and the store
verify_model
True when the model's files match the SHA-256 in its meta.json; ValueError on a mismatch.
sg2.verify_model(name=None, tumor_type=None, soi=None, seq_type=None, root_dir=None) -> bool
| Parameter | Description | Default |
|---|---|---|
| namestr | The cell as <tumor_type>/<soi>/<seq_type>; or give the three parts as keywords. | None |
| tumor_typestr | The tumor type, when the cell is given as parts. | None |
| soistr | The signature, when the cell is given as parts. | None |
| seq_typestr | The platform, when the cell is given as parts. | None |
| root_dirstr | A store of your own instead of the data directory's. | None |
Returns True when the model's files match their recorded SHA-256; ValueError on a mismatch.
m = sg2.model("breast/SBS3/msk") # by name, any case
m = sg2.model(tumor_type="breast", soi="SBS3", seq_type="msk") # by parts
# True, or ValueError on a checksum mismatch
sg2.verify_model("breast/SBS3/msk")
Used in Manage models and the store
delete_model
Remove one of your own models from the store.
sg2.delete_model(name=None, tumor_type=None, soi=None, seq_type=None, root_dir=None, force=False)
| Parameter | Description | Default |
|---|---|---|
| namestr | The cell as <tumor_type>/<soi>/<seq_type>; or give the three parts as keywords. | None |
| tumor_typestr | The tumor type, when the cell is given as parts. | None |
| soistr | The signature, when the cell is given as parts. | None |
| seq_typestr | The platform, when the cell is given as parts. | None |
| root_dirstr | A store of your own instead of the data directory's. | None |
| forcebool | Delete without a confirmation prompt. | False |
Returns list of the names of the models deleted; each one's directory is removed from the store.
Used in Manage models and the store
models.migrate
Move a store that still holds weights a release retired (retired.json).
sg2.models.migrate(dry_run=True, root_dir=None)
| Parameter | Description | Default |
|---|---|---|
| dry_runbool | True reports what would change; False moves the store's retired weights. | True |
| root_dirstr | A store of your own instead of the data directory's. | None |
Returns DataFrame, one row per stored model the package has retired: name, stored_hash, action, reason, retired_in, path. dry_run=False applies each row and adds a done column; a retired copy is replaced by the package's model or moved to <store>/retired/, never deleted, and a model you trained is never touched.
dry_run=True reports; False applies.
sg2.models.migrate(dry_run=True)
Used in Manage models and the store
classifiers.cards
Every installed cell as data.
from sigma2 import classifiers
classifiers.cards(root_dir=None, tumor_type=None, classifier=None, seq_type=None) -> list[Card]
| Parameter | Description | Default |
|---|---|---|
| root_dirstr | A store of your own to list; HRD and MMRD/POLE models ship with the package. | None |
| tumor_typestr | Keep the cards of this tumor type. | None |
| classifierstr | Keep the cards of this signature (or HRD, MMRD). | None |
| seq_typestr | Keep the cards of this platform. | None |
Returns A list of Cards, one per installed cell: tumor_type, classifier, seq_type, kind, status, verified, trained, snv_cutoff.
A Card has tumor_type, classifier, seq_type, kind (signature, hrd, mmrd), status (released, weak, experimental), verified, trained, snv_cutoff.
import sigma2 as sg2
from sigma2 import classifiers
# Card(tumor_type, classifier, seq_type, kind, status, verified, trained, snv_cutoff)
cards = classifiers.cards(tumor_type="breast")
released = [c for c in cards if c.kind == "signature" and c.status != "experimental"]
names = sg2.models(tumor_type="breast", seq_type="msk")
covered = sg2.hrd_model("msk").covered_tumor_types()
platforms = classifiers.mmrd_platforms()
# ['fo', 'msk', 'op', 'seqcap', 'tcga_mc3']
tumor_types = sg2.get("indices/tumor_types")
seq_types = sg2.SeqType.options()
Used in 2. Detect a signature (SBS3, APOBEC, any other), For AI agents, Manage models and the store, Release status
classifiers.mmrd_platforms
The platforms with a SigMA2 MMRD/POLE model: fo, msk, op, seqcap, tcga_mc3.
from sigma2 import classifiers
classifiers.mmrd_platforms() -> list[str]
Returns The platforms with a SigMA2 MMRD/POLE model, as a list of names.
import sigma2 as sg2
from sigma2 import classifiers
# Card(tumor_type, classifier, seq_type, kind, status, verified, trained, snv_cutoff)
cards = classifiers.cards(tumor_type="breast")
released = [c for c in cards if c.kind == "signature" and c.status != "experimental"]
names = sg2.models(tumor_type="breast", seq_type="msk")
covered = sg2.hrd_model("msk").covered_tumor_types()
platforms = classifiers.mmrd_platforms()
# ['fo', 'msk', 'op', 'seqcap', 'tcga_mc3']
tumor_types = sg2.get("indices/tumor_types")
seq_types = sg2.SeqType.options()
Used in For AI agents