Result types¶
Frozen dataclasses over numpy arrays.
Frozen result records.
Plain dataclasses over numpy arrays. eq=False because elementwise == on
arrays does not return a bool, so a generated __eq__ would raise.
Tree
dataclass
¶
A rooted tree over the cells.
Leaves are 0..n_leaves in input order; internal nodes follow, ordered
by height above the leaves. Every function in this package that takes a
tree assumes that ordering, so build trees with this package (or
read_newick) rather than by hand.
Attributes:
| Name | Type | Description |
|---|---|---|
parent |
ndarray
|
Parent of each node, |
branch |
ndarray
|
Length of the branch above each node; the root's is ignored. |
n_leaves |
int
|
Number of leaves. |
BonsaiResult
dataclass
¶
BonsaiResult(
tree: Tree,
loglik: float,
features: ndarray,
dropped: ndarray,
node_means: ndarray,
node_sds: ndarray,
steps: list[Step],
)
A finished reconstruction.
Attributes:
| Name | Type | Description |
|---|---|---|
tree |
Tree
|
The tree. Leaf |
loglik |
float
|
Final loglikelihood, meaningful only up to an additive constant. |
features |
ndarray
|
Input column of each retained feature, ascending. For
|
dropped |
ndarray
|
Genes the Sanity conversion dropped as ill-conditioned. Empty
unless the run started from counts. From |
node_means |
ndarray
|
Posterior mean of every node, |
node_sds |
ndarray
|
Posterior standard deviation, same layout. |
steps |
list[Step]
|
The loglikelihood after each search step, in order. |
plot
¶
plot(
*,
kind: Literal[
"daylight", "angle", "dendrogram"
] = "angle",
colours: Sequence[Any] | ndarray | None = None,
ax: Any = None,
figsize: tuple[float, float] = (6.0, 6.0),
) -> tuple[Any, Any]
Draw the tree: leaves scattered over a radial layout, edges as lines.
The look mirrors the comparison harness's tree-layout figure
(reference/comparison/figures.py): grey edges, coloured leaf
points, no axes chrome. Coordinates come from layout, not
recomputed here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
Literal['daylight', 'angle', 'dendrogram']
|
Layout to draw, as |
'angle'
|
colours
|
Sequence[Any] | ndarray | None
|
One value per leaf, in leaf order. Numeric arrays are
mapped through a colormap; anything else is treated as
categorical labels and given a discrete palette. |
None
|
ax
|
Any
|
Axes to draw into. |
None
|
figsize
|
tuple[float, float]
|
Figure size in inches. Ignored if |
(6.0, 6.0)
|
Returns:
| Type | Description |
|---|---|
tuple[Any, Any]
|
The |
Raises:
| Type | Description |
|---|---|
ImportError
|
If matplotlib is not installed. |
ValueError
|
If |
Step
dataclass
¶
What one step of the search bought.
Attributes:
| Name | Type | Description |
|---|---|---|
step |
str
|
Which step, |
loglik |
float
|
Tree loglikelihood after it, up to an additive constant. |
gain |
float
|
Change from the previous step. |
SanityResult
dataclass
¶
SanityResult(
log_fold_changes: ndarray,
error_bars: ndarray,
mean_log_quotient: ndarray,
mean_log_quotient_error: ndarray,
variance: ndarray,
)
Sanity posteriors.
Attributes:
| Name | Type | Description |
|---|---|---|
log_fold_changes |
ndarray
|
Posterior log fold change |
error_bars |
ndarray
|
Posterior SD on each log fold change, same layout. |
mean_log_quotient |
ndarray
|
Per-gene mean log transcription quotient |
mean_log_quotient_error |
ndarray
|
Error bar on |
variance |
ndarray
|
Per-gene variance of the log fold changes |
log_transcription_quotients
property
¶
Normalised expression m + d_c, (n_cells, n_genes).
Likelihood
dataclass
¶
Likelihood(
means: ndarray,
sds: ndarray,
variances: ndarray,
features: ndarray,
dropped: ndarray,
)
Likelihood means and SDs recovered from Sanity posteriors (S5).
Attributes:
| Name | Type | Description |
|---|---|---|
means |
ndarray
|
|
sds |
ndarray
|
Same layout. |
variances |
ndarray
|
Sanity's |
features |
ndarray
|
Input column of each kept gene. |
dropped |
ndarray
|
Input columns dropped as ill-conditioned. |
Clustering
dataclass
¶
A cut of the tree into clusters.
Attributes:
| Name | Type | Description |
|---|---|---|
leaf_cluster |
ndarray
|
Cluster of each leaf, numbered by decreasing size. |
centres |
ndarray
|
Representative node of each cluster. |
sizes |
ndarray
|
Leaves per cluster. |
SimulatedData
dataclass
¶
SimulatedData(
tree: Tree,
truth: ndarray,
means: ndarray,
sds: ndarray,
variances: ndarray,
)
Brownian motion on a known tree.
Attributes:
| Name | Type | Description |
|---|---|---|
tree |
Tree
|
The generating tree. |
truth |
ndarray
|
Noise-free leaf positions, |
means |
ndarray
|
Observed means, truth plus noise. |
sds |
ndarray
|
Error bars on the means. |
variances |
ndarray
|
Per-feature variance the data was scaled by. |
SimulatedCounts
dataclass
¶
SimulatedCounts(
tree: Tree, counts: ndarray, cell_totals: ndarray
)
UMI counts drawn on a known tree.
Attributes:
| Name | Type | Description |
|---|---|---|
tree |
Tree
|
The generating tree. |
counts |
ndarray
|
|
cell_totals |
ndarray
|
The library size each cell was drawn with. Pass these, not the row sums: with a few hundred high-variance genes the row sums carry a per-cell compositional shift that costs the tree. |