Heatmap Scored Strategy¶
heatmap_scored_strategy ¶
Heatmap Scored Strategy - Completeness and Compliance Scoring.
This module implements the HeatmapScoredStrategy for creating heatmap visualizations showing scoring/completeness metrics across samples and various categories (compounds, pathways, agencies).
Classes:
| Name | Description |
|---|---|
HeatmapScoredStrategy | Strategy for scored heatmap generation with completeness metrics. |
Notes
- Supports KO completeness scoring (unique KO counts)
- Supports compound compliance scoring (regulatory agencies)
- Scores displayed as percentages (0-100%)
For supported use cases, refer to the official documentation.
Classes¶
HeatmapScoredStrategy ¶
Bases: BasePlotStrategy
Strategy for scored heatmap completeness/compliance visualizations.
This strategy creates heatmaps showing scoring metrics (0-100%) where rows represent samples, columns represent categories, and cell values represent completeness or compliance scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Dict[str, Any] | Complete configuration from YAML file. | required |
Attributes:
| Name | Type | Description |
|---|---|---|
data_config | Dict[str, Any] | Data processing configuration. |
plotly_config | Dict[str, Any] | Plotly-specific configuration. |
scoring_mode | str | Scoring algorithm: 'ko_completeness' or 'compound_compliance'. |
category_column | str | Column containing categories (e.g., 'Pathway', 'referenceAG'). |
sample_column | str | Column containing sample identifiers (default: 'Sample'). |
value_column | str | Column for aggregation ('KO' for completeness, 'compoundname' for compliance). |
Methods:
| Name | Description |
|---|---|
validate_data | Validate input data for heatmap requirements |
process_data | Process data and calculate scoring matrix |
create_figure | Create heatmap figure from scoring matrix |
Notes
- Supports two scoring modes: KO completeness and compound compliance
- Scores displayed as percentages (0-100%)
- Heatmap uses color scale to represent score intensity
Initialize strategy with configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | Dict[str, Any] | Complete configuration from YAML file. | required |
Source code in src/domain/plot_strategies/charts/heatmap_scored_strategy.py
Functions¶
validate_data ¶
Validate input data for heatmap requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data to validate. | required |
Raises:
| Type | Description |
|---|---|
ValueError | If DataFrame is empty, required columns missing, or no valid samples/categories found. |
Source code in src/domain/plot_strategies/charts/heatmap_scored_strategy.py
process_data ¶
Process data and calculate scoring matrix.
Implements scoring algorithms based on configured mode: KO completeness or compound compliance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data with required columns. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | Heatmap matrix with samples as rows, categories as columns, and scores (0-100%) as values. |
Source code in src/domain/plot_strategies/charts/heatmap_scored_strategy.py
create_figure ¶
Create heatmap figure from scoring matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_df | DataFrame | Scoring matrix (samples × categories). | required |
Returns:
| Type | Description |
|---|---|
Figure | Configured Plotly heatmap. |
Source code in src/domain/plot_strategies/charts/heatmap_scored_strategy.py
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
apply_filters ¶
Apply filters to data.
This is a common implementation that can be overridden by subclasses if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Data to filter. | required |
filters | Optional[Dict[str, Any]] | Filter specifications. | None |
Returns:
| Type | Description |
|---|---|
DataFrame | Filtered data. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
apply_customizations ¶
Apply custom styling to figure.
This is a hook for future customization features (FLEXIVEL and FLEXIVEL2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fig | Figure | Base figure. | required |
customizations | Optional[Any] | Customization specifications. | None |
Returns:
| Type | Description |
|---|---|
Figure | Customized figure. |
Source code in src/domain/plot_strategies/base/base_plot_strategy.py
generate_plot ¶
generate_plot(data: DataFrame, filters: Optional[Dict[str, Any]] = None, customizations: Optional[Any] = None) -> go.Figure
Generate complete plot (Template Method).
This method orchestrates the entire plot generation process: 1. Validate input data 2. Process data 3. Apply filters 4. Create figure 5. Apply customizations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data | DataFrame | Input data. | required |
filters | Optional[Dict[str, Any]] | Filters to apply. | None |
customizations | Optional[Any] | Customizations to apply. | None |
Returns:
| Type | Description |
|---|---|
Figure | Complete Plotly figure. |
Raises:
| Type | Description |
|---|---|
ValueError | If validation fails. |