Skip to content

Commit 82490f5

Browse files
authored
Merge pull request #15 from ACCLAB/v0.1.3
v0.1.3
2 parents 344e26d + 0c3f09f commit 82490f5

20 files changed

Lines changed: 325 additions & 104 deletions

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The Clear BSD License
22

3-
Copyright (c) 2016-2017 Joses W. Ho
3+
Copyright (c) 2016-2018 Joses W. Ho
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DABEST (Python)
22
[![Travis CI](https://travis-ci.org/ACCLAB/DABEST-python.svg?branch=master)](https://travis-ci.org/ACCLAB/DABEST-python)
3-
[![PyPI](https://img.shields.io/pypi/v/dabest.svg)](https://pypi.python.org/pypi/dabest/0.1.1)
3+
[![PyPI](https://img.shields.io/pypi/v/dabest.svg)](https://pypi.python.org/pypi/dabest/0.1.3)
44

55
## About
66

@@ -17,7 +17,7 @@ In addition, the following packages are also required:
1717
- [scipy](https://www.scipy.org/) (1.0.x)
1818
- [matplotlib](https://www.matplotlib.org/) (2.0.x)
1919
- [seaborn](https://seaborn.pydata.org/) (0.8.x)
20-
- [pandas](https://pandas.pydata.org/) (0.22.x).
20+
- [pandas](https://pandas.pydata.org/) (0.23.x).
2121

2222
To obtain these package dependencies easily, it is highly recommended to download the [Anaconda distribution](https://www.continuum.io/downloads) of Python.
2323

@@ -42,10 +42,19 @@ Then, navigate to the cloned repo in the command line and run
4242
pip install .
4343
```
4444

45+
4546
## Usage
4647

4748
Please refer to the [documentation](https://acclab.github.io/DABEST-python-docs/index.html).
4849

50+
4951
## Matlab version
5052

5153
There is also a [Matlab version](https://github.com/ACCLAB/DABEST-Matlab) of DABEST.
54+
55+
56+
## R version
57+
58+
There isn't an implementation of DABEST in R, and there are no current plans to create one.
59+
60+
However, it is possible to use the R package `reticulate` to run Python code. Please take a look at this [tutorial](https://acclab.github.io/DABEST-python-docs/dabest-r.html) on how to use `reticulate` to analyse data in R.

dabest/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .api import plot
33
from .bootstrap_tools import bootstrap
44

5-
__version__="0.1.2"
5+
__version__="0.1.3"

dabest/api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/usr/bin/python
2+
# -*-coding: utf-8 -*-
3+
# Author: Joses Ho
4+
# Email : joseshowh@gmail.com
5+
16

27

38
def plot(data, idx,
@@ -732,5 +737,9 @@ def plot(data, idx,
732737
value=np.nan).dropna(axis=1)
733738
# Reset seaborn aesthetic parameters.
734739
sns.set()
740+
741+
if swarm_label is not None:
742+
fig.axes[0].set_ylabel(swarm_label)
743+
735744
# Return the figure and the results DataFrame.
736745
return fig, bootlist_df

dabest/bootstrap_tools.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#!/usr/bin/python
2+
# -*-coding: utf-8 -*-
3+
# Author: Joses Ho
4+
# Email : joseshowh@gmail.com
5+
6+
17
from __future__ import division
28

39

@@ -160,7 +166,7 @@ def __init__(self, x1, x2=None,
160166

161167
else:
162168
diff = True
163-
tx = x2-x1
169+
tx = x2 - x1
164170
ttest_single = 'NIL'
165171
ttest_2_ind = 'NIL'
166172
ttest_2_paired = ttest_rel(x1,x2)[1]
@@ -183,6 +189,7 @@ def __init__(self, x1, x2=None,
183189

184190
elif x2 is not None and paired is False:
185191
diff = True
192+
x2 = pd.Series(x2).dropna()
186193
# Generate statarrays for both arrays.
187194
ref_statarray = sns.algorithms.bootstrap(x1, **sns_bootstrap_kwargs)
188195
exp_statarray = sns.algorithms.bootstrap(x2, **sns_bootstrap_kwargs)
@@ -290,6 +297,8 @@ def bca(data, alphas, statarray, statfunction, ostat, reps):
290297
Subroutine called to calculate the BCa statistics.
291298
Borrowed heavily from scikits.bootstrap code.
292299
'''
300+
import warnings
301+
293302
import numpy as np
294303
import pandas as pd
295304
import seaborn as sns

dabest/misc_tools.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/usr/bin/python
2+
# -*-coding: utf-8 -*-
3+
# Author: Joses Ho
4+
# Email : joseshowh@gmail.com
5+
16
# CONVENIENCE FUNCTIONS THAT DON'T DIRECTLY DEAL WITH PLOTTING OR
27
# BOOTSTRAP COMPUTATIONS ARE PLACED HERE.
38

dabest/plot_tools.py

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
"""
2-
A set of convenience functions used for producing plots in `dabest`.
1+
#!/usr/bin/python
2+
# -*-coding: utf-8 -*-
3+
# Author: Joses Ho
4+
# Email : joseshowh@gmail.com
5+
# A set of convenience functions used for producing plots in `dabest`.
36

4-
Author: Joses W. Ho
5-
Email: joseshowh@gmail.com
6-
License: MIT
7-
"""
87

98

109
import matplotlib.pyplot as plt
@@ -14,6 +13,7 @@
1413
from .misc_tools import merge_two_dicts
1514

1615

16+
1717
def halfviolin(v, half = 'right', color = 'k'):
1818
for b in v['bodies']:
1919
mVertical = np.mean(b.get_paths()[0].vertices[:, 0])
@@ -33,6 +33,8 @@ def halfviolin(v, half = 'right', color = 'k'):
3333
mHorizontal, np.inf)
3434
b.set_color(color)
3535

36+
37+
3638
def align_yaxis(ax1, v1, ax2, v2):
3739
"""adjust ax2 ylimit so that v2 in ax2 is aligned to v1 in ax1"""
3840
# Taken from
@@ -50,90 +52,7 @@ def rotate_ticks(axes, angle=45, alignment='right'):
5052
tick.set_rotation(angle)
5153
tick.set_horizontalalignment(alignment)
5254

53-
def tufte_summary_line(df, x, y, type='mean_sd',
54-
offset=0.3, ax=None, **kwargs):
55-
'''Convenience function to plot sumamry statistics (mean and standard
56-
deviation, or median and 25th & 75th percentiles) for ach group in the `x`
57-
column of `df`. This style is inspired by Edward Tufte.
58-
59-
Keywords
60-
--------
61-
data: pandas DataFrame.
62-
This DataFrame should be in 'long' format.
63-
64-
x, y: string.
65-
x and y columns to be plotted.
66-
67-
type: {'mean_sd', 'median_quartiles'}, default 'mean_sd'
68-
Plots the summary statistics for each group. If 'mean_sd', then the
69-
mean and standard deviation of each group is plotted as a notched
70-
line beside each group. If 'median_quantile', then the
71-
median and 25th and 75th percentiles of each group is plotted
72-
instead.
73-
74-
offset: float, default 0.4
75-
The x-offset of the summary line.
76-
77-
offset: matplotlib Axes, default None
78-
If specified, the axes to plot on.
79-
80-
kwargs: dict, default None
81-
Dictionary with kwargs passed to `matplotlib.patches.FancyArrow`.
82-
See docs at
83-
https://matplotlib.org/api/_as_gen/
84-
matplotlib.patches.FancyArrow.html#matplotlib.patches.FancyArrow
85-
86-
'''
87-
import matplotlib.patches as mpatches
88-
89-
if ax is None:
90-
ax = plt.gca()
91-
92-
means = df.groupby(x)[y].mean()
93-
sd = df.groupby(x)[y].std()
94-
lower_sd = means - sd
95-
upper_sd = means + sd
9655

97-
medians = df.groupby(x)[y].median()
98-
quantiles = df.groupby(x)[y].quantile([0.25, 0.75]).unstack()
99-
lower_quartiles = quantiles[0.25]
100-
upper_quartiles = quantiles[0.75]
101-
102-
if type == 'mean_sd':
103-
central_measures = means
104-
low = lower_sd
105-
high = upper_sd
106-
elif type == 'median_quartiles':
107-
central_measures = medians
108-
low = lower_quartiles
109-
high = upper_quartiles
110-
111-
total_width = 0.05 # the horizontal span of the line, aka `linewidth`.
112-
113-
for k, m in enumerate(central_measures):
114-
115-
kwargs['dx'] = 0
116-
kwargs['width'] = total_width
117-
kwargs['head_width'] = total_width
118-
kwargs['length_includes_head'] = True
119-
120-
if type == 'mean_sd':
121-
dy_low = dy_high = sd[k]
122-
elif type == 'median_quartiles':
123-
dy_low = m - low[k]
124-
dy_high = high[k] - m
125-
126-
arrow = mpatches.FancyArrow(x=offset+k, y=low[k],
127-
dy=dy_low,
128-
head_length=0.3*dy_low,
129-
**kwargs)
130-
ax.add_patch(arrow)
131-
132-
arrow = mpatches.FancyArrow(x=offset+k, y=high[k],
133-
dy=-dy_high,
134-
head_length=0.3*dy_high,
135-
**kwargs)
136-
ax.add_patch(arrow)
13756

13857
def get_swarm_spans(coll):
13958
"""
@@ -147,6 +66,8 @@ def get_swarm_spans(coll):
14766
except ValueError:
14867
return None
14968

69+
70+
15071
def gapped_lines(data, x, y,
15172
type='mean_sd',
15273
offset=0.3,

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ help:
1717
# Catch-all target: route all unknown targets to Sphinx using the new
1818
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1919
%: Makefile
20-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
344 KB
Loading
47.7 KB
Loading

0 commit comments

Comments
 (0)