scdecon.signature¶
signature ¶
Signature construction: marker selection and signature-matrix assembly.
This layer operates purely on in-memory AnnData objects and pandas structures;
it performs no file I/O of its own (saving is the caller's responsibility via
:mod:scdecon.io).
MarkerSelector ¶
Bases: ABC
Abstract strategy for selecting cell-type marker genes.
select
abstractmethod
¶
Return specific marker genes per cell type.
MarkerSet
dataclass
¶
Type-specific marker genes, one ordered tuple per cell type.
RankGenesGroupsSelector ¶
RankMethod ¶
Bases: StrEnum
Differential-expression method for Scanpy rank_genes_groups.
StrEnum members are plain strings, so they pass directly to Scanpy and
serialise as their value (e.g. "wilcoxon").
SignatureConfig
dataclass
¶
SignatureConfig(cell_type_key: str = 'cell_type', n_markers_per_type: int = 25, method: RankMethod = RankMethod.WILCOXON, min_cells_per_type: int = 2)
Immutable configuration for marker selection and signature construction.
Attributes:
| Name | Type | Description |
|---|---|---|
cell_type_key |
str
|
Column in |
n_markers_per_type |
int
|
Number of top-ranked marker genes to take per cell type before the cross-type specificity filter. |
method |
RankMethod
|
Differential-expression ranking method (:class: |
min_cells_per_type |
int
|
Minimum number of cells a cell type must have; below this, ranking is unreliable and selection fails loudly. |
build_signature ¶
Build a signature matrix of linear-scale mean profiles.
The signature frame obeys this contract:
- index = the marker genes, in exactly
markers.genes()order. This ordering is part of the public contract and is reproducible. - columns = the reference cell types, sorted deterministically.
- values = per-cell-type mean of
expm1(adata.X)over the marker genes (linear scale); finite and non-negative.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Log-normalised reference data (as produced by
:mod: |
required |
markers
|
MarkerSet
|
Marker genes per cell type; |
required |
config
|
SignatureConfig
|
Supplies |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Genes (index, |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
select_markers ¶
select_markers(adata: AnnData, config: SignatureConfig, selector: MarkerSelector | None = None) -> MarkerSet
Select cell-type markers using selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adata
|
AnnData
|
Log-normalised single-cell data. |
required |
config
|
SignatureConfig
|
Marker-selection parameters. |
required |
selector
|
MarkerSelector | None
|
Strategy to use. Defaults to :class: |
None
|
Returns:
| Type | Description |
|---|---|
MarkerSet
|
Deduplicated, type-specific markers. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |