BLPlot package

Submodules

BLPlot.PlotAUPRC module

class BLPlot.PlotAUPRC.PlotAUPRC[source]

Bases: Plotter

Plotter that produces one AUPRC graphic per dataset.

For datasets with a single run a precision-recall curve is drawn (one line per algorithm). For datasets with multiple runs a box plot is drawn (one box per algorithm, distribution across runs). Each dataset is written as both a PDF and PNG under an AUPRC/ subdirectory of the output directory, named <dataset_label>-AUPRC.pdf and <dataset_label>-AUPRC.png.

BLPlot.PlotAUROC module

class BLPlot.PlotAUROC.PlotAUROC[source]

Bases: Plotter

Plotter that produces one AUROC graphic per dataset.

For datasets with a single run a ROC curve is drawn (one line per algorithm). For datasets with multiple runs a box plot is drawn (one box per algorithm, distribution across runs). Each dataset is written as both a PDF and PNG under an AUROC/ subdirectory of the output directory, named <dataset_label>-AUROC.pdf and <dataset_label>-AUROC.png.

BLPlot.PlotEPR module

class BLPlot.PlotEPR.PlotEPR[source]

Bases: Plotter

Plotter that produces one early precision box plot per dataset.

For each dataset, reads EarlyPrecision.csv and draws a box plot with one box per algorithm showing the distribution across runs. A dashed reference line marks the random-predictor EPR baseline. Each dataset is written as both a PDF and PNG under an EPR/ subdirectory of the output directory, named <dataset_label>-EPR.pdf and <dataset_label>-EPR.png.

BLPlot.PlotEPRHeatmap module

class BLPlot.PlotEPRHeatmap.PlotEPRHeatmap[source]

Bases: Plotter

Replicates Figure 4 of Pratapa et al. 2020 (BEELINE).

Produces a four-section heatmap: median AUPRC ratio, median EPR ratio, median EPR for activating edges, and median EPR for inhibitory edges. Algorithms (rows) are sorted by decreasing median AUPRC ratio. Each section uses a distinct colour palette; cells below the random-predictor cutoff are shown in dark grey. Writes EPRSummary.pdf to the output directory.

BLPlot.PlotSummaryHeatmap module

class BLPlot.PlotSummaryHeatmap.PlotSummaryHeatmap[source]

Bases: Plotter

Replicates Figure 2 of Pratapa et al. 2020 (BEELINE).

Produces a two-section heatmap: median AUPRC ratios (left) and median Spearman stability scores (right). Algorithms (rows) are sorted by decreasing median AUPRC ratio; datasets are columns. Each cell contains a rounded square sized and colored by its value. Values above the random predictor baseline (ratio >= 1) are drawn full-size with their raw value as white text. Alternating row backgrounds aid readability. Writes Summary.pdf to the output directory.

BLPlot.plotter module

class BLPlot.plotter.Plotter[source]

Bases: ABC

Abstract base class for BEELINE plot generators.

Each subclass implements __call__ to read pre-computed evaluation CSVs and write one or more plot files to a caller-specified output directory. Shared loading and rendering helpers are provided as module-level functions in this module: iter_datasets, iter_datasets_with_runs, load_dataset_metric, make_box_figure, random_classifier_baseline.

BLPlot.plotter.get_algo_ids(config: dict) List[str][source]

Return the list of enabled algorithm IDs from the config.

Parameters:

config (dict) – Parsed YAML configuration.

Returns:

Algorithm IDs whose should_run flag is truthy.

Return type:

list[str]

BLPlot.plotter.iter_datasets(config: dict, root: Path) Iterator[Tuple[str, str, Path, Path]][source]

Yield (dataset_id, dataset_label, dataset_path, gt_path) for each enabled dataset in config.

Parameters:
  • config (dict) – Parsed YAML configuration.

  • root (Path) – Working directory from which config paths are resolved.

Yields:

tuple of (str, str, Path, Path) – dataset_id, dataset_label (nickname if set else dataset_id), output dataset directory, ground truth file path.

BLPlot.plotter.iter_datasets_with_runs(config: dict, root: Path) Iterator[Tuple[str, str, Path, Path, list]][source]

Yield (dataset_id, dataset_label, dataset_path, gt_path, runs) for each enabled dataset.

Extends iter_datasets by also yielding the raw list of run dicts from the config, so callers can determine run count and resolve per-run paths via dataset_path / run[‘run_id’].

Parameters:
  • config (dict) – Parsed YAML configuration.

  • root (Path) – Working directory from which config paths are resolved.

Yields:

tuple of (str, str, Path, Path, list) – dataset_id, dataset_label (nickname if set else dataset_id), output dataset directory, ground truth file path, list of run dicts from config (each has at least ‘run_id’).

BLPlot.plotter.load_dataset_metric(dataset_path: Path, metric_csv: str) Dict[str, List[float]][source]

Load per-algorithm metric values from one dataset’s pre-computed CSV.

The CSV is expected to have rows = algorithms (index column) and columns = run_ids. Returns an empty dict (with a warning) if the file is missing.

Parameters:
  • dataset_path (Path) – Output directory for the dataset (contains the metric CSV).

  • metric_csv (str) – Filename of the metric CSV (e.g. ‘AUPRC.csv’).

Returns:

Algorithm name -> list of non-NaN run values for this dataset.

Return type:

dict[str, list[float]]

BLPlot.plotter.make_box_figure(values: Dict[str, List[float]], title: str, ylabel: str, rand_value: float = None, ylim: Tuple[float, float] | None = (0.0, 1.0)) plt.Figure | None[source]

Create and return a box plot figure without saving it.

Renders a seaborn box plot with individual data points overlaid as a swarm plot. When rand_value is provided, a dashed grey reference line marks the expected performance of a random predictor. Returns None when values is empty so callers can skip adding an empty page to a multi-page PDF.

Parameters:
  • values (dict[str, list[float]]) – Algorithm name -> list of observed metric values.

  • title (str) – Plot title.

  • ylabel (str) – Y-axis label.

  • rand_value (float or None) – If provided, a dashed grey horizontal line is drawn at this y value to indicate the random-predictor baseline.

  • ylim (tuple of (float, float) or None) – Y-axis limits. Pass None to let matplotlib auto-scale (required for metrics like EPR whose values can exceed 1.0). Defaults to (0.0, 1.0), which is appropriate for AUPRC and AUROC.

Returns:

The created figure, or None if values is empty.

Return type:

plt.Figure or None

BLPlot.plotter.random_classifier_baseline(gt_path: Path) float[source]

Compute the expected precision of a random predictor for a dataset.

Equals k / (n*(n-1)) where k is the number of non-self-loop ground truth edges and n is the number of unique genes. This is the random baseline for both AUPRC and early precision (the PR curve of a random predictor is flat at height k / n_possible).

Parameters:

gt_path (Path) – Path to the ground truth edge list CSV (columns Gene1, Gene2).

Returns:

Random predictor baseline in (0, 1], or nan if undefined (empty network).

Return type:

float

Module contents