Frozenset Strategy¶
frozenset_strategy ¶
Frozenset Strategy - Minimal Sample-Group Visualization.
This module implements the FrozensetStrategy for creating grouped scatter plots that visualize samples organized by their compound profiles (frozenset) with set cover minimization to reduce redundancy.
Classes:
| Name | Description |
|---|---|
FrozensetStrategy | Strategy for frozenset-based sample grouping visualization. |
Notes
- Groups samples by compound profile (frozenset)
- Applies greedy set cover algorithm for minimization
- Color-codes markers by unique KO count per compound
For supported use cases, refer to the official documentation.
Classes¶
FrozensetStrategy ¶
Bases: BasePlotStrategy
Strategy for minimal sample-group visualization using frozensets.
This strategy creates grouped scatter plots showing samples organized by their compound profiles (frozenset), with set cover minimization to reduce redundancy and maximize compound coverage.
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. |
sample_column | str | Column name for sample identifiers. |
compound_column | str | Column name for compound identifiers. |
compoundclass_column | str | Column name for compound class filtering. |
ko_column | str | Column name for KO identifiers (for color scaling). |
color_scale | str | Plotly color scale for markers. |
marker_size | int | Size of scatter markers. |
Methods:
| Name | Description |
|---|---|
validate_data | Validate input data for frozenset visualization requirements |
process_data | Process data with filtering, grouping, and set cover minimization |
create_figure | Create frozenset visualization figure from processed data |
apply_filters | Apply filters including compound class selection |
get_available_compound_classes | Get list of available compound classes |
get_group_statistics | Calculate statistics for visualization |
Notes
- Applies greedy set cover algorithm for group minimization
- Color-codes by unique KO count per compound
- Supports compound class filtering
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/frozenset_strategy.py
Functions¶
validate_data ¶
Validate input data for frozenset visualization requirements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data to validate. | required |
Raises:
| Type | Description |
|---|---|
ValueError | If DataFrame is empty or required columns missing. |
Source code in src/domain/plot_strategies/charts/frozenset_strategy.py
process_data ¶
Process data for frozenset visualization.
Applies filtering by compound class, groups samples by compound profile (frozenset), applies set cover minimization, and calculates KO counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data with required columns. | required |
Returns:
| Type | Description |
|---|---|
DataFrame | Processed data with group labels and KO counts. |
Source code in src/domain/plot_strategies/charts/frozenset_strategy.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 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 | |
create_figure ¶
Create frozenset visualization figure from processed data.
Creates subplots with one scatter plot per minimized group, with markers color-coded by unique KO count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_df | DataFrame | Processed data with group labels and KO counts. | required |
Returns:
| Type | Description |
|---|---|
Figure | Configured Plotly figure with subplots. |
Source code in src/domain/plot_strategies/charts/frozenset_strategy.py
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 441 442 443 444 445 446 447 448 | |
apply_filters ¶
Apply filters including compound class selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Data to filter. | required |
filters | Optional[Dict[str, Any]] | Filter specifications including 'compoundclass'. | None |
Returns:
| Type | Description |
|---|---|
DataFrame | Filtered data. |
Source code in src/domain/plot_strategies/charts/frozenset_strategy.py
get_available_compound_classes ¶
Get list of available compound classes from data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df | DataFrame | Input data. | required |
Returns:
| Type | Description |
|---|---|
List[str] | Sorted list of unique compound classes. |
Source code in src/domain/plot_strategies/charts/frozenset_strategy.py
get_group_statistics ¶
Calculate statistics for visualization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
processed_df | DataFrame | Processed data. | required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | Statistics including group counts, samples, compounds. |
Source code in src/domain/plot_strategies/charts/frozenset_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. |