Skip to content

Commit a45291c

Browse files
committed
Squashed commit of the following:
commit 95bea8a Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 17:43:54 2024 +0800 Fix on nbdev diff commit bd7bcde Merge: aa6a84c 7ef4681 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 17:30:54 2024 +0800 Merge branch 'feat-forestplot-apiTut-changes' of github.com:ACCLAB/DABEST-python into JAnns98-patch-1 # Conflicts: # nbs/tests/mpl_image_tests/baseline_images/test_01_gardner_altman_unpaired_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_02_gardner_altman_unpaired_mediandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_03_gardner_altman_unpaired_hedges_g.png # nbs/tests/mpl_image_tests/baseline_images/test_04_gardner_altman_paired_hedges_g.png # nbs/tests/mpl_image_tests/baseline_images/test_04_gardner_altman_paired_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_05_cummings_two_group_unpaired_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_06_cummings_two_group_paired_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_07_cummings_multi_group_unpaired.png # nbs/tests/mpl_image_tests/baseline_images/test_08_cummings_multi_group_paired.png # nbs/tests/mpl_image_tests/baseline_images/test_09_cummings_shared_control.png # nbs/tests/mpl_image_tests/baseline_images/test_101_gardner_altman_unpaired_propdiff.png # nbs/tests/mpl_image_tests/baseline_images/test_103_cummings_two_group_unpaired_propdiff.png # nbs/tests/mpl_image_tests/baseline_images/test_105_cummings_multi_group_unpaired_propdiff.png # nbs/tests/mpl_image_tests/baseline_images/test_106_cummings_shared_control_propdiff.png # nbs/tests/mpl_image_tests/baseline_images/test_107_cummings_multi_groups_propdiff.png # nbs/tests/mpl_image_tests/baseline_images/test_109_gardner_altman_ylabel.png # nbs/tests/mpl_image_tests/baseline_images/test_10_cummings_multi_groups.png # nbs/tests/mpl_image_tests/baseline_images/test_110_change_fig_size.png # nbs/tests/mpl_image_tests/baseline_images/test_111_change_palette_b.png # nbs/tests/mpl_image_tests/baseline_images/test_112_change_palette_c.png # nbs/tests/mpl_image_tests/baseline_images/test_113_desat.png # nbs/tests/mpl_image_tests/baseline_images/test_114_change_ylims.png # nbs/tests/mpl_image_tests/baseline_images/test_115_invert_ylim.png # nbs/tests/mpl_image_tests/baseline_images/test_116_ticker_gardner_altman.png # nbs/tests/mpl_image_tests/baseline_images/test_117_err_color.png # nbs/tests/mpl_image_tests/baseline_images/test_118_cummings_two_group_unpaired_meandiff_bar_width.png # nbs/tests/mpl_image_tests/baseline_images/test_119_wide_df_nan.png # nbs/tests/mpl_image_tests/baseline_images/test_11_inset_plots.png # nbs/tests/mpl_image_tests/baseline_images/test_120_long_df_nan.png # nbs/tests/mpl_image_tests/baseline_images/test_121_cohens_h_gardner_altman.png # nbs/tests/mpl_image_tests/baseline_images/test_122_cohens_h_cummings.png # nbs/tests/mpl_image_tests/baseline_images/test_123_sankey_gardner_altman.png # nbs/tests/mpl_image_tests/baseline_images/test_124_sankey_cummings.png # nbs/tests/mpl_image_tests/baseline_images/test_125_sankey_2paired_groups.png # nbs/tests/mpl_image_tests/baseline_images/test_126_sankey_2sequential_groups.png # nbs/tests/mpl_image_tests/baseline_images/test_127_sankey_multi_group_paired.png # nbs/tests/mpl_image_tests/baseline_images/test_128_sankey_transparency.png # nbs/tests/mpl_image_tests/baseline_images/test_129_zero_to_zero.png # nbs/tests/mpl_image_tests/baseline_images/test_12_gardner_altman_ylabel.png # nbs/tests/mpl_image_tests/baseline_images/test_130_zero_to_one.png # nbs/tests/mpl_image_tests/baseline_images/test_131_one_to_zero.png # nbs/tests/mpl_image_tests/baseline_images/test_132_shared_control_sankey_off.png # nbs/tests/mpl_image_tests/baseline_images/test_133_shared_control_flow_off.png # nbs/tests/mpl_image_tests/baseline_images/test_134_separate_control_sankey_off.png # nbs/tests/mpl_image_tests/baseline_images/test_135_separate_control_flow_off.png # nbs/tests/mpl_image_tests/baseline_images/test_136_style_sheets.png # nbs/tests/mpl_image_tests/baseline_images/test_13_multi_2group_color.png # nbs/tests/mpl_image_tests/baseline_images/test_14_gardner_altman_paired_color.png # nbs/tests/mpl_image_tests/baseline_images/test_15_change_palette_a.png # nbs/tests/mpl_image_tests/baseline_images/test_16_change_palette_b.png # nbs/tests/mpl_image_tests/baseline_images/test_17_change_palette_c.png # nbs/tests/mpl_image_tests/baseline_images/test_18_desat.png # nbs/tests/mpl_image_tests/baseline_images/test_19_dot_sizes.png # nbs/tests/mpl_image_tests/baseline_images/test_201_forest_plot_no_colorpalette.png # nbs/tests/mpl_image_tests/baseline_images/test_202_forest_plot_with_colorpalette.png # nbs/tests/mpl_image_tests/baseline_images/test_203_horizontal_forest_plot_no_colorpalette.png # nbs/tests/mpl_image_tests/baseline_images/test_204_horizontal_forest_plot_with_colorpalette.png # nbs/tests/mpl_image_tests/baseline_images/test_205_forest_mini_meta_horizontal.png # nbs/tests/mpl_image_tests/baseline_images/test_206_forest_mini_meta.png # nbs/tests/mpl_image_tests/baseline_images/test_20_change_ylims.png # nbs/tests/mpl_image_tests/baseline_images/test_21_invert_ylim.png # nbs/tests/mpl_image_tests/baseline_images/test_22_ticker_gardner_altman.png # nbs/tests/mpl_image_tests/baseline_images/test_23_ticker_cumming.png # nbs/tests/mpl_image_tests/baseline_images/test_24_wide_df_nan.png # nbs/tests/mpl_image_tests/baseline_images/test_25_long_df_nan.png # nbs/tests/mpl_image_tests/baseline_images/test_26_slopegraph_kwargs.png # nbs/tests/mpl_image_tests/baseline_images/test_27_gardner_altman_reflines_kwargs.png # nbs/tests/mpl_image_tests/baseline_images/test_28_unpaired_cumming_reflines_kwargs.png # nbs/tests/mpl_image_tests/baseline_images/test_29_paired_cumming_slopegraph_reflines_kwargs.png # nbs/tests/mpl_image_tests/baseline_images/test_30_sequential_cumming_slopegraph.png # nbs/tests/mpl_image_tests/baseline_images/test_31_baseline_cumming_slopegraph.png # nbs/tests/mpl_image_tests/baseline_images/test_47_cummings_unpaired_delta_delta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_48_cummings_sequential_delta_delta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_49_cummings_baseline_delta_delta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_50_delta_plot_ylabel.png # nbs/tests/mpl_image_tests/baseline_images/test_51_delta_plot_change_palette_a.png # nbs/tests/mpl_image_tests/baseline_images/test_52_delta_specified.png # nbs/tests/mpl_image_tests/baseline_images/test_53_delta_change_ylims.png # nbs/tests/mpl_image_tests/baseline_images/test_54_delta_invert_ylim.png # nbs/tests/mpl_image_tests/baseline_images/test_55_delta_median_diff.png # nbs/tests/mpl_image_tests/baseline_images/test_56_delta_cohens_d.png # nbs/tests/mpl_image_tests/baseline_images/test_57_delta_show_delta2.png # nbs/tests/mpl_image_tests/baseline_images/test_58_delta_axes_invert_ylim.png # nbs/tests/mpl_image_tests/baseline_images/test_59_delta_axes_invert_ylim_not_showing_delta2.png # nbs/tests/mpl_image_tests/baseline_images/test_60_cummings_unpaired_mini_meta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_61_cummings_sequential_mini_meta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_62_cummings_baseline_mini_meta_meandiff.png # nbs/tests/mpl_image_tests/baseline_images/test_63_mini_meta_plot_ylabel.png # nbs/tests/mpl_image_tests/baseline_images/test_64_mini_meta_plot_change_palette_a.png # nbs/tests/mpl_image_tests/baseline_images/test_65_mini_meta_dot_sizes.png # nbs/tests/mpl_image_tests/baseline_images/test_66_mini_meta_change_ylims.png # nbs/tests/mpl_image_tests/baseline_images/test_67_mini_meta_invert_ylim.png # nbs/tests/mpl_image_tests/baseline_images/test_68_mini_meta_median_diff.png # nbs/tests/mpl_image_tests/baseline_images/test_69_mini_meta_cohens_d.png # nbs/tests/mpl_image_tests/baseline_images/test_70_mini_meta_not_show.png # nbs/tests/mpl_image_tests/baseline_images/test_71_unpaired_delta_g.png # nbs/tests/mpl_image_tests/baseline_images/test_72_sequential_delta_g.png # nbs/tests/mpl_image_tests/baseline_images/test_73_baseline_delta_g.png # nbs/tests/mpl_image_tests/baseline_images/test_99_style_sheets.png commit aa6a84c Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 17:26:57 2024 +0800 Place holder for forest plot tutorial commit b922c16 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 16:52:04 2024 +0800 nbdev-related fix commit cb195d8 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 16:15:45 2024 +0800 tst commit 9b0c918 Merge: 1fdbd49 c080f82 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Apr 16 15:15:20 2024 +0800 Merge branch 'v2024.03.29' of github.com:ACCLAB/DABEST-python into JAnns98-patch-1 # Conflicts: # nbs/tutorials/07-forest_plot.ipynb commit 7ef4681 Author: LucasWZY1213 <e0552341@u.nus.edu> Date: Fri Apr 12 17:05:29 2024 +0800 Add: new test images commit dbb62c3 Author: LucasWZY1213 <e0552341@u.nus.edu> Date: Fri Apr 12 16:35:36 2024 +0800 feat: update api, tutorial, and tests commit c080f82 Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 23:40:30 2024 +0800 Update on documentations commit 973eafb Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 22:38:36 2024 +0800 Edit on README.md of installation commit 839a892 Merge: 314de76 1c4b6eb Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 22:07:58 2024 +0800 Merge branch 'vnbdev' of github.com:ACCLAB/DABEST-python into vnbdev # Conflicts: # README.md commit 314de76 Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 21:51:35 2024 +0800 Minor edits on the README commit 1c4b6eb Author: Jacob Luke <javcobll@gmail.com> Date: Fri Mar 22 20:18:19 2024 +0800 Update README.md commit bd3319a Author: Jacob Luke <javcobll@gmail.com> Date: Fri Mar 22 20:17:41 2024 +0800 Update README.md commit b54871a Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 17:26:09 2024 +0800 Minor adjustment on docs and python req commit ff779d2 Merge: 1cc16d3 781f31d Author: Jacob Luke <javcobll@gmail.com> Date: Fri Mar 22 10:08:01 2024 +0800 Merge pull request #173 from ACCLAB/patch-splash-page-edit Documentation Edits commit 781f31d Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 22 09:58:47 2024 +0800 Hide forest plot announcement commit 8b93633 Author: Jacobluke- <javcobll@gmail.com> Date: Wed Mar 20 17:02:52 2024 +0800 Hide forest plot from current release commit 498df8f Author: Jacobluke- <javcobll@gmail.com> Date: Wed Mar 20 10:30:16 2024 +0800 Splash page plot change commit c2e989d Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 16:39:03 2024 +0800 Change the tut link to the latest commit cbde4d8 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 16:29:59 2024 +0800 Suppress warning for docs commit 17f5b90 Merge: 00f513b a86572e Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 16:10:25 2024 +0800 Merge branch 'patch-splash-page-edit' of github.com:ACCLAB/DABEST-python into patch-splash-page-edit commit 00f513b Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 15:58:44 2024 +0800 Edit version number in notebooks commit a86572e Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 15:58:44 2024 +0800 Edit version number in notebooks commit 46ca02d Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 15:20:42 2024 +0800 Bump version and write release info commit 81a4a64 Merge: 162be6d 1cc16d3 Author: Jacobluke- <javcobll@gmail.com> Date: Tue Mar 19 15:08:15 2024 +0800 Merge branch 'vnbdev' of github.com:ACCLAB/DABEST-python into patch-splash-page-edit commit 162be6d Author: Jacobluke- <javcobll@gmail.com> Date: Mon Mar 18 14:45:44 2024 +0800 Add favicon for Tut pages commit cd2f398 Author: Jacobluke- <javcobll@gmail.com> Date: Fri Mar 15 10:24:34 2024 +0800 Add favicon for DABEST tutorial pages commit 5e94ea0 Author: Jacobluke- <javcobll@gmail.com> Date: Thu Mar 14 10:12:38 2024 +0800 Edit on getting-started commit b48711c Author: Jacobluke- <javcobll@gmail.com> Date: Thu Mar 14 09:50:17 2024 +0800 Edit on Splash page
1 parent 1fdbd49 commit a45291c

