Faceted Heatmap Strategy¶
faceted_heatmap_strategy ¶
Faceted Heatmap Strategy - Toxicity Profile Visualizations.
This module implements the FacetedHeatmapStrategy for creating faceted heatmap visualizations showing toxicity scores across multiple super-categories (facets) for compounds analyzed by the ToxCSM model.
Classes:
| Name | Description |
|---|---|
FacetedHeatmapStrategy | Strategy for faceted heatmap generation with toxicity profiles. |
Notes
- Creates faceted visualizations with multiple toxicity categories
- Shared Y-axis (compounds) across facets
- Unique X-axis (endpoints) per facet
- Color-coded toxicity scores (0-1 scale)
For supported use cases, refer to the official documentation.
Classes¶
FacetedHeatmapStrategy ¶
Bases: BasePlotStrategy
Strategy for faceted heatmap toxicity profile visualizations.
This strategy creates faceted heatmaps showing toxicity scores where facets represent super-categories, rows show compounds, columns show toxicological endpoints, and cell values represent toxicity 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. |
compound_column | str | Column containing compound names (default: 'compoundname'). |
endpoint_column | str | Column containing endpoint names (default: 'endpoint'). |
score_column | str | Column containing toxicity scores (default: 'toxicity_score'). |
category_column | str | Column containing super-categories (default: 'super_category'). |
category_order | List[str] | Order of facets from left to right. |
Methods:
| Name | Description |
|---|---|
validate_data | Validate input data for faceted heatmap requirements |
process_data | Process data with cleaning and aggregation |
create_figure | Create faceted heatmap figure from processed data |
Notes
- Supports multiple toxicity response categories as facets
- Shared Y-axis (compounds) across all facets
- Color scale: 0 (low risk) to 1 (high risk)
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/faceted_heatmap_strategy.py
Functions¶
validate_data ¶
Validate input data for faceted 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, score column not numeric, or no valid compounds/endpoints/categories found. |
Source code in src/domain/plot_strategies/charts/faceted_heatmap_strategy.py
process_data ¶
Process data for faceted heatmap visualization.
Applies cleaning, aggregation, and sorting to prepare data for visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data with required columns. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | Processed data ready for visualization. |
Source code in src/domain/plot_strategies/charts/faceted_heatmap_strategy.py
create_figure ¶
Create faceted heatmap figure.
Creates a subplot with one heatmap per super-category, with shared Y-axis (compounds) and unique X-axis per facet (endpoints).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_df | DataFrame | Processed data with compound_order column for sorting. | required |
Returns:
| Type | Description |
|---|---|
Figure | Configured Plotly faceted heatmap. |
Source code in src/domain/plot_strategies/charts/faceted_heatmap_strategy.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 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 | |
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. |