Skip to content

Commit 67f5232

Browse files
committed
Adjusted delta g label, fixed a sankey bug, and trimmed some plot tools code
> Trimmed some plot tools functions > Adjusted delta g label name in code and tutorials > two group sankey now doesnt allow flow=False if there's only two-groups (very buggy).
1 parent c014093 commit 67f5232

24 files changed

+318
-283
lines changed

README.md

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ We are proud to announce **DABEST Version Dadar (v2025.03.27)** This new
1818
version of the DABEST Python library includes several new features and
1919
performance improvements. It’s a big one!
2020

21-
1. **Python 3.13 Support**: DABEST now supports Python 3.10-3.13.
21+
1. **Python 3.13 Support**: DABEST now supports Python 3.103.13.
2222

2323
2. **Horizontal Plots**: Users can now create horizontal layout plots,
2424
providing compact data visualization. This can be achieved by
@@ -27,19 +27,18 @@ performance improvements. It’s a big one!
2727
for more details.
2828

2929
3. **Forest Plots**: Forest plots provide a simple and intuitive way to
30-
visualize many delta-delta (or Deltas’ g), mini-meta, or regular
30+
visualize many delta-delta (or delta *g*), mini-meta, or regular
3131
delta effect sizes at once from multiple different dabest objects
3232
without presenting the raw data. See the [Forest
3333
Plots](../tutorials/07-forest_plot.html) tutorial for more details.
3434

35-
4. **Gridkey**: Users can now represent their experimental labels in a
36-
gridkey format. This can be accessed with the `gridkey` argument in
37-
the `plot()` method. See the gridkey section in the [Plot
35+
4. **Gridkey**: Users can now represent experimental labels in a
36+
gridkey’ table. This can be accessed with the `gridkey` parameter
37+
in the `plot()` method. See the gridkey section in the [Plot
3838
Aesthetics](../tutorials/09-plot_aesthetics.html) tutorial for more
3939
details.
4040

41-
5. **Aesthetic Updates**: We have made several aesthetic improvements
42-
to the plots, including:
41+
5. **Other Visualization Improvements**:
4342

4443
- **Raw, Contrast, and Summary bars**: We added bars highlighting
4544
the various groups’ differences. These bars can be customized to
@@ -49,32 +48,41 @@ performance improvements. It’s a big one!
4948
Aesthetics](../tutorials/09-plot_aesthetics.html) tutorial for
5049
more details.
5150

52-
- **Delta-Delta and Mini-Meta Plots**: We have adjusted the spacing
53-
of delta-delta and mini-meta plots to reduce whitespace. The new
54-
format brings the added effect size closer to the regular effect
55-
sizes. In addition, delta-delta plots now have a gap in the
56-
zeroline to separate the delta-delta and regular effect sizes.
51+
- **Tighter spacing in Delta-Delta and Mini-Meta Plots**: We have
52+
adjusted the spacing of delta-delta and mini-meta plots to reduce
53+
whitespace. The new format brings the overall effect size closer
54+
to the two-groups effect sizes. In addition, delta-delta plots now
55+
have a gap in the zero line to separate the delta-delta from the ∆
56+
effect sizes.
5757

58-
- **Delta-Delta Effect Sizes for Proportion Plots**: Delta-delta
59-
experimental plotting now supports binary data.
58+
- **Delta-Delta Effect Sizes for Proportion Plots**: In addition to
59+
continuous data, delta-delta plots now support binary data
60+
(proportions). This means that 2-way designs for binary outcomes
61+
can be analyzed with DABEST.
6062

6163
- **Proportion Plots Sample Sizes**: The sample size of each binary
6264
option for each group can now be displayed. These can be toggled
6365
on or off via the `prop_sample_counts` parameter.
6466

65-
- **Effect Size Lines for Paired Plots**: Paired plots now display
66-
lines linking the effect sizes within a group together in the
67-
contrast axes. These can be toggled on or off via the
67+
- **Effect Size Lines for Paired Plots**: Along with lines
68+
connecting paired observed values, the paired plots now also
69+
display lines linking the effect sizes within a group in the
70+
contrast axes. These lines can be toggled on or off via the
6871
`contrast_paired_lines` parameter.
6972

70-
- **Baseline Error Curves**: Baseline error dot and curve are now
71-
available to represent the baseline/control group in the contrast
72-
axes. The dot is shown by default, while the curve can be toggled
73-
on/off by the user (via the `show_baseline_ec` parameter).
73+
- **Baseline Error Curves**: To represent the baseline/control group
74+
in the contrast axes, it is now possible to plot the baseline dot
75+
and the baseline error curve. The dot is shown by default, while
76+
the curve can be toggled on/off by the user (via the
77+
`show_baseline_ec` parameter). This dot helps make it clear where
78+
the baseline comes from i.e. the control minus itself. The
79+
baseline error curve can be used to show that the baseline itself
80+
is an estimate inferred from the observed values of the control
81+
data.
7482

