Inputs and data
Inputs
Samples
Read mutations into a 96-channel table (.df, with total_snvs): a MAF, a VCF, a list or folder of VCFs, or a matrix.
sg2.Samples(input, ref_genome="hg19", verbose=None, indels=None, beds=None, types=None) -> Samples
| Parameter | Description | Default |
|---|---|---|
| inputpath or str or DataFrame | The mutations: a MAF path, a VCF path, a folder of VCFs, or a DataFrame of SBS-96 counts. | Required |
| verboseint | 0 prints errors and some warnings; 1 also reports the samples read. | None |
| ref_genomepath or str | The build of the coordinates (hg19, hg38) or a FASTA path. | 'hg19' |
| min_del_sizeint | The smallest deletion counted for the indel features. | None |
| min_mh_sizeint | The smallest microhomology counted as microhomology-mediated. | None |
| fixbool | Repair known formatting faults of the input (TRUE for T, chromosome 23 and 24) while reading. | True |
| flank_formatFlankFormat | How the trinucleotide flanks are spelled in the 96 channels; the package's default. | <MXYN> |
| typeslist of str | Restrict the variant types read. | None |
| indelsVCF | Indels from a separate VCF. | None |
| bedslist of BED | Repeat-locus BED files of another build. | None |
Internal parameters (2)
| loggerLogger | Internal: the logger the object reports through. | None |
| warningslist of str | Internal: a list the reader's warnings are appended to. | None |
Returns A Samples object: .df is the 96-channel table with total_snvs, one row per sample.
A folder names each sample by file name without the extension.
spectra = sg2.Samples("test_mutations_50sample.maf", ref_genome="hg19").df.iloc[:, :96]
spectra.to_csv("spectra.csv")
out = sg2.run(input="spectra.csv", tumor_type="breast", seq_type="msk", soi="SBS3")
Used in 1. Prepare your input files, Train a classifier, Worked example: train on your own genomes
MAF, VCF, CSV, BED, SeqType
The file objects behind input.
sg2.MAF(path); sg2.VCF(path); sg2.CSV(path); sg2.BED(path, name); sg2.SeqType(path, name)
sg2.SeqType.options() # the platform names
sg2.SeqType.from_name("msk") # a bundled platform with its regions
SeqType(path, name) is a platform with your own BED under a vocabulary name.
Reference data
get
Read-only access to the package's tables: "sig_catalogs/cosmic_v3p2_inhouse", "indices/tumor_types", "sigs_per_tissue", "cosmic_catalogs/<catalog>" ("cosmic_catalogs/cosmic_v2"), "snv_counts", "mva_cutoffs", "tumor_sig_catalogs/<tumor type>" ("tumor_sig_catalogs/breast"). A key with a literal * returns None.
sg2.get(key, file_name=None)
| Parameter | Description | Default |
|---|---|---|
| keystr | The table's key in the package data, such as "sig_catalogs/cosmic_v3p2_inhouse" or "indices/tumor_types". | Required |
| file_namestr | Another data file than the package's data.h5. | None |
Returns A DataFrame, or a dict of DataFrames, from the package's reference tables.
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
set and clear
Your own tables in sysdata/custom.h5, for advanced use.
sg2.set(key, data, verbose=0) -> bool
sg2.clear() -> bool
Returns bool. clear() asks on the terminal, "Are you sure you want to delete all non-default files?", and deletes only on y; in a script it waits for that answer.
Legacy
legacy_store.available
SigMA v1's grid as a table.
sg2.legacy_store.available() -> DataFrame
Returns DataFrame.
The classifiers run through run(model="legacy") and predict_mmrd_ppd(model="legacy") (Reproduce SigMA v1).
Removed and deprecated
sg2.tune() and Tune were removed and raise an error pointing to Add. Samples.from_df is deprecated and warns. apply_json and extend_soi are aliases of apply and extend. sg2.quick_simulation is on SigMA v1 tools.
Used in Reproduce SigMA v1