Package: taplib
🚩 Index of ContentsWhat is TAP?FeaturesInstallationExamplesSimilar workContributorsCitation📌 What is TAP?Python package to make statistical tests and add statistical annotations on plot generated with Plotly✅ FeaturesSingle function to make statistical tests and add statistical annotations on plot generated with Plotly:Box plotsStrip plotsIntegrated statistical tests (scipy.statsmethods):Mann-Whitney testt-test (independent and paired)t-test-related (dipendent)Levene testWilcoxon testKruskal-Wallis testBrunner-Munzel testAnsari-Bradley testCramerVon-Mises testKolmogorov-Smirnov testAlexander-Govern testFligner-Killeen testBartlett testCorrection for statistical tests can be applied (statsmodel.stats.multitest.multipletestsmethod):BonferroniSidakHolm-SidakBenjamini-HochbergExporting plots to formats:pngjpegwebpsvgpdfhtml📦 InstallationTAPis present on pipy, and can be downloaded directly with pippipinstalltaplibOr if you prefer you can clone the repository and install it manuallygitclonehttps://github.com/FedericaPersiani/tap.gitcdtap
pipinstall.🔍 ExampleOnce your dataframe has been loaded you can pass it to theplot_statsfunction which will apply theMann-Whitneytest by default on all classes present in the column indicated asx, using theycolumn as the valueimporttapimportseabornassnsdf=sns.load_dataset("tips")x="day"y="total_bill"tap.plot_stats(df,x,y)Cutoff pvalue: You can change the significance of the null hypothesis through thecutoff_pvalueparameter, 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 thetype_testparametertap.plot_stats(df,x,y,type_test="CramerVon-Mises")Type correction: You can apply a p-value correction algorithm via thetype_correctionparametertap.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 thexcolumn ordered as you prefertap.plot_stats(df,x,y,order=["Thur","Fri","Sat","Sun"])Type plot: You can change the plot type using thetype_plotparametertap.plot_stats(df,x,y,type_plot="strip")Pairs: You can decide the pairs that will be used to generate the statistics to plottap.plot_stats(df,x,y,pairs=[("Sun","Sat"),("Sun","Thur")])Sub category: Through thesubcategoryparameter it is possible to divide the various entries into a further sub-category, you can decide the various pairings using thepairsparameter but in this case you will need to declare them as a tuple (primary category, subcategory)tap.plot_stats(df,x,y,subcategory="sex")tap.plot_stats(df,x,y,subcategory="sex",pairs=[(("Sun","Male"),("Sat","Male")),(("Sun","Male"),("Sun","Female"))])Filename: To directly export the image you can use thefilenameparameter, the standard export size is (800, 600, 3) but you can modify it via theexport_sizeparameter (width, height, scale-factor)tap.plot_stats(df,x,y,filename="images/export_1.png",export_size=(800,400,3))Kwargs: Through thekwargsparameter you can pass a key/value pairs directly to the plotly function, such as the size of the figure, or a titletap.plot_stats(df,x,y,kwargs={"width":500,"height":500,"title":"My title"})📝 Similar workThis repository is inspired by trevismd/statannotations (Statannotations), which compute statistical tests and annotations with seaborn💬 CitationBibTeX@software{persiani_2024_10604555,
  author       = {Persiani, Federica and
                  Malori, Damiano},
  title        = {Discovery-Circle/tap: v0.1.3},
  month        = feb,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {0.1.3},
  doi          = {10.5281/zenodo.10604555},
  url          = {https://doi.org/10.5281/zenodo.10604555}
}APAPersiani, F., & Malori, D. (2024). Discovery-Circle/tap: v0.1.3 (0.1.3). Zenodo. https://doi.org/10.5281/zenodo.10604555✨ ContributorsFederica Persiani💻🔬Damiano Malori💻📦