133 files changed

Lines changed: 1755 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22

33
<!-- do not remove -->
44

5-
## 2023.03.29
5+
## v2024.03.29
66

77
### New Features
8-
- Add new form of paired proportion plots for a better support of Repeated Measures
98

9+
- **Standardized Delta-delta Effect Size**: We added a new metric akin to a Hedges’ g for delta-delta effect size, which allows comparisons between delta-delta effects generated from metrics with different units.
1010

11-
## 0.2.3
11+
- **New Paired Proportion Plot**: This feature builds upon the existing proportional analysis capabilities by introducing advanced aesthetics and clearer visualization of changes in proportions between different groups, inspired by the informative nature of Sankey Diagrams. It's particularly useful for studies that require detailed examination of how proportions shift in paired observations.
1212

13-
### Bug Fixes
14-
- Fixes a bug that jammed up when the xvar column was already a pandas Categorical. Now we check for this and act appropriately.
13+
- **Customizable Swarm Plot**: Enhancements allow for tailored swarm plot aesthetics, notably the adjustment of swarm sides to produce asymmetric swarm plots. This customization enhances data representation, making visual distinctions more pronounced and interpretations clearer.
14+
15+
### Enhancement
16+
17+
- **Miscellaneous Improvements**: This version also encompasses a broad range of miscellaneous enhancements, including bug fixes, Bootstrapping speed improvements, new templates for raising issues, and updated unit tests. These improvements are designed to streamline the user experience, increase the software's stability, and expand its versatility. By addressing user feedback and identified issues, DABEST continues to refine its functionality and reliability.
18+
19+
20+
21+
## v2023.03.29
22+
23+
### New Features
24+
- **Repeated measures**: Augments the prior function for plotting (independent) multiple test groups versus a shared control; it can now do the same for repeated-measures experimental designs. Thus, together, these two methods can be used to replace both flavors of the 1-way ANOVA with an estimation analysis.
25+
26+
- **Proportional data**: Generates proportional bar plots, proportional differences, and calculates Cohen’s h. Also enables plotting Sankey diagrams for paired binary data. This is the estimation equivalent to a bar chart with Fischer’s exact test.
27+
28+
- **The ∆∆ plot**: Calculates the delta-delta (∆∆) for 2 × 2 experimental designs and plots the four groups with their relevant effect sizes. This design can be used as a replacement for the 2 × 2 ANOVA.
29+
30+
- **Mini-meta**: Calculates and plots a weighted delta (∆) for meta-analysis of experimental replicates. Useful for summarizing data from multiple replicated experiments, for example by different scientists in the same lab, or the same scientist at different times. When the observed values are known (and share a common metric), this makes meta-analysis available as a routinely accessible tool.

