Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dabest/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def load(data, idx, x=None, y=None, paired=False, id_col=None,
ci=95, resamples=5000, random_seed=12345):
ci=95, resamples=5000, random_seed=12345, proportional=False):
'''
Loads data in preparation for estimation statistics.

Expand Down Expand Up @@ -34,6 +34,7 @@ def load(data, idx, x=None, y=None, paired=False, id_col=None,
This integer is used to seed the random number generator during
bootstrap resampling, ensuring that the confidence intervals
reported are replicable.
proportional : boolean, default False.

Returns
-------
Expand Down Expand Up @@ -62,4 +63,4 @@ def load(data, idx, x=None, y=None, paired=False, id_col=None,
'''
from ._classes import Dabest

return Dabest(data, idx, x, y, paired, id_col, ci, resamples, random_seed)
return Dabest(data, idx, x, y, paired, id_col, ci, resamples, random_seed, proportional)
55 changes: 46 additions & 9 deletions dabest/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Dabest(object):
"""

def __init__(self, data, idx, x, y, paired, id_col, ci, resamples,
random_seed):
random_seed, proportional):

"""
Parses and stores pandas DataFrames in preparation for estimation
Expand All @@ -30,6 +30,7 @@ def __init__(self, data, idx, x, y, paired, id_col, ci, resamples,
self.__is_paired = paired
self.__resamples = resamples
self.__random_seed = random_seed
self.__proportional = proportional

# Make a copy of the data, so we don't make alterations to it.
data_in = data.copy()
Expand Down Expand Up @@ -183,7 +184,8 @@ def __init__(self, data, idx, x, y, paired, id_col, ci, resamples,

EffectSizeDataFrame_kwargs = dict(ci=ci, is_paired=paired,
random_seed=random_seed,
resamples=resamples)
resamples=resamples,
proportional=proportional)

self.__mean_diff = EffectSizeDataFrame(self, "mean_diff",
**EffectSizeDataFrame_kwargs)
Expand Down Expand Up @@ -535,6 +537,15 @@ def _plot_data(self):
"""
return self.__plot_data


@property
def proportional(self):
"""
Returns the proportional parameter
class.
"""
return self.__proportional

@property
def _all_plot_groups(self):
"""
Expand All @@ -546,7 +557,6 @@ def _all_plot_groups(self):




class TwoGroupsEffectSize(object):

"""
Expand Down Expand Up @@ -1313,7 +1323,7 @@ class EffectSizeDataFrame(object):
sizes for several comparisons."""

def __init__(self, dabest, effect_size,
is_paired, ci=95,
is_paired, ci=95, proportional=False,
resamples=5000,
permutation_count=5000,
random_seed=12345):
Expand All @@ -1329,6 +1339,7 @@ def __init__(self, dabest, effect_size,
self.__resamples = resamples
self.__permutation_count = permutation_count
self.__random_seed = random_seed
self.__proportional = proportional


def __pre_calc(self):
Expand Down Expand Up @@ -1501,10 +1512,10 @@ def plot(self, color_col=None,

raw_marker_size=6, es_marker_size=9,

swarm_label=None, contrast_label=None,
swarm_ylim=None, contrast_ylim=None,
swarm_label=None, barchart_label=None, contrast_label=None,
swarm_ylim=None, barchart_ylim=None, contrast_ylim=None,

custom_palette=None, swarm_desat=0.5, halfviolin_desat=1,
custom_palette=None, swarm_desat=0.5, barchart_desat=0.5, halfviolin_desat=1,
halfviolin_alpha=0.8,

float_contrast=True,
Expand All @@ -1516,6 +1527,8 @@ def plot(self, color_col=None,
dpi=100,
ax=None,


barchartplot_kwargs=None,
swarmplot_kwargs=None,
violinplot_kwargs=None,
slopegraph_kwargs=None,
Expand Down Expand Up @@ -1682,19 +1695,35 @@ def plot(self, color_col=None,

"""

from .plotter import EffectSizeDataFramePlotter
from .plotter import EffectSizeDataFramePlotter, ProportionalDataFramePlotter


if hasattr(self, "results") is False:
self.__pre_calc()

if self.__proportional:
raw_marker_size = 0.01

all_kwargs = locals()
del all_kwargs["self"]

if self.__proportional:
out = ProportionalDataFramePlotter(self, **all_kwargs)
return out

out = EffectSizeDataFramePlotter(self, **all_kwargs)

return out


@property
def proportional(self):
"""
Returns the proportional parameter
class.
"""
return self.__proportional

@property
def results(self):
"""Prints all pairwise comparisons nicely."""
Expand Down Expand Up @@ -1780,7 +1809,14 @@ def dabest_obj(self):
class.
"""
return self.__dabest_obj


@property
def proportional(self):
"""
Returns the proportional parameter
class.
"""
return self.__proportional

@property
def lqrt(self):
Expand All @@ -1795,6 +1831,7 @@ def lqrt(self):
self.__calc_lqrt()
return self.__lqrt_results





Expand Down
Loading