Skip to main content

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

Default: 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)

img

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"])

img

Type test: You can change the test type using the type_test parameter

tap.plot_stats(df, x, y, type_test="CramerVon-Mises")

img

Type correction: You can apply a p-value correction algorithm via the type_correction parameter

tap.plot_stats(df, x, y, type_correction="Bonferroni")

img

Type plot: You can change the plot type using the type_plot parameter

tap.plot_stats(df, x, y, type_plot="strip")

img

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")])

img

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})

img

📝 Similar work

This repository is inspired by trevismd/statannotations (Statannotations), which compute statistical test and annotations with seaborn

✨ Contributors

Federica Persiani
Federica Persiani

💻 🔬
Damiano Malori
Damiano Malori

💻 📦

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taplib-0.0.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

taplib-0.0.1-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page