Skip to content

Commit

Permalink
Merge pull request #89 from ACCLAB/v0.2.8
Browse files Browse the repository at this point in the history
v0.2.8
  • Loading branch information
josesho committed Dec 26, 2019
2 parents e6cd4b8 + 270519c commit e0c487b
Show file tree
Hide file tree
Showing 43 changed files with 218 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Byte-compiled / optimized / DLL files
__pycache__/
.idea/*
*.py[cod]
*$py.class

Expand Down
2 changes: 1 addition & 1 deletion dabest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
from ._stats_tools import effsize as effsize
from ._classes import TwoGroupsEffectSize

__version__ = "0.2.7"
__version__ = "0.2.8"
106 changes: 105 additions & 1 deletion dabest/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ def __init__(self, control, test, effect_size,
'pct_low': -0.763588353717278,
'pvalue_brunner_munzel': nan,
'pvalue_kruskal': nan,
'pvalue_lqrt_paired': nan,
'pvalue_lqrt_unpaired_equal_variance': 0.36,
'pvalue_lqrt_unpaired_unequal_variance': 0.36,
'pvalue_mann_whitney': 0.2600723060808019,
'pvalue_paired_students_t': nan,
'pvalue_students_t': 0.34743913903372836,
Expand All @@ -458,6 +461,9 @@ def __init__(self, control, test, effect_size,
'resamples': 5000,
'statistic_brunner_munzel': nan,
'statistic_kruskal': nan,
'statistic_lqrt_paired': nan,
'statistic_lqrt_unpaired_equal_variance': 0.8894980773231964,
'statistic_lqrt_unpaired_unequal_variance': 0.8916901409507432,
'statistic_mann_whitney': 406.0,
'statistic_paired_students_t': nan,
'statistic_students_t': 0.9472545159069105,
Expand All @@ -470,6 +476,7 @@ def __init__(self, control, test, effect_size,
from numpy.random import choice, seed

import scipy.stats as spstats
import lqrt

# import statsmodels.stats.power as power

Expand Down Expand Up @@ -601,6 +608,12 @@ def __init__(self, control, test, effect_size,
wilcoxon = spstats.wilcoxon(control, test)
self.__pvalue_wilcoxon = wilcoxon.pvalue
self.__statistic_wilcoxon = wilcoxon.statistic

lqrt_result = lqrt.lqrtest_rel(control, test,
random_state=random_seed)

self.__pvalue_paired_lqrt = lqrt_result.pvalue
self.__statistic_paired_lqrt = lqrt_result.statistic

if effect_size != "median_diff":
# Paired Student's t-test.
Expand Down Expand Up @@ -658,7 +671,24 @@ def __init__(self, control, test, effect_size,
# in terms of rank (eg. all zeros.)
pass

# Likelihood Q-Ratio test:
lqrt_equal_var_result = lqrt.lqrtest_ind(control, test,
random_state=random_seed,
equal_var=True)

self.__pvalue_lqrt_equal_var = lqrt_equal_var_result.pvalue
self.__statistic_lqrt_equal_var = lqrt_equal_var_result.statistic

lqrt_unequal_var_result = lqrt.lqrtest_ind(control, test,
random_state=random_seed,
equal_var=False)

self.__pvalue_lqrt_unequal_var = lqrt_unequal_var_result.pvalue
self.__statistic_lqrt_unequal_var = lqrt_unequal_var_result.statistic


standardized_es = es.cohens_d(control, test, is_paired=False)

# self.__power = power.tt_ind_solve_power(standardized_es,
# len(control),
# alpha=self.__alpha,
Expand Down Expand Up @@ -968,6 +998,65 @@ def statistic_mann_whitney(self):




@property
def pvalue_lqrt_paired(self):
from numpy import nan as npnan
try:
return self.__pvalue_paired_lqrt
except AttributeError:
return npnan



@property
def statistic_lqrt_paired(self):
from numpy import nan as npnan
try:
return self.__statistic_paired_lqrt
except AttributeError:
return npnan


@property
def pvalue_lqrt_unpaired_equal_variance(self):
from numpy import nan as npnan
try:
return self.__pvalue_lqrt_equal_var
except AttributeError:
return npnan



@property
def statistic_lqrt_unpaired_equal_variance(self):
from numpy import nan as npnan
try:
return self.__statistic_lqrt_equal_var
except AttributeError:
return npnan


@property
def pvalue_lqrt_unpaired_unequal_variance(self):
from numpy import nan as npnan
try:
return self.__pvalue_lqrt_unequal_var
except AttributeError:
return npnan



@property
def statistic_lqrt_unpaired_unequal_variance(self):
from numpy import nan as npnan
try:
return self.__statistic_lqrt_unequal_var
except AttributeError:
return npnan



# @property
# def power(self):
# from numpy import nan as npnan
Expand Down Expand Up @@ -1089,7 +1178,16 @@ def __pre_calc(self):
'statistic_paired_students_t',

'pvalue_kruskal',
'statistic_kruskal']
'statistic_kruskal',

'pvalue_lqrt_paired',
'statistic_lqrt_paired',

'pvalue_lqrt_unpaired_equal_variance',
'statistic_lqrt_unpaired_equal_variance',

'pvalue_lqrt_unpaired_unequal_variance',
'statistic_lqrt_unpaired_unequal_variance']

self.__results = out_.reindex(columns=columns_in_order)
self.__results.dropna(axis="columns", how="all", inplace=True)
Expand Down Expand Up @@ -1209,6 +1307,12 @@ def plot(self, color_col=None,
pyplot.violinplot` command here, as a dict. If None, the following
keywords are passed to violinplot : {'widths':0.5, 'vert':True,
'showextrema':False, 'showmedians':False}.
slopegraph_kwargs : dict, default None
This will change the appearance of the lines used to join each pair
of observations when `show_pairs=True`. Pass any keyword arguments
accepted by matplotlib `plot()` function here, as a dict.
If None, the following keywords are
passed to plot() : {'linewidth':1, 'alpha':0.5}.
reflines_kwargs : dict, default None
This will change the appearance of the zero reference lines. Pass
any keyword arguments accepted by the matplotlib Axes `hlines`
Expand Down
4 changes: 2 additions & 2 deletions dabest/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
if plot_kwargs["slopegraph_kwargs"] is None:
slopegraph_kwargs = default_slopegraph_kwargs
else:
slopegraph_kwargs = merge_two_dicts(slopegraph_kwargs,
slopegraph_kwargs = merge_two_dicts(default_slopegraph_kwargs,
plot_kwargs["slopegraph_kwargs"])


Expand Down Expand Up @@ -697,7 +697,7 @@ def EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs):
else:
contrast_ylim_high, contrast_ylim_low = contrast_axes_ylim
if contrast_ylim_low < 0 < contrast_ylim_high:
contrast_axes.axhline(y=0, lw=0.75, color=ytick_color)
contrast_axes.axhline(y=0, **reflines_kwargs)

# Compute the end of each x-axes line.
rightend_ticks = np.array([len(i)-1 for i in idx]) + np.array(ticks_to_skip)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_09_cummings_shared_control.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_10_cummings_multi_groups.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_11_inset_plots.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_12_gardner_altman_ylabel.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_13_multi_2group_color.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_15_change_palette_a.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_16_change_palette_b.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_17_change_palette_c.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_18_desat.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_19_dot_sizes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_20_change_ylims.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_21_invert_ylim.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_22_ticker_gardner_altman.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_23_ticker_cumming.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dabest/tests/baseline_images/test_99_style_sheets.png
32 changes: 30 additions & 2 deletions dabest/tests/test_01_effsizes_pvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@


import sys
import pytest
import lqrt
import numpy as np
import scipy as sp
import pytest
import pandas as pd
from .._stats_tools import effsize
from .._classes import TwoGroupsEffectSize
Expand Down Expand Up @@ -176,4 +177,31 @@ def test_ordinal_dominance():
"cliffs_delta", is_paired=False)

p1 = sp.stats.brunnermunzel(likert_control, likert_treatment).pvalue
assert es.pvalue_brunner_munzel == pytest.approx(p1)
assert es.pvalue_brunner_munzel == pytest.approx(p1)



def test_lqrt_unpaired():
es = TwoGroupsEffectSize(wellbeing.control, wellbeing.expt,
"mean_diff", is_paired=False)

p1 = lqrt.lqrtest_ind(wellbeing.control, wellbeing.expt,
equal_var=False,
random_state=12345)

p2 = lqrt.lqrtest_ind(wellbeing.control, wellbeing.expt,
equal_var=True,
random_state=12345)

assert es.pvalue_lqrt_unpaired_unequal_variance == pytest.approx(p1.pvalue)
assert es.pvalue_lqrt_unpaired_equal_variance == pytest.approx(p2.pvalue)


def test_lqrt_paired():
es = TwoGroupsEffectSize(paired_wellbeing.pre, paired_wellbeing.post,
"mean_diff", is_paired=True)

p1 = lqrt.lqrtest_rel(paired_wellbeing.pre, paired_wellbeing.post,
random_state=12345)

assert es.pvalue_lqrt_paired == pytest.approx(p1.pvalue)
49 changes: 46 additions & 3 deletions dabest/tests/test_03_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_14_gardner_altman_paired_color():

@pytest.mark.mpl_image_compare
def test_15_change_palette_a():
return multi_2group.mean_diff.plot(fig_size=(7, 6),
return multi_2group.mean_diff.plot(fig_size=(8, 6),
color_col="Gender",
custom_palette="Dark2");

Expand Down Expand Up @@ -285,7 +285,7 @@ def test_23_ticker_cumming():


@pytest.mark.mpl_image_compare
def test_24_test_wide_df_nan():
def test_24_wide_df_nan():

wide_df_dabest = load(wide_df,
idx=("Control", "Test 1", "Test 2", "Test 3")
Expand All @@ -296,16 +296,59 @@ def test_24_test_wide_df_nan():


@pytest.mark.mpl_image_compare
def test_25_test_long_df_nan():
def test_25_long_df_nan():

long_df_dabest = load(long_df, x="group", y="value",
idx=("Control", "Test 1", "Test 2", "Test 3")
)

return long_df_dabest.mean_diff.plot();



@pytest.mark.mpl_image_compare
def test_26_slopegraph_kwargs():

return two_groups_paired.mean_diff.plot(
slopegraph_kwargs=dict(linestyle='dotted')
);



@pytest.mark.mpl_image_compare
def test_27_gardner_altman_reflines_kwargs():

return two_groups_unpaired.mean_diff.plot(
reflines_kwargs=dict(linestyle='dotted')
);



@pytest.mark.mpl_image_compare
def test_28_unpaired_cumming_reflines_kwargs():

return two_groups_unpaired.mean_diff.plot(
fig_size=(12,10),
float_contrast=False,
reflines_kwargs=dict(linestyle='dotted',
linewidth=2),
contrast_ylim=(-1, 1)
);



@pytest.mark.mpl_image_compare
def test_28_paired_cumming_slopegraph_reflines_kwargs():

return two_groups_paired.mean_diff.plot(float_contrast=False,
color_col="Gender",
slopegraph_kwargs=dict(linestyle='dotted'),
reflines_kwargs=dict(linestyle='dashed',
linewidth=2),
contrast_ylim=(-1, 1)
);


@pytest.mark.mpl_image_compare
def test_99_style_sheets():
# Perform this test last so we don't have to reset the plot style.
Expand Down
7 changes: 6 additions & 1 deletion docs/source/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ To find out more about the authors’ research, please visit the `Claridge-Chang
Contributors
------------

- DizietAsahi (`DizietAsahi <https://github.com/DizietAsahi>`_) with `PR #86 <https://github.com/ACCLAB/DABEST-python/pull/86>`_: Fix bugs in slopegraph and reference line keyword parsing.

- Adam Li (`@adam2392 <https://github.com/adam2392>`_) with `PR #85 <https://github.com/ACCLAB/DABEST-python/pull/85>`_: Implement `Lq-Likelihood-Ratio-Type Test <https://github.com/alyakin314/lqrt>`_ in statistical output.

- Mason Malone (`@MasonM <https://github.com/MasonM>`_) with `PR #30 <https://github.com/ACCLAB/DABEST-python/pull/30>`_: Fix plot error when effect size is 0.

- Matthew Edwards (`@mje-nz <https://github.com/mje-nz>`_) with `PR #71 <https://github.com/ACCLAB/DABEST-python/pull/30>`_: Specify dependencies correctly in ``setup.py``.

- Adam Nekimken (`@anekimken <https://github.com/anekimken>`_) with `PR #73 <https://github.com/ACCLAB/DABEST-python/pull/73>`_: Implement inset axes so estimation plots can be plotted on a pre-determined :py:mod:`matplotlib` :py:class:`Axes` object.


Typography
----------

Expand All @@ -31,7 +36,7 @@ License

The DABEST package in Python is licenced under the `BSD 3-clause Clear License <https://choosealicense.com/licenses/bsd-3-clause-clear/>`_.

Copyright (c) 2016-2019, Joses W. Ho
Copyright (c) 2016-2020, Joses W. Ho
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
# The short X.Y version.
version = '0.2'
# The full version, including alpha/beta/rc tags.
release = '0.2.7'
release = '0.2.8'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 3 additions & 2 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ Requirements

Python 3.7 is strongly recommended. DABEST has also been tested with Python 3.5 and 3.6.

In addition, the following packages are also required:
In addition, the following packages are also required (listed with their minimal versions):

* `numpy 1.15 <https://www.numpy.org>`_
* `scipy 1.2 <https://www.scipy.org>`_
* `matplotlib 3.0 <https://www.matplotlib.org>`_
* `pandas 0.24 <https://pandas.pydata.org>`_
* `pandas 0.25.3 <https://pandas.pydata.org>`_
* `seaborn 0.9 <https://seaborn.pydata.org>`_
* `lqrt 0.3.2 <https://github.com/alyakin314/lqrt>`_

To obtain these package dependencies easily, it is highly recommended to download the `Anaconda <https://www.continuum.io/downloads>`_ distribution of Python.

Expand Down
5 changes: 4 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ Analyze your data with estimation statistics!

News
----
December 2019:
- v0.2.8 released. This release adds the `Lq-Likelihood-Ratio-Type Test <https://github.com/alyakin314/lqrt>`_ in the statistical output, and also a bugfix for slopegraph and reference line keyword parsing. For more information, see the :doc:`release-notes`.

October 2019:
- v0.2.7 released. A minor bugfix in the handling of wide datasets with unequal Ns in each group. For more information, see the :doc:`release-notes`.
- v0.2.7 released. A minor bugfix in the handling of wide datasets with unequal Ns in each group.
- v0.2.6 released. This release has one new feature (plotting of estimation plot inside any :py:mod:`matplotlib` :py:class:`Axes`; see the section on :ref:`inset_plot` in the :doc:`tutorial`). There are also two bug patches for the handling of bootstrap plotting, and of dependency installation.

September 2019:
Expand Down

0 comments on commit e0c487b

Please sign in to comment.