Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f45d3c
Update styles.css
JAnns98 Apr 1, 2025
fd1b16c
Updated slopegraph format to include group summaries
JAnns98 Aug 18, 2025
9ca8aa1
initial commit for vortexmap and tutorial
sangyu Aug 19, 2025
a293e89
added vortexmap 2d functionality
sangyu Aug 20, 2025
770798b
delete old vortexmap file
sangyu Aug 20, 2025
905a4ad
Add custom_palette option for coloring barplots with 0 and 1 keys
JAnns98 Aug 21, 2025
ef4d4b5
Updated edge thickness for barplots with the custom palette [0,1] dic…
JAnns98 Aug 22, 2025
03bafb7
Merge pull request #208 from ACCLAB/feat-paired-coloroption
JAnns98 Aug 25, 2025
a9829b7
Integration with Forest plot
sangyu Aug 25, 2025
9e08d9f
Update README.md
sangyu Aug 25, 2025
5a1eeed
Merge pull request #1 from sangyu/master
sangyu Aug 25, 2025
babf285
fixed extract_data
sangyu Aug 26, 2025
8973fbd
Update 10-multicontrast.ipynb
sangyu Aug 26, 2025
c25ddc3
updated figure labels capitlisation
JAnns98 Sep 25, 2025
a0247b3
additional label updates
JAnns98 Sep 25, 2025
034e59d
Merge pull request #211 from ACCLAB/feat-update-labels
JAnns98 Oct 9, 2025
6adb788
Mini-meta weight update
maiyishan Sep 15, 2025
70da2b9
Commented out permutation p_val test
maiyishan Sep 15, 2025
fbd6251
Update test_502_minimeta_forest.png
maiyishan Sep 15, 2025
ebd1bb6
Fixed mini-meta pvals test file
JAnns98 Oct 13, 2025
06cae31
Minor image test changes
JAnns98 Oct 13, 2025
8ceb192
Merge pull request #210 from ACCLAB/mini-meta-weight-fix
JAnns98 Oct 13, 2025
bc5d8d9
Added tests for MultiContrast Class and Whorlmaps
sangyu Oct 16, 2025
06a1cc1
adjusting tests
sangyu Oct 16, 2025
537afa1
Bug fix in Test 11
sangyu Oct 16, 2025
00bbd2c
Corrected tests further
sangyu Oct 16, 2025
81905f9
Fixed baseline image for test 554
sangyu Oct 16, 2025
c9d14f6
Merge branch 'feat-multicontrast_vortexmap_forest_plot_integration' i…
sangyu Oct 16, 2025
4e1c212
Merge pull request #2 from ACCLAB/vnbdev
sangyu Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# DABEST-Python


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

