Skip to content

scdecon.plotting

plotting

Plotting: figures rendered from scdecon results.

This layer depends on the computational core (it consumes core outputs such as a signature DataFrame), but the core never depends on plotting. matplotlib and seaborn live only here.

plot_benchmark

plot_benchmark(result: BenchmarkResult, path: str | Path, *, metric: str = 'overall_rmse', title: str | None = None) -> Path

Render a bar chart comparing solvers on a benchmark metric.

Parameters:

Name Type Description Default
result BenchmarkResult

The :class:~scdecon.deconvolution.BenchmarkResult to plot. Solver names are used exactly as recorded.

required
path str | Path

Destination image path. Missing parent directories are created.

required
metric str

Column of result.to_frame() to plot (e.g. "overall_rmse", "mean_pearson", "runtime_s").

'overall_rmse'
title str | None

Optional figure title.

None

Returns:

Type Description
Path

The path that was written.

Raises:

Type Description
ValueError

If the result is empty or metric is not a benchmark column.

plot_signature_heatmap

plot_signature_heatmap(signature: DataFrame, path: str | Path, *, title: str | None = None) -> Path

Render a genes-by-cell-types signature heatmap and save it to path.

Parameters:

Name Type Description Default
signature DataFrame

Signature matrix (genes x cell types), as returned by :func:scdecon.signature.build_signature. Not modified.

required
path str | Path

Destination image path (e.g. .png). Missing parent directories are created.

required
title str | None

Optional figure title.

None

Returns:

Type Description
Path

The path that was written.

Raises:

Type Description
ValueError

If signature is empty.

plot_truth_vs_prediction

plot_truth_vs_prediction(truth: DataFrame, prediction: DataFrame, path: str | Path, *, title: str | None = None) -> Path

Render a truth-vs-prediction scatter grid (one panel per cell type).

Each panel plots true (x) against predicted (y) proportions across samples, with a y = x reference line and [0, 1] axes.

Parameters:

Name Type Description Default
truth DataFrame

Ground-truth proportions, cell types (index) x samples (columns).

required
prediction DataFrame

Estimated proportions, same orientation and labels as truth.

required
path str | Path

Destination image path. Missing parent directories are created.

required
title str | None

Optional overall figure title.

None

Returns:

Type Description
Path

The path that was written.

Raises:

Type Description
ValueError

If the inputs cannot be aligned (see :func:scdecon.validation.align_proportions).