mibiscreen.visualize API reference
mibiscreen module for data visualization.
ordination_plots
Ordination plot.
@author: Alraune Zech
ordination_plot(ordination_output, plot_loadings=True, plot_scores=True, rescale_loadings_scores=False, adjust_text=True, scale_focus='loadings', axis_ranges=False, save_fig=False, **kwargs)
Function creating ordination plot.
Based on ordination analysis providing ordination loadings and scores.
Input
ordination_output : Dictionary
contains ordination results:
- as numpy arrays; ordination loading and scores
- names of the samples and the Environmental and Species variables
- method : String (pca, cca, rda) The ordination method used in the analysis.
plot_loadings : Boolean; default is True
flag to plot the ordination loadings
plot_scores : Boolean; default is True
flag to plot the ordiantion scores
rescale_loadings_scores : Boolean; default is False
flag to rescale loadings and scores to have a loading close to 1
adjust_text : Boolean, default is True
flag to perform automized adjustment of text labes of loadings and scores to avoid overlap
scale_focus : String, default is "loadings"
flag to specify if scaling focusses on either 'loadings' or 'scores' or 'none'.
axis_ranges : Boolean or list/array of 4 values, default is False,
if array or list it gives fixed x and y axis dimensions [x_min, x_maxm y_min, y_max]
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
**kwargs: dict
dictionary with plot settings (e.g. fonts, arrow specifics, etc)
Output
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/ordination_plots.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 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 | |
screening_plots
Activity plot.
@author: alraune
activity_data_prep(data, verbose=False)
Preparing data required for activity plot.
Activity plot requires data analysis of
- contaminant concentrations
- metabolites counts
- NA screening
Functions checks if required quantities are provided as columns in DataFrame, extracts it from DataFrame and saves it to dictionary.
When data is provided as list of pd.Series/np.arrays/lists it checks data on compatibility and saves it to dictionary.
Input
data: list or pandas.DataFrame
quantities required in plot:
- total concentration of contaminants per sample
- total count of metabolites per sample
- traffic light on NA activity per sample
if DataFrame, it contains the three required quantities with their standard names
if list of arrays: the three quantities are given order above
if list of pandas-Series, quantities given in standard names
verbose: Boolean, default True
verbosity flag
Output
activity_data_dict: dict
of np.arrays containing quantities required in activity plot:
- total concentration of contaminants per sample
- total count of metabolites per sample
- traffic light on NA activity per sample
Source code in mibiscreen/visualize/screening_plots.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
activity_plot(activity_data_dict, xlabel='Concentration contaminants [$\\mu$g/L]', ylabel='Metabolite count', save_fig=False, title_text=False, **kwargs)
Creating activity plot.
Activity plot shows scatter of total number of metabolites vs total concentration of contaminant per well with color coding of NA traffic lights: red/yellow/green corresponding to no natural attenuation going on (red), limited/unknown NA activity (yellow) or active natural attenuation (green)
Input
activity_data_dict: dict
list or pandas.DataFrame
quantities required in plot:
- total concentration of contaminants per sample
- total count of metabolites per sample
- traffic light on NA activity per sample
if DataFrame, it contains the three required quantities with their standard names
if list of arrays: the three quantities are given order above
if list of pandas-Series, quantities given in standard names
xlabel: str, default r"Concentration contaminants"
x-axis label
ylabel: str, default "Metabolite count"
y-axis label
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
title_text: str or False, default False
text displayed as figure title,
in case of False, no title will be displayed
**kwargs: dict
dictionary with plot settings
Output
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/screening_plots.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 | |
contaminants_bar(data_frame, list_contaminants, list_labels=False, sort=False, name_sample=False, xlabel='Samples', ylabel='Total concentration [$\\mu$g/l]', yscale='linear', title_text='Total concentration of contaminants per sample', xtick_autorotate=False, save_fig=False, **kwargs)
Creating a bar plot of contaminant concentrations (or counts) per sample.
A selected list on quantities (at least 2) from a data frame is displayed as overlaying bars showing concentrations of individual components and/or sums of different contaminants with one bar per sample. The plot can also be used to display total counts of a selected range of contaminants per sample.
Input
data_frame : pd.DataFrame
Contaminant concentrations in [ug/l], i.e. microgram per liter
list_contaminants : list
list of column names to select from data_frame
list_labels: list or False, default: False
list of quantity names to be displayed in legend
if False, the names in 'list_contaminants' will be used
sort: Boolean, default False
weather to sort data and display concentrations bars
in ascending order (based on values of first quantity in
list_contaminants)
name_sample: Boolean, default False
weather to display sample_nr on x-axis (True) or
just number all samples starting from 1 (False)
xlabel: str, default 'Samples'
x-axis label
ylabel: str, default 'Total concentration',
y-axis label
yscale: str, default 'linear',
scaling of y-axis, typically 'log' or 'linear'
title_text: str or False, default 'Total concentration of contaminants per sample'
text displayed as figure title,
in case of False, no title will be displayed
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/screening_plots.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
electron_balance_bar(electron_balance_bar_dict, sample_nr=False, sort=False, xlabel='Samples', ylabel='Electron capacity/needed [mmol e-/l]', yscale='linear', title_text='Electron balance per sample', xtick_autorotate=False, save_fig=False, **kwargs)
Creating a bar plot for electron balance per sample.
Displayed are bars of electron concentrations for: - “total_reductors” - ‘total_oxidators_BTEXIIN’ - ‘total_oxidators_BTEX’
The plot shows the three quantities as overlapping bars with the smallest in front and the largest to the back, indicating if an excess of or need for electrons is present at the sample location, including quantitative differences.
Operates on dictionary containing electron concentration values extracted from data frame, color and sample selection. The dictionary can be prepared by running the function ‘electron_balance_bar_data_prep()’ on the data frame.
Input
electron_balance_bar_dict : dict
dictionary with plot relevant specifics
sort: Boolean, default False
weather to sort data and display concentrations bars
in ascending order (based on values of first quantity in
list_contaminants)
sample_nr: Boolean, default False
weather to display sample_nr on x-axis (True) or
just number all samples starting from 1 (False)
xlabel: str, default 'Samples'
x-axis label
ylabel: str, default r'Electron capacity/needed [mmol e-/l]'
y-axis label
yscale: str, default 'linear',
scaling of y-axis, typically 'log' or 'linear'
title_text: str or False, default 'Total concentration of contaminants per sample'
text displayed as figure title,
in case of False, no title will be displayed
xtick_autorotate: Boolean, default 'False'
sample names at x-axis are rotated by 45 degrees
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/screening_plots.py
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 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
electron_balance_bar_data_prep(data_frame, color_order=['C1', 'C0', 'C2'], list_samples=False)
Preparing dictionary from data_frame for electron balance plot.
Requires data_frame to contain the following quantities
- “total_reductors”
- ‘total_oxidators_BTEXIIN’
- ‘total_oxidators_BTEX’
Input
data_frame : pd.DataFrame
Contaminant concentrations in [ug/l], i.e. microgram per liter
color_order: list of colors, default = ['C1','C0','C2']
colors to be used in the plot for the three quantities
list_samples: list or False, default: False
if False, bars for all samples are displayed
if list, bars are only displayed for selected samples (given by indexs)
electron_balance_bar_dict : dict
dictionary with plot relevant specifics
Source code in mibiscreen/visualize/screening_plots.py
threshold_ratio_bar(data_threshold_ratios, list_contaminants=False, list_labels=False, list_samples=False, nrows=1, ncols=False, unity_line=False, list_sort=False, list_colors=False, sharex=False, sharey=False, xlabel='ratio to threshold concentration $C/C_\\mathrm{threshold}$', ylabel=False, xscale=False, title_text=False, save_fig=False, **kwargs)
Horizontal bar plots showing relative threshold exceedance of contaminants per sample.
Creates a figure with subfigures for each (selected) sample displaying the relative exceedance of contaminant concentrations are ratio of concentration to exceedance value (with <1 being lower then exceedance value).
The required input data frame can be create with the function: ‘thresholds_for_intervention_ratio()’ using the recommended keywords: - include = False - keep_setting_data = False
Input
data_threshold_ratios: pd.Data_frame
each column contains a relative contaminant concentration
each rows contains a sample
list_contaminants : list
list of column names to select from data_frame
list_labels: list or False, default: False
list of quantity names to be displayed in legend
if False, the names in 'list_contaminants' will be used
list_samples: list or False, default: False
if False, bars for all samples are displayed
if list, bars are only displayed for selected samples (given by indexs)
nrows, ncolsint, default: 1
Number of rows/columns of the subplot grid.
Number of total subfigures need to fit to number of selected samples.
unity_line: Boolean, default False
weather to include unity line (i.e. solid black line at 1 indicating
equality of contaminant concentration and exceedance threshold value)
list_sort: list or False, default False
list representing order of display of quantities
list_colors: list or False, default False
list of colors to use for individual bars
in case of False the standard color order in python is used
sharex, sharey: bool or {'none', 'all', 'row', 'col'}, default: False
Controls sharing of properties among x (sharex) or y (sharey) axes
See matplotlib.pyplot.subplots() for more details
xlabel: str, default r'ratio to threshold concentration'
x-axis label
ylabel: str, default False
y-axis label
xscale: str or False, default 'False',
scaling of y-axis, when False --> 'linear', typical other option: 'log'
title_text: str or False, default 'False'
text displayed as figure title,
in case of False, no title will be displayed
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/screening_plots.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 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 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 | |
stable_isotope_plots
Linear regression plots for stable isotope analysis in mibiscreen.
@author: Alraune Zech
Keeling_plot(concentration, delta, coefficients, relative_abundance=None, save_fig=False, **kwargs)
Creating a Keeling plot.
A Keeling plot is an approach to identify the isotopic composition of a contaminating source from measured concentrations and isotopic composition (delta) of a target species in the mix of the source and a pool. It is based on the linear relationship of the concentration and the delta-value which are measured over time or across a spatial interval.
The plot shows the inverse concentration data against the delta-values along the linear regression line. For gaining the regression coefficients perform a linear fitting or run
Keeling_regression() [in the module analysis]
The parameter of interest, the delta (or relative_abundance, respectively) of the source quantity is the intercept of linear fit with the y-axis, or in other words, the absolute value of the linear fit function.
Input
c_mix : np.array, pd.dataframe
total molecular mass/molar concentration of target substance
at different locations (at a time) or at different times (at one location)
delta_mix : np.array, pd.dataframe (same length as c_mix)
relative isotope ratio (delta-value) of target substance
relative_abundance : None or np.array, pd.dataframe (same length as c_mix), default None
if not None it replaces delta_mix in the inverse estimation and plotting
relative abundance of target substance
coefficients : tuple of lenght 2
containing coefficients of the linear fit
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string. =
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/stable_isotope_plots.py
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 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 | |
Lambda_plot(delta_C, delta_H, coefficients, save_fig=False, **kwargs)
Creating a Lambda plot.
A Lambda plot shows the δ13C versus δ2H signatures of a chemical compound. Relative changes in the carbon and hydrogen isotope ratios can indicate the occurrence of specific enzymatic degradation reactions. The relative changes are indicated by the lambda-H/C value which is the slope of the linear regression of hydrogen versus carbon isotope signatures. For gaining the regression coefficients perform a linear fitting or run
Lambda_regression() [in the module analysis]
Lambda-values linking to specific enzymatic reactions
To be added!
Details provided in Vogt et al. [2016, 2020].
References
C. Vogt, C. Dorer, F. Musat, and H. H. Richnow. Multi-element isotope fractionation concepts to characterize the biodegradation of hydrocarbons - from enzymes to the environment. Current Opinion in Biotechnology, 41:90–98, 2016. C. Vogt, F. Musat, and H.-H. Richnow. Compound-Specific Isotope Analysis for Studying the Biological Degradation of Hydrocarbons. In Anaerobic Utilization of Hydrocarbons, Oils, and Lipids, pages 285-321. Springer Nature Switzerland, 2020.
A. Fischer, I. Herklotz, S. Herrmann, M. Thullner, S. A. Weelink, A. J. Stams, M. Schl ̈omann, H.-H. Richnow, and C. Vogt. Combined Carbon and Hydrogen Isotope Fractionation Investigations for Elucidating Benzene Biodegradation Pathways. Environmental Science and Technology, 42:4356–4363, 2008.
S. Kuemmel, F.-A. Herbst, A. Bahr, M. Arcia Duarte, D. H. Pieper, N. Jehmlich, J. Seifert, M. Von Bergen, P. Bombach, H. H. Richnow, and C. Vogt. Anaerobic naphthalene degradation by sulfate-reducing Desulfobacteraceae from various anoxic aquifers. FEMS Microbiology Ecology, 91(3), 2015.
Input
delta_C : np.array, pd.series
relative isotope ratio (delta-value) of carbon of target molecule
delta_H : np.array, pd.series (same length as delta_C)
relative isotope ratio (delta-value) of hydrogen of target molecule
coefficients : tuple of lenght 2
containing coefficients of the linear fit
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string.
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/stable_isotope_plots.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
Rayleigh_fractionation_plot(concentration, delta, coefficients, save_fig=False, **kwargs)
Creating a Rayleigh fractionation plot.
Rayleigh fractionation is a common application to characterize the removal of a substance from a finite pool using stable isotopes. It is based on the change in the isotopic composition of the pool due to different kinetics of the change in lighter and heavier isotopes.
We follow the most simple approach assuming that the substance removal follows first-order kinetics, where the rate coefficients for the lighter and heavier isotopes of the substance differ due to kinetic isotope fractionation effects. The isotopic composition of the remaining substance in the pool will change over time, leading to the so-called Rayleigh fractionation.
The plot shows the log-transformed concentration data against the delta-values along the linear regression line. For gaining the regression coefficients perform a linear fitting or run
Rayleigh_fractionation() [in the module analysis]
The parameter of interest, the kinetic fractionation factor (epsilon or alpha -1) of the removal process is the slope of the the linear trend line.
Input
concentration : np.array, pd.series
total molecular mass/molar concentration of target substance
at different locations (at a time) or at different times (at one location)
delta : np.array, pd.series (same length as concentration)
relative isotope ratio (delta-value) of target substance
coefficients : tuple of lenght 2
containing coefficients of the linear fit
save_fig: Boolean or string, optional, default is False.
Flag to save figure to file with name provided as string. =
**kwargs: dict
dictionary with plot settings
fig : Figure object
Figure object of created activity plot.
ax : Axes object
Axes object of created activity plot.
Source code in mibiscreen/visualize/stable_isotope_plots.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 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 | |