GithubHelp home page GithubHelp logo

josephlalli / statannotations Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trevismd/statannotations

0.0 1.0 0.0 3.88 MB

add statistical annotations (pvalue significance) on existing boxplot/barplot generated by seaborn

License: Other

Python 100.00%

statannotations's Introduction

coverage

What is it

Python package to optionnally compute statistical test and add statistical annotations on an existing boxplot/barplot generated by seaborn.

Derived work

This repositoty is evolving independently from webermarcolivier/statannot by Marc Weber. It is based on commit 1835078 of Feb 21, 2020, tagged "v0.2.3".

Additions/modifications since that fork are below represented in bold (previous fixes are not listed). New issues and PRs are welcome and will be looked into.

Contrary to statannot, this repository does not publish releases on pypi.org. The statannot interface, at least until its version 0.2.3, is directly usable in statannotations, which provides additional features.

Features

  • Single function to add statistical annotations on an existing boxplot/barplot generated by seaborn boxplot.
  • Integrated statistical tests (binding to scipy.stats methods):
    • Mann-Whitney
    • t-test (independent and paired)
    • Welch's t-test
    • Levene test
    • Wilcoxon test
    • Kruskal-Wallis test
  • Smart layout of multiple annotations with correct y offsets.
  • Annotations can be located inside or outside the plot.
  • Corrections for multiple testing can be applied (binding to statsmodels.stats.multitest.multipletests methods):
    • Bonferroni
    • Holm-Bonferroni
    • Benjamini-Hochberg
    • Benjamini-Yekutieli
    • And any other function from any source with minimal extra code
  • Format of the statistical test annotation can be customized: star annotation, simplified p-value, or explicit p-value.
  • Optionally, custom p-values can be given as input. In this case, no statistical test is performed, but corrections for multiple testing can be applied.

Installation

pip install git+https://github.com/trevismd/statannotations.git

or, from the directory into which this repository was cloned:

pip install -r requirements.txt .

Documentation

See example jupyter notebook doc/example.ipynb.

Usage

Here is a minimal example:

import seaborn as sns
from statannotations import add_stat_annotation

df = sns.load_dataset("tips")
x = "day"
y = "total_bill"
order = ['Sun', 'Thur', 'Fri', 'Sat']
ax = sns.boxplot(data=df, x=x, y=y, order=order)
test_results = add_stat_annotation(
    ax, data=df, x=x, y=y, order=order,
    box_pairs=[("Thur", "Fri"), ("Thur", "Sat"), ("Fri", "Sun")],
    test='Mann-Whitney', text_format='star', loc='outside', verbose=2)

test_results

Examples

Example 1

Example 2

Requirements

  • Python >= 3.5
  • numpy >= 1.12.1
  • seaborn >= 0.8.1
  • matplotlib >= 2.2.2
  • pandas >= 0.23.0
  • scipy >= 1.1.0
  • statsmodels (optional, for multiple testing corrections)

statannotations's People

Contributors

agamemnonc avatar dizak avatar efharkin avatar louisonf avatar mmagnus avatar stfnrpplngr avatar trevismd avatar webermarcolivier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.