Skip to content

Commit 3ac4852

Browse files
committed
Merge branch 'vnbdev' of github.com:ACCLAB/DABEST-python into pullrequests/siemdejong/issue-183
# Conflicts: # dabest/_modidx.py # dabest/misc_tools.py # dabest/plot_tools.py # dabest/plotter.py # nbs/API/misc_tools.ipynb # nbs/API/plot_tools.ipynb # nbs/API/plotter.ipynb
2 parents 9a42975 + 360fdc3 commit 3ac4852

File tree

134 files changed

+5724
-3806
lines changed

Some content is hidden

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

134 files changed

+5724
-3806
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _proc/
55
.gitattributes
66
.last_checked
77
.gitconfig
8+
.cursorignore
89
*.bak
910
*.log
1011
*~

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
44

55
[![minimal Python
6-
version](https://img.shields.io/badge/Python%3E%3D-3.8-6666ff.svg)](https://www.anaconda.com/distribution/)
6+
version](https://img.shields.io/badge/Python%3E%3D-3.9-6666ff.svg)](https://www.anaconda.com/distribution/)
77
[![PyPI
88
version](https://badge.fury.io/py/dabest.svg)](https://badge.fury.io/py/dabest)
99
[![Downloads](https://img.shields.io/pepy/dt/dabest.svg)](https://pepy.tech/project/dabest)

dabest/_dabest_object.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# %% ../nbs/API/dabest_object.ipynb 4
99
# Import standard data science libraries
1010
from numpy import array, repeat, random, issubdtype, number
11+
import numpy as np
1112
import pandas as pd
1213
from scipy.stats import norm
1314
from scipy.stats import randint
@@ -479,7 +480,7 @@ def _check_errors(self, x, y, idx, experiment, experiment_label, x1_level):
479480

480481
# Handling str type condition
481482
if is_str_condition_met:
482-
if len(pd.unique(idx).tolist()) != 2:
483+
if len(np.unique(idx).tolist()) != 2:
483484
err0 = "`mini_meta` is True, but `idx` ({})".format(idx)
484485
err1 = "does not contain exactly 2 unique columns."
485486
raise ValueError(err0 + err1)

dabest/_effsize_objects.py

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ def plot(
973973
contrast_ylim=None,
974974
delta2_ylim=None,
975975
swarm_side=None,
976+
empty_circle=False,
976977
custom_palette=None,
977978
swarm_desat=0.5,
978979
halfviolin_desat=1,
@@ -996,10 +997,6 @@ def plot(
996997
fig_size=None,
997998
dpi=100,
998999
ax=None,
999-
contrast_show_es=False,
1000-
es_sf=2,
1001-
es_fontsize=10,
1002-
contrast_show_deltas=True,
10031000
gridkey_rows=None,
10041001
gridkey_merge_pairs=False,
10051002
gridkey_show_Ns=True,
@@ -1019,6 +1016,17 @@ def plot(
10191016
fontsize_contrastxlabel=12,
10201017
fontsize_contrastylabel=12,
10211018
fontsize_delta2label=12,
1019+
#### Contrast bars and delta text and delta dots WIP ####
1020+
contrast_bars=True,
1021+
swarm_bars=True,
1022+
contrast_bars_kwargs=None,
1023+
swarm_bars_kwargs=None,
1024+
summary_bars=None,
1025+
summary_bars_kwargs=None,
1026+
delta_text=True,
1027+
delta_text_kwargs=None,
1028+
delta_dot=True,
1029+
delta_dot_kwargs=None,
10221030
):
10231031
"""
10241032
Creates an estimation plot for the effect size of interest.
@@ -1066,6 +1074,12 @@ def plot(
10661074
https://seaborn.pydata.org/generated/seaborn.cubehelix_palette.html
10671075
The named colors of matplotlib can be found here:
10681076
https://matplotlib.org/examples/color/named_colors.html
1077+
swarm_side: string, default None
1078+
The side on which points are swarmed for swarmplots ("center", "left", or "right").
1079+
empty_circle: boolean, default False
1080+
Boolean value determining if empty circles will be used for plotting of
1081+
swarmplot for control groups. Color of each individual swarm is also now
1082+
dependent on the comparison group.
10691083
swarm_desat : float, default 1
10701084
Decreases the saturation of the colors in the swarmplot by the
10711085
desired proportion. Uses `seaborn.desaturate()` to acheive this.
@@ -1161,7 +1175,39 @@ def plot(
11611175
Font size for the contrast axes ylabel.
11621176
fontsize_delta2label : float, default 12
11631177
Font size for the delta-delta axes ylabel.
1164-
1178+
1179+
1180+
contrast_bars : boolean, default True
1181+
Whether or not to display the contrast bars.
1182+
swarm_bars : boolean, default True
1183+
Whether or not to display the swarm bars.
1184+
contrast_bars_kwargs : dict, default None
1185+
Pass relevant keyword arguments to the contrast bars. Pass any keyword arguments accepted by
1186+
matplotlib.patches.Rectangle here, as a string. If None, the following keywords are passed:
1187+
{"color": None, "alpha": 0.3}
1188+
swarm_bars_kwargs : dict, default None
1189+
Pass relevant keyword arguments to the swarm bars. Pass any keyword arguments accepted by
1190+
matplotlib.patches.Rectangle here, as a string. If None, the following keywords are passed:
1191+
{"color": None, "alpha": 0.3}
1192+
1193+
summary_bars : list, default None
1194+
Pass a list of indices of the contrast objects to have summary bars displayed on the plot.
1195+
For example, [0,1] will show summary bars for the first two contrast objects.
1196+
summary_bars_kwargs: dict, default None
1197+
If None, the following keywords are passed: {"color": None, "alpha": 0.15}
1198+
delta_text : boolean, default True
1199+
Whether or not to display the text deltas.
1200+
delta_text_kwargs : dict, default None
1201+
Pass relevant keyword arguments to the delta text. Pass any keyword arguments accepted by
1202+
matplotlib.text.Text here, as a string. If None, the following keywords are passed:
1203+
{"color": None, "alpha": 1, "fontsize": 10, "ha": 'center', "va": 'center', "rotation": 0,
1204+
"x_location": 'right', "x_coordinates": None, "y_coordinates": None}
1205+
Use "x_coordinates" and "y_coordinates" if you would like to specify the text locations manually.
1206+
delta_dot : boolean, default True
1207+
Whether or not to display the delta dots on paired or repeated measure plots.
1208+
delta_dot_kwargs : dict, default None
1209+
Pass relevant keyword arguments. If None, the following keywords are passed:
1210+
{"marker": "^", "alpha": 0.5, "zorder": 2, "size": 3, "side": "right"}
11651211
11661212
Returns
11671213
-------
@@ -1182,7 +1228,7 @@ def plot(
11821228
if hasattr(self, "results") is False:
11831229
self.__pre_calc()
11841230

1185-
if self.__delta2:
1231+
if self.__delta2 and not empty_circle:
11861232
color_col = self.__x2
11871233

11881234
# if self.__proportional:

dabest/_modidx.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,35 @@
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')},
68-
'dabest.misc_tools': { 'dabest.misc_tools.get_unique_categories': ( 'API/misc_tools.html#get_unique_categories',
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')},
70+
'dabest.misc_tools': { 'dabest.misc_tools.Cumming_Plot_Aesthetic_Adjustments': ( 'API/misc_tools.html#cumming_plot_aesthetic_adjustments',
71+
'dabest/misc_tools.py'),
72+
'dabest.misc_tools.Gardner_Altman_Plot_Aesthetic_Adjustments': ( 'API/misc_tools.html#gardner_altman_plot_aesthetic_adjustments',
73+
'dabest/misc_tools.py'),
74+
'dabest.misc_tools.General_Plot_Aesthetic_Adjustments': ( 'API/misc_tools.html#general_plot_aesthetic_adjustments',
75+
'dabest/misc_tools.py'),
76+
'dabest.misc_tools.add_counts_to_ticks': ( 'API/misc_tools.html#add_counts_to_ticks',
77+
'dabest/misc_tools.py'),
78+
'dabest.misc_tools.extract_contrast_plotting_ticks': ( 'API/misc_tools.html#extract_contrast_plotting_ticks',
79+
'dabest/misc_tools.py'),
80+
'dabest.misc_tools.get_color_palette': ('API/misc_tools.html#get_color_palette', 'dabest/misc_tools.py'),
81+
'dabest.misc_tools.get_kwargs': ('API/misc_tools.html#get_kwargs', 'dabest/misc_tools.py'),
82+
'dabest.misc_tools.get_params': ('API/misc_tools.html#get_params', 'dabest/misc_tools.py'),
83+
'dabest.misc_tools.get_plot_groups': ('API/misc_tools.html#get_plot_groups', 'dabest/misc_tools.py'),
84+
'dabest.misc_tools.get_unique_categories': ( 'API/misc_tools.html#get_unique_categories',
6985
'dabest/misc_tools.py'),
7086
'dabest.misc_tools.get_varname': ('API/misc_tools.html#get_varname', 'dabest/misc_tools.py'),
87+
'dabest.misc_tools.initialize_fig': ('API/misc_tools.html#initialize_fig', 'dabest/misc_tools.py'),
7188
'dabest.misc_tools.merge_two_dicts': ('API/misc_tools.html#merge_two_dicts', 'dabest/misc_tools.py'),
7289
'dabest.misc_tools.print_greeting': ('API/misc_tools.html#print_greeting', 'dabest/misc_tools.py'),
90+
'dabest.misc_tools.set_xaxis_ticks_and_lims': ( 'API/misc_tools.html#set_xaxis_ticks_and_lims',
91+
'dabest/misc_tools.py'),
92+
'dabest.misc_tools.show_legend': ('API/misc_tools.html#show_legend', 'dabest/misc_tools.py'),
7393
'dabest.misc_tools.unpack_and_add': ('API/misc_tools.html#unpack_and_add', 'dabest/misc_tools.py')},
74-
'dabest.plot_tools': { 'dabest.plot_tools.SwarmPlot': ('API/plot_tools.html#swarmplot', 'dabest/plot_tools.py'),
94+
'dabest.plot_tools': { 'dabest.plot_tools.DeltaDotsPlotter': ('API/plot_tools.html#deltadotsplotter', 'dabest/plot_tools.py'),
95+
'dabest.plot_tools.SwarmPlot': ('API/plot_tools.html#swarmplot', 'dabest/plot_tools.py'),
7596
'dabest.plot_tools.SwarmPlot.__init__': ( 'API/plot_tools.html#swarmplot.__init__',
7697
'dabest/plot_tools.py'),
7798
'dabest.plot_tools.SwarmPlot._adjust_gutter_points': ( 'API/plot_tools.html#swarmplot._adjust_gutter_points',
@@ -84,14 +105,30 @@
84105
'dabest/plot_tools.py'),
85106
'dabest.plot_tools.SwarmPlot._swarm': ('API/plot_tools.html#swarmplot._swarm', 'dabest/plot_tools.py'),
86107
'dabest.plot_tools.SwarmPlot.plot': ('API/plot_tools.html#swarmplot.plot', 'dabest/plot_tools.py'),
108+
'dabest.plot_tools.barplotter': ('API/plot_tools.html#barplotter', 'dabest/plot_tools.py'),
87109
'dabest.plot_tools.check_data_matches_labels': ( 'API/plot_tools.html#check_data_matches_labels',
88110
'dabest/plot_tools.py'),
111+
'dabest.plot_tools.contrast_bars_plotter': ( 'API/plot_tools.html#contrast_bars_plotter',
112+
'dabest/plot_tools.py'),
113+
'dabest.plot_tools.delta_text_plotter': ( 'API/plot_tools.html#delta_text_plotter',
114+
'dabest/plot_tools.py'),
115+
'dabest.plot_tools.effect_size_curve_plotter': ( 'API/plot_tools.html#effect_size_curve_plotter',
116+
'dabest/plot_tools.py'),
89117
'dabest.plot_tools.error_bar': ('API/plot_tools.html#error_bar', 'dabest/plot_tools.py'),
90118
'dabest.plot_tools.get_swarm_spans': ('API/plot_tools.html#get_swarm_spans', 'dabest/plot_tools.py'),
119+
'dabest.plot_tools.grid_key_WIP': ('API/plot_tools.html#grid_key_wip', 'dabest/plot_tools.py'),
91120
'dabest.plot_tools.halfviolin': ('API/plot_tools.html#halfviolin', 'dabest/plot_tools.py'),
92121
'dabest.plot_tools.normalize_dict': ('API/plot_tools.html#normalize_dict', 'dabest/plot_tools.py'),
122+
'dabest.plot_tools.plot_minimeta_or_deltadelta_violins': ( 'API/plot_tools.html#plot_minimeta_or_deltadelta_violins',
123+
'dabest/plot_tools.py'),
93124
'dabest.plot_tools.sankeydiag': ('API/plot_tools.html#sankeydiag', 'dabest/plot_tools.py'),
94125
'dabest.plot_tools.single_sankey': ('API/plot_tools.html#single_sankey', 'dabest/plot_tools.py'),
126+
'dabest.plot_tools.slopegraph_plotter': ( 'API/plot_tools.html#slopegraph_plotter',
127+
'dabest/plot_tools.py'),
128+
'dabest.plot_tools.summary_bars_plotter': ( 'API/plot_tools.html#summary_bars_plotter',
129+
'dabest/plot_tools.py'),
130+
'dabest.plot_tools.swarm_bars_plotter': ( 'API/plot_tools.html#swarm_bars_plotter',
131+
'dabest/plot_tools.py'),
95132
'dabest.plot_tools.swarmplot': ('API/plot_tools.html#swarmplot', 'dabest/plot_tools.py'),
96133
'dabest.plot_tools.width_determine': ('API/plot_tools.html#width_determine', 'dabest/plot_tools.py')},
97134
'dabest.plotter': {'dabest.plotter.effectsize_df_plotter': ('API/plotter.html#effectsize_df_plotter', 'dabest/plotter.py')}}}

dabest/_stats_tools/effsize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def cohens_h(control:list|tuple|np.ndarray,
223223
)->float:
224224
'''
225225
Computes Cohen's h for test v.s. control.
226-
See [here](https://en.wikipedia.org/wiki/Cohen%27s_h for reference.)
226+
See [here](https://en.wikipedia.org/wiki/Cohen%27s_h) for reference.
227227
228228
`Notes`:
229229

0 commit comments

Comments
 (0)