Skip to content

Commit 2f6b5b2

Browse files
committed
Merge remote-tracking branch 'origin/sankey'
2 parents c7c394a + 5164bad commit 2f6b5b2

9 files changed

Lines changed: 627 additions & 101 deletions

File tree

dabest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
from ._stats_tools import effsize as effsize
2424
from ._classes import TwoGroupsEffectSize, PermutationTest
2525

26-
__version__ = "0.3.1"
26+
__version__ = "2023.02.14"

dabest/_classes.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,8 @@ class TwoGroupsEffectSize(object):
15701570
mean differences between two groups.
15711571
"""
15721572

1573-
def __init__(self, control, test, effect_size,proportional,
1573+
def __init__(self, control, test, effect_size,
1574+
proportional=False,
15741575
is_paired=None, ci=95,
15751576
resamples=5000,
15761577
permutation_count=5000,
@@ -1706,6 +1707,7 @@ def __init__(self, control, test, effect_size,proportional,
17061707
import scipy.stats as spstats
17071708

17081709
# import statsmodels.stats.power as power
1710+
import statsmodels
17091711

17101712
from string import Template
17111713
import warnings
@@ -2661,7 +2663,7 @@ def plot(self, color_col=None,
26612663
#bar plot
26622664
bar_label=None, bar_desat=0.5, bar_width = 0.5,bar_ylim = None,
26632665
# error bar of proportion plot
2664-
ci=None, err_color=None,
2666+
ci=None, ci_type='bca', err_color=None,
26652667

26662668
float_contrast=True,
26672669
show_pairs=True,
@@ -2678,6 +2680,7 @@ def plot(self, color_col=None,
26782680
barplot_kwargs=None,
26792681
violinplot_kwargs=None,
26802682
slopegraph_kwargs=None,
2683+
sankey_kwargs=None,
26812684
reflines_kwargs=None,
26822685
group_summary_kwargs=None,
26832686
legend_kwargs=None):
@@ -2778,6 +2781,12 @@ def plot(self, color_col=None,
27782781
accepted by matplotlib `plot()` function here, as a dict.
27792782
If None, the following keywords are
27802783
passed to plot() : {'linewidth':1, 'alpha':0.5}.
2784+
sankey_kwargs: dict, default None
2785+
Whis will change the appearance of the sankey diagram used to depict
2786+
paired proportional data when `show_pairs=True` and `proportional=True`.
2787+
Pass any keyword arguments accepted by plot_tools.sankeydiag() function
2788+
here, as a dict. If None, the following keywords are passed to sankey diagram:
2789+
{"width": 0.5, "align": "center", "alpha": 0.4, "bar_width": 0.1, "rightColor": False}
27812790
reflines_kwargs : dict, default None
27822791
This will change the appearance of the zero reference lines. Pass
27832792
any keyword arguments accepted by the matplotlib Axes `hlines`

dabest/_stats_tools/effsize.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
88
two_group_difference
99
cohens_d
10+
cohens_h
1011
hedges_g
1112
cliffs_delta
1213
func_difference
@@ -71,11 +72,19 @@ def two_group_difference(control, test, is_paired=False,
7172
float: The desired effect size.
7273
"""
7374
import numpy as np
75+
import warnings
7476

7577
if effect_size == "mean_diff":
7678
return func_difference(control, test, np.mean, is_paired)
7779

7880
elif effect_size == "median_diff":
81+
mes1 = "Using median as the statistic in bootstrapping may \
82+
result in a biased estimate and cause problems with \
83+
BCa confidence intervals. Consider using a different statistic, such as the mean.\n"
84+
mes2 = "When plotting, please consider using percetile confidence intervals\
85+
by specifying `ci_type='percentile'`. For detailed information, \
86+
refer to https://github.com/ACCLAB/DABEST-python/issues/129"
87+
warnings.warn(message=mes1+mes2, category=UserWarning)
7988
return func_difference(control, test, np.median, is_paired)
8089

8190
elif effect_size == "cohens_d":
@@ -257,7 +266,7 @@ def cohens_h(control, test):
257266
import pandas as pd
258267

259268
# Check whether dataframe contains only 0s and 1s.
260-
if pd.unique(control)==np.array([0,1]).all()==False and (pd.unique(test)==np.array([0,1])).all()==False:
269+
if np.isin(control, [0, 1]).all() == False or np.isin(test, [0, 1]).all() == False:
261270
raise ValueError("Input data must be binary.")
262271

263272
# Convert to numpy arrays for speed.

0 commit comments

Comments
 (0)