75-
- **Delta Text**: Effect size deltas are now displayed as text next
76-
to their respective effect size. This can be toggled on or off via
77-
the `delta_text` parameter.
83+
- **Delta Text**: Effect-size deltas (e.g. mean differences) are now
84+
displayed as numerals next to their respective effect size. This
85+
can be toggled on or off via the `delta_text` parameter.
7886

7987
- **Empty Circle Color Palette**: A new swarmplot color palette
8088
modification is available for unpaired plots via the
@@ -84,26 +92,27 @@ performance improvements. It’s a big one!
8492

8593
6. **Miscellaneous Improvements & Adjustments**
8694

87-
- **Numba for Speed Improvements**: We have included Numba to speed
88-
up the various calculations in DABEST. Precalculations will be
89-
performed during import, which will help speed up the subsequent
90-
loading and plotting of data.
95+
- **Numba for Speed Improvements**: We have added
96+
[Numba](https://numba.pydata.org/) to speed up the various
97+
calculations in DABEST. Precalculations will be performed during
98+
import, which will help speed up the subsequent loading and
99+
plotting of data.
91100

92-
- **Terminology Updates**: We have made several updates to the
93-
documentation and terminology to improve clarity and consistency.
94-
For example:
101+
- **Terminology/Naming Updates**: During the refactoring of the
102+
code, we have made several updates to the documentation and
103+
terminology to improve clarity and consistency. For example:
95104

96-
- Plot arguments have been adjusted to bring more clarity and
105+
- Many plot arguments have been adjusted to bring more clarity and
97106
consistency in naming. Arguments relating to the rawdata plot
98-
axis will now be typically referred to with raw while
107+
axis will now be typically referred to with `raw` while
99108
arguments relating to the contrast axis will be referred to with
100-
contrast. For example, raw_label replaces swarm_label and
101-
bar_label. The various kwargs relating to each different type
102-
of plot (e.g., swarmplot_kwargs) remain unchanged.
103-
- The method to utilise the Deltas’ g effect size is now via the
109+
`contrast`. For example, `raw_label` replaces `swarm_label` and
110+
`bar_label`. The various kwargs relating to each different type
111+
of plot (e.g., `swarmplot_kwargs`) remain unchanged.
112+
- The method to utilise the Delta *g* effect size is now via the
104113
.hedges_g.plot() method rather than creating a whole new Delta_g
105114
object as before. The functionality remains the same, it plots
106-
hedges_g effect sizes and then the Deltas’ g effect size
115+
hedges_g effect sizes and then the Delta *g* effect size
107116
alongside these (if a delta-delta experiment was loaded
108117
correctly).
109118

dabest/_dabest_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ def cliffs_delta(self):
248248
@property
249249
def delta_g(self):
250250
"""
251-
Returns an :py:class:`EffectSizeDataFrame` for deltas' g, its confidence interval, and relevant statistics, for all comparisons as indicated via the `idx` and `paired` argument in `dabest.load()`.
251+
Returns an :py:class:`EffectSizeDataFrame` for delta g, its confidence interval, and relevant statistics, for all comparisons as indicated via the `idx` and `paired` argument in `dabest.load()`.
252252
"""
253-
raise DeprecationWarning("delta_g has been depreciated - Please use hedges_g (with delta2=True) for deltas' g experiments")
253+
raise DeprecationWarning("delta_g has been depreciated - Please use hedges_g (with delta2=True) for delta g experiments")
254254

255255

256256
@property

dabest/_delta_objects.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DeltaDelta(object):
3333
3434
$$\Delta_{\Delta} = \Delta_{2} - \Delta_{1}$$
3535
36-
and a deltas' g value is calculated as the mean difference between the two primary deltas divided by
36+
and a delta g value is calculated as the mean difference between the two primary deltas divided by
3737
the standard deviation of the delta-delta value, which is calculated from a pooled variance of the 4 samples:
3838
3939
$$\Delta_{g} = \frac{\Delta_{\Delta}}{s_{\Delta_{\Delta}}}$$
@@ -63,7 +63,7 @@ def __init__(
6363
self.__control = self.__dabest_obj.experiment_label[0]
6464
self.__test = self.__dabest_obj.experiment_label[1]
6565

66-
# Compute the bootstrap delta-delta or deltas' g and the true dela-delta based on the raw data
66+
# Compute the bootstrap delta-delta or delta g and the true dela-delta based on the raw data
6767
if self.__effect_size == "mean_diff":
6868
self.__bootstraps_delta_delta = bootstraps_delta_delta[2]
6969
self.__difference = (
@@ -157,7 +157,7 @@ def __repr__(self, header=True, sigfig=3):
157157
if self.__effect_size == "mean_diff":
158158
out1 = "The delta-delta between {control} and {test} ".format(**first_line)
159159
else:
160-
out1 = "The deltas' g between {control} and {test} ".format(**first_line)
160+
out1 = "The delta g between {control} and {test} ".format(**first_line)
161161

162162
base_string_fmt = "{:." + str(sigfig) + "}"
163163
if "." in str(self.__ci):

dabest/forest_plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,12 @@ def forest_plot(
647647
effect_attr_map = {
648648
"mean_diff": "Mean Difference",
649649
"hedges_g": "Hedges' g",
650-
"delta_g": "Deltas' g"
650+
"delta_g": "Delta g"
651651
}
652652
if contrast_type=='delta2' and idx is None and effect_size == "hedges_g":
653-
ylabel = "Deltas' g"
653+
ylabel = "Delta g"
654654
elif contrast_type=='delta2' and idx is not None and (effect_size == "delta_g" or effect_size == "hedges_g"):
655-
ylabel = "Hedges' g with Deltas' g"
655+
ylabel = "Hedges' g with Delta g"
656656
else:
657657
ylabel = effect_attr_map[effect_size]
658658
lim_key = ax.set_xlabel if horizontal else ax.set_ylabel

dabest/misc_tools.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,13 @@ def get_params(
193193
else "right" if not horizontal
194194
else "left"
195195
)
196+
# Whether to show sample sizes with ticklabels
197+
show_sample_size = plot_kwargs["show_sample_size"]
196198

197199
return (dabest_obj, plot_data, xvar, yvar, is_paired, effect_size, proportional, all_plot_groups,
198200
idx, show_delta2, show_mini_meta, float_contrast, show_pairs, group_summaries,
199201
horizontal, results, ci_type, x1_level, experiment_label, show_baseline_ec,
200-
one_sankey, two_col_sankey, asymmetric_side)
202+
one_sankey, two_col_sankey, asymmetric_side, show_sample_size)
201203

202204
def get_kwargs(
203205
plot_kwargs: dict,
@@ -219,6 +221,7 @@ def get_kwargs(
219221
default_swarmplot_kwargs = {
220222
"size": plot_kwargs["raw_marker_size"],
221223
"alpha": plot_kwargs["raw_alpha"],
224+
"fontsize": plot_kwargs.get("fontsize_rawxlabel"),
222225
}
223226
if plot_kwargs["swarmplot_kwargs"] is None:
224227
swarmplot_kwargs = default_swarmplot_kwargs
@@ -234,6 +237,7 @@ def get_kwargs(
234237
"width": plot_kwargs["bar_width"],
235238
"alpha": plot_kwargs["raw_alpha"],
236239
"err_kws": {'color': 'black'},
240+
"fontsize": plot_kwargs["fontsize_rawxlabel"]
237241
}
238242
if plot_kwargs["barplot_kwargs"] is None:
239243
barplot_kwargs = default_barplot_kwargs
@@ -251,6 +255,7 @@ def get_kwargs(
251255
"alpha": plot_kwargs['raw_alpha'],
252256
"rightColor": False,
253257
"bar_width": 0.2,
258+
"fontsize": plot_kwargs.get("fontsize_rawxlabel")
254259
}
255260
if plot_kwargs["sankey_kwargs"] is None:
256261
sankey_kwargs = default_sankey_kwargs
@@ -280,7 +285,7 @@ def get_kwargs(
280285
"linewidth": 1,
281286
"alpha": plot_kwargs["raw_alpha"],
282287
'jitter': 0,
283-
'jitter_seed': 9876543210
288+
'jitter_seed': 9876543210,
284289
}
285290
if plot_kwargs["slopegraph_kwargs"] is None:
286291
slopegraph_kwargs = default_slopegraph_kwargs
@@ -1066,12 +1071,12 @@ def lookup_value(text):
10661071
else:
10671072
ticks_with_counts.append(f"{t}\n(N={value})")
10681073

1069-
fontsize_rawxlabel = plot_kwargs.get("fontsize_rawxlabel")
10701074
set_major_loc_method(plt.FixedLocator(get_ticks()))
1071-
if plot_kwargs['show_sample_size']:
1072-
set_label(ticks_with_counts, fontsize=fontsize_rawxlabel)
1073-
else:
1074-
set_label(get_label(), fontsize=fontsize_rawxlabel)
1075+
1076+
# label = ticks_with_counts if plot_kwargs['show_sample_size'] else get_label()
1077+
# set_label(label, fontsize=plot_kwargs.get("fontsize_rawxlabel"))
1078+
1079+
set_label(ticks_with_counts, fontsize=plot_kwargs.get("fontsize_rawxlabel"))
10751080

10761081
# Ensure ticks are at the correct locations
10771082
set_major_loc_method(plt.FixedLocator(get_ticks()))

0 commit comments

Comments
 (0)