GithubHelp home page GithubHelp logo

kastnerkyle / scikit-posthocs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maximtrp/scikit-posthocs

0.0 1.0 0.0 179 KB

Pairwise Multiple Comparisons Post-hoc Tests

License: Other

Python 92.66% Jupyter Notebook 7.34%

scikit-posthocs's Introduction

scikit-posthocs

image

image

image

This Python package provides statistical post-hoc tests for pairwise multiple comparisons and outlier detection algorithms.

Features

  • Multiple comparisons parametric and nonparametric tests (some are ported from R's PMCMR package):

    • Conover, Dunn, and Nemenyi tests for use with Kruskal-Wallis test.
    • Conover and Nemenyi tests for use with Friedman test.
    • Quade, van Waerden, and Durbin tests.
    • Student, Mann-Whitney, Wilcoxon, and TukeyHSD tests.
    • Anderson-Darling test.

    All tests are capable of p adjustments for multiple pairwise comparisons.

  • Plotting functionality (e.g. significance plots).
  • Outlier detection algorithms:
    • Simple test based on interquartile range (IQR).
    • Grubbs test.
    • Tietjen-Moore test.
    • Generalized Extreme Studentized Deviate test (ESD test).

Dependencies

Compatibility

Package is compatible with Python 2 and Python 3.

Install

You can install the package with: pip install scikit-posthocs

Examples

List or NumPy array

import scikit_posthocs as sp
x = [[1,2,3,5,1], [12,31,54], [10,12,6,74,11]]
sp.posthoc_conover(x, p_adjust = 'holm')
array([[-1.        ,  0.00119517,  0.00278329],
       [ 0.00119517, -1.        ,  0.18672227],
       [ 0.00278329,  0.18672227, -1.        ]])

Pandas DataFrame

Columns specified with val_col and group_col args must be melted prior to making comparisons.

import scikit_posthocs as sp
import pandas as pd
x = pd.DataFrame({"a": [1,2,3,5,1], "b": [12,31,54,62,12], "c": [10,12,6,74,11]})
x = x.melt(var_name='groups', value_name='values')

image

sp.posthoc_conover(x, val_col='values', group_col='groups')

image

Significance plots

P values can be plotted using a heatmap:

pc = sp.posthoc_conover(x, val_col='values', group_col='groups')
heatmap_args = {'linewidths': 0.25, 'linecolor': '0.5', 'clip_on': False, 'square': True, 'cbar_ax_bbox': [0.80, 0.35, 0.04, 0.3]}
sp.sign_plot(pc, **heatmap_args)

image

Custom colormap applied to a plot:

pc = sp.posthoc_conover(x, val_col='values', group_col='groups')
# Format: diagonal, non-significant, p<0.001, p<0.01, p<0.05
cmap = ['1', '#fb6a4a',  '#08306b',  '#4292c6', '#c6dbef']
heatmap_args = {'cmap': cmap, 'linewidths': 0.25, 'linecolor': '0.5', 'clip_on': False, 'square': True, 'cbar_ax_bbox': [0.80, 0.35, 0.04, 0.3]}
sp.sign_plot(pc, **heatmap_args)

image

Credits

Thorsten Pohlert, PMCMR author and maintainer

scikit-posthocs's People

Contributors

maximtrp avatar

Watchers

James Cloos 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.