Python package to make statistical test and add statistical annotations on plots generated with Plotly
Project description
🚩 Index of Contents
📌 What is TAP?
Python package to make statistical test and add statistical annotations on plots generated with Plotly
✅ Features
-
Single function to make statistical tests and add statistical annotations on plots generated by Plotly:
- Box plots
- Strip plots
-
Integrated statistical tests (
scipy.stats
methods):- Mann-Whitney test
- t-test (independent and paired)
- t-test-related (dipendent)
- Levene test
- Wilcoxon test
- Kruskal-Wallis test
- Brunner-Munzel test
- Ansari-Bradley test
- CramerVon-Mises test
- Kolmogorov-Smirnov test
- Alexander-Govern test
- Fligner-Killeen test
- Bartlett test
-
Correction for statistical test can be applied (
statsmodel.stats.multitest.multipletests
method):- Bonferroni
- Sidak
- Holm-Sidak
- Benjamini-Hochberg
📦 Installation
TAP is present on pipy, and can be downloaded directly with pip
pip install taplib
Or if you prefer you can clone the repository and install it manually
git clone https://github.com/FedericaPersiani/tap.git
cd tap
pip install .
🔍 Example
Once your dataframe has been loaded you can pass it to the "plot_stats" function which will apply the "Mann-Whitney" test by default on all classes present in the column indicated as x, using the y column as the value
import tap
import pandas as pd
df = pd.read_csv("example.csv")
x = "day"
y = "total_bill"
tap.plot_stats(df, x, y)
Cutoff pvalue: You can change the significance of the null hypothesis through the cutoff_pvalue parameter, by default it is set to 0.05.
tap.plot_stats(df, x, y, cutoff_pvalue=0.01)
Type test: You can change the test type using the type_test parameter
tap.plot_stats(df, x, y, type_test="CramerVon-Mises")
Type correction: You can apply a p-value correction algorithm via the type_correction parameter
tap.plot_stats(df, x, y, type_correction="Bonferroni")
Order: You can change the sorting of the plot by passing the list with all the entries present in the x column ordered as you prefer
tap.plot_stats(df, x, y, order=["Thur", "Fri", "Sat", "Sun"])
Type plot: You can change the plot type using the type_plot parameter
tap.plot_stats(df, x, y, type_plot="strip")
Pairs: You can decide the pairs that will be used to generate the statistics to plot
tap.plot_stats(df, x, y, pairs=[("Sun", "Sat"), ("Sun", "Thur")])
Kwargs: Through the kwargs parameter you can pass a key/value pairs directly to the plotly function, such as the size of the figure
tap.plot_stats(df, x, y, kwargs={"width":500, "height":500})
📝 Similar work
This repository is inspired by trevismd/statannotations (Statannotations), which compute statistical test and annotations with seaborn
✨ Contributors
Federica Persiani 💻 🔬 |
Damiano Malori 💻 📦 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.