ecotyper.model¶
EcoTyper discovery results (“models”) in the R directory layout.
A model is the folder EcoTyper/<discovery>/<fractions>/ written by the R
discovery wrappers (the prebuilt Carcinoma and Lymphoma models ship in this
layout) or by ecotyper.workflows. Only the files used by recovery are
loaded; numbers are parsed with R’s own read.delim number parser so that
recovery starts from exactly the values R sees.
Functions
|
Levels of |
|
|
|
|
|
|
|
Write the files recovery reads from a discovery result into |
Classes
|
Cell states of one cell type ( |
|
A discovery result: chosen ranks, per-cell-type states and ecotypes. |
- class ecotyper.model.CellTypeModel(cell_type, n_states, W, mapping, initial_gene_info, gene_info=None, heatmap_genes=None, path=None)[source]¶
Bases:
objectCell states of one cell type (
Cell_States/discovery/<ct>/<rank>).- Parameters:
- class ecotyper.model.EcoTyperModel(name, fractions, rank_data, cell_types=<factory>, ecotypes=None, path=None, discovery_result=None)[source]¶
Bases:
objectA discovery result: chosen ranks, per-cell-type states and ecotypes.
Get one from
ecotyper.discovery(),load()(a saved model, an R discovery folder, or a built-in model by name:"Carcinoma","Lymphoma") and pass it toecotyper.recovery().save()writes the files recovery needs in the R layout, so a saved model can be used by both this package and the R scripts.- Parameters:
- discovery_result: object | None = None¶
full in-memory discovery result (
ecotyper.workflows.DiscoveryResult) when the model comes fromecotyper.discovery(); not saved
- classmethod from_discovery(result, name='custom', fractions=None)[source]¶
Model from an in-memory discovery result (
discover_from_profiles/discover_scrna_frame).The R pipeline hands discovery results to recovery through text files (15 significant digits). To stay exact, the model tables take the same text round trip here (through a temporary folder that is removed again), so recovery with this model equals recovery with the model written by the file-based workflow.
- Parameters:
- Return type:
- save(path, *, heatmap=True)[source]¶
Write the model to
path(the R<discovery>/<fractions>folder layout).Load it back with
EcoTyperModel.load(path). Withheatmapthe (large)heatmap_data.txt/heatmap_top_ann.txtfiles that the R recovery scripts use for their heatmap plots are written too, when available.
- classmethod load(root, discovery=None, fractions=None)[source]¶
Load a model.
load("Carcinoma")/load("Lymphoma"): a built-in model (seeecotyper.builtin; downloaded and cached on first use);load(path): a folder written bysave()or an REcoTyper/<discovery>/<fractions>folder (containsAnalysis/);load(root, discovery, fractions):<root>/<discovery>/<fractions>(fractionsdefaults to<discovery>_Fractions).
- Parameters:
- Return type:
- ecotyper.model.model_ecotypes_table(result)[source]¶
ecotypes.txtas written by the discovery workflow (the scRNA variant has R’s extraCell typecolumn, ecotypes_scRNA.R:152).- Return type:
- ecotyper.model.write_model_files(result, base, *, heatmap=True)[source]¶
Write the files recovery reads from a discovery result into
base(<discovery>/<fractions>), byte-identical to the corresponding files ofecotyper.workflows.write_discovery()/write_discovery_scrna.