ecotyper.io

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

The readers reproduce how the R scripts read the same files (read.delim for bulk/Visium matrices and annotations, data.table::fread for scRNA-seq matrices), including R’s number parsers, so that a Python run starts from bit-identical values.

Functions

annotation_from_anndata(adata)

from_anndata(adata[, layer])

AnnData → genes x samples DataFrame (dense).

read_annotation(path)

read.delim(annotation); None if path is None/"NULL"/missing.

read_bulk_matrix(path)

read.delim(path); rownames(data) = data[,1]; data = data[,-1].

read_fractions(path)

CIBERSORTx fractions (read_fractions in lib/misc.R): columns up to (excluding) P.value are kept.

read_scrna_matrix(path)

fread(path, data.table = F), then drop NA and duplicated gene names (read_scRNA in lib/scRNA.R).

to_anndata(expr[, annotation])

Genes x samples DataFrame (+ annotation with an ID column) → AnnData with samples/cells as obs and genes as var.

ecotyper.io.read_bulk_matrix(path)[source]

read.delim(path); rownames(data) = data[,1]; data = data[,-1].

Returns a genes x samples DataFrame; sample names go through make.names as in R (check.names = TRUE).

Return type:

DataFrame

ecotyper.io.read_scrna_matrix(path)[source]

fread(path, data.table = F), then drop NA and duplicated gene names (read_scRNA in lib/scRNA.R). Column names are kept verbatim.

Return type:

DataFrame

ecotyper.io.read_annotation(path)[source]

read.delim(annotation); None if path is None/”NULL”/missing.

Return type:

DataFrame | None

ecotyper.io.read_fractions(path)[source]

CIBERSORTx fractions (read_fractions in lib/misc.R): columns up to (excluding) P.value are kept.

Return type:

DataFrame

ecotyper.io.to_anndata(expr, annotation=None)[source]

Genes x samples DataFrame (+ annotation with an ID column) → AnnData with samples/cells as obs and genes as var.

Parameters:
ecotyper.io.from_anndata(adata, layer=None)[source]

AnnData → genes x samples DataFrame (dense).

Parameters:

layer (str | None)

Return type:

DataFrame

ecotyper.io.annotation_from_anndata(adata)[source]
Return type:

DataFrame