Skip to main content

🚩 Index of Contents

📌 What is TAP?

Python package to make statistical tests and add statistical annotations on plot generated with Plotly

✅ Features

  • Single function to make statistical tests and add statistical annotations on plot generated with 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
    • Dunn test
    • Brunner-Munzel test
    • Ansari-Bradley test
    • CramerVon-Mises test
    • Kolmogorov-Smirnov test
    • Alexander-Govern test
    • Fligner-Killeen test
    • Bartlett test
  • Correction for statistical tests can be applied (statsmodel.stats.multitest.multipletests method):

    • Bonferroni
    • Sidak
    • Holm-Sidak
    • Benjamini-Hochberg
  • Exporting plots to formats:

    • png
    • jpeg
    • webp
    • svg
    • pdf
    • html

📦 Installation

Downloads

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 seaborn as sns

df = sns.load_dataset("tips")
x = "day"
y = "total_bill"

tap.plot_stats(df, x, y)

img

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)

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

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

Sub category: Through the subcategory parameter it is possible to divide the various entries into a further sub-category, you can decide the various pairings using the pairs parameter but in this case you will need to declare them as a tuple (primary category, subcategory)

tap.plot_stats(df, x, y, subcategory="sex")

img

tap.plot_stats(df, x, y, subcategory="sex", pairs=[(("Sun", "Male"), ("Sat", "Male")), (("Sun", "Male"), ("Sun", "Female"))])

img

Filename: To directly export the image you can use the filename parameter, the standard export size is (800, 600, 3) but you can modify it via the export_size parameter (width, height, scale-factor)

tap.plot_stats(df, x, y, filename="images/export_1.png", export_size=(800, 400, 3))

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, or a title

tap.plot_stats(df, x, y, kwargs={"width":500, "height":500, "title": "My title", "log_y": True})

img

📝 Similar work

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

💬 Citation

DOI

BibTeX

@software{persiani_2024_13844301,
  author       = {Persiani, Federica and
                  Malori, Damiano},
  title        = {Discovery-Circle/tap: v0.1.7},
  month        = sep,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {0.1.7},
  doi          = {10.5281/zenodo.13844301},
  url          = {https://doi.org/10.5281/zenodo.13844301}
}

APA

Persiani, F., & Malori, D. (2024). Discovery-Circle/tap: v0.1.7 (0.1.7). Zenodo. https://doi.org/10.5281/zenodo.13844301

✨ Contributors

Federica Persiani
Federica Persiani

💻 🔬
Damiano Malori
Damiano Malori

💻 📦

Metadata

Release files for taplib 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for taplib 0.1.8
File Size Uploaded
taplib-0.1.8.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for taplib 0.1.8
File Interpreter ABI Platform
taplib-0.1.8-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / taplib-0.1.8.tar.gz

Download URL taplib-0.1.8.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ead25a2e3125a02d6960f7331e2d8d4a37c7e20b27ada928474c8aa91fa4a77f
BLAKE2b-256 checksum
How to use checksums
f679e527895e1f2b14be93c297dfb5e039a78142567b333b7b793235d2d405df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Release files / taplib-0.1.8-py3-none-any.whl

Download URL taplib-0.1.8-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e77c719ad33851635156ef2f62d29bbc76a7798eb76153af6708b2ecfc7c1518
BLAKE2b-256 checksum
How to use checksums
1a8955fe15afebd99c0dec4b18c2a460a84bbef0ded37f2571cb185ba7c60c7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.14

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page