API reference

Most users only need the scverse API (ecotyper.recovery(), ecotyper.discovery(), ecotyper.EcoTyperModel). ecotyper.workflows mirrors the R wrapper scripts on pandas objects and files, and ecotyper.io reads the R pipeline’s input files. The other modules expose each step of the R pipeline as a function, for custom pipelines and for checking intermediate results against R.

scverse API

recovery

Recover cell states and ecotypes defined by model in new data.

discovery

Discover cell states and ecotypes; returns an in-memory EcoTyperModel.

infer_data_type

Guess the data type of adata.

EcoTyperModel

A discovery result: chosen ranks, per-cell-type states and ecotypes.

File-based and pandas workflows

Recovery

recover_bulk

Recover cell states and ecotypes in bulk samples (adata: samples x genes).

recover_bulk_frame

Bulk recovery on a genes x samples DataFrame (values as read by R).

recover_bulk_files

File-based equivalent of Rscript EcoTyper_recovery_bulk.R -m matrix -a annotation.

recover_scrna

Recover cell states in single cells (adata: cells x genes, raw-scale expression; obs must have CellType and, for ecotypes, Sample).

recover_scrna_frame

scRNA-seq recovery on a genes x cells DataFrame (fread semantics) and a cell annotation with ID, CellType and optionally Sample.

recover_scrna_files

File-based equivalent of Rscript EcoTyper_recovery_scRNA.R.

read_visium

spatial_load_visium_data.R: 10x Visium folder → (genes x spots counts, spot annotation with ID, X (array row), Y (array col)).

recover_visium_frame

Returns (state_results, state_abundances_long, state_abundances, ecotype_abundances).

recover_visium_files

File-based equivalent of Rscript EcoTyper_recovery_visium.R -c config.yml with precomputed fractions.

ecotype_abundances_long

melt(ecotype_data, id.vars = c("ID", "X", "Y", "Sample", "Malignant")).

Discovery

discover_from_profiles

Cell state + ecotype discovery from per-cell-type expression profiles (EcoTyper_discovery_bulk.R steps 3–6 and 8 with CSx HiRes profiles as input, or EcoTyper_discovery_presorted.R with "no filter").

discover_files

File-based discovery from a folder of per-cell-type profiles (CSx HiRes output or presorted profiles) and a sample annotation file.

read_profiles

Per-cell-type profiles <input_dir>/<cell type>.txt (read.delim(row.names = 1)).

write_discovery

Write the R layout <out_dir>/EcoTyper/<name>/<fractions>/....

discover_scrna

scRNA-seq discovery on AnnData (cells x genes, raw-scale expression; obs with CellType and Sample).

discover_scrna_frame

EcoTyper_discovery_scRNA.R on a genes x cells matrix (fread semantics) and a cell annotation with ID, CellType and Sample.

write_discovery_scrna

Write the R layout of a scRNA discovery run.

DiscoveryResult

Results of a discovery run (attribute access to the dict keys).

Modules

ecotyper.api

scverse-style entry points: recovery(), discovery(), infer_data_type().

ecotyper.workflows

High-level workflows mirroring the R wrapper scripts.

ecotyper.io

Readers for EcoTyper's user-facing inputs and conversion to AnnData.

ecotyper.builtin

The prebuilt EcoTyper models (Carcinoma, Lymphoma) by name.

ecotyper.model

EcoTyper discovery results ("models") in the R directory layout.

ecotyper.recovery_steps

Cell state and ecotype recovery (pipeline/state_recovery_*.R, ecotypes_recovery*.R, spatial_states.R, spatial_ecotypes.R).

ecotyper.discovery_steps

Cell state and ecotype discovery from purified (CIBERSORTx HiRes) or presorted profiles: state_discovery_*.R, ecotypes.R, ecotypes_assign_samples.R (bulk and presorted discovery wrappers).

ecotyper.discovery_scrna

scRNA-seq discovery (EcoTyper_discovery_scRNA.R):

ecotyper.nmf

Port of the parts of the R package NMF (v0.28) that EcoTyper uses.

ecotyper.rlayout

Write results in the R pipeline's directory layout and file formats (write.table(x, sep = "\t")), so outputs can be diffed with R's.

ecotyper.validate

Compare output trees of the Python port with the R pipeline's.

ecotyper.cli

ecotyper-py command line, mirroring the R wrapper scripts.

ecotyper.rcompat

R semantics needed for exact parity: RNG and sample, number parsing and formatting, hclust/cutree/dist/silhouette, cor/var/mean with R's long-double accumulation, quantiles, BH, t-test, Wilcoxon, string collation, merge/order.