[![minimal Python
Expand Down
14 changes: 12 additions & 2 deletions dabest/_delta_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,19 @@ def __init__(self, effectsizedataframe, permutation_count,
self.__control_N,
self.__test_var,
self.__test_N)

self.__bootstraps_variance = ci2g.calculate_bootstraps_var(self.__bootstraps)

# Compute the weighted average mean differences of the bootstrap data
# using the pooled group variances of the raw data as the inverse of
# weights
self.__bootstraps_weighted_delta = ci2g.calculate_weighted_delta(
self.__group_var,
self.__bootstraps_variance,
self.__bootstraps)

# Compute the weighted average mean difference based on the raw data
self.__difference = es.weighted_delta(np.array(self.__effsizedf["difference"]),
self.__group_var)
self.__bootstraps_variance)

sorted_weighted_deltas = npsort(self.__bootstraps_weighted_delta)

Expand Down Expand Up @@ -753,6 +755,14 @@ def group_var(self):
in order.
'''
return self.__group_var

@property
def bootstraps_var(self):
'''
Return the variances of each bootstrapped mean difference distribution
in order.
'''
return self.__bootstraps_variance


@property
Expand Down
5 changes: 3 additions & 2 deletions dabest/_effsize_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ def plot(
face_color=None,

raw_desat=0.5, # swarm_desat=0.5, OLD # bar_desat=0.5, OLD
contrast_desat=1, # halfviolin_desat=1, OLD
contrast_desat=1.0, # halfviolin_desat=1, OLD

raw_alpha=None, # NEW
contrast_alpha=0.8, # halfviolin_alpha=0.8, OLD
Expand Down Expand Up @@ -1478,7 +1478,8 @@ def plot(

if raw_alpha is None:
raw_alpha = (0.4 if self.is_proportional and self.is_paired
else 0.5 if self.is_paired
else 0.5 if self.is_paired and (color_col is not None or self.__delta2)
else 0.2 if self.is_paired and color_col is None
else 1.0
)

Expand Down
32 changes: 32 additions & 0 deletions dabest/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
'dabest/_stats_tools/confint_2group_diff.py'),
'dabest._stats_tools.confint_2group_diff.bootstrap_indices': ( 'API/confint_2group_diff.html#bootstrap_indices',
'dabest/_stats_tools/confint_2group_diff.py'),
'dabest._stats_tools.confint_2group_diff.calculate_bootstraps_var': ( 'API/confint_2group_diff.html#calculate_bootstraps_var',
'dabest/_stats_tools/confint_2group_diff.py'),
'dabest._stats_tools.confint_2group_diff.calculate_group_var': ( 'API/confint_2group_diff.html#calculate_group_var',
'dabest/_stats_tools/confint_2group_diff.py'),
'dabest._stats_tools.confint_2group_diff.calculate_weighted_delta': ( 'API/confint_2group_diff.html#calculate_weighted_delta',
Expand Down Expand Up @@ -107,6 +109,36 @@
'dabest/misc_tools.py'),
'dabest.misc_tools.show_legend': ('API/misc_tools.html#show_legend', 'dabest/misc_tools.py'),
'dabest.misc_tools.unpack_and_add': ('API/misc_tools.html#unpack_and_add', 'dabest/misc_tools.py')},
'dabest.multi': { 'dabest.multi.MultiContrast': ('API/multi.html#multicontrast', 'dabest/multi.py'),
'dabest.multi.MultiContrast.__init__': ('API/multi.html#multicontrast.__init__', 'dabest/multi.py'),
'dabest.multi.MultiContrast.__repr__': ('API/multi.html#multicontrast.__repr__', 'dabest/multi.py'),
'dabest.multi.MultiContrast._extract_data': ('API/multi.html#multicontrast._extract_data', 'dabest/multi.py'),
'dabest.multi.MultiContrast._extract_single_contrast': ( 'API/multi.html#multicontrast._extract_single_contrast',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_and_parse_structure': ( 'API/multi.html#multicontrast._validate_and_parse_structure',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_ci_type': ( 'API/multi.html#multicontrast._validate_ci_type',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_contrast_consistency': ( 'API/multi.html#multicontrast._validate_contrast_consistency',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_effect_size': ( 'API/multi.html#multicontrast._validate_effect_size',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_effect_size_compatibility': ( 'API/multi.html#multicontrast._validate_effect_size_compatibility',
'dabest/multi.py'),
'dabest.multi.MultiContrast._validate_individual_dabest_obj': ( 'API/multi.html#multicontrast._validate_individual_dabest_obj',
'dabest/multi.py'),
'dabest.multi.MultiContrast.bootstraps': ('API/multi.html#multicontrast.bootstraps', 'dabest/multi.py'),
'dabest.multi.MultiContrast.confidence_intervals': ( 'API/multi.html#multicontrast.confidence_intervals',
'dabest/multi.py'),
'dabest.multi.MultiContrast.effect_sizes': ('API/multi.html#multicontrast.effect_sizes', 'dabest/multi.py'),
'dabest.multi.MultiContrast.forest_plot': ('API/multi.html#multicontrast.forest_plot', 'dabest/multi.py'),
'dabest.multi.MultiContrast.get_bootstrap_by_position': ( 'API/multi.html#multicontrast.get_bootstrap_by_position',
'dabest/multi.py'),
'dabest.multi.MultiContrast.whorlmap': ('API/multi.html#multicontrast.whorlmap', 'dabest/multi.py'),
'dabest.multi._sample_bootstrap': ('API/multi.html#_sample_bootstrap', 'dabest/multi.py'),
'dabest.multi._spiralize': ('API/multi.html#_spiralize', 'dabest/multi.py'),
'dabest.multi.combine': ('API/multi.html#combine', 'dabest/multi.py'),
'dabest.multi.whorlmap': ('API/multi.html#whorlmap', 'dabest/multi.py')},
'dabest.plot_tools': { 'dabest.plot_tools.SwarmPlot': ('API/plot_tools.html#swarmplot', 'dabest/plot_tools.py'),
'dabest.plot_tools.SwarmPlot.__init__': ( 'API/plot_tools.html#swarmplot.__init__',
'dabest/plot_tools.py'),
Expand Down
16 changes: 12 additions & 4 deletions dabest/_stats_tools/confint_2group_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__all__ = ['create_jackknife_indexes', 'create_repeated_indexes', 'compute_meandiff_jackknife', 'bootstrap_indices',
'compute_bootstrapped_diff', 'delta2_bootstrap_loop', 'compute_delta2_bootstrapped_diff',
'compute_meandiff_bias_correction', 'compute_interval_limits', 'calculate_group_var',
'calculate_weighted_delta']
'calculate_bootstraps_var', 'calculate_weighted_delta']

# %% ../../nbs/API/confint_2group_diff.ipynb 4
import numpy as np
Expand Down Expand Up @@ -319,15 +319,23 @@ def calculate_group_var(control_var, control_N, test_var, test_N):

return pooled_var

def calculate_bootstraps_var(bootstraps):

def calculate_weighted_delta(group_var, differences):
bootstraps_var_list = [np.var(x, ddof=1) for x in bootstraps]
bootstraps_var_array = np.array(bootstraps_var_list)

return bootstraps_var_array



def calculate_weighted_delta(bootstrap_dist_var, differences):
"""
Compute the weighted deltas.
"""

weight = 1 / group_var
weight = np.true_divide(1, bootstrap_dist_var)
denom = np.sum(weight)
num = 0.0
for i in range(len(weight)):
num += weight[i] * differences[i]
return num / denom
return np.true_divide(num, denom)
4 changes: 2 additions & 2 deletions dabest/_stats_tools/effsize.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ def _compute_hedges_correction_factor(n1,

# %% ../../nbs/API/effsize.ipynb 13
@njit(cache=True)
def weighted_delta(difference, group_var):
def weighted_delta(difference, bootstrap_dist_var):
'''
Compute the weighted deltas where the weight is the inverse of the
pooled group difference.
'''

weight = np.true_divide(1, group_var)
weight = np.true_divide(1, bootstrap_dist_var)
return np.sum(difference*weight)/np.sum(weight)
53 changes: 39 additions & 14 deletions dabest/misc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def get_params(

def get_kwargs(
plot_kwargs: dict,
ytick_color
ytick_color,
is_paired: bool = False
):
"""
Extracts the kwargs from the `plot_kwargs` object for use in the plotter function.
Expand All @@ -214,6 +215,8 @@ def get_kwargs(
Kwargs passed to the plot function.
ytick_color : str or color list
Color of the yticks.
is_paired : bool, optional
A boolean flag to determine if the plot is for paired data. Default is False.
"""
from .misc_tools import merge_two_dicts

Expand Down Expand Up @@ -334,7 +337,7 @@ def get_kwargs(
default_group_summaries_kwargs = {
"zorder": 3,
"lw": 2,
"alpha": 1,
"alpha": 1 if not is_paired else 0.6,
'gap_width_percent': 1.5,
'offset': 0.1,
'color': None
Expand Down Expand Up @@ -513,7 +516,7 @@ def get_color_palette(
idx: list,
all_plot_groups: list,
delta2: bool,
sankey: bool
proportional: bool
):
"""
Create the color palette to be used in the plotter function.
Expand All @@ -534,9 +537,11 @@ def get_color_palette(
A list of all the group names.
delta2 : bool
A boolean flag to determine if the plot will have a delta-delta effect size.
sankey : bool
A boolean flag to determine if the plot is for a Sankey diagram.
proportional : bool
A boolean flag to determine if the plot is for a proportional plot.
"""
sankey = True if proportional and show_pairs else False

# Create color palette that will be shared across subplots.
color_col = plot_kwargs["color_col"]
if color_col is None:
Expand All @@ -548,7 +553,13 @@ def get_color_palette(
color_groups = pd.unique(plot_data[color_col])
bootstraps_color_by_group = False
if show_pairs:
bootstraps_color_by_group = False
if plot_kwargs["custom_palette"] is not None:
if delta2 or sankey:
bootstraps_color_by_group = False
else:
bootstraps_color_by_group = True
else:
bootstraps_color_by_group = False

# Handle the color palette.
filled = True
Expand Down Expand Up @@ -599,6 +610,17 @@ def get_color_palette(
groups_in_palette = {
k: custom_pal[k] for k in color_groups
}
elif proportional and not sankey: # barplots (unpaired proportional data)
keys = list(custom_pal.keys())
if all(k in keys for k in [1, 0]) and len(keys) == 2:
groups_in_palette = {
k: custom_pal[k] for k in [1, 0]
}
bootstraps_color_by_group = False
else:
groups_in_palette = {
k: custom_pal[k] for k in all_plot_groups if k in color_groups
}
elif sankey:
groups_in_palette = {
k: custom_pal[k] for k in [1, 0]
Expand Down Expand Up @@ -915,7 +937,7 @@ def initialize_fig(
raw_label = plot_kwargs["raw_label"]
if raw_label is None:
if proportional:
raw_label = "Proportion of Success" if effect_size_type != "cohens_h" else "Value"
raw_label = "Proportion of success" if effect_size_type != "cohens_h" else "Value"
else:
raw_label = yvar

Expand All @@ -929,16 +951,16 @@ def initialize_fig(

# Set contrast axes y-label.
contrast_label_dict = {
"mean_diff": "Mean Difference",
"median_diff": "Median Difference",
"mean_diff": "Mean difference",
"median_diff": "Median difference",
"cohens_d": "Cohen's d",
"hedges_g": "Hedges' g",
"cliffs_delta": "Cliff's delta",
"cohens_h": "Cohen's h",
}

if proportional and effect_size_type != "cohens_h":
default_contrast_label = "Proportion Difference"
default_contrast_label = "Proportion difference"
else:
default_contrast_label = contrast_label_dict[effect_size_type]

Expand Down Expand Up @@ -1856,13 +1878,15 @@ def color_picker(color_type: str,
elements: list,
color_col: str,
show_pairs: bool,
color_palette: dict) -> list:
color_palette: dict,
bootstraps_color_by_group: bool) -> list:
num_of_elements = len(elements)
colors = (
[kwargs.pop('color')] * num_of_elements
if kwargs.get('color', None) is not None
else ['black'] * num_of_elements
if color_col is not None or show_pairs
# if color_col is not None or show_pairs
if color_col is not None or not bootstraps_color_by_group
else list(color_palette.values())
)
if color_type in ['contrast', 'summary', 'delta_text']:
Expand All @@ -1877,7 +1901,7 @@ def color_picker(color_type: str,
return final_colors


def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, color_col, show_pairs,
def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, color_col, show_pairs, bootstraps_color_by_group,
plot_data = None, xvar = None, yvar = None, # Raw data
results = None, ticks_to_plot = None, extra_delta = None, # Contrast data
reference_band = None, summary_axes = None, ci_type = None # Summary data
Expand Down Expand Up @@ -1951,7 +1975,8 @@ def prepare_bars_for_plot(bar_type, bar_kwargs, horizontal, plot_palette_raw, co
elements = ticks_to_plot if bar_type=='contrast' else ticks,
color_col = color_col,
show_pairs = show_pairs,
color_palette = plot_palette_raw
color_palette = plot_palette_raw,
bootstraps_color_by_group = bootstraps_color_by_group
)
if bar_type == 'contrast' and extra_delta is not None:
colors.append('black')
Expand Down
Loading