diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 29bfc575..41e29a16 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -11,4 +11,4 @@ on: jobs: deploy: runs-on: ubuntu-latest - steps: [uses: fastai/workflows/quarto-ghp@master] + steps: [uses: fastai/workflows/quarto-ghp3@master] diff --git a/.github/workflows/test-nbdev.yaml b/.github/workflows/test-nbdev.yaml index 948a7b69..fef02636 100644 --- a/.github/workflows/test-nbdev.yaml +++ b/.github/workflows/test-nbdev.yaml @@ -4,4 +4,4 @@ on: [workflow_dispatch, pull_request, push] jobs: test-nbdev: runs-on: ubuntu-latest - steps: [uses: fastai/workflows/nbdev-ci@master] + steps: [uses: fastai/workflows/nbdev3-ci@master] diff --git a/README.md b/README.md index 530577d4..10c80543 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,8 @@ brings new visualizations, refined plots, and improved accuracy. You can generate a Whorlmap directly from multi-dimensional DABEST objects using the `.whorlmap()` method. See the [Whorlmap - tutorial](10-whorlmap.html) for more details. + tutorial](https://acclab.github.io/DABEST-python/tutorials/10-whorlmap.html) + for more details. 2. **Slopegraphs 📈: Enhanced summaries for paired data** @@ -52,7 +53,8 @@ brings new visualizations, refined plots, and improved accuracy. - Customize appearance with `group_summaries_kwargs`. See the Group Summaries section in the [Plot Aesthetics - tutorial](08-plot_aesthetics.html) for more details. + tutorial](https://acclab.github.io/DABEST-python/tutorials/08-plot_aesthetics.html) + for more details. 3. **Mini-meta Weighted Delta Fix 🧮** @@ -69,7 +71,8 @@ brings new visualizations, refined plots, and improved accuracy. now color contrast bars and effect-size curves. See the Custom Palette section in the [Plot Aesthetics -tutorial](08-plot_aesthetics.html) for examples. +tutorial](https://acclab.github.io/DABEST-python/tutorials/08-plot_aesthetics.html) +for examples. Thank you for your continued support! @@ -170,6 +173,17 @@ snippets. ## How to cite +**Getting over ANOVA: Estimation graphics for multi-group comparisons** + +*Zinan Lu, Jonathan Anns, Yishan Mai, Rou Zhang, Kahseng Lian, Nicole +MynYi Lee, Shan Hashir, Lucas Wang Zhuoyu, A. Rosa Castillo Gonzalez, +Joses Ho, Hyungwon Choi, Sangyu Xu, Adam Claridge-Chang* + +bioRxiv preprint 2026. +[10.64898/2026.01.26.701654](http://dx.doi.org/10.64898/2026.01.26.701654) + +[PDF](https://www.biorxiv.org/content/10.64898/2026.01.26.701654v1.full.pdf) + **Moving beyond P values: Everyday data analysis with estimation plots** *Joses Ho, Tayfun Tumkaya, Sameer Aryal, Hyungwon Choi, Adam diff --git a/dabest/_api.py b/dabest/_api.py index 0f4ad140..cf34b9f4 100644 --- a/dabest/_api.py +++ b/dabest/_api.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/load.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['load', 'prop_dataset'] -# %% ../nbs/API/load.ipynb 4 +# %% ../nbs/API/load.ipynb #218e4f14 def load( data, idx=None, @@ -112,7 +112,7 @@ def load( ps_adjust, ) -# %% ../nbs/API/load.ipynb 5 +# %% ../nbs/API/load.ipynb #570ff65a import numpy as np from typing import Union, Optional import pandas as pd diff --git a/dabest/_bootstrap_tools.py b/dabest/_bootstrap_tools.py index 7a3e979c..b4333635 100644 --- a/dabest/_bootstrap_tools.py +++ b/dabest/_bootstrap_tools.py @@ -1,9 +1,9 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/bootstrap.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['bootstrap', 'jackknife_indexes', 'bca'] -# %% ../nbs/API/bootstrap.ipynb 3 +# %% ../nbs/API/bootstrap.ipynb #4231300f import numpy as np import pandas as pd import seaborn as sns @@ -12,7 +12,7 @@ from scipy.stats import mannwhitneyu, wilcoxon, norm import warnings -# %% ../nbs/API/bootstrap.ipynb 4 +# %% ../nbs/API/bootstrap.ipynb #e86b4b8d class bootstrap: """ Computes the summary statistic and a bootstrapped confidence interval. @@ -230,7 +230,7 @@ def __repr__(self): b = "[{} CI: {}, {}]".format(self.ci, self.bca_ci_low, self.bca_ci_high) return "\n".join([a, b]) -# %% ../nbs/API/bootstrap.ipynb 5 +# %% ../nbs/API/bootstrap.ipynb #00c814b9 def jackknife_indexes(data): # Taken without modification from scikits.bootstrap package. """ diff --git a/dabest/_dabest_object.py b/dabest/_dabest_object.py index a055cdd1..53b36360 100644 --- a/dabest/_dabest_object.py +++ b/dabest/_dabest_object.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/dabest_object.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['Dabest'] -# %% ../nbs/API/dabest_object.ipynb 5 +# %% ../nbs/API/dabest_object.ipynb #d3c6f47a # Import standard data science libraries import warnings from numpy import array, repeat, random, issubdtype, number @@ -14,7 +14,7 @@ from scipy.stats import norm from scipy.stats import randint -# %% ../nbs/API/dabest_object.ipynb 7 +# %% ../nbs/API/dabest_object.ipynb #350b12c1 class Dabest(object): """ @@ -559,14 +559,12 @@ def _check_errors(self, x, y, idx, experiment, experiment_label, x1_level): self.__x1_level = x1_level if self.__is_paired and self.__output_data.isnull().values.any(): - warn1 = f"NaN values detected under paired setting and removed," + warn1 = f"NaN values detected under paired setting," warn2 = f" please check your data." warnings.warn(warn1 + warn2) if x is not None and y is not None: rmname = self.__output_data[self.__output_data[y].isnull()][self.__id_col].tolist() self.__output_data = self.__output_data[~self.__output_data[self.__id_col].isin(rmname)] - elif x is None and y is None: - self.__output_data.dropna(inplace=True) # Check if there is a typo on paired if self.__is_paired and self.__is_paired not in ("baseline", "sequential"): diff --git a/dabest/_delta_objects.py b/dabest/_delta_objects.py index 07b15ea8..b843ce06 100644 --- a/dabest/_delta_objects.py +++ b/dabest/_delta_objects.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/delta_objects.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['DeltaDelta', 'MiniMetaDelta'] -# %% ../nbs/API/delta_objects.ipynb 5 +# %% ../nbs/API/delta_objects.ipynb #1814896d from scipy.stats import norm import pandas as pd import numpy as np @@ -15,7 +15,7 @@ import warnings import datetime as dt -# %% ../nbs/API/delta_objects.ipynb 6 +# %% ../nbs/API/delta_objects.ipynb #1bb53e06 class DeltaDelta(object): r""" A class to compute and store the delta-delta statistics for experiments with a 2-by-2 arrangement where two independent variables, A and B, each have two categorical values, 1 and 2. The data is divided into two pairs of two groups, and a primary delta is first calculated as the mean difference between each of the pairs: @@ -382,7 +382,7 @@ def results(self): self.__compute_results() return self.__results -# %% ../nbs/API/delta_objects.ipynb 10 +# %% ../nbs/API/delta_objects.ipynb #18462ec5 class MiniMetaDelta(object): """ A class to compute and store the weighted delta. diff --git a/dabest/_effsize_objects.py b/dabest/_effsize_objects.py index fae4b10f..fce3e822 100644 --- a/dabest/_effsize_objects.py +++ b/dabest/_effsize_objects.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/effsize_objects.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['TwoGroupsEffectSize', 'EffectSizeDataFrame', 'PermutationTest'] -# %% ../nbs/API/effsize_objects.ipynb 5 +# %% ../nbs/API/effsize_objects.ipynb #430d4ea8 import pandas as pd import lqrt from scipy.stats import norm @@ -23,7 +23,7 @@ from string import Template import scipy.stats as spstats -# %% ../nbs/API/effsize_objects.ipynb 6 +# %% ../nbs/API/effsize_objects.ipynb #9d988bdd class TwoGroupsEffectSize(object): """ @@ -818,7 +818,7 @@ def bec_pct_high(self): return self.__bec_pct_high -# %% ../nbs/API/effsize_objects.ipynb 10 +# %% ../nbs/API/effsize_objects.ipynb #024b1d00 class EffectSizeDataFrame(object): """A class that generates and stores the results of bootstrapped effect sizes for several comparisons.""" @@ -1658,7 +1658,7 @@ def delta2(self): def is_delta_delta(self): return self.__delta2 -# %% ../nbs/API/effsize_objects.ipynb 29 +# %% ../nbs/API/effsize_objects.ipynb #5d49f77f class PermutationTest: """ A class to compute and report permutation tests. diff --git a/dabest/_stats_tools/confint_1group.py b/dabest/_stats_tools/confint_1group.py index 744a7142..cc71e389 100644 --- a/dabest/_stats_tools/confint_1group.py +++ b/dabest/_stats_tools/confint_1group.py @@ -2,17 +2,17 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/API/confint_1group.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['create_bootstrap_indexes', 'compute_1group_jackknife', 'compute_1group_acceleration', 'compute_1group_bootstraps', 'compute_1group_bias_correction', 'summary_ci_1group'] -# %% ../../nbs/API/confint_1group.ipynb 4 +# %% ../../nbs/API/confint_1group.ipynb #9181f236 import numpy as np from numpy.random import PCG64, RandomState from scipy.stats import norm from numpy import sort as npsort -# %% ../../nbs/API/confint_1group.ipynb 5 +# %% ../../nbs/API/confint_1group.ipynb #bac09924 def create_bootstrap_indexes(array, resamples=5000, random_seed=12345): """Given an array-like, returns a generator of bootstrap indexes to be used for resampling. diff --git a/dabest/_stats_tools/confint_2group_diff.py b/dabest/_stats_tools/confint_2group_diff.py index 1950da36..03d7df11 100644 --- a/dabest/_stats_tools/confint_2group_diff.py +++ b/dabest/_stats_tools/confint_2group_diff.py @@ -2,13 +2,13 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/API/confint_2group_diff.ipynb. -# %% auto 0 +# %% auto #0 __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_bootstraps_var', 'calculate_weighted_delta'] -# %% ../../nbs/API/confint_2group_diff.ipynb 4 +# %% ../../nbs/API/confint_2group_diff.ipynb #fa733643 import numpy as np from numpy import arange, delete, errstate from numpy import mean as npmean @@ -18,7 +18,7 @@ from scipy.stats import norm from numpy import isnan -# %% ../../nbs/API/confint_2group_diff.ipynb 5 +# %% ../../nbs/API/confint_2group_diff.ipynb #8cf9b1fc @njit(cache=True, parallel=True) def create_jackknife_indexes(data): """ diff --git a/dabest/_stats_tools/effsize.py b/dabest/_stats_tools/effsize.py index 2e597185..216a513f 100644 --- a/dabest/_stats_tools/effsize.py +++ b/dabest/_stats_tools/effsize.py @@ -2,7 +2,7 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/API/effsize.ipynb. -# %% ../../nbs/API/effsize.ipynb 4 +# %% ../../nbs/API/effsize.ipynb #9d92d449 from __future__ import annotations import numpy as np from numba import njit @@ -11,10 +11,10 @@ from scipy.stats import mannwhitneyu -# %% auto 0 +# %% auto #0 __all__ = ['two_group_difference', 'func_difference', 'cohens_d', 'cohens_h', 'hedges_g', 'cliffs_delta', 'weighted_delta'] -# %% ../../nbs/API/effsize.ipynb 5 +# %% ../../nbs/API/effsize.ipynb #0547f8a7 def two_group_difference(control:list|tuple|np.ndarray, #Accepts lists, tuples, or numpy ndarrays of numeric types. test:list|tuple|np.ndarray, #Accepts lists, tuples, or numpy ndarrays of numeric types. is_paired=None, #If not None, returns the paired Cohen's d @@ -99,7 +99,7 @@ def two_group_difference(control:list|tuple|np.ndarray, #Accepts lists, tuples, return cliffs_delta(control, test) -# %% ../../nbs/API/effsize.ipynb 6 +# %% ../../nbs/API/effsize.ipynb #c93f36d4 def func_difference(control:list|tuple|np.ndarray, # NaNs are automatically discarded. test:list|tuple|np.ndarray, # NaNs are automatically discarded. func, # Summary function to apply. @@ -135,7 +135,7 @@ def func_difference(control:list|tuple|np.ndarray, # NaNs are automatically disc return func(test) - func(control) -# %% ../../nbs/API/effsize.ipynb 7 +# %% ../../nbs/API/effsize.ipynb #c6dd20e4 @njit(cache=True) def cohens_d(control:list|tuple|np.ndarray, test:list|tuple|np.ndarray, @@ -210,7 +210,7 @@ def cohens_d(control:list|tuple|np.ndarray, return M / divisor -# %% ../../nbs/API/effsize.ipynb 8 +# %% ../../nbs/API/effsize.ipynb #93688770 # @njit(cache=True) # It uses np.seterr which is not supported by Numba def cohens_h(control:list|tuple|np.ndarray, test:list|tuple|np.ndarray @@ -247,7 +247,7 @@ def cohens_h(control:list|tuple|np.ndarray, return phi_test - phi_control -# %% ../../nbs/API/effsize.ipynb 9 +# %% ../../nbs/API/effsize.ipynb #bcd77c32 def hedges_g(control:list|tuple|np.ndarray, test:list|tuple|np.ndarray, is_paired:str=None)->float: @@ -271,7 +271,7 @@ def hedges_g(control:list|tuple|np.ndarray, correction_factor = _compute_hedges_correction_factor(len_c, len_t) return correction_factor * d -# %% ../../nbs/API/effsize.ipynb 10 +# %% ../../nbs/API/effsize.ipynb #8fafb111 @njit(cache=True) def _mann_whitney_u(x, y): """Numba-optimized Mann-Whitney U calculation""" @@ -307,7 +307,7 @@ def cliffs_delta(control:list|tuple|np.ndarray, return _cliffs_delta_core(c, t) -# %% ../../nbs/API/effsize.ipynb 11 +# %% ../../nbs/API/effsize.ipynb #7a772510 @njit(cache=True) def _compute_standardizers(control, test): """ @@ -356,7 +356,7 @@ def _compute_standardizers(control, test): return pooled, average -# %% ../../nbs/API/effsize.ipynb 12 +# %% ../../nbs/API/effsize.ipynb #4529e82c def _compute_hedges_correction_factor(n1, n2 )->float: @@ -390,7 +390,7 @@ def _compute_hedges_correction_factor(n1, return out -# %% ../../nbs/API/effsize.ipynb 13 +# %% ../../nbs/API/effsize.ipynb #249e5375 @njit(cache=True) def weighted_delta(difference, bootstrap_dist_var): ''' diff --git a/dabest/_stats_tools/precompile.py b/dabest/_stats_tools/precompile.py index 46cc2bc4..e6205c0f 100644 --- a/dabest/_stats_tools/precompile.py +++ b/dabest/_stats_tools/precompile.py @@ -2,16 +2,16 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/API/precompile.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['precompile_all'] -# %% ../../nbs/API/precompile.ipynb 4 +# %% ../../nbs/API/precompile.ipynb #35aa9337 import numpy as np from tqdm import tqdm from . import effsize from . import confint_2group_diff -# %% ../../nbs/API/precompile.ipynb 5 +# %% ../../nbs/API/precompile.ipynb #472d8104 _NUMBA_COMPILED = False def precompile_all(): diff --git a/dabest/forest_plot.py b/dabest/forest_plot.py index b7a406c9..b404e963 100644 --- a/dabest/forest_plot.py +++ b/dabest/forest_plot.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/forest_plot.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['load_plot_data', 'check_for_errors', 'get_kwargs', 'color_palette', 'forest_plot'] -# %% ../nbs/API/forest_plot.ipynb 5 +# %% ../nbs/API/forest_plot.ipynb #a1cba2aa import matplotlib.pyplot as plt # %matplotlib inline import seaborn as sns @@ -14,7 +14,7 @@ import matplotlib.axes as axes import matplotlib.patches as mpatches -# %% ../nbs/API/forest_plot.ipynb 6 +# %% ../nbs/API/forest_plot.ipynb #b4634b4b def load_plot_data( data: List, effect_size: str = "mean_diff", diff --git a/dabest/misc_tools.py b/dabest/misc_tools.py index 3b400497..d0a56422 100644 --- a/dabest/misc_tools.py +++ b/dabest/misc_tools.py @@ -2,14 +2,14 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/misc_tools.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['merge_two_dicts', 'unpack_and_add', 'print_greeting', 'get_varname', 'get_unique_categories', 'get_params', 'get_kwargs', 'get_color_palette', 'initialize_fig', 'get_plot_groups', 'add_counts_to_ticks', 'extract_contrast_plotting_ticks', 'set_xaxis_ticks_and_lims', 'show_legend', 'gardner_altman_adjustments', 'draw_zeroline', 'redraw_independent_spines', 'redraw_dependent_spines', 'extract_group_summaries', 'color_picker', 'prepare_bars_for_plot'] -# %% ../nbs/API/misc_tools.ipynb 4 +# %% ../nbs/API/misc_tools.ipynb #3c9a6ef1 import datetime as dt import numpy as np from numpy import repeat @@ -19,7 +19,7 @@ import matplotlib import matplotlib.axes as axes -# %% ../nbs/API/misc_tools.ipynb 5 +# %% ../nbs/API/misc_tools.ipynb #5f54be1c def merge_two_dicts( x: dict, y: dict ) -> dict: # A dictionary containing a union of all keys in both original dicts. diff --git a/dabest/multi.py b/dabest/multi.py index 8edbb022..50b38721 100644 --- a/dabest/multi.py +++ b/dabest/multi.py @@ -1,9 +1,9 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/multi.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['MultiContrast', 'combine', 'whorlmap'] -# %% ../nbs/API/multi.ipynb 3 +# %% ../nbs/API/multi.ipynb #80099a4b import pandas as pd import numpy as np import matplotlib.pyplot as plt @@ -12,7 +12,7 @@ from typing import List, Optional, Union, Tuple, Dict, Any -# %% ../nbs/API/multi.ipynb 6 +# %% ../nbs/API/multi.ipynb #e4b58920 class MultiContrast: """ Unified multiple contrast object for forest plots and whorlmaps. @@ -482,7 +482,7 @@ def __repr__(self): f"effect_size='{self.effect_size}', " f"contrast_type='{types_info}')") -# %% ../nbs/API/multi.ipynb 8 +# %% ../nbs/API/multi.ipynb #b6952d49 def combine(dabest_objs: Union[List, List[List]], labels: Optional[List[str]] = None, row_labels: Optional[List[str]] = None, @@ -556,7 +556,7 @@ def combine(dabest_objs: Union[List, List[List]], return mc -# %% ../nbs/API/multi.ipynb 10 +# %% ../nbs/API/multi.ipynb #7814cc58 def _sample_bootstrap(bootstrap, m, n, reverse_neg, abs_rank, chop_tail): """Sample bootstrap values and prepare for spiral visualization.""" bootstrap_sorted = sorted(bootstrap) @@ -576,7 +576,7 @@ def _sample_bootstrap(bootstrap, m, n, reverse_neg, abs_rank, chop_tail): long_ranks = [bootstrap_sorted[r - 1] for r in ranks_to_look] return long_ranks -# %% ../nbs/API/multi.ipynb 11 +# %% ../nbs/API/multi.ipynb #725c96b5 def _spiralize(fill, m, n): """Convert linear array into spiral pattern.""" i = 0 @@ -622,7 +622,7 @@ def _spiralize(fill, m, n): return array -# %% ../nbs/API/multi.ipynb 12 +# %% ../nbs/API/multi.ipynb #20809f1d def whorlmap(multi_contrast, n=21, sort_by=None, cmap = 'vlag', vmax = None, vmin = None, reverse_neg=True, abs_rank=False, chop_tail=0, ax=None, fig_size=None, title = None, heatmap_kwargs=None, plot_kwargs=None): """ @@ -796,6 +796,6 @@ def whorlmap(multi_contrast, n=21, sort_by=None, cmap = 'vlag', vmax = None, vmi else: return a, mean_delta -# %% ../nbs/API/multi.ipynb 13 +# %% ../nbs/API/multi.ipynb #4f23adcf __all__ = ['MultiContrast', 'combine', 'whorlmap'] diff --git a/dabest/plot_tools.py b/dabest/plot_tools.py index 5eb6349e..45cb2134 100644 --- a/dabest/plot_tools.py +++ b/dabest/plot_tools.py @@ -2,16 +2,16 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/plot_tools.ipynb. -# %% ../nbs/API/plot_tools.ipynb 2 +# %% ../nbs/API/plot_tools.ipynb #dd831e92 from __future__ import annotations -# %% auto 0 +# %% auto #0 __all__ = ['halfviolin', 'get_swarm_spans', 'error_bar', 'check_data_matches_labels', 'normalize_dict', 'width_determine', 'single_sankey', 'sankeydiag', 'add_bars_to_plot', 'delta_text_plotter', 'delta_dots_plotter', 'slopegraph_plotter', 'plot_minimeta_or_deltadelta_violins', 'effect_size_curve_plotter', 'gridkey_plotter', 'barplotter', 'table_for_horizontal_plots', 'add_counts_to_prop_plots', 'swarmplot', 'SwarmPlot'] -# %% ../nbs/API/plot_tools.ipynb 4 +# %% ../nbs/API/plot_tools.ipynb #b070950d import math import warnings import itertools @@ -27,7 +27,7 @@ from pandas.api.types import CategoricalDtype from matplotlib.colors import ListedColormap -# %% ../nbs/API/plot_tools.ipynb 5 +# %% ../nbs/API/plot_tools.ipynb #98550688 def halfviolin(v, half="right", fill_color="k", alpha=1, line_color="k", line_width=0): for b in v["bodies"]: V = b.get_paths()[0].vertices @@ -2115,7 +2115,7 @@ def add_counts_to_prop_plots( rawdata_axes.text(sample_text_x, 0.05, sample_text_y1, **prop_sample_counts_kwargs) rawdata_axes.text(sample_text_x, 0.95, sample_text_y0, **prop_sample_counts_kwargs) -# %% ../nbs/API/plot_tools.ipynb 6 +# %% ../nbs/API/plot_tools.ipynb #24823471 def swarmplot( data: pd.DataFrame, x: str, diff --git a/dabest/plotter.py b/dabest/plotter.py index df9a3641..23302e39 100644 --- a/dabest/plotter.py +++ b/dabest/plotter.py @@ -2,10 +2,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/API/plotter.ipynb. -# %% auto 0 +# %% auto #0 __all__ = ['effectsize_df_plotter'] -# %% ../nbs/API/plotter.ipynb 4 +# %% ../nbs/API/plotter.ipynb #7562c1a1 import numpy as np import seaborn as sns import matplotlib @@ -16,7 +16,7 @@ import warnings import logging -# %% ../nbs/API/plotter.ipynb 5 +# %% ../nbs/API/plotter.ipynb #36a42b1c # TODO refactor function name def effectsize_df_plotter(effectsize_df: object, **plot_kwargs) -> matplotlib.figure.Figure: """ diff --git a/nbs/API/dabest_object.ipynb b/nbs/API/dabest_object.ipynb index 4054d6a6..f082c62b 100644 --- a/nbs/API/dabest_object.ipynb +++ b/nbs/API/dabest_object.ipynb @@ -664,14 +664,12 @@ " self.__x1_level = x1_level\n", "\n", " if self.__is_paired and self.__output_data.isnull().values.any():\n", - " warn1 = f\"NaN values detected under paired setting and removed,\"\n", + " warn1 = f\"NaN values detected under paired setting,\"\n", " warn2 = f\" please check your data.\"\n", " warnings.warn(warn1 + warn2)\n", " if x is not None and y is not None:\n", " rmname = self.__output_data[self.__output_data[y].isnull()][self.__id_col].tolist()\n", " self.__output_data = self.__output_data[~self.__output_data[self.__id_col].isin(rmname)]\n", - " elif x is None and y is None:\n", - " self.__output_data.dropna(inplace=True)\n", "\n", " # Check if there is a typo on paired\n", " if self.__is_paired and self.__is_paired not in (\"baseline\", \"sequential\"):\n", diff --git a/nbs/API/delta_objects.ipynb b/nbs/API/delta_objects.ipynb index ca09104f..91656b16 100644 --- a/nbs/API/delta_objects.ipynb +++ b/nbs/API/delta_objects.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "3bce2f06", "metadata": {}, "source": [ "# Delta objects\n", @@ -14,6 +15,7 @@ { "cell_type": "code", "execution_count": null, + "id": "639a4774", "metadata": {}, "outputs": [], "source": [ @@ -23,6 +25,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e883312c", "metadata": {}, "outputs": [], "source": [ @@ -33,6 +36,7 @@ { "cell_type": "code", "execution_count": null, + "id": "aa0262b3", "metadata": {}, "outputs": [], "source": [ @@ -45,6 +49,7 @@ { "cell_type": "code", "execution_count": null, + "id": "fae983d8", "metadata": {}, "outputs": [ { @@ -92,6 +97,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1814896d", "metadata": {}, "outputs": [], "source": [ @@ -109,6 +115,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1bb53e06", "metadata": {}, "outputs": [], "source": [ @@ -482,6 +489,7 @@ }, { "cell_type": "markdown", + "id": "4dc056b1", "metadata": {}, "source": [ "\n", @@ -496,6 +504,7 @@ }, { "cell_type": "markdown", + "id": "81decd9b", "metadata": {}, "source": [ "#### Example: delta-delta" @@ -504,6 +513,7 @@ { "cell_type": "code", "execution_count": null, + "id": "37dacdfc", "metadata": {}, "outputs": [ { @@ -568,6 +578,7 @@ { "cell_type": "code", "execution_count": null, + "id": "18462ec5", "metadata": {}, "outputs": [], "source": [ @@ -1062,6 +1073,7 @@ }, { "cell_type": "markdown", + "id": "02f5a7a2", "metadata": {}, "source": [ "The weighted delta is calcuated as follows:\n", @@ -1082,6 +1094,7 @@ }, { "cell_type": "markdown", + "id": "33de49d5", "metadata": {}, "source": [ "#### Example: mini-meta-delta" @@ -1090,6 +1103,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a7f99dff", "metadata": {}, "outputs": [ { @@ -1132,6 +1146,7 @@ }, { "cell_type": "markdown", + "id": "419b00fb", "metadata": {}, "source": [ "As of version 2023.02.14, weighted delta can only be calculated for mean difference, and not for standardized measures such as Cohen's *d*.\n", @@ -1145,6 +1160,7 @@ }, { "cell_type": "markdown", + "id": "2dd1d796", "metadata": {}, "source": [] } @@ -1157,5 +1173,5 @@ } }, "nbformat": 4, - "nbformat_minor": 4 + "nbformat_minor": 5 } diff --git a/nbs/API/effsize_objects.ipynb b/nbs/API/effsize_objects.ipynb index 4da0136f..1d200a2e 100644 --- a/nbs/API/effsize_objects.ipynb +++ b/nbs/API/effsize_objects.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "a8f6e14c", "metadata": {}, "source": [ "# Effectsize objects\n", @@ -14,6 +15,7 @@ { "cell_type": "code", "execution_count": null, + "id": "becd3bdf", "metadata": {}, "outputs": [], "source": [ @@ -23,6 +25,7 @@ { "cell_type": "code", "execution_count": null, + "id": "956b12a4", "metadata": {}, "outputs": [], "source": [ @@ -33,6 +36,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9a991fb5", "metadata": {}, "outputs": [], "source": [ @@ -45,6 +49,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ab97c8f0", "metadata": {}, "outputs": [ { @@ -84,6 +89,7 @@ { "cell_type": "code", "execution_count": null, + "id": "430d4ea8", "metadata": {}, "outputs": [], "source": [ @@ -109,6 +115,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9d988bdd", "metadata": {}, "outputs": [], "source": [ @@ -910,6 +917,7 @@ }, { "cell_type": "markdown", + "id": "955a36d1", "metadata": {}, "source": [ "#### Example" @@ -918,6 +926,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c1f1647d", "metadata": {}, "outputs": [ { @@ -948,6 +957,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0142a8ab", "metadata": {}, "outputs": [ { @@ -1015,6 +1025,7 @@ { "cell_type": "code", "execution_count": null, + "id": "024b1d00", "metadata": {}, "outputs": [], "source": [ @@ -1861,6 +1872,7 @@ }, { "cell_type": "markdown", + "id": "0c622e1a", "metadata": {}, "source": [ "#### Example: plot\n", @@ -1871,6 +1883,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a9a1388f", "metadata": {}, "outputs": [], "source": [ @@ -1912,6 +1925,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e7f5f4bc", "metadata": {}, "outputs": [ { @@ -1931,6 +1945,7 @@ }, { "cell_type": "markdown", + "id": "f7fb5efe", "metadata": {}, "source": [ " Create a Gardner-Altman plot for the Hedges' g effect size." @@ -1939,6 +1954,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e457ae1e", "metadata": {}, "outputs": [ { @@ -1958,6 +1974,7 @@ }, { "cell_type": "markdown", + "id": "012f7a06", "metadata": {}, "source": [ "Create a Cumming estimation plot for the mean difference." @@ -1966,6 +1983,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0dd903b1", "metadata": {}, "outputs": [ { @@ -1985,6 +2003,7 @@ }, { "cell_type": "markdown", + "id": "0838d251", "metadata": {}, "source": [ " Create a paired Gardner-Altman plot." @@ -1993,6 +2012,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c38cb10f", "metadata": {}, "outputs": [ { @@ -2014,6 +2034,7 @@ }, { "cell_type": "markdown", + "id": "86a5516a", "metadata": {}, "source": [ "Create a multi-group Cumming plot." @@ -2022,6 +2043,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ea5da412", "metadata": {}, "outputs": [ { @@ -2054,6 +2076,7 @@ }, { "cell_type": "markdown", + "id": "10675566", "metadata": {}, "source": [ "Create a shared control Cumming plot." @@ -2062,6 +2085,7 @@ { "cell_type": "code", "execution_count": null, + "id": "97e2eb40", "metadata": {}, "outputs": [ { @@ -2092,6 +2116,7 @@ }, { "cell_type": "markdown", + "id": "58dc1b2d", "metadata": {}, "source": [ "Create a repeated meausures (against baseline) Slopeplot." @@ -2100,6 +2125,7 @@ { "cell_type": "code", "execution_count": null, + "id": "4f101c31", "metadata": {}, "outputs": [ { @@ -2122,6 +2148,7 @@ }, { "cell_type": "markdown", + "id": "45dda7bb", "metadata": {}, "source": [ "Create a repeated meausures (sequential) Slopeplot." @@ -2130,6 +2157,7 @@ { "cell_type": "code", "execution_count": null, + "id": "83847a02", "metadata": {}, "outputs": [ { @@ -2153,6 +2181,7 @@ { "cell_type": "code", "execution_count": null, + "id": "68bcc034", "metadata": {}, "outputs": [], "source": [] @@ -2160,6 +2189,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5d49f77f", "metadata": {}, "outputs": [], "source": [ @@ -2338,6 +2368,7 @@ }, { "cell_type": "markdown", + "id": "b82bc6e5", "metadata": {}, "source": [ "**Notes**:\n", @@ -2357,6 +2388,7 @@ }, { "cell_type": "markdown", + "id": "4456d8db", "metadata": {}, "source": [ "#### Example: permutation test" @@ -2365,6 +2397,7 @@ { "cell_type": "code", "execution_count": null, + "id": "284f1c75", "metadata": {}, "outputs": [ { @@ -2390,6 +2423,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7f5be104", "metadata": {}, "outputs": [], "source": [] @@ -2403,5 +2437,5 @@ } }, "nbformat": 4, - "nbformat_minor": 4 + "nbformat_minor": 5 } diff --git a/nbs/API/forest_plot.ipynb b/nbs/API/forest_plot.ipynb index 22fd57b5..6fd10835 100644 --- a/nbs/API/forest_plot.ipynb +++ b/nbs/API/forest_plot.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "9bbabcc9", "metadata": {}, "source": [ "# Forest plot\n", @@ -14,6 +15,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a726b52e", "metadata": {}, "outputs": [], "source": [ @@ -23,6 +25,7 @@ { "cell_type": "code", "execution_count": null, + "id": "fe67d602", "metadata": {}, "outputs": [], "source": [ @@ -33,6 +36,7 @@ { "cell_type": "code", "execution_count": null, + "id": "efe6d6bf", "metadata": {}, "outputs": [], "source": [ @@ -45,6 +49,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5e714e51", "metadata": {}, "outputs": [], "source": [ @@ -55,6 +60,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a1cba2aa", "metadata": {}, "outputs": [], "source": [ @@ -71,6 +77,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b4634b4b", "metadata": {}, "outputs": [], "source": [ @@ -838,5 +845,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/API/load.ipynb b/nbs/API/load.ipynb index c71302db..86c7782c 100644 --- a/nbs/API/load.ipynb +++ b/nbs/API/load.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "bba9fe58", "metadata": {}, "source": [ "# Loading Data\n", @@ -14,6 +15,7 @@ { "cell_type": "code", "execution_count": null, + "id": "292ee915", "metadata": {}, "outputs": [], "source": [ @@ -23,6 +25,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b51d167", "metadata": {}, "outputs": [], "source": [ @@ -33,6 +36,7 @@ { "cell_type": "code", "execution_count": null, + "id": "bc61493e", "metadata": {}, "outputs": [], "source": [ @@ -46,6 +50,7 @@ { "cell_type": "code", "execution_count": null, + "id": "218e4f14", "metadata": {}, "outputs": [], "source": [ @@ -160,6 +165,7 @@ { "cell_type": "code", "execution_count": null, + "id": "570ff65a", "metadata": {}, "outputs": [], "source": [ @@ -242,6 +248,7 @@ }, { "cell_type": "markdown", + "id": "db38d192", "metadata": {}, "source": [ "## Example" @@ -250,6 +257,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f8762853", "metadata": {}, "outputs": [], "source": [ @@ -261,6 +269,7 @@ }, { "cell_type": "markdown", + "id": "5ccb211a", "metadata": {}, "source": [ "Create dummy data for demonstration." @@ -269,6 +278,7 @@ { "cell_type": "code", "execution_count": null, + "id": "30187b91", "metadata": {}, "outputs": [], "source": [ @@ -281,6 +291,7 @@ }, { "cell_type": "markdown", + "id": "7cc8867d", "metadata": {}, "source": [ "Load the data." @@ -289,6 +300,7 @@ { "cell_type": "code", "execution_count": null, + "id": "171a15fc", "metadata": {}, "outputs": [ { @@ -318,6 +330,7 @@ }, { "cell_type": "markdown", + "id": "b480536a", "metadata": {}, "source": [ "For proportion plot." @@ -326,6 +339,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f74b6325", "metadata": {}, "outputs": [], "source": [ @@ -346,5 +360,5 @@ } }, "nbformat": 4, - "nbformat_minor": 4 + "nbformat_minor": 5 } diff --git a/nbs/API/precompile.ipynb b/nbs/API/precompile.ipynb index 223c4ce9..95b8c834 100644 --- a/nbs/API/precompile.ipynb +++ b/nbs/API/precompile.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "60e69f4a", "metadata": {}, "source": [ "# precompile\n", @@ -14,6 +15,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3bcca32a", "metadata": {}, "outputs": [], "source": [ @@ -23,6 +25,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5d3e285a", "metadata": {}, "outputs": [], "source": [ @@ -33,6 +36,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e6eb02d0", "metadata": {}, "outputs": [], "source": [ @@ -45,6 +49,7 @@ { "cell_type": "code", "execution_count": null, + "id": "35aa9337", "metadata": {}, "outputs": [], "source": [ @@ -58,6 +63,7 @@ { "cell_type": "code", "execution_count": null, + "id": "472d8104", "metadata": {}, "outputs": [], "source": [ @@ -107,5 +113,5 @@ ], "metadata": {}, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/read_me.ipynb b/nbs/read_me.ipynb index 702dc10d..de60a0a6 100644 --- a/nbs/read_me.ipynb +++ b/nbs/read_me.ipynb @@ -43,7 +43,7 @@ "\n", " They are especially useful for large-scale or multi-condition experiments, serving as a **space-efficient alternative to stacked forest plots**.\n", "\n", - " You can generate a Whorlmap directly from multi-dimensional DABEST objects using the `.whorlmap()` method. See the [Whorlmap tutorial](10-whorlmap.html) for more details.\n", + " You can generate a Whorlmap directly from multi-dimensional DABEST objects using the `.whorlmap()` method. See the [Whorlmap tutorial](https://acclab.github.io/DABEST-python/tutorials/10-whorlmap.html) for more details.\n", "\n", "2. **Slopegraphs 📈: Enhanced summaries for paired data**\n", " \n", @@ -55,7 +55,7 @@ " \n", " - Customize appearance with `group_summaries_kwargs`.\n", "\n", - " See the Group Summaries section in the [Plot Aesthetics tutorial](08-plot_aesthetics.html) for more details.\n", + " See the Group Summaries section in the [Plot Aesthetics tutorial](https://acclab.github.io/DABEST-python/tutorials/08-plot_aesthetics.html) for more details.\n", "\n", "3. **Mini-meta Weighted Delta Fix 🧮**\n", " \n", @@ -69,7 +69,7 @@ " - **Slopegraphs (paired, non-proportional):**\n", " `custom_palette` can now color contrast bars and effect-size curves.\n", "\n", - " See the Custom Palette section in the [Plot Aesthetics tutorial](08-plot_aesthetics.html) for examples.\n", + " See the Custom Palette section in the [Plot Aesthetics tutorial](https://acclab.github.io/DABEST-python/tutorials/08-plot_aesthetics.html) for examples.\n", "\n", "Thank you for your continued support! \n", "\n", @@ -177,6 +177,16 @@ "metadata": {}, "source": [ "## How to cite\n", + "**Getting over ANOVA: Estimation graphics for multi-group comparisons**\n", + "\n", + "*Zinan Lu, Jonathan Anns, Yishan Mai, Rou Zhang, Kahseng Lian, Nicole MynYi Lee, Shan Hashir, Lucas Wang Zhuoyu, A. Rosa Castillo Gonzalez, Joses Ho, Hyungwon Choi, Sangyu Xu, Adam Claridge-Chang*\n", + "\n", + "bioRxiv preprint 2026. [10.64898/2026.01.26.701654](http://dx.doi.org/10.64898/2026.01.26.701654)\n", + "\n", + "[PDF](https://www.biorxiv.org/content/10.64898/2026.01.26.701654v1.full.pdf)\n", + "\n", + "\n", + "\n", "\n", "**Moving beyond P values: Everyday data analysis with estimation plots**\n", "\n", diff --git a/nbs/tests/mpl_image_tests/baseline_images/test_266_multigroups_prop_paired_meandiff_gridkey_userdefinedrows.png b/nbs/tests/mpl_image_tests/baseline_images/test_266_multigroups_prop_paired_meandiff_gridkey_userdefinedrows.png index 712ebaf7..4d3faf47 100644 Binary files a/nbs/tests/mpl_image_tests/baseline_images/test_266_multigroups_prop_paired_meandiff_gridkey_userdefinedrows.png and b/nbs/tests/mpl_image_tests/baseline_images/test_266_multigroups_prop_paired_meandiff_gridkey_userdefinedrows.png differ diff --git a/nbs/tests/mpl_image_tests/baseline_images/test_267_multigroups_prop_paired_meandiff_gridkey_autoparser.png b/nbs/tests/mpl_image_tests/baseline_images/test_267_multigroups_prop_paired_meandiff_gridkey_autoparser.png index de973894..ac0c22c5 100644 Binary files a/nbs/tests/mpl_image_tests/baseline_images/test_267_multigroups_prop_paired_meandiff_gridkey_autoparser.png and b/nbs/tests/mpl_image_tests/baseline_images/test_267_multigroups_prop_paired_meandiff_gridkey_autoparser.png differ diff --git a/nbs/tests/mpl_image_tests/baseline_images/test_33_multi_paired_different_sizes.png b/nbs/tests/mpl_image_tests/baseline_images/test_33_multi_paired_different_sizes.png new file mode 100644 index 00000000..94778eba Binary files /dev/null and b/nbs/tests/mpl_image_tests/baseline_images/test_33_multi_paired_different_sizes.png differ diff --git a/nbs/tests/mpl_image_tests/test_03_plotting.py b/nbs/tests/mpl_image_tests/test_03_plotting.py index 8d82e432..f8c588db 100644 --- a/nbs/tests/mpl_image_tests/test_03_plotting.py +++ b/nbs/tests/mpl_image_tests/test_03_plotting.py @@ -451,6 +451,34 @@ def test_32_multigroups_baseline_change_palette(): plt.rcdefaults() return multi_groups_baseline.mean_diff.plot(custom_palette="Dark2", delta_text=True) +@pytest.mark.mpl_image_compare(tolerance=8) +def test_33_multi_paired_different_sizes(): + # Test for GitHub issue #216: multi-group paired data with different sample sizes + plt.rcdefaults() + np.random.seed(9999) + + # Create three test pairs with different sample sizes (20, 10, 40) + c1DF = pd.DataFrame({'Test 1_pre': norm.rvs(loc=3, scale=0.4, size=20)}) + t1DF = pd.DataFrame({'Test 1_post': norm.rvs(loc=3.5, scale=0.5, size=20)}) + t2DF = pd.DataFrame({'Test 2_pre': norm.rvs(loc=2.5, scale=0.6, size=10)}) + t3DF = pd.DataFrame({'Test 2_post': norm.rvs(loc=3, scale=0.75, size=10)}) + t4DF = pd.DataFrame({'Test 3_pre': norm.rvs(loc=3.5, scale=0.75, size=40)}) + t5DF = pd.DataFrame({'Test 3_post': norm.rvs(loc=3.25, scale=0.4, size=40)}) + + df = pd.concat([c1DF, t1DF, t2DF, t3DF, t4DF, t5DF], axis=1) + df["ID"] = pd.Series(range(1, len(df)+1)) + + multi_paired_diff_sizes = load( + df, + idx=(("Test 1_pre", "Test 1_post"), + ("Test 2_pre", "Test 2_post"), + ("Test 3_pre", "Test 3_post")), + paired="baseline", + id_col="ID" + ) + + return multi_paired_diff_sizes.mean_diff.plot() + @pytest.mark.mpl_image_compare(tolerance=8) def test_99_style_sheets(): # Perform this test last so we don't have to reset the plot style. diff --git a/nbs/tutorials/01-basics.ipynb b/nbs/tutorials/01-basics.ipynb index 306d7880..8122498b 100644 --- a/nbs/tutorials/01-basics.ipynb +++ b/nbs/tutorials/01-basics.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "e18874ef", "metadata": {}, "source": [ "# Basics\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "ae22b5d6", "metadata": {}, "source": [ "## Load libraries" @@ -21,6 +23,7 @@ { "cell_type": "code", "execution_count": null, + "id": "111cdeea", "metadata": {}, "outputs": [ { @@ -64,6 +67,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2cf8be3b", "metadata": {}, "outputs": [], "source": [ @@ -74,6 +78,7 @@ }, { "cell_type": "markdown", + "id": "edc6c807", "metadata": {}, "source": [ "## Create dataset for demo" @@ -81,6 +86,7 @@ }, { "cell_type": "markdown", + "id": "c447ed0f", "metadata": {}, "source": [ "Here, we create a dataset to illustrate how ``dabest`` works. In\n", @@ -90,6 +96,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f5460d95", "metadata": {}, "outputs": [ { @@ -261,6 +268,7 @@ }, { "cell_type": "markdown", + "id": "86d8a014", "metadata": {}, "source": [ "Note that we have 9 groups (3 Control samples and 6 Test samples). Our\n", @@ -270,6 +278,7 @@ }, { "cell_type": "markdown", + "id": "cd100b68", "metadata": {}, "source": [ "This is known as a *wide* dataset. See this \n", @@ -279,6 +288,7 @@ }, { "cell_type": "markdown", + "id": "a443fa57", "metadata": {}, "source": [ "## Loading data" @@ -286,6 +296,7 @@ }, { "cell_type": "markdown", + "id": "5cad58c8", "metadata": {}, "source": [ "Before creating estimation plots and obtaining confidence intervals for our effect sizes, we need to load the data and specify the relevant groups.\n", @@ -296,6 +307,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1199b169", "metadata": {}, "outputs": [], "source": [ @@ -304,6 +316,7 @@ }, { "cell_type": "markdown", + "id": "035952a1", "metadata": {}, "source": [ "Calling this ``Dabest`` object gives you a gentle greeting, as well as\n", @@ -313,6 +326,7 @@ { "cell_type": "code", "execution_count": null, + "id": "99952ec9", "metadata": {}, "outputs": [ { @@ -341,6 +355,7 @@ }, { "cell_type": "markdown", + "id": "0287ca98", "metadata": {}, "source": [ "### Changing statistical parameters" @@ -348,6 +363,7 @@ }, { "cell_type": "markdown", + "id": "be5b3ece", "metadata": {}, "source": [ "You can change the width of the confidence interval by manipulating the ``ci`` argument." @@ -356,6 +372,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1056c239", "metadata": {}, "outputs": [ { @@ -385,6 +402,7 @@ }, { "cell_type": "markdown", + "id": "a0d70d5e", "metadata": {}, "source": [ "## Effect sizes" @@ -392,6 +410,7 @@ }, { "cell_type": "markdown", + "id": "47ad9810", "metadata": {}, "source": [ "The **dabest** library now features a range of effect sizes:\n", @@ -411,6 +430,7 @@ { "cell_type": "code", "execution_count": null, + "id": "aa21edeb", "metadata": {}, "outputs": [ { @@ -444,6 +464,7 @@ }, { "cell_type": "markdown", + "id": "600ca0d1", "metadata": {}, "source": [ "For each comparison, the type of effect size is reported (here, it's the\n", @@ -464,6 +485,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e3dae0a5", "metadata": {}, "outputs": [ { @@ -612,6 +634,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d01a764f", "metadata": {}, "outputs": [ { @@ -704,6 +727,7 @@ }, { "cell_type": "markdown", + "id": "416979fe", "metadata": {}, "source": [ "**Note:**\n", @@ -715,6 +739,7 @@ { "cell_type": "code", "execution_count": null, + "id": "530c46db", "metadata": {}, "outputs": [ { @@ -808,6 +833,7 @@ }, { "cell_type": "markdown", + "id": "d3f49f35", "metadata": {}, "source": [ "Let's compute the *Hedges'g* for our comparison." @@ -816,6 +842,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5831bdc1", "metadata": {}, "outputs": [ { @@ -850,6 +877,7 @@ { "cell_type": "code", "execution_count": null, + "id": "64e6eb76", "metadata": {}, "outputs": [ { @@ -993,6 +1021,7 @@ }, { "cell_type": "markdown", + "id": "cc0f5147", "metadata": {}, "source": [ "## Producing estimation plots" @@ -1000,6 +1029,7 @@ }, { "cell_type": "markdown", + "id": "0c80d617", "metadata": {}, "source": [ "To generate a **Gardner-Altman estimation plot**, simply use the\n", @@ -1012,6 +1042,7 @@ { "cell_type": "code", "execution_count": null, + "id": "62cdc948", "metadata": {}, "outputs": [ { @@ -1032,6 +1063,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5ff94b20", "metadata": {}, "outputs": [ { @@ -1051,6 +1083,7 @@ }, { "cell_type": "markdown", + "id": "70030bd6", "metadata": {}, "source": [ "Instead of a Gardner-Altman plot, you can generate a **Cumming estimation\n", @@ -1064,6 +1097,7 @@ { "cell_type": "code", "execution_count": null, + "id": "dfaa2a76", "metadata": {}, "outputs": [ { @@ -1083,6 +1117,7 @@ }, { "cell_type": "markdown", + "id": "9ca13ba8", "metadata": {}, "source": [ "The confidence interval shown on the contrast axis is a BCa confidence interval by default.\n", @@ -1093,6 +1128,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f04a831f", "metadata": {}, "outputs": [ { @@ -1112,6 +1148,7 @@ }, { "cell_type": "markdown", + "id": "b0e04dec", "metadata": {}, "source": [ "### Using long (aka 'melted') data frames" @@ -1119,6 +1156,7 @@ }, { "cell_type": "markdown", + "id": "122503d9", "metadata": {}, "source": [ "``dabest`` can also handle 'melted' or 'long' data. This term is used because each row now corresponds to a single data point, with one column carrying the value and other columns containing 'metadata'\n", @@ -1133,6 +1171,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c339b076", "metadata": {}, "outputs": [ { @@ -1233,6 +1272,7 @@ }, { "cell_type": "markdown", + "id": "5899e787", "metadata": {}, "source": [ "When your data is in this format, you need to specify the ``x`` and\n", @@ -1242,6 +1282,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c786fe1b", "metadata": {}, "outputs": [ { @@ -1273,6 +1314,7 @@ }, { "cell_type": "markdown", + "id": "e38e0455", "metadata": {}, "source": [ "## Dabest estimation plot designs" @@ -1280,6 +1322,7 @@ }, { "cell_type": "markdown", + "id": "0ac037ad", "metadata": {}, "source": [ "The ``dabest`` package implements a range of estimation plot\n", @@ -1311,5 +1354,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/02-two_group.ipynb b/nbs/tutorials/02-two_group.ipynb index e8389300..89660520 100644 --- a/nbs/tutorials/02-two_group.ipynb +++ b/nbs/tutorials/02-two_group.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "a1cdbcc7", "metadata": {}, "source": [ "# Two-Group Experiments\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "792fd7f1", "metadata": {}, "source": [ "## Load libraries" @@ -21,6 +23,7 @@ { "cell_type": "code", "execution_count": null, + "id": "bf339009", "metadata": {}, "outputs": [ { @@ -64,6 +67,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e4add02e", "metadata": {}, "outputs": [], "source": [ @@ -74,6 +78,7 @@ }, { "cell_type": "markdown", + "id": "0328684f", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -81,6 +86,7 @@ }, { "cell_type": "markdown", + "id": "ee9ab56d", "metadata": {}, "source": [ "Here, we create a dataset to illustrate how to perform Two-Group analyses using dabest." @@ -89,6 +95,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3093c1ea", "metadata": {}, "outputs": [ { @@ -261,6 +268,7 @@ }, { "cell_type": "markdown", + "id": "ab098bed", "metadata": {}, "source": [ "## Loading data" @@ -268,6 +276,7 @@ }, { "cell_type": "markdown", + "id": "80318f9c", "metadata": {}, "source": [ "First, we need to load the data and specify the relevant groups. \n", @@ -288,6 +297,7 @@ { "cell_type": "code", "execution_count": null, + "id": "de97031d", "metadata": {}, "outputs": [], "source": [ @@ -297,6 +307,7 @@ }, { "cell_type": "markdown", + "id": "b6252cfc", "metadata": {}, "source": [ "In addition, we can specify the `paired` argument to indicate paired data.\n", @@ -309,6 +320,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b84cb874", "metadata": {}, "outputs": [], "source": [ @@ -319,6 +331,7 @@ }, { "cell_type": "markdown", + "id": "3fa1ced9", "metadata": {}, "source": [ "The **dabest** library features a range of effect sizes. In this case, we shall proceed with the default effect size, which is the mean difference.\n", @@ -329,6 +342,7 @@ { "cell_type": "code", "execution_count": null, + "id": "bba3d764", "metadata": {}, "outputs": [ { @@ -362,6 +376,7 @@ }, { "cell_type": "markdown", + "id": "ede08ee8", "metadata": {}, "source": [ "A dataframe of the mean_diff results can be extracted by calling the `results` attribute of the `dabest.mean_diff` object." @@ -370,6 +385,7 @@ { "cell_type": "code", "execution_count": null, + "id": "262835eb", "metadata": {}, "outputs": [ { @@ -476,6 +492,7 @@ }, { "cell_type": "markdown", + "id": "0ab07696", "metadata": {}, "source": [ "## Producing estimation plots\n", @@ -486,6 +503,7 @@ { "cell_type": "code", "execution_count": null, + "id": "90a3b185", "metadata": {}, "outputs": [ { @@ -505,6 +523,7 @@ }, { "cell_type": "markdown", + "id": "3714b336", "metadata": {}, "source": [ "For singular two-group comparisons, the plot will display the effect size curve by default to the right of the raw data.\n", @@ -516,6 +535,7 @@ { "cell_type": "code", "execution_count": null, + "id": "59ca18fb", "metadata": {}, "outputs": [ { @@ -535,6 +555,7 @@ }, { "cell_type": "markdown", + "id": "a47f367a", "metadata": {}, "source": [ "For multi two-group comparisons, the effect size curves will always be displayed below the raw data.\n", @@ -549,6 +570,7 @@ { "cell_type": "code", "execution_count": null, + "id": "09c70e90", "metadata": {}, "outputs": [ { @@ -568,6 +590,7 @@ }, { "cell_type": "markdown", + "id": "027cce0f", "metadata": {}, "source": [ "For paired data, we use\n", @@ -579,6 +602,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1d60fb95", "metadata": {}, "outputs": [ { @@ -599,6 +623,7 @@ { "cell_type": "code", "execution_count": null, + "id": "51ba277c", "metadata": {}, "outputs": [ { @@ -619,6 +644,7 @@ { "cell_type": "code", "execution_count": null, + "id": "fb7b1c05", "metadata": {}, "outputs": [ { @@ -638,6 +664,7 @@ }, { "cell_type": "markdown", + "id": "08937736", "metadata": {}, "source": [ "For further aesthetic changes, the [Plot Aesthetics Tutorial](08-plot_aesthetics.html) provides detailed examples of how to customize the plot.\n" @@ -652,5 +679,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/03-shared_control_and_repeated_measures.ipynb b/nbs/tutorials/03-shared_control_and_repeated_measures.ipynb index 3f561723..de380b59 100644 --- a/nbs/tutorials/03-shared_control_and_repeated_measures.ipynb +++ b/nbs/tutorials/03-shared_control_and_repeated_measures.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "50ee557d", "metadata": {}, "source": [ "# Shared Control & Repeated Measures\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "3e3615d9", "metadata": {}, "source": [ "The **shared control plot** and **repeated measures plot** display common experimental\n", @@ -26,6 +28,7 @@ }, { "cell_type": "markdown", + "id": "234c2c3d", "metadata": {}, "source": [ "## Load libraries" @@ -34,6 +37,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d091cc8f", "metadata": {}, "outputs": [ { @@ -77,6 +81,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8db598c8", "metadata": {}, "outputs": [], "source": [ @@ -87,6 +92,7 @@ }, { "cell_type": "markdown", + "id": "9aad420a", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -95,6 +101,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7057855f", "metadata": {}, "outputs": [], "source": [ @@ -135,6 +142,7 @@ }, { "cell_type": "markdown", + "id": "83066710", "metadata": {}, "source": [ "## Shared control plot" @@ -143,6 +151,7 @@ { "cell_type": "code", "execution_count": null, + "id": "575eacac", "metadata": {}, "outputs": [ { @@ -181,6 +190,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b3833f45", "metadata": {}, "outputs": [ { @@ -230,6 +240,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b7d077b1", "metadata": {}, "outputs": [ { @@ -249,6 +260,7 @@ }, { "cell_type": "markdown", + "id": "b5cb76fb", "metadata": {}, "source": [ "``dabest`` allows for combining both two-group and shared control experiments into the same plot. This empowers you to perform robust analyses and present complex visualizations of your statistics elegantly." @@ -257,6 +269,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5d4dd491", "metadata": {}, "outputs": [ { @@ -295,6 +308,7 @@ { "cell_type": "code", "execution_count": null, + "id": "26f2a0ff", "metadata": {}, "outputs": [ { @@ -344,6 +358,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d88959b3", "metadata": {}, "outputs": [ { @@ -363,6 +378,7 @@ }, { "cell_type": "markdown", + "id": "d2831872", "metadata": {}, "source": [ "## Repeated measures plot" @@ -370,6 +386,7 @@ }, { "cell_type": "markdown", + "id": "3f46c2db", "metadata": {}, "source": [ "DABEST **v2023.02.14** expands the repertoire of plots for experiments with repeated-measures designs. DABEST now allows the visualization of paired experiments with one control and multiple test \n", @@ -391,6 +408,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a33de166", "metadata": {}, "outputs": [ { @@ -425,6 +443,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5c5a31f3", "metadata": {}, "outputs": [ { @@ -468,6 +487,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0105af59", "metadata": {}, "outputs": [ { @@ -488,6 +508,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7a73ccfc", "metadata": {}, "outputs": [ { @@ -522,6 +543,7 @@ { "cell_type": "code", "execution_count": null, + "id": "901b65f4", "metadata": {}, "outputs": [ { @@ -565,6 +587,7 @@ { "cell_type": "code", "execution_count": null, + "id": "968787fd", "metadata": {}, "outputs": [ { @@ -584,6 +607,7 @@ }, { "cell_type": "markdown", + "id": "5bafd7ea", "metadata": {}, "source": [ "Similar to unpaired data, DABEST empowers you to perform complex \n", @@ -593,6 +617,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f307d789", "metadata": {}, "outputs": [ { @@ -615,6 +640,7 @@ }, { "cell_type": "markdown", + "id": "9a08d862", "metadata": {}, "source": [ "For further aesthetic changes, the [Plot Aesthetics Tutorial](08-plot_aesthetics.html) provides detailed examples of how to customize the plot.\n" @@ -629,5 +655,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/04-proportion_plot.ipynb b/nbs/tutorials/04-proportion_plot.ipynb index 6601e44a..69a9afbf 100644 --- a/nbs/tutorials/04-proportion_plot.ipynb +++ b/nbs/tutorials/04-proportion_plot.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "9d86b658", "metadata": {}, "source": [ "# Proportion Plots\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "55afb331", "metadata": {}, "source": [ "
As of v2023.02.14, DABEST can be used to generate Cohen's *h* and the corresponding proportion plot for binary data. It's important to note that the code we provide only supports numerical proportion data, \n", @@ -22,6 +24,7 @@ }, { "cell_type": "markdown", + "id": "af2a0920", "metadata": {}, "source": [ "## Load libraries" @@ -30,6 +33,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7ba2369c", "metadata": {}, "outputs": [ { @@ -73,6 +77,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0fefb0a2", "metadata": {}, "outputs": [], "source": [ @@ -84,6 +89,7 @@ }, { "cell_type": "markdown", + "id": "bbff8ce9", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -92,6 +98,7 @@ { "cell_type": "code", "execution_count": null, + "id": "13d6539a", "metadata": {}, "outputs": [ { @@ -288,6 +295,7 @@ }, { "cell_type": "markdown", + "id": "e6353a8b", "metadata": {}, "source": [ "### Helper function to create a binary table - `dabest.prop_dataset` " @@ -295,6 +303,7 @@ }, { "cell_type": "markdown", + "id": "f92c4f73", "metadata": {}, "source": [ "In DABEST **v2024.3.29**, we incorporated feedback from biologists who may not have tables of 0’s and 1’s readily available. As a result, a convenient function - `dabest.prop_dataset` - to generate a binary dataset based on the specified sample sizes is provided. Users can generate a pandas.DataFrame containing the sample sizes for each element in the groups and the group names (optional if the sample sizes are provided in a dict)." @@ -303,6 +312,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a9bf4e00", "metadata": {}, "outputs": [ { @@ -399,6 +409,7 @@ }, { "cell_type": "markdown", + "id": "d1bd3244", "metadata": {}, "source": [ "## Loading data" @@ -406,6 +417,7 @@ }, { "cell_type": "markdown", + "id": "5bfaa1dc", "metadata": {}, "source": [ "When loading data, you need to set the parameter ``proportional=True``." @@ -414,6 +426,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e55047ff", "metadata": {}, "outputs": [ { @@ -443,6 +456,7 @@ }, { "cell_type": "markdown", + "id": "10f6baae", "metadata": {}, "source": [ "## Effect sizes" @@ -450,6 +464,7 @@ }, { "cell_type": "markdown", + "id": "065fa56e", "metadata": {}, "source": [ "To generate a proportion plot, the **dabest** library features two effect sizes:\n", @@ -463,6 +478,7 @@ { "cell_type": "code", "execution_count": null, + "id": "07c58d18", "metadata": {}, "outputs": [ { @@ -496,6 +512,7 @@ }, { "cell_type": "markdown", + "id": "93cd38c0", "metadata": {}, "source": [ "Let's compute the *Cohen's h* for our comparison." @@ -504,6 +521,7 @@ { "cell_type": "code", "execution_count": null, + "id": "23784a52", "metadata": {}, "outputs": [ { @@ -537,6 +555,7 @@ }, { "cell_type": "markdown", + "id": "7e87cf4c", "metadata": {}, "source": [ "## Generating proportion plots" @@ -544,6 +563,7 @@ }, { "cell_type": "markdown", + "id": "78792b19", "metadata": {}, "source": [ "To generate an **estimation plot**, simply use the\n", @@ -554,6 +574,7 @@ }, { "cell_type": "markdown", + "id": "4928f5a7", "metadata": {}, "source": [ "### Unpaired proportion plots" @@ -561,6 +582,7 @@ }, { "cell_type": "markdown", + "id": "885f928d", "metadata": {}, "source": [ "Unpaired proportion plots utilise the common bar plot. The bar plot displays the proportion of observations in the dataset that belong to the category of interest: \n", @@ -571,6 +593,7 @@ }, { "cell_type": "markdown", + "id": "b4cf37fd", "metadata": {}, "source": [ "#### Two-Group" @@ -579,6 +602,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a7dccfe5", "metadata": {}, "outputs": [ { @@ -599,6 +623,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b91842f", "metadata": {}, "outputs": [ { @@ -618,6 +643,7 @@ }, { "cell_type": "markdown", + "id": "243a1a0b", "metadata": {}, "source": [ "Instead of a Gardner-Altman plot, you can generate a **Cumming estimation plot** by setting ``float_contrast=False`` in the ``.plot()`` method. This will plot the bootstrap effect sizes below the raw data." @@ -626,6 +652,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8f79c196", "metadata": {}, "outputs": [ { @@ -645,6 +672,7 @@ }, { "cell_type": "markdown", + "id": "99528f73", "metadata": {}, "source": [ "#### Multi Two-Group, Shared-Control, and Multi Groups\n", @@ -654,6 +682,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7d189c13", "metadata": {}, "outputs": [ { @@ -687,6 +716,7 @@ { "cell_type": "code", "execution_count": null, + "id": "314910b1", "metadata": {}, "outputs": [ { @@ -727,6 +757,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ff871f09", "metadata": {}, "outputs": [ { @@ -747,6 +778,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9cbe7f9b", "metadata": {}, "outputs": [ { @@ -781,6 +813,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d4dbcf1b", "metadata": {}, "outputs": [ { @@ -824,6 +857,7 @@ { "cell_type": "code", "execution_count": null, + "id": "55fa5ca2", "metadata": {}, "outputs": [ { @@ -844,6 +878,7 @@ { "cell_type": "code", "execution_count": null, + "id": "36620e79", "metadata": {}, "outputs": [ { @@ -878,6 +913,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a6817f58", "metadata": {}, "outputs": [ { @@ -921,6 +957,7 @@ { "cell_type": "code", "execution_count": null, + "id": "40d8ee2b", "metadata": {}, "outputs": [ { @@ -940,6 +977,7 @@ }, { "cell_type": "markdown", + "id": "d015dc02", "metadata": {}, "source": [ "### Paired proportion plots" @@ -947,6 +985,7 @@ }, { "cell_type": "markdown", + "id": "487b18ed", "metadata": {}, "source": [ "For the paired version of the proportion plot, we adopt the style of a Sankey Diagram. The width of each bar in each xtick represents the proportion of the corresponding label in the group, and the strip denotes the paired relationship for each observation.\n", @@ -958,6 +997,7 @@ }, { "cell_type": "markdown", + "id": "b662e9e6", "metadata": {}, "source": [ "#### Two-Group" @@ -966,6 +1006,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6bc7c8f1", "metadata": {}, "outputs": [ { @@ -998,6 +1039,7 @@ { "cell_type": "code", "execution_count": null, + "id": "4f4b7bc3", "metadata": {}, "outputs": [ { @@ -1033,6 +1075,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ca073736", "metadata": {}, "outputs": [ { @@ -1052,6 +1095,7 @@ }, { "cell_type": "markdown", + "id": "17832542", "metadata": {}, "source": [ "The Sankey plots for paired proportions also supports the ``float_contrast`` parameter, which can be set to ``False`` to produce a **Cumming estimation plot**.\n" @@ -1060,6 +1104,7 @@ { "cell_type": "code", "execution_count": null, + "id": "24f34bc2", "metadata": {}, "outputs": [ { @@ -1079,6 +1124,7 @@ }, { "cell_type": "markdown", + "id": "0c13d47c", "metadata": {}, "source": [ "#### Multi Two-Group, Repeated Measures, and Multi Groups\n", @@ -1088,6 +1134,7 @@ { "cell_type": "code", "execution_count": null, + "id": "897bbfd5", "metadata": {}, "outputs": [ { @@ -1122,6 +1169,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9f3903b6", "metadata": {}, "outputs": [ { @@ -1165,6 +1213,7 @@ { "cell_type": "code", "execution_count": null, + "id": "bb3e2aa2", "metadata": {}, "outputs": [ { @@ -1185,6 +1234,7 @@ { "cell_type": "code", "execution_count": null, + "id": "126405f4", "metadata": {}, "outputs": [ { @@ -1220,6 +1270,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e852ebf7", "metadata": {}, "outputs": [ { @@ -1267,6 +1318,7 @@ { "cell_type": "code", "execution_count": null, + "id": "47edfc40", "metadata": {}, "outputs": [ { @@ -1287,6 +1339,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e74c1dfe", "metadata": {}, "outputs": [ { @@ -1322,6 +1375,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6fd66091", "metadata": {}, "outputs": [ { @@ -1369,6 +1423,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3dfcf13c", "metadata": {}, "outputs": [ { @@ -1389,6 +1444,7 @@ { "cell_type": "code", "execution_count": null, + "id": "73e4aaf1", "metadata": {}, "outputs": [ { @@ -1424,6 +1480,7 @@ { "cell_type": "code", "execution_count": null, + "id": "664ad256", "metadata": {}, "outputs": [ { @@ -1471,6 +1528,7 @@ { "cell_type": "code", "execution_count": null, + "id": "716f3bae", "metadata": {}, "outputs": [ { @@ -1490,6 +1548,7 @@ }, { "cell_type": "markdown", + "id": "fbf34d17", "metadata": {}, "source": [ "## Aesthetic adjustments\n", @@ -1499,6 +1558,7 @@ }, { "cell_type": "markdown", + "id": "8dd438f2", "metadata": {}, "source": [ "### Bar Width\n", @@ -1509,6 +1569,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a5cabdfa", "metadata": {}, "outputs": [ { @@ -1528,6 +1589,7 @@ }, { "cell_type": "markdown", + "id": "651cd0d4", "metadata": {}, "source": [ "### Bar desaturation\n", @@ -1539,6 +1601,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9b41c4a5", "metadata": {}, "outputs": [ { @@ -1558,6 +1621,7 @@ }, { "cell_type": "markdown", + "id": "03639659", "metadata": {}, "source": [ "### Raw Label and Contrast Label\n", @@ -1567,6 +1631,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2783f021", "metadata": {}, "outputs": [ { @@ -1597,6 +1662,7 @@ }, { "cell_type": "markdown", + "id": "3763336c", "metadata": {}, "source": [ "### Barplot kwargs\n", @@ -1606,6 +1672,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b9225c1", "metadata": {}, "outputs": [ { @@ -1625,6 +1692,7 @@ }, { "cell_type": "markdown", + "id": "2e283cfc", "metadata": {}, "source": [ "### Sankey and Flow\n", @@ -1635,6 +1703,7 @@ { "cell_type": "code", "execution_count": null, + "id": "68515743", "metadata": {}, "outputs": [ { @@ -1681,6 +1750,7 @@ }, { "cell_type": "markdown", + "id": "f47070a9", "metadata": {}, "source": [ "### Sankey kwargs\n", @@ -1695,6 +1765,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e482c557", "metadata": {}, "outputs": [ { @@ -1715,6 +1786,7 @@ }, { "cell_type": "markdown", + "id": "32f41159", "metadata": {}, "source": [ "### Custom Palette\n", @@ -1724,6 +1796,7 @@ }, { "cell_type": "markdown", + "id": "6626a173", "metadata": {}, "source": [ "A `custom_palette` dict can be passed for sankey plots, whereby two keys used are 0 and 1. The color associated with these keys will be used to color the bars in the sankey plot.\n", @@ -1734,6 +1807,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c244c015", "metadata": {}, "outputs": [ { @@ -1764,6 +1838,7 @@ }, { "cell_type": "markdown", + "id": "802b4eb6", "metadata": {}, "source": [ "Similarly, premade matplotlib/seaborn color palette can be passed. For sankey plots, the first two colors in the palette will be used to color the bars in the sankey plot. For bar plots, the colors will be used to color the filled portion of the bar plot." @@ -1772,6 +1847,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c2dbbb57", "metadata": {}, "outputs": [ { @@ -1802,6 +1878,7 @@ }, { "cell_type": "markdown", + "id": "d3da6311", "metadata": {}, "source": [ "Passing a custom palette list functions differently for bar plots and sankey plots:\n", @@ -1813,6 +1890,7 @@ { "cell_type": "code", "execution_count": null, + "id": "32005eb2", "metadata": {}, "outputs": [ { @@ -1843,6 +1921,7 @@ }, { "cell_type": "markdown", + "id": "ed09d7ed", "metadata": {}, "source": [ "### Add counts to proportion plots\n", @@ -1857,6 +1936,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f4c41e28", "metadata": {}, "outputs": [ { @@ -1877,6 +1957,7 @@ }, { "cell_type": "markdown", + "id": "96671380", "metadata": {}, "source": [ "The sample counts kwargs can be utilised via `prop_sample_counts_kwargs` in the `.plot()` method." @@ -1885,6 +1966,7 @@ { "cell_type": "code", "execution_count": null, + "id": "37ddc29b", "metadata": {}, "outputs": [ { @@ -1904,6 +1986,7 @@ }, { "cell_type": "markdown", + "id": "e7fb10a4", "metadata": {}, "source": [ "For further aesthetic changes, the [Plot Aesthetics Tutorial](08-plot_aesthetics.html) provides detailed examples of how to customize the plot.\n" @@ -1918,5 +2001,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/05-mini_meta.ipynb b/nbs/tutorials/05-mini_meta.ipynb index 5d70306f..e89510f8 100644 --- a/nbs/tutorials/05-mini_meta.ipynb +++ b/nbs/tutorials/05-mini_meta.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "e074b4cd", "metadata": {}, "source": [ "# Mini-Meta\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "d7602abf", "metadata": {}, "source": [ "When scientists conduct replicates of the same experiment, the effect size of each replicate often varies, complicating the interpretation of the results. Starting from v2023.02.14, DABEST can now compute the meta-analyzed weighted effect size given multiple replicates of the same experiment. This can help resolve differences between replicates and simplify interpretation.\n", @@ -46,6 +48,7 @@ }, { "cell_type": "markdown", + "id": "f60f347a", "metadata": {}, "source": [ "Note that this utilizes the fixed-effects model of meta-analysis, in contrast to the random-effects model. In the fixed-effects model, all variation between the results of each replicate is assumed to be solely due to sampling error. Therefore, we recommend using this function exclusively for replications of the same experiment, where it can be safely assumed that each replicate estimates the same population mean $\\mu$.\n", @@ -57,6 +60,7 @@ }, { "cell_type": "markdown", + "id": "93359477", "metadata": {}, "source": [ "## Load libraries" @@ -65,6 +69,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5f889eb3", "metadata": {}, "outputs": [ { @@ -108,6 +113,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0d6f8ba8", "metadata": {}, "outputs": [], "source": [ @@ -118,6 +124,7 @@ }, { "cell_type": "markdown", + "id": "2a77eb0b", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -126,6 +133,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6bd57c4c", "metadata": {}, "outputs": [ { @@ -268,6 +276,7 @@ }, { "cell_type": "markdown", + "id": "5acf961f", "metadata": {}, "source": [ "We now have three *Control* and three *Test* groups, simulating three replicates of the same experiment. Our\n", @@ -277,6 +286,7 @@ }, { "cell_type": "markdown", + "id": "f634f0b7", "metadata": {}, "source": [ "This is known as a 'wide' dataset. See this\n", @@ -286,6 +296,7 @@ }, { "cell_type": "markdown", + "id": "148c542e", "metadata": {}, "source": [ "## Loading data" @@ -293,6 +304,7 @@ }, { "cell_type": "markdown", + "id": "fbdc1083", "metadata": {}, "source": [ "Next, we load data as usual using ``dabest.load()``. However, this time, we also specify the argument ``mini_meta=True``. Since we are loading data from three experiments, ``idx`` is passed as a tuple of tuples, as shown below.\n", @@ -303,6 +315,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b456a848", "metadata": {}, "outputs": [ { @@ -335,6 +348,7 @@ }, { "cell_type": "markdown", + "id": "adbf8252", "metadata": {}, "source": [ "By calling the ``mean_diff`` attribute, you can view the mean differences for each group as well as the weighted delta.\n" @@ -343,6 +357,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b9fec10b", "metadata": {}, "outputs": [ { @@ -385,6 +400,7 @@ }, { "cell_type": "markdown", + "id": "be1075b3", "metadata": {}, "source": [ "You can view the details of each experiment by accessing the property `mean_diff.results` as follows." @@ -393,6 +409,7 @@ { "cell_type": "code", "execution_count": null, + "id": "49d8375e", "metadata": {}, "outputs": [ { @@ -636,6 +653,7 @@ }, { "cell_type": "markdown", + "id": "fb25bb87", "metadata": {}, "source": [ "Note, however, that this does not contain the relevant information for our weighted delta. The details of the weighted delta are stored as attributes of the ``mini_meta`` object, such as:\n", @@ -654,6 +672,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8e428551", "metadata": {}, "outputs": [ { @@ -784,6 +803,7 @@ }, { "cell_type": "markdown", + "id": "fdb67182", "metadata": {}, "source": [ "## Generating mini meta plots" @@ -792,6 +812,7 @@ { "cell_type": "code", "execution_count": null, + "id": "95ae87cd", "metadata": {}, "outputs": [ { @@ -811,6 +832,7 @@ }, { "cell_type": "markdown", + "id": "18855f31", "metadata": {}, "source": [ "You can also hide the weighted delta by passing the argument ``show_mini_meta=False``. In this case, the resulting graph would be identical to a multiple two-groups plot.\n" @@ -819,6 +841,7 @@ { "cell_type": "code", "execution_count": null, + "id": "52b75aa6", "metadata": {}, "outputs": [ { @@ -838,6 +861,7 @@ }, { "cell_type": "markdown", + "id": "07dd8ed5", "metadata": {}, "source": [ "As with regular two-groups plots, you can also analyse paired mini meta experiments via the `paired=baseline` argument." @@ -846,6 +870,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f8a30435", "metadata": {}, "outputs": [ { @@ -866,6 +891,7 @@ }, { "cell_type": "markdown", + "id": "3fa36675", "metadata": {}, "source": [ "For further aesthetic changes, the [Plot Aesthetics Tutorial](08-plot_aesthetics.html) provides detailed examples of how to customize the plot.\n" @@ -880,5 +906,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/06-delta_delta.ipynb b/nbs/tutorials/06-delta_delta.ipynb index 5a7f09a4..20c76929 100644 --- a/nbs/tutorials/06-delta_delta.ipynb +++ b/nbs/tutorials/06-delta_delta.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "20ccf903", "metadata": {}, "source": [ "# Delta-Delta\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "0f3b6b88", "metadata": {}, "source": [ "**Since v2023.02.14, DABEST also supports the calculation of delta-delta, an experimental function that facilitates the comparison between two bootstrapped effect sizes computed from two independent categorical variables.** \n", @@ -28,6 +30,7 @@ }, { "cell_type": "markdown", + "id": "4cab153a", "metadata": {}, "source": [ "| | Wildtype | Mutant |\n", @@ -38,6 +41,7 @@ }, { "cell_type": "markdown", + "id": "cba57b53", "metadata": {}, "source": [ "There are two ``Treatment`` conditions, ``Placebo`` (control group) and ``Drug`` (test group). There are two ``Genotype``\\s: ``W`` (wild type population) and ``M`` (mutant population). Additionally, each experiment was conducted twice (``Rep1`` and ``Rep2``). We will perform several analyses to visualise these differences in a simulated dataset. \n" @@ -45,6 +49,7 @@ }, { "cell_type": "markdown", + "id": "eba4dd06", "metadata": {}, "source": [ "## Load libraries" @@ -53,6 +58,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f7051d73", "metadata": {}, "outputs": [ { @@ -74,6 +80,7 @@ { "cell_type": "code", "execution_count": null, + "id": "0c1bdbb7", "metadata": {}, "outputs": [], "source": [ @@ -84,6 +91,7 @@ }, { "cell_type": "markdown", + "id": "aeeafbcf", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -92,6 +100,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3a5686f3", "metadata": {}, "outputs": [ { @@ -228,6 +237,7 @@ }, { "cell_type": "markdown", + "id": "f645a28b", "metadata": {}, "source": [ "## Loading data" @@ -235,6 +245,7 @@ }, { "cell_type": "markdown", + "id": "accc2f5c", "metadata": {}, "source": [ "To create a delta-delta plot, you simply need to set ``delta2=True`` in the \n", @@ -244,6 +255,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ab57196f", "metadata": {}, "outputs": [ { @@ -276,6 +288,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d3d23b98", "metadata": {}, "outputs": [ { @@ -315,6 +328,7 @@ }, { "cell_type": "markdown", + "id": "55eecede", "metadata": {}, "source": [ "## Generating delta-delta plots" @@ -323,6 +337,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9beac2bf", "metadata": {}, "outputs": [ { @@ -342,6 +357,7 @@ }, { "cell_type": "markdown", + "id": "9beeb024", "metadata": {}, "source": [ "In the above plot, the horizontal axis represents the ``Genotype`` condition\n", @@ -374,6 +390,7 @@ }, { "cell_type": "markdown", + "id": "cbe874ee", "metadata": {}, "source": [ "The configuration of comparison we performed above is reminiscent of a two-way ANOVA. In fact, the delta - delta is an effect size estimated for the interaction term between ``Treatment`` and ``Genotype``. Main effects of ``Treatment`` and ``Genotype``, on the other hand, can be determined by simpler, univariate contrast plots. " @@ -381,6 +398,7 @@ }, { "cell_type": "markdown", + "id": "5d743a46", "metadata": {}, "source": [ "## Specifying grouping for comparisons" @@ -388,6 +406,7 @@ }, { "cell_type": "markdown", + "id": "5f603498", "metadata": {}, "source": [ "In the example above, we used the convention of *test - control* but you can manipulate the orders of the experiment groups as well as the horizontal axis variable by setting the paremeters ``experiment_label`` and ``x1_level``.\n" @@ -396,6 +415,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7e29be58", "metadata": {}, "outputs": [ { @@ -421,6 +441,7 @@ }, { "cell_type": "markdown", + "id": "347872d1", "metadata": {}, "source": [ "Utilising the `show_delta2` argument within the `.plot()` method allows for control of whether the delta-delta effect size is displayed on the plot. By default, this is set to `True`. " @@ -429,6 +450,7 @@ { "cell_type": "code", "execution_count": null, + "id": "21886e87", "metadata": {}, "outputs": [ { @@ -448,6 +470,7 @@ }, { "cell_type": "markdown", + "id": "69aa38f7", "metadata": {}, "source": [ "The delta-delta function also supports paired data, providing a useful alternative visualization of the data. Assuming that the placebo and drug treatment were administered to the same subjects, our data is paired between the treatment conditions. We can specify this by using ``Treatment`` as ``x`` and ``Genotype`` as ``experiment``, and we further specify that ``id_col`` is ``ID``, linking data from the same subject with each other. Since we have conducted two replicates of the experiments, we can also colour the slope lines according to ``Rep``. " @@ -456,6 +479,7 @@ { "cell_type": "code", "execution_count": null, + "id": "fc76ceea", "metadata": {}, "outputs": [ { @@ -479,6 +503,7 @@ }, { "cell_type": "markdown", + "id": "b89c0f82", "metadata": {}, "source": [ "We see that the drug had a non-specific effect of -0.321 [95%CI -0.498, -0.131] on wild type subjects even when they were not sick, and it had a bigger effect of -1.22 [95%CI -1.52, -0.906] in mutant subjects. In this visualisation, we can see the delta-delta value of -0.903 [95%CI -1.21, -0.587] as the net effect of the drug accounting for non-specific actions in healthy individuals. \n" @@ -486,6 +511,7 @@ }, { "cell_type": "markdown", + "id": "c35731fc", "metadata": {}, "source": [ "The mean difference between drug and placebo treatments in wild type subjects is:\n", @@ -505,6 +531,7 @@ }, { "cell_type": "markdown", + "id": "bbddc245", "metadata": {}, "source": [ "## Standardising delta-delta effect sizes with Delta g" @@ -512,6 +539,7 @@ }, { "cell_type": "markdown", + "id": "1677b7e1", "metadata": {}, "source": [ "Standardized mean difference statistics like Cohen's d and Hedges' g quantify effect sizes in terms of the sample variance. We have introduced a metric, *Delta g*, to standardize delta-delta effects. This metric enables the comparison between measurements of different dimensions.\n", @@ -533,6 +561,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1da01bb3", "metadata": {}, "outputs": [ { @@ -572,6 +601,7 @@ }, { "cell_type": "markdown", + "id": "e19e2991", "metadata": {}, "source": [ "We see the standardised delta-delta (delta *g*) value of -2.11 standard deviations [95%CI -2.98, -1.2] as the net effect of the drug accounting for non-specific actions in healthy individuals. " @@ -580,6 +610,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6d7e0170", "metadata": {}, "outputs": [ { @@ -599,6 +630,7 @@ }, { "cell_type": "markdown", + "id": "54c0438a", "metadata": {}, "source": [ "## Delta-delta for binary data\n", @@ -608,6 +640,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e8b8c2d7", "metadata": {}, "outputs": [ { @@ -689,6 +722,7 @@ }, { "cell_type": "markdown", + "id": "bdbf61d8", "metadata": {}, "source": [ "## Statistics" @@ -696,6 +730,7 @@ }, { "cell_type": "markdown", + "id": "38e23d1d", "metadata": {}, "source": [ "You can find all outputs of the delta-delta calculation by assessing the attribute named ``delta_delta`` of the effect size object." @@ -704,6 +739,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d070ee64", "metadata": {}, "outputs": [ { @@ -735,6 +771,7 @@ }, { "cell_type": "markdown", + "id": "8fc68867", "metadata": {}, "source": [ "The ``delta_delta`` object has its own attributes, containing various information of delta-delta.\n", @@ -752,6 +789,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f3bec88c", "metadata": {}, "outputs": [ { @@ -868,6 +906,7 @@ }, { "cell_type": "markdown", + "id": "c10aa935", "metadata": {}, "source": [ "Similarly, for the standardised delta-delta effect size, the `hedges_g` object has its own delta delta (Delta *g*) results attribute." @@ -876,6 +915,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3b30812a", "metadata": {}, "outputs": [ { @@ -992,6 +1032,7 @@ }, { "cell_type": "markdown", + "id": "991ca7ab", "metadata": {}, "source": [ "For further aesthetic changes, the [Plot Aesthetics Tutorial](08-plot_aesthetics.html) provides detailed examples of how to customize the plot.\n" @@ -1006,5 +1047,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/07-horizontal_plot.ipynb b/nbs/tutorials/07-horizontal_plot.ipynb index a1516109..206f6073 100644 --- a/nbs/tutorials/07-horizontal_plot.ipynb +++ b/nbs/tutorials/07-horizontal_plot.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "717ffa0a", "metadata": {}, "source": [ "# Horizontal Plots\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "2063d217", "metadata": {}, "source": [ "In DABEST **v2025.03.27**, we introduce a new plotting orientation: **horizontal plots**. \n", @@ -22,6 +24,7 @@ }, { "cell_type": "markdown", + "id": "83c78436", "metadata": {}, "source": [ "## Load libraries" @@ -30,6 +33,7 @@ { "cell_type": "code", "execution_count": null, + "id": "90f630c9", "metadata": {}, "outputs": [ { @@ -73,6 +77,7 @@ { "cell_type": "code", "execution_count": null, + "id": "afc3ff31", "metadata": {}, "outputs": [], "source": [ @@ -83,6 +88,7 @@ }, { "cell_type": "markdown", + "id": "c563c6f3", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -91,6 +97,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ab728900", "metadata": {}, "outputs": [], "source": [ @@ -132,6 +139,7 @@ }, { "cell_type": "markdown", + "id": "c1395293", "metadata": {}, "source": [ "## Generating two-group plots" @@ -140,6 +148,7 @@ { "cell_type": "code", "execution_count": null, + "id": "228a940a", "metadata": {}, "outputs": [ { @@ -173,6 +182,7 @@ }, { "cell_type": "markdown", + "id": "f181ddf6", "metadata": {}, "source": [ "## Generating shared-control and repeated-measures plots" @@ -181,6 +191,7 @@ { "cell_type": "code", "execution_count": null, + "id": "42b671b5", "metadata": {}, "outputs": [ { @@ -227,6 +238,7 @@ }, { "cell_type": "markdown", + "id": "1a95d54f", "metadata": {}, "source": [ "## Generating multi-group plots" @@ -235,6 +247,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a23d4b81", "metadata": {}, "outputs": [ { @@ -255,6 +268,7 @@ }, { "cell_type": "markdown", + "id": "39ca23c1", "metadata": {}, "source": [ "## Generating proportion plots\n" @@ -263,6 +277,7 @@ { "cell_type": "code", "execution_count": null, + "id": "818e7fe6", "metadata": {}, "outputs": [], "source": [ @@ -311,6 +326,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a15c416d", "metadata": {}, "outputs": [ { @@ -344,6 +360,7 @@ }, { "cell_type": "markdown", + "id": "ff282295", "metadata": {}, "source": [ "## Generating delta-delta plots" @@ -352,6 +369,7 @@ { "cell_type": "code", "execution_count": null, + "id": "cfaa807c", "metadata": {}, "outputs": [], "source": [ @@ -401,6 +419,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e4fd9646", "metadata": {}, "outputs": [ { @@ -421,6 +440,7 @@ }, { "cell_type": "markdown", + "id": "1d95a2e1", "metadata": {}, "source": [ "## Generating mini-meta plots" @@ -429,6 +449,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f101777c", "metadata": {}, "outputs": [ { @@ -449,6 +470,7 @@ }, { "cell_type": "markdown", + "id": "42cc7f56", "metadata": {}, "source": [ "## Controlling aesthetics\n", @@ -458,6 +480,7 @@ }, { "cell_type": "markdown", + "id": "78e4e3e1", "metadata": {}, "source": [ "### Swarm side\n", @@ -469,6 +492,7 @@ }, { "cell_type": "markdown", + "id": "a1583cd9", "metadata": {}, "source": [ "Default is `swarm_side='left'`" @@ -477,6 +501,7 @@ { "cell_type": "code", "execution_count": null, + "id": "27a1ac31", "metadata": {}, "outputs": [ { @@ -497,6 +522,7 @@ }, { "cell_type": "markdown", + "id": "5db94d12", "metadata": {}, "source": [ "`swarm_side='center'`" @@ -505,6 +531,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3f37935e", "metadata": {}, "outputs": [ { @@ -524,6 +551,7 @@ }, { "cell_type": "markdown", + "id": "752c6946", "metadata": {}, "source": [ "`swarm_side='right'`" @@ -532,6 +560,7 @@ { "cell_type": "code", "execution_count": null, + "id": "30eb0a24", "metadata": {}, "outputs": [ { @@ -551,6 +580,7 @@ }, { "cell_type": "markdown", + "id": "aea8e8b5", "metadata": {}, "source": [ "### Table kwargs\n", @@ -573,6 +603,7 @@ { "cell_type": "code", "execution_count": null, + "id": "74b97613", "metadata": {}, "outputs": [ { @@ -601,6 +632,7 @@ }, { "cell_type": "markdown", + "id": "f521d0fe", "metadata": {}, "source": [ "The table axis can be hidden using the `'show':False` in the `horizontal_table_kwargs` dict." @@ -609,6 +641,7 @@ { "cell_type": "code", "execution_count": null, + "id": "112b692a", "metadata": {}, "outputs": [ { @@ -629,6 +662,7 @@ }, { "cell_type": "markdown", + "id": "f26c5762", "metadata": {}, "source": [ "### Gridkey \n", @@ -643,6 +677,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a0b1cc86", "metadata": {}, "outputs": [ { @@ -670,5 +705,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/08-plot_aesthetics.ipynb b/nbs/tutorials/08-plot_aesthetics.ipynb index cd4f0e62..450cdd55 100644 --- a/nbs/tutorials/08-plot_aesthetics.ipynb +++ b/nbs/tutorials/08-plot_aesthetics.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "f050658e", "metadata": {}, "source": [ "# Controlling Plot Aesthetics\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "9608e377", "metadata": {}, "source": [ " Since **v2024.03.29**, swarmplots are, by default, plotted asymmetrically to the right side. For detailed information, please refer to [Swarm Side](#changing-swarm-side).\n", @@ -40,6 +42,7 @@ }, { "cell_type": "markdown", + "id": "7a82e9a2", "metadata": {}, "source": [ "## Load libraries" @@ -48,6 +51,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2fbf7ec7", "metadata": {}, "outputs": [ { @@ -92,6 +96,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e74d9aaf", "metadata": {}, "outputs": [], "source": [ @@ -102,6 +107,7 @@ }, { "cell_type": "markdown", + "id": "e127428c", "metadata": {}, "source": [ "## Creating a demo dataset" @@ -110,6 +116,7 @@ { "cell_type": "code", "execution_count": null, + "id": "4a87b641", "metadata": {}, "outputs": [], "source": [ @@ -244,6 +251,7 @@ }, { "cell_type": "markdown", + "id": "312bf080", "metadata": {}, "source": [ "## Changing the graph colours\n", @@ -255,6 +263,7 @@ { "cell_type": "code", "execution_count": null, + "id": "54dd7271", "metadata": {}, "outputs": [ { @@ -286,6 +295,7 @@ }, { "cell_type": "markdown", + "id": "e822f932", "metadata": {}, "source": [ "### Custom palette\n", @@ -304,6 +314,7 @@ }, { "cell_type": "markdown", + "id": "6b551273", "metadata": {}, "source": [ "#### A list of colors" @@ -312,6 +323,7 @@ { "cell_type": "code", "execution_count": null, + "id": "823b7192", "metadata": {}, "outputs": [ { @@ -331,6 +343,7 @@ }, { "cell_type": "markdown", + "id": "3d78e17f", "metadata": {}, "source": [ "#### Seaborn color palette" @@ -339,6 +352,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1aa7bbea", "metadata": {}, "outputs": [ { @@ -358,6 +372,7 @@ }, { "cell_type": "markdown", + "id": "45b3ceff", "metadata": {}, "source": [ "#### Matplotlib color map/palette" @@ -366,6 +381,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2d9a0e16", "metadata": {}, "outputs": [ { @@ -396,6 +412,7 @@ }, { "cell_type": "markdown", + "id": "9062fecb", "metadata": {}, "source": [ "#### A user-defined dictionary\n", @@ -406,6 +423,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8b81a893", "metadata": {}, "outputs": [ { @@ -431,6 +449,7 @@ }, { "cell_type": "markdown", + "id": "4d0e3fd1", "metadata": {}, "source": [ "For proportion plots (barplots and sankey), a color palette dict can also be supplied via `{1: first_color, 0, second_color}` where first_color and second_color are valid matplotlib colours." @@ -439,6 +458,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6581fc9f", "metadata": {}, "outputs": [ { @@ -459,6 +479,7 @@ { "cell_type": "code", "execution_count": null, + "id": "b32b802f", "metadata": {}, "outputs": [ { @@ -478,6 +499,7 @@ }, { "cell_type": "markdown", + "id": "b4687df4", "metadata": {}, "source": [ "#### Color palette changes also now affect the effect size curve colors in paired plots\n", @@ -488,6 +510,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d1e34f90", "metadata": {}, "outputs": [ { @@ -507,6 +530,7 @@ }, { "cell_type": "markdown", + "id": "18e6c0e9", "metadata": {}, "source": [ "## Color saturation\n", @@ -520,6 +544,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6d2cc09a", "metadata": {}, "outputs": [ { @@ -541,6 +566,7 @@ }, { "cell_type": "markdown", + "id": "976d3d7a", "metadata": {}, "source": [ "## Alpha (transparency)\n", @@ -551,6 +577,7 @@ { "cell_type": "code", "execution_count": null, + "id": "09345d42", "metadata": {}, "outputs": [ { @@ -582,6 +609,7 @@ }, { "cell_type": "markdown", + "id": "f454d2bc", "metadata": {}, "source": [ "It is also possible change the transparency of the effect size curves by using the `contrast_alpha` parameter. This can also be \n", @@ -591,6 +619,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9ad0dfc7", "metadata": {}, "outputs": [ { @@ -622,6 +651,7 @@ }, { "cell_type": "markdown", + "id": "13da3fc1", "metadata": {}, "source": [ "## Marker size\n", @@ -631,6 +661,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7239686e", "metadata": {}, "outputs": [ { @@ -651,6 +682,7 @@ }, { "cell_type": "markdown", + "id": "482b1497", "metadata": {}, "source": [ "## Axes" @@ -658,6 +690,7 @@ }, { "cell_type": "markdown", + "id": "ff0d7fb7", "metadata": {}, "source": [ "### Lims\n", @@ -668,6 +701,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1c4f9835", "metadata": {}, "outputs": [ { @@ -688,6 +722,7 @@ }, { "cell_type": "markdown", + "id": "4643eb83", "metadata": {}, "source": [ "If the effect size is qualitatively inverted (ie. a smaller value is a\n", @@ -698,6 +733,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a5c27d52", "metadata": {}, "outputs": [ { @@ -717,6 +753,7 @@ }, { "cell_type": "markdown", + "id": "59414b18", "metadata": {}, "source": [ "The contrast axes share the same y-limits as those of the delta-delta plot. Thus, the y axis of the delta-delta plot changes as well." @@ -725,6 +762,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f1606464", "metadata": {}, "outputs": [ { @@ -744,6 +782,7 @@ }, { "cell_type": "markdown", + "id": "c5013e84", "metadata": {}, "source": [ "You can also change the y-limit of the delta-delta axes and the regular delta axes via the `delta2_ylim` parameter." @@ -752,6 +791,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e87009b1", "metadata": {}, "outputs": [ { @@ -771,6 +811,7 @@ }, { "cell_type": "markdown", + "id": "6c8ce9d5", "metadata": {}, "source": [ "### Labels\n", @@ -782,6 +823,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e7e095c7", "metadata": {}, "outputs": [ { @@ -803,6 +845,7 @@ }, { "cell_type": "markdown", + "id": "97230328", "metadata": {}, "source": [ "Unique for delta-delta:\n", @@ -812,6 +855,7 @@ { "cell_type": "code", "execution_count": null, + "id": "07225a03", "metadata": {}, "outputs": [ { @@ -831,6 +875,7 @@ }, { "cell_type": "markdown", + "id": "1db8d529", "metadata": {}, "source": [ "### Axes ticks\n", @@ -845,6 +890,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1dfc1df3", "metadata": {}, "outputs": [ { @@ -875,6 +921,7 @@ }, { "cell_type": "markdown", + "id": "a2d0461a", "metadata": {}, "source": [ "### Add counts to tick labels\n", @@ -885,6 +932,7 @@ { "cell_type": "code", "execution_count": null, + "id": "40fa2021", "metadata": {}, "outputs": [ { @@ -905,6 +953,7 @@ }, { "cell_type": "markdown", + "id": "2ec11b77", "metadata": {}, "source": [ "## Changing swarm side\n", @@ -916,6 +965,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c98edf2b", "metadata": {}, "outputs": [ { @@ -957,6 +1007,7 @@ }, { "cell_type": "markdown", + "id": "bfb6a084", "metadata": {}, "source": [ "## Creating estimation plots in existing axes" @@ -964,6 +1015,7 @@ }, { "cell_type": "markdown", + "id": "c2cbd8b2", "metadata": {}, "source": [ "*Implemented in v0.2.6 by Adam Nekimken*.\n", @@ -976,6 +1028,7 @@ { "cell_type": "code", "execution_count": null, + "id": "093bbd83", "metadata": {}, "outputs": [], "source": [ @@ -990,6 +1043,7 @@ { "cell_type": "code", "execution_count": null, + "id": "65f86ec5", "metadata": {}, "outputs": [ { @@ -1021,6 +1075,7 @@ }, { "cell_type": "markdown", + "id": "091e817d", "metadata": {}, "source": [ "In this case, to access the individual rawdata axes, use\n", @@ -1031,6 +1086,7 @@ { "cell_type": "code", "execution_count": null, + "id": "babb6587", "metadata": {}, "outputs": [ { @@ -1054,6 +1110,7 @@ }, { "cell_type": "markdown", + "id": "91106d74", "metadata": {}, "source": [ "## Legend\n", @@ -1063,6 +1120,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1228fc1d", "metadata": {}, "outputs": [ { @@ -1083,6 +1141,7 @@ }, { "cell_type": "markdown", + "id": "7dd00ed6", "metadata": {}, "source": [ "## Hiding options \n", @@ -1092,6 +1151,7 @@ { "cell_type": "code", "execution_count": null, + "id": "012a6452", "metadata": {}, "outputs": [ { @@ -1111,6 +1171,7 @@ }, { "cell_type": "markdown", + "id": "9d0b2d3f", "metadata": {}, "source": [ "Similarly, you can hide the delta-delta effect size by setting \n", @@ -1120,6 +1181,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9306729c", "metadata": {}, "outputs": [ { @@ -1139,6 +1201,7 @@ }, { "cell_type": "markdown", + "id": "81c87af0", "metadata": {}, "source": [ "## Effect size error bar and marker\n", @@ -1160,6 +1223,7 @@ { "cell_type": "code", "execution_count": null, + "id": "62b74c3e", "metadata": {}, "outputs": [ { @@ -1179,6 +1243,7 @@ }, { "cell_type": "markdown", + "id": "47140b62", "metadata": {}, "source": [ "Modifying the appearance of the effect size error bar can be done via the `contrast_errorbar_kwargs` parameter. This parameter accepts a dictionary of keyword arguments.\n", @@ -1195,6 +1260,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7d9dbb13", "metadata": {}, "outputs": [ { @@ -1214,6 +1280,7 @@ }, { "cell_type": "markdown", + "id": "f3d6bc15", "metadata": {}, "source": [ "## Group summaries\n", @@ -1227,6 +1294,7 @@ }, { "cell_type": "markdown", + "id": "ff2fd6cc", "metadata": {}, "source": [ "The type of group summary can be specified via `group_summaries` in the `.plot()` method and must be one of these: `'median_quartiles'`, `'mean_sd'`, `None`.\n", @@ -1237,6 +1305,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e61f77c2", "metadata": {}, "outputs": [ { @@ -1278,6 +1347,7 @@ }, { "cell_type": "markdown", + "id": "b7908353", "metadata": {}, "source": [ "For slopegraphs, the group summary is represented by a solid line connecting the group mean/median with error bars." @@ -1286,6 +1356,7 @@ { "cell_type": "code", "execution_count": null, + "id": "862d87b1", "metadata": {}, "outputs": [ { @@ -1327,6 +1398,7 @@ }, { "cell_type": "markdown", + "id": "00176729", "metadata": {}, "source": [ "**Group summaries** have an associated kwargs `group_summaries_kwargs`\n", @@ -1344,6 +1416,7 @@ { "cell_type": "code", "execution_count": null, + "id": "441e5147", "metadata": {}, "outputs": [ { @@ -1364,6 +1437,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ea5e118c", "metadata": {}, "outputs": [ { @@ -1383,6 +1457,7 @@ }, { "cell_type": "markdown", + "id": "4033f7c2", "metadata": {}, "source": [ "## Raw bars" @@ -1390,6 +1465,7 @@ }, { "cell_type": "markdown", + "id": "d5eed93f", "metadata": {}, "source": [ "**Raw bars** are included in swarmplots by default. It can be turned off by setting `raw_bars=False` in the `.plot()` method." @@ -1398,6 +1474,7 @@ { "cell_type": "code", "execution_count": null, + "id": "afe820f4", "metadata": {}, "outputs": [ { @@ -1417,6 +1494,7 @@ }, { "cell_type": "markdown", + "id": "684b8010", "metadata": {}, "source": [ "Raw bar kwargs can be utilised via `raw_bars_kwargs` in the `.plot()` method.\n", @@ -1427,6 +1505,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d207d2bf", "metadata": {}, "outputs": [ { @@ -1448,6 +1527,7 @@ }, { "cell_type": "markdown", + "id": "d0aa1055", "metadata": {}, "source": [ "## Contrast bars\n", @@ -1457,6 +1537,7 @@ { "cell_type": "code", "execution_count": null, + "id": "61626d46", "metadata": {}, "outputs": [ { @@ -1476,6 +1557,7 @@ }, { "cell_type": "markdown", + "id": "0667877a", "metadata": {}, "source": [ "Contrast bar kwargs can be utilised via `contrast_bars_kwargs` in the `.plot()` method.\n", @@ -1486,6 +1568,7 @@ { "cell_type": "code", "execution_count": null, + "id": "1087421b", "metadata": {}, "outputs": [ { @@ -1507,6 +1590,7 @@ }, { "cell_type": "markdown", + "id": "ecdfcb2e", "metadata": {}, "source": [ "## Reference band\n", @@ -1516,6 +1600,7 @@ { "cell_type": "code", "execution_count": null, + "id": "31b7831a", "metadata": {}, "outputs": [ { @@ -1535,6 +1620,7 @@ }, { "cell_type": "markdown", + "id": "d76dc0f7", "metadata": {}, "source": [ "Reference band kwargs can be utilised via `reference_band_kwargs` in the `.plot()` method.\n", @@ -1550,6 +1636,7 @@ { "cell_type": "code", "execution_count": null, + "id": "173c109c", "metadata": {}, "outputs": [ { @@ -1571,6 +1658,7 @@ }, { "cell_type": "markdown", + "id": "319bf446", "metadata": {}, "source": [ "## Delta text\n", @@ -1580,6 +1668,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7ce8da49", "metadata": {}, "outputs": [ { @@ -1599,6 +1688,7 @@ }, { "cell_type": "markdown", + "id": "5d8ec997", "metadata": {}, "source": [ "Delta text kwargs can be utilised via `delta_text_kwargs` in the `.plot()` method.\n", @@ -1621,6 +1711,7 @@ { "cell_type": "code", "execution_count": null, + "id": "cd25ccc7", "metadata": {}, "outputs": [ { @@ -1641,6 +1732,7 @@ }, { "cell_type": "markdown", + "id": "5179c353", "metadata": {}, "source": [ "`'x_coordinates'` and/or `'y_coordinates'` if you would like to specify the text locations manually. " @@ -1649,6 +1741,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8501251a", "metadata": {}, "outputs": [ { @@ -1670,6 +1763,7 @@ }, { "cell_type": "markdown", + "id": "ae1a40ff", "metadata": {}, "source": [ "`'offset'` to adjust the x location of all the texts (positive moves right, negative left)." @@ -1678,6 +1772,7 @@ { "cell_type": "code", "execution_count": null, + "id": "00d65bcd", "metadata": {}, "outputs": [ { @@ -1698,6 +1793,7 @@ }, { "cell_type": "markdown", + "id": "feaec766", "metadata": {}, "source": [ "## Adding jitter to slopegraph plots\n", @@ -1712,6 +1808,7 @@ { "cell_type": "code", "execution_count": null, + "id": "4a4bf97f", "metadata": {}, "outputs": [], "source": [ @@ -1734,6 +1831,7 @@ }, { "cell_type": "markdown", + "id": "6cd63ad4", "metadata": {}, "source": [ "For the example below, there are many overlapping points for the paired plot, which makes it look like only one sample." @@ -1742,6 +1840,7 @@ { "cell_type": "code", "execution_count": null, + "id": "6275895f", "metadata": {}, "outputs": [ { @@ -1762,6 +1861,7 @@ }, { "cell_type": "markdown", + "id": "121516bd", "metadata": {}, "source": [ "Adding jitter can help to visualize the data better." @@ -1770,6 +1870,7 @@ { "cell_type": "code", "execution_count": null, + "id": "81a91b34", "metadata": {}, "outputs": [ { @@ -1789,6 +1890,7 @@ }, { "cell_type": "markdown", + "id": "54c58acc", "metadata": {}, "source": [ "## Gridkey\n", @@ -1801,6 +1903,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ca1012f1", "metadata": {}, "outputs": [ { @@ -1820,6 +1923,7 @@ }, { "cell_type": "markdown", + "id": "e0136f07", "metadata": {}, "source": [ "Gridkey kwargs can be utilised via `gridkey_kwargs` in the `.plot()` method.\n", @@ -1838,6 +1942,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5d20e84a", "metadata": {}, "outputs": [ { @@ -1860,6 +1965,7 @@ }, { "cell_type": "markdown", + "id": "4e5b0d2f", "metadata": {}, "source": [ "## Delta dot\n", @@ -1872,6 +1978,7 @@ { "cell_type": "code", "execution_count": null, + "id": "74b02990", "metadata": {}, "outputs": [ { @@ -1891,6 +1998,7 @@ }, { "cell_type": "markdown", + "id": "8108826e", "metadata": {}, "source": [ "Delta dot kwargs can be utilised via `delta_dot_kwargs` in the `.plot()` method.\n", @@ -1908,6 +2016,7 @@ { "cell_type": "code", "execution_count": null, + "id": "58acb413", "metadata": {}, "outputs": [ { @@ -1927,6 +2036,7 @@ }, { "cell_type": "markdown", + "id": "ed845c6f", "metadata": {}, "source": [ "## Effect size paired lines\n", @@ -1939,6 +2049,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c302afd2", "metadata": {}, "outputs": [ { @@ -1958,6 +2069,7 @@ }, { "cell_type": "markdown", + "id": "88d55d19", "metadata": {}, "source": [ "Effect size line kwargs can be utilised via `contrast_paired_lines_kwargs` in the `.plot()` method.\n", @@ -1974,6 +2086,7 @@ { "cell_type": "code", "execution_count": null, + "id": "41d08b48", "metadata": {}, "outputs": [ { @@ -1994,6 +2107,7 @@ }, { "cell_type": "markdown", + "id": "e3969990", "metadata": {}, "source": [ "## Baseline error curve\n", @@ -2005,6 +2119,7 @@ { "cell_type": "code", "execution_count": null, + "id": "081d9d27", "metadata": {}, "outputs": [ { @@ -2031,5 +2146,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/09-forest_plot.ipynb b/nbs/tutorials/09-forest_plot.ipynb index 5b17c7e1..4a7401fb 100644 --- a/nbs/tutorials/09-forest_plot.ipynb +++ b/nbs/tutorials/09-forest_plot.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "9f60d8c2", "metadata": {}, "source": [ "# Forest Plots: Visualizing Multiple Contrasts\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "73c68853", "metadata": {}, "source": [ "In DABEST **v2025.03.27**, we introduce a new function to plot separately calculated effect sizes in the same axes to allow direct visual comparisons. \n", @@ -22,6 +24,7 @@ }, { "cell_type": "markdown", + "id": "0113d4b4", "metadata": {}, "source": [ "## Load libraries" @@ -30,6 +33,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3919becd", "metadata": {}, "outputs": [ { @@ -73,6 +77,7 @@ }, { "cell_type": "markdown", + "id": "f0b0907e", "metadata": {}, "source": [ "## Delta-delta effects" @@ -80,6 +85,7 @@ }, { "cell_type": "markdown", + "id": "3c77114d", "metadata": {}, "source": [ "First please revisit the notebook [Delta-Delta Tutorial](06-delta_delta.html) for how to generate a delta-delta effect size. We will generate three of them plot them into the same axes. Here we test the efficacy of 3 drugs named ``Drug1``, ``Drug2`` , and ``Drug3`` on a disease-causing mutation ```M``` based on disease metric ```Tumor Size```. We want to know how the three drugs fare in ameliorating the phenotype metric ```Tumor Size```. " @@ -87,6 +93,7 @@ }, { "cell_type": "markdown", + "id": "e7ded244", "metadata": {}, "source": [ "| | Wildtype | Mutant |\n", @@ -97,6 +104,7 @@ }, { "cell_type": "markdown", + "id": "7fd677d0", "metadata": {}, "source": [ "| | Wildtype | Mutant |\n", @@ -107,6 +115,7 @@ }, { "cell_type": "markdown", + "id": "95cca8ae", "metadata": {}, "source": [ "| | Wildtype | Mutant |\n", @@ -117,6 +126,7 @@ }, { "cell_type": "markdown", + "id": "5e1f9a3e", "metadata": {}, "source": [ "In each scenario, there are two ``Treatment`` conditions, ``Placebo`` (control group) and ``Drug`` (test group). There are two ``Genotype``\\'s: ``W`` (wild type population) and ``M`` (mutant population). Additionally, each experiment was conducted twice (``Rep1`` and ``Rep2``). We will perform several analyses to visualise these differences in a simulated dataset. We will simulate three separte datasets below. " @@ -124,6 +134,7 @@ }, { "cell_type": "markdown", + "id": "273579c0", "metadata": {}, "source": [ "### Creating a demo dataset" @@ -132,6 +143,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f0467048", "metadata": {}, "outputs": [], "source": [ @@ -176,6 +188,7 @@ }, { "cell_type": "markdown", + "id": "0faf0466", "metadata": {}, "source": [ "### Loading data" @@ -184,6 +197,7 @@ { "cell_type": "code", "execution_count": null, + "id": "706cc02b", "metadata": {}, "outputs": [], "source": [ @@ -205,6 +219,7 @@ }, { "cell_type": "markdown", + "id": "52381d78", "metadata": {}, "source": [ "### Generate delta-delta plots for each datasets " @@ -212,6 +227,7 @@ }, { "cell_type": "markdown", + "id": "3013cd12", "metadata": {}, "source": [ "To create a delta-delta plot, you simply need to set ``delta2=True`` in the \n", @@ -225,6 +241,7 @@ { "cell_type": "code", "execution_count": null, + "id": "f5621a8b", "metadata": {}, "outputs": [ { @@ -289,6 +306,7 @@ }, { "cell_type": "markdown", + "id": "6ec8759b", "metadata": {}, "source": [ "### Generate a forest plot" @@ -296,6 +314,7 @@ }, { "cell_type": "markdown", + "id": "f8c731a4", "metadata": {}, "source": [ "This will allow for comparisons of different ``Drug`` effects.\n", @@ -322,6 +341,7 @@ { "cell_type": "code", "execution_count": null, + "id": "adfdf4c5", "metadata": {}, "outputs": [ { @@ -344,6 +364,7 @@ }, { "cell_type": "markdown", + "id": "aa104dab", "metadata": {}, "source": [ "### Generate a forest plot with delta effect sizes alongside the delta-delta effect sizes\n", @@ -356,6 +377,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a3b8885f", "metadata": {}, "outputs": [ { @@ -379,6 +401,7 @@ }, { "cell_type": "markdown", + "id": "63926f6a", "metadata": {}, "source": [ "### Selecting normalised effect sizes via `hedges_g` or `delta_g`\n", @@ -389,6 +412,7 @@ { "cell_type": "code", "execution_count": null, + "id": "11cdbfb1", "metadata": {}, "outputs": [ { @@ -441,6 +465,7 @@ }, { "cell_type": "markdown", + "id": "3497e3c4", "metadata": {}, "source": [ "## Mini-meta effects\n", @@ -451,6 +476,7 @@ }, { "cell_type": "markdown", + "id": "1e66885f", "metadata": {}, "source": [ "### Creating a demo dataset" @@ -459,6 +485,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3727d3b6", "metadata": {}, "outputs": [], "source": [ @@ -509,6 +536,7 @@ }, { "cell_type": "markdown", + "id": "53b9bdf6", "metadata": {}, "source": [ "### Loading data" @@ -517,6 +545,7 @@ { "cell_type": "code", "execution_count": null, + "id": "be7881aa", "metadata": {}, "outputs": [], "source": [ @@ -535,6 +564,7 @@ }, { "cell_type": "markdown", + "id": "dde6d98a", "metadata": {}, "source": [ "### Generate a forest plot" @@ -543,6 +573,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3720e1ad", "metadata": {}, "outputs": [ { @@ -565,6 +596,7 @@ }, { "cell_type": "markdown", + "id": "d09c48a4", "metadata": {}, "source": [ "### Generate a forest plot with delta effect sizes alongside the mini-meta effect sizes\n", @@ -577,6 +609,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d7c60fe5", "metadata": {}, "outputs": [ { @@ -600,6 +633,7 @@ }, { "cell_type": "markdown", + "id": "5c9ada3f", "metadata": {}, "source": [ "## Delta effects\n", @@ -609,6 +643,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9e5dc341", "metadata": {}, "outputs": [], "source": [ @@ -624,6 +659,7 @@ { "cell_type": "code", "execution_count": null, + "id": "54aa5353", "metadata": {}, "outputs": [ { @@ -644,6 +680,7 @@ }, { "cell_type": "markdown", + "id": "110264fa", "metadata": {}, "source": [ "Unlike delta-delta and mini-meta experiments, here you can choose between more effect size metrics (where applicable): `mean_diff`, `cohens_d`, `cohens_h`, `hedges_g`, and `cliffs_delta`" @@ -652,6 +689,7 @@ { "cell_type": "code", "execution_count": null, + "id": "9105f80e", "metadata": {}, "outputs": [ { @@ -672,6 +710,7 @@ }, { "cell_type": "markdown", + "id": "5d48c72c", "metadata": {}, "source": [ "## Controlling aesthetics" @@ -679,6 +718,7 @@ }, { "cell_type": "markdown", + "id": "be8c4949", "metadata": {}, "source": [ "The main aesthetic parameters for the forest_plot function are:\n", @@ -734,6 +774,7 @@ }, { "cell_type": "markdown", + "id": "ee5b7648", "metadata": {}, "source": [ "### Changing layout with `horizontal`\n", @@ -743,6 +784,7 @@ { "cell_type": "code", "execution_count": null, + "id": "48f672bc", "metadata": {}, "outputs": [ { @@ -765,6 +807,7 @@ }, { "cell_type": "markdown", + "id": "dbec9054", "metadata": {}, "source": [ "### Using a custom palette \n", @@ -774,6 +817,7 @@ { "cell_type": "code", "execution_count": null, + "id": "226e0ad9", "metadata": {}, "outputs": [ { @@ -796,6 +840,7 @@ }, { "cell_type": "markdown", + "id": "5108d27f", "metadata": {}, "source": [ "### Plotting other effect sizes \n", @@ -805,6 +850,7 @@ { "cell_type": "code", "execution_count": null, + "id": "3810d975", "metadata": {}, "outputs": [ { @@ -828,6 +874,7 @@ }, { "cell_type": "markdown", + "id": "5817dc8b", "metadata": {}, "source": [ "### Delta text\n", @@ -837,6 +884,7 @@ { "cell_type": "code", "execution_count": null, + "id": "4b8ef827", "metadata": {}, "outputs": [ { @@ -860,6 +908,7 @@ }, { "cell_type": "markdown", + "id": "636d8142", "metadata": {}, "source": [ "You can set a variety of kwargs to customize the delta text via `delta_text_kwargs`.\n", @@ -880,6 +929,7 @@ { "cell_type": "code", "execution_count": null, + "id": "5d32f9e2", "metadata": {}, "outputs": [ { @@ -908,6 +958,7 @@ }, { "cell_type": "markdown", + "id": "adf2a443", "metadata": {}, "source": [ "### Contrast bars\n", @@ -917,6 +968,7 @@ { "cell_type": "code", "execution_count": null, + "id": "84fcd0c0", "metadata": {}, "outputs": [ { @@ -940,6 +992,7 @@ }, { "cell_type": "markdown", + "id": "6e0002ae", "metadata": {}, "source": [ "You can set a variety of kwargs to customize the delta text via `contrast_bars_kwargs`.\n", @@ -950,6 +1003,7 @@ { "cell_type": "code", "execution_count": null, + "id": "df1fa100", "metadata": {}, "outputs": [ { @@ -974,6 +1028,7 @@ }, { "cell_type": "markdown", + "id": "5db33a33", "metadata": {}, "source": [ "### Reference band\n", @@ -983,6 +1038,7 @@ { "cell_type": "code", "execution_count": null, + "id": "c16b4146", "metadata": {}, "outputs": [ { @@ -1006,6 +1062,7 @@ }, { "cell_type": "markdown", + "id": "3dbfc1d4", "metadata": {}, "source": [ "You can set a variety of kwargs to customize the reference bands via `reference_band_kwargs`.\n", @@ -1018,6 +1075,7 @@ { "cell_type": "code", "execution_count": null, + "id": "8833e72c", "metadata": {}, "outputs": [ { @@ -1042,6 +1100,7 @@ }, { "cell_type": "markdown", + "id": "05d55fdd", "metadata": {}, "source": [ "### Embedding forest plots into an existing Axes \n", @@ -1052,6 +1111,7 @@ { "cell_type": "code", "execution_count": null, + "id": "dce18882", "metadata": {}, "outputs": [ { @@ -1097,5 +1157,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 5 } diff --git a/nbs/tutorials/10-whorlmap.ipynb b/nbs/tutorials/10-whorlmap.ipynb index 42b3bdd8..e2bae374 100644 --- a/nbs/tutorials/10-whorlmap.ipynb +++ b/nbs/tutorials/10-whorlmap.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "id": "cfe53651", "metadata": {}, "source": [ "# Whorlmaps: Visualizing Even More Contrasts\n", @@ -13,6 +14,7 @@ }, { "cell_type": "markdown", + "id": "fb7414d4", "metadata": {}, "source": [ "In DABEST **v2025.10.20**, we introduce a new and more compact way of visualizing bootstrap distributions:\n", @@ -21,6 +23,7 @@ }, { "cell_type": "markdown", + "id": "b8d232aa", "metadata": {}, "source": [ "## Load libraries" @@ -29,6 +32,7 @@ { "cell_type": "code", "execution_count": null, + "id": "d4b8d786", "metadata": {}, "outputs": [ { @@ -71,6 +75,7 @@ }, { "cell_type": "markdown", + "id": "d4874fc4", "metadata": {}, "source": [ "## Create a simulated dataset and generate a list of corresponding dabest objects" @@ -79,6 +84,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e7a5e74a", "metadata": {}, "outputs": [], "source": [ @@ -114,6 +120,7 @@ }, { "cell_type": "markdown", + "id": "46c0292f", "metadata": {}, "source": [ "## Working with many many Dabest objects\n", @@ -123,6 +130,7 @@ { "cell_type": "code", "execution_count": null, + "id": "af3ade87", "metadata": {}, "outputs": [], "source": [ @@ -161,6 +169,7 @@ }, { "cell_type": "markdown", + "id": "c9946643", "metadata": {}, "source": [ "We are going to create a new object called MultiContrast which will contain the array of contrast objects and information about them." @@ -169,6 +178,7 @@ { "cell_type": "code", "execution_count": null, + "id": "486e60e4", "metadata": {}, "outputs": [ { @@ -186,6 +196,7 @@ }, { "cell_type": "markdown", + "id": "bc2e2d31", "metadata": {}, "source": [ "As we have seen in the previous tutorial, we can visualize these effect sizes with forest plot as follows:" @@ -194,6 +205,7 @@ { "cell_type": "code", "execution_count": null, + "id": "2ed4ac7f", "metadata": {}, "outputs": [ { @@ -213,6 +225,7 @@ }, { "cell_type": "markdown", + "id": "e3a3e186", "metadata": {}, "source": [ " This data would require a stack of forest plots to visualize. So instead, we plot a whorlmap for a concise representation and use color to represent the dimension of effect size. For each effect size, the full bootstrap distribution is binned by quantiles and ranked by value, and then each bin is represented by a pixel. All the pixels correponding to the bins of effects are arranged in a spiral in a cell. The redness and the blueness of the cells represent the magnitude of the effects in the positive and negative direction." @@ -221,6 +234,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e1beb9b1", "metadata": {}, "outputs": [ { @@ -245,6 +259,7 @@ }, { "cell_type": "markdown", + "id": "311bf96e", "metadata": {}, "source": [ "The resulting graphic is easy to interpret. Drug B and E induces the most broad spectrum reduction. However the data for Drug E seems a little less precise, mixing blue and red colored pixels. We can say Drug B is a surer bet. \n", @@ -256,6 +271,7 @@ { "cell_type": "code", "execution_count": null, + "id": "7ee951a8", "metadata": {}, "outputs": [ { @@ -296,6 +312,7 @@ }, { "cell_type": "markdown", + "id": "95695191", "metadata": {}, "source": [ "## MultiContrast object can also handle 1-D dabest object arrays" @@ -304,6 +321,7 @@ { "cell_type": "code", "execution_count": null, + "id": "350000c0", "metadata": {}, "outputs": [], "source": [ @@ -312,6 +330,7 @@ }, { "cell_type": "markdown", + "id": "fe7a8d27", "metadata": {}, "source": [ "You can plot a forest plot from this MultiContrast object" @@ -320,6 +339,7 @@ { "cell_type": "code", "execution_count": null, + "id": "184aa227", "metadata": {}, "outputs": [ { @@ -339,6 +359,7 @@ }, { "cell_type": "markdown", + "id": "5d54f722", "metadata": {}, "source": [ "## 1-D whorlmap also works" @@ -347,6 +368,7 @@ { "cell_type": "code", "execution_count": null, + "id": "dd82e1ad", "metadata": {}, "outputs": [ { @@ -372,6 +394,7 @@ { "cell_type": "code", "execution_count": null, + "id": "e4c6176a", "metadata": {}, "outputs": [ { @@ -401,6 +424,7 @@ { "cell_type": "code", "execution_count": null, + "id": "ad60757d", "metadata": {}, "outputs": [ { @@ -426,6 +450,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a1053e97", "metadata": {}, "outputs": [ { @@ -451,6 +476,7 @@ }, { "cell_type": "markdown", + "id": "ad82941f", "metadata": {}, "source": [ "## Heatmap and plot kwargs\n", @@ -460,6 +486,7 @@ { "cell_type": "code", "execution_count": null, + "id": "a7c7e109", "metadata": {}, "outputs": [ { @@ -493,5 +520,5 @@ } }, "nbformat": 4, - "nbformat_minor": 4 + "nbformat_minor": 5 } diff --git a/pyproject.toml b/pyproject.toml index 244792ad..6bb7257b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,38 @@ [build-system] -requires = ["setuptools>=64.0"] +requires = ["setuptools>=64"] build-backend = "setuptools.build_meta" [project] -name="dabest" -requires-python=">=3.10" -dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"] +name = "dabest" +dynamic = ["version"] +description = "Data Analysis and Visualization using Bootstrap-Coupled Estimation." +readme = "README.md" +requires-python = ">=3.10" +license = {text = "Apache-2.0"} +authors = [{name = "Joses W. Ho", email = "joseshowh@gmail.com"}] +keywords = ['nbdev', 'jupyter', 'notebook', 'python'] +classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"] +dependencies = ['fastcore', 'pandas~=2.2.3', 'numpy~=2.1.0', 'matplotlib~=3.10.0', 'seaborn~=0.13.2', 'scipy~=1.15.2', 'numba~=0.61.0', 'datetime', 'statsmodels', 'lqrt', 'tqdm'] -[tool.uv] -cache-keys = [{ file = "pyproject.toml" }, { file = "settings.ini" }, { file = "setup.py" }] +[project.urls] +Repository = "https://github.com/acclab/DABEST-python" +Documentation = "https://acclab.github.io/DABEST-python" + +[project.entry-points.nbdev] +dabest = "dabest._modidx:d" + +[project.optional-dependencies] +dev = ['pytest~=8.3.4', 'pytest-mpl~=0.17.0'] + +[tool.setuptools.dynamic] +version = {attr = "dabest.__version__"} + +[tool.setuptools.packages.find] +include = ["dabest"] + +[tool.nbdev] +branch = 'master' +readme_nb = 'read_me.ipynb' +jupyter_hooks = true +custom_sidebar = true +title = 'dabest'