README.md

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,48 @@
22

33
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
44

5+
[![minimal Python
6+
version](https://img.shields.io/badge/Python%3E%3D-3.8-6666ff.svg)](https://www.anaconda.com/distribution/)
7+
[![PyPI
8+
version](https://badge.fury.io/py/dabest.svg)](https://badge.fury.io/py/dabest)
9+
[![Downloads](https://img.shields.io/pepy/dt/dabest.svg)](https://pepy.tech/project/dabest)
10+
[![Free-to-view
11+
citation](https://zenodo.org/badge/DOI/10.1038/s41592-019-0470-3.svg)](https://rdcu.be/bHhJ4)
12+
[![License](https://img.shields.io/badge/License-BSD%203--Clause--Clear-orange.svg)](https://spdx.org/licenses/BSD-3-Clause-Clear.html)
13+
514
## Recent Version Update
615

7-
On 20 March 2023, we officially released **DABEST v2023.02.14 for
8-
Python**. This new version provided the following new features:
9-
10-
1. **Repeated measures.** Augments the prior function for plotting
11-
(independent) multiple test groups versus a shared control; it can
12-
now do the same for repeated-measures experimental designs. Thus,
13-
together, these two methods can be used to replace both flavors of
14-
the 1-way ANOVA with an estimation analysis.
15-
16-
2. **Proportional data.** Generates proportional bar plots,
17-
proportional differences, and calculates Cohen’s h. Also enables
18-
plotting Sankey diagrams for paired binary data. This is the
19-
estimation equivalent to a bar chart with Fisher’s exact test.
20-
21-
3. **The $\Delta\Delta$ plot.** Calculates the delta-delta
22-
($\Delta\Delta$) for 2 × 2 experimental designs and plots the four
23-
groups with their relevant effect sizes. This design can be used as
24-
a replacement for the 2 × 2 ANOVA.
25-
26-
4. **Mini-meta.** Calculates and plots a weighted delta ($\Delta$) for
27-
meta-analysis of experimental replicates. Useful for summarizing
28-
data from multiple replicated experiments, for example by different
29-
scientists in the same lab, or the same scientist at different
30-
times. When the observed values are known (and share a common
31-
metric), this makes meta-analysis available as a routinely
32-
accessible tool.
16+
We are proud to announce **DABEST Version Ondeh (v2024.03.29)**. This
17+
new version of the DABEST Python library provides several new features
18+
and includes performance improvements.
19+
20+
1. **New Paired Proportion Plot**: This feature builds upon the
21+
existing proportional analysis capabilities by introducing advanced
22+
aesthetics and clearer visualization of changes in proportions
23+
between different groups, inspired by the informative nature of
24+
Sankey Diagrams. It’s particularly useful for studies that require
25+
detailed examination of how proportions shift in paired
26+
observations.
27+
28+
2. **Customizable Swarm Plot**: Enhancements allow for tailored swarm
29+
plot aesthetics, notably the adjustment of swarm sides to produce
30+
asymmetric swarm plots. This customization enhances data
31+
representation, making visual distinctions more pronounced and
32+
interpretations clearer.
33+
34+
3. **Standardized Delta-delta Effect Size**: We added a new metric akin
35+
to a Hedges’ g for delta-delta effect size, which allows comparisons
36+
between delta-delta effects generated from metrics with different
37+
units.
38+
39+
4. **Miscellaneous Improvements**: This version also encompasses a
40+
broad range of miscellaneous enhancements, including bug fixes,
41+
Bootstrapping speed improvements, new templates for raising issues,
42+
and updated unit tests. These improvements are designed to
43+
streamline the user experience, increase the software’s stability,
44+
and expand its versatility. By addressing user feedback and
45+
identified issues, DABEST continues to refine its functionality and
46+
reliability.
3347

3448
## Contents
3549

@@ -77,7 +91,7 @@ allowing everyone access to high-quality estimation plots.
7791

7892
## Installation
7993

80-
This package is tested on Python 3.6, 3.7, 3.8 and 3.10. It is highly
94+
This package is tested on Python 3.8 and onwards. It is highly
8195
recommended to download the [Anaconda
8296
distribution](https://www.continuum.io/downloads) of Python in order to
8397
obtain the dependencies easily.
@@ -86,13 +100,6 @@ You can install this package via `pip`.
86100

87101
To install, at the command line run
88102

89-
``` shell
90-
conda config --add channels conda-forge
91-
conda install dabest
92-
```
93-
94-
or –\>
95-
96103
``` shell
97104
pip install dabest
98105
```
@@ -128,8 +135,8 @@ iris_dabest.mean_diff.plot();
128135
dataset](iris.png)
129136

130137
Please refer to the official
131-
[tutorial](https://acclab.github.io/DABEST-python-docs/tutorial.html)
132-
for more useful code snippets.
138+
[tutorial](https://acclab.github.io/DABEST-python/) for more useful code
139+
snippets.
133140

134141
## How to cite
135142

@@ -147,8 +154,8 @@ PDF](https://rdcu.be/bHhJ4)
147154

148155
## Bugs
149156

150-
Please report any bugs on the [Github issue
151-
tracker](https://github.com/ACCLAB/DABEST-python/issues/new).
157+
Please report any bugs on the [issue
158+
page](https://github.com/ACCLAB/DABEST-python/issues/new).
152159

153160
## Contributing
154161

@@ -184,7 +191,7 @@ To test DABEST, you need to install
184191
- Run `pytest` in the root directory of the source distribution. This
185192
runs the test suite in the folder `dabest/tests/mpl_image_tests`.
186193
- Run `nbdev_test` in the root directory of the source distribution.
187-
This runs the value assertion tests in parent folder `dabest/tests`
194+
This runs the value assertion tests in the folder `dabest/tests`
188195

189196
The test suite ensures that the bootstrapping functions and the plotting
190197
functions perform as expected.

dabest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
from ._effsize_objects import TwoGroupsEffectSize, PermutationTest
44
from ._dabest_object import Dabest
55

6-
__version__ = "2023.03.29"
6+
__version__ = "2024.03.29"

dabest/_modidx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
'dabest.forest_plot': { 'dabest.forest_plot.extract_plot_data': ( 'API/forest_plot.html#extract_plot_data',
6565
'dabest/forest_plot.py'),
6666
'dabest.forest_plot.forest_plot': ('API/forest_plot.html#forest_plot', 'dabest/forest_plot.py'),
67-
'dabest.forest_plot.load_plot_data': ('API/forest_plot.html#load_plot_data', 'dabest/forest_plot.py')},
67+
'dabest.forest_plot.load_plot_data': ('API/forest_plot.html#load_plot_data', 'dabest/forest_plot.py'),
68+
'dabest.forest_plot.map_effect_attribute': ( 'API/forest_plot.html#map_effect_attribute',
69+
'dabest/forest_plot.py')},
6870
'dabest.misc_tools': { 'dabest.misc_tools.get_varname': ('API/misc_tools.html#get_varname', 'dabest/misc_tools.py'),
6971
'dabest.misc_tools.merge_two_dicts': ('API/misc_tools.html#merge_two_dicts', 'dabest/misc_tools.py'),
7072
'dabest.misc_tools.print_greeting': ('API/misc_tools.html#print_greeting', 'dabest/misc_tools.py'),

dabest/forest_plot.py

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/forest_plot.ipynb.
22

33
# %% auto 0
4-
__all__ = ['load_plot_data', 'extract_plot_data', 'forest_plot']
4+
__all__ = ['load_plot_data', 'extract_plot_data', 'map_effect_attribute', 'forest_plot']
55

66
# %% ../nbs/API/forest_plot.ipynb 5
77
import matplotlib.pyplot as plt
@@ -72,28 +72,42 @@ def extract_plot_data(contrast_plot_data, contrast_type):
7272

7373
return bootstraps, differences, bcalows, bcahighs
7474

75+
def map_effect_attribute(attribute_key):
76+
# Check if the attribute key exists in the dictionary
77+
effect_attr_map = {
78+
"mean_diff": "Mean Difference",
79+
"median_diff": "Median Difference",
80+
"cliffs_delta": "Cliffs Delta",
81+
"cohens_d": "Cohens d",
82+
"hedges_g": "Hedges g",
83+
"delta_g": "Delta g"
84+
}
85+
if attribute_key in effect_attr_map:
86+
return effect_attr_map[attribute_key]
87+
else:
88+
raise TypeError("The `effect_size` argument must be a string. Please choose from the following effect sizes: `mean_diff`,`median_diff`,`cliffs_delta`,`cohens_d``, and `hedges_g`.") # Return a default value or message if the key is not found
7589

7690
def forest_plot(
7791
contrasts: List,
7892
selected_indices: Optional[List] = None,
7993
contrast_type: str = "delta2",
80-
xticklabels: Optional[List] = None,
8194
effect_size: str = "mean_diff",
8295
contrast_labels: List[str] = None,
83-
ylabel: str = "value",
96+
ylabel: str = "effect size",
8497
plot_elements_to_extract: Optional[List] = None,
8598
title: str = "ΔΔ Forest",
8699
custom_palette: Optional[Union[dict, list, str]] = None,
87-
fontsize: int = 20,
100+
fontsize: int = 12,
101+
title_font_size: int =16,
88102
violin_kwargs: Optional[dict] = None,
89103
marker_size: int = 20,
90104
ci_line_width: float = 2.5,
91-
zero_line_width: int = 1,
105+
desat_violin: float = 1,
92106
remove_spines: bool = True,
93107
ax: Optional[plt.Axes] = None,
94108
additional_plotting_kwargs: Optional[dict] = None,
95109
rotation_for_xlabels: int = 45,
96-
alpha_violin_plot: float = 0.4,
110+
alpha_violin_plot: float = 0.8,
97111
horizontal: bool = False # New argument for horizontal orientation
98112
)-> plt.Figure:
99113
"""
@@ -106,11 +120,9 @@ def forest_plot(
106120
selected_indices : Optional[List], default=None
107121
Indices of specific contrasts to plot, if not plotting all.
108122
analysis_type : str
109-
the type of analysis (e.g., 'delta2', 'minimeta').
110-
xticklabels : Optional[List], default=None
111-
Custom labels for the x-axis ticks.
123+
the type of analysis (e.g., 'delta2', 'mini_meta').
112124
effect_size : str
113-
Type of effect size to plot (e.g., 'mean_diff', 'median_diff').
125+
Type of effect size to plot (e.g., 'mean_diff', 'median_diff', `cliffs_delta`,`cohens_d``, and `hedges_g`).
114126
contrast_labels : List[str]
115127
Labels for each contrast.
116128
ylabel : str
@@ -125,14 +137,14 @@ def forest_plot(
125137
Custom color palette for the plot.
126138
fontsize : int
127139
Font size for text elements in the plot.
140+
title_font_size: int =16
141+
Font size for text of plot title.
128142
violin_kwargs : Optional[dict], default=None
129143
Additional arguments for violin plot customization.
130144
marker_size : int
131145
Marker size for plotting mean differences or effect sizes.
132146
ci_line_width : float
133147
Width of confidence interval lines.
134-
zero_line_width : int
135-
Width of the line indicating zero effect size.
136148
remove_spines : bool, default=False
137149
If True, removes top and right plot spines.
138150
ax : Optional[plt.Axes], default=None
@@ -161,14 +173,13 @@ def forest_plot(
161173
if selected_indices is not None and not isinstance(selected_indices, (list, type(None))):
162174
raise TypeError("The `selected_indices` must be a list of integers or `None`.")
163175

176+
# For the 'contrast_type' parameter
164177
if not isinstance(contrast_type, str):
165-
raise TypeError("The `contrast_type` argument must be a string.")
166-
167-
if xticklabels is not None and not all(isinstance(label, str) for label in xticklabels):
168-
raise TypeError("The `xticklabels` must be a list of strings or `None`.")
169-
178+
raise TypeError("The `contrast_type` argument must be a string. Please choose from `delta2` and `mini_meta`.")
179+
180+
# For the 'effect_size' parameter
170181
if not isinstance(effect_size, str):
171-
raise TypeError("The `effect_size` argument must be a string.")
182+
raise TypeError("The `effect_size` argument must be a string. Please choose from the following effect sizes: `mean_diff`, `median_diff`, `cliffs_delta`, `cohens_d`, and `hedges_g`.")
172183

173184
if contrast_labels is not None and not all(isinstance(label, str) for label in contrast_labels):
174185
raise TypeError("The `contrast_labels` must be a list of strings or `None`.")
@@ -191,9 +202,6 @@ def forest_plot(
191202
if not isinstance(ci_line_width, (int, float)) or ci_line_width <= 0:
192203
raise TypeError("`ci_line_width` must be a positive integer or float.")
193204

194-
if not isinstance(zero_line_width, (int, float)) or zero_line_width <= 0:
195-
raise TypeError("`zero_line_width` must be a positive integer or float.")
196-
197205
if not isinstance(remove_spines, bool):
198206
raise TypeError("`remove_spines` must be a boolean value.")
199207

@@ -209,6 +217,8 @@ def forest_plot(
209217
if not isinstance(horizontal, bool):
210218
raise TypeError("`horizontal` must be a boolean value.")
211219

220+
if (effect_size and isinstance(effect_size, str)):
221+
ylabel = map_effect_attribute(effect_size)
212222
# Load plot data
213223
contrast_plot_data = load_plot_data(contrasts, effect_size, contrast_type)
214224

@@ -250,7 +260,7 @@ def forest_plot(
250260
if custom_palette:
251261
if isinstance(custom_palette, dict):
252262
violin_colors = [
253-
custom_palette.get(c, sns.color_palette()[0]) for c in contrasts
263+
custom_palette.get(c, sns.color_palette()[0]) for c in contrast_labels
254264
]
255265
elif isinstance(custom_palette, list):
256266
violin_colors = custom_palette[: len(contrasts)]
@@ -262,12 +272,18 @@ def forest_plot(
262272
f"The specified `custom_palette` {custom_palette} is not a recognized Matplotlib palette."
263273
)
264274
else:
265-
violin_colors = sns.color_palette()[: len(contrasts)]
275+
violin_colors = sns.color_palette(n_colors=len(contrasts))
266276

277+
violin_colors = [sns.desaturate(color, desat_violin) for color in violin_colors]
278+
267279
for patch, color in zip(v["bodies"], violin_colors):
268280
patch.set_facecolor(color)
269281
patch.set_alpha(alpha_violin_plot)
270-
282+
if horizontal:
283+
ax.plot([0, 0], [0, len(contrasts)+1], 'k', linewidth = 1)
284+
else:
285+
ax.plot([0, len(contrasts)+1], [0, 0], 'k', linewidth = 1)
286+
271287
# Flipping the axes for plotting based on 'horizontal'
272288
for k in range(1, len(contrasts) + 1):
273289
if horizontal:
@@ -280,19 +296,26 @@ def forest_plot(
280296
# Adjusting labels, ticks, and limits based on 'horizontal'
281297
if horizontal:
282298
ax.set_yticks(range(1, len(contrasts) + 1))
283-
ax.set_yticklabels(contrast_labels, rotation=rotation_for_xlabels, fontsize=fontsize)
299+
ax.set_yticklabels(contrast_labels, rotation=0, fontsize=fontsize)
284300
ax.set_xlabel(ylabel, fontsize=fontsize)
301+
ax.set_ylim([0.7, len(contrasts) + 0.5])
285302
else:
286303
ax.set_xticks(range(1, len(contrasts) + 1))
287304
ax.set_xticklabels(contrast_labels, rotation=rotation_for_xlabels, fontsize=fontsize)
288305
ax.set_ylabel(ylabel, fontsize=fontsize)
306+
ax.set_xlim([0.7, len(contrasts) + 0.5])
289307

290308
# Setting the title and adjusting spines as before
291-
ax.set_title(title, fontsize=fontsize)
309+
ax.set_title(title, fontsize=title_font_size)
292310
if remove_spines:
293-
for spine in ax.spines.values():
294-
spine.set_visible(False)
295-
311+
if horizontal:
312+
ax.spines['left'].set_visible(False)
313+
ax.spines['right'].set_visible(False)
314+
ax.spines['top'].set_visible(False)
315+
else:
316+
ax.spines['top'].set_visible(False)
317+
ax.spines['bottom'].set_visible(False)
318+
ax.spines['right'].set_visible(False)
296319
# Apply additional customizations if provided
297320
if additional_plotting_kwargs:
298321
ax.set(**additional_plotting_kwargs)

0 commit comments

Comments
 (0)