Giter Site home page Giter Site logo

moseleybioinformaticslab / chi2plookup Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 0.0 32 KB

chi2plookup package provides a simple interface for creating C++ header file that contains pre-generated array(s) of p-values for chi-square distribution.

License: BSD 3-Clause Clear License

Python 100.00%
python cpp chi-square bioinformatics statistics

chi2plookup's Introduction

chi2plookup

https://travis-ci.org/MoseleyBioinformaticsLab/chi2plookup.svg?branch=master

The chi2plookup package provides a simple interface for creating C++ header file for use in C++ projects. This header file contains pregenerated array(s) of p-values for chi-square distribution for specified degrees of freedom.

Why?

Need a way to calculate p-value for different degrees of freedom for a given chi2 value and bypass third-party dependencies:

Inspired by:

Usage example

  1. To view command-line help message:
$ python3 -m chi2plookup --help

chi2plookup command-line interface

Usage:
    chi2plookup -h | --help
    chi2plookup --version
    chi2plookup generate [--headerfile=<path>] [--precision=<precision>] [--df=<df>] [--start_chi=<start_chi>] [--verbose]

Options:
    -h, --help                    Show this screen.
    --version                     Show version.
    --verbose                     Print more information.
    --headerfile=<path>           Path where to save generated header file [default: Chi2PLookup.h]
    --precision=<precision>       Parameter that controls precision [default: 10000].
    --df=<df>                     Degrees of freedom, how many to ganarate [default: 6].
    --start_chi=<start_chi>       Maximum chi2 value for given degree of freedom [default: 25].
  1. Generate a header file with p-values for necessary degrees of freedom (we are using default number degrees of freedom, precision, and header file path):
$ python3 -m chi2plookup generate --verbose

Generating p-value arrays...
  df=6
  precision=10000

    Adding p-values array to template for degree of freedom = 1 ...
    Adding p-values array to template for degree of freedom = 2 ...
    Adding p-values array to template for degree of freedom = 3 ...
    Adding p-values array to template for degree of freedom = 4 ...
    Adding p-values array to template for degree of freedom = 5 ...
    Adding p-values array to template for degree of freedom = 6 ...
  1. Use generated file within your C++ project.
#include <iostream>
#include "Chi2PLookup.h"

int main() {

    Chi2PLookup Chi2PLookupTable;
    double x = 1;
    int df = 1;
    double outvalue;

    outvalue = Chi2PLookupTable.getPValue(x, df);
    std::cout << outvalue << "\n";

    return 0;
}

Note

Use the following approach for smaller number of degrees of freedom to avoid generating huge header files (e.g. header file with 6 degrees of freedom ~34 MB).

chi2plookup's People

Contributors

andreysmelter avatar smelandr avatar

Watchers

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