GithubHelp home page GithubHelp logo

maclandrol / fisherexact Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 12.0 199 KB

Fisher exact test for mxn contingency table in python

License: GNU Lesser General Public License v3.0

Python 10.73% Shell 0.05% Fortran 44.75% C 44.47%

fisherexact's People

Contributors

maclandrol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fisherexact's Issues

Segmentation fault in python3

Running fisher_exact() procedure on 2x5 table, getting segmentation fault(core dumped).
Contigency matrix:
vals a b c d e
0 8472 9541 4581 7998 2755
1 19031 20811 12565 17134 5302

Error Backtrace:
*** Error in `python3': double free or corruption (out): 0x0000000003891730 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fc0cd45c7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fc0cd46537a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fc0cd46953c]
/home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so(__fisher_exact_MOD_f2xact+0x5196)[0x7fc0ab5cce96]
/home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so(_fisher_exact_MOD_fexact+0x459)[0x7fc0ab5cd9e9]
/home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so(f2pywrap_fisher_exact_fexact
+0x7d)[0x7fc0ab5cdcdd]
/home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so(+0x6a95)[0x7fc0ab5baa95]
python3(PyObject_Call+0x47)[0x5c1797]
python3(PyEval_EvalFrameEx+0x4ec6)[0x53bba6]
python3[0x540199]
python3(PyEval_EvalFrameEx+0x50b2)[0x53bd92]
python3[0x540199]
python3(PyEval_EvalFrameEx+0x50b2)[0x53bd92]
python3[0x540199]
python3(PyEval_EvalCode+0x1f)[0x540e4f]
python3[0x60c272]
python3(PyRun_InteractiveOneObject+0x2b1)[0x46b89f]
python3(PyRun_InteractiveLoopFlags+0xe8)[0x46ba48]
python3[0x46cfa0]
python3[0x4cf2bd]
python3(main+0xe1)[0x4cfeb1]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fc0cd405830]
python3(_start+0x29)[0x5d6049]
======= Memory map: ========
00400000-007a9000 r-xp 00000000 08:01 22682644 /usr/bin/python3.5
009a9000-009ab000 r--p 003a9000 08:01 22682644 /usr/bin/python3.5
009ab000-00a42000 rw-p 003ab000 08:01 22682644 /usr/bin/python3.5
00a42000-00a73000 rw-p 00000000 00:00 0
0244a000-038af000 rw-p 00000000 00:00 0 [heap]
7fc0a4000000-7fc0a4021000 rw-p 00000000 00:00 0
7fc0a4021000-7fc0a8000000 ---p 00000000 00:00 0
7fc0aa671000-7fc0aac2a000 rw-p 00000000 00:00 0
7fc0aac2a000-7fc0aac3a000 r-xp 00000000 08:01 5505473 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa205.cpython-35m-x86_64-linux-gnu.so
7fc0aac3a000-7fc0aae39000 ---p 00010000 08:01 5505473 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa205.cpython-35m-x86_64-linux-gnu.so
7fc0aae39000-7fc0aae3a000 r--p 0000f000 08:01 5505473 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa205.cpython-35m-x86_64-linux-gnu.so
7fc0aae3a000-7fc0aae3c000 rw-p 00010000 08:01 5505473 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa205.cpython-35m-x86_64-linux-gnu.so
7fc0aae3c000-7fc0aae48000 r-xp 00000000 08:01 5505472 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa159.cpython-35m-x86_64-linux-gnu.so
7fc0aae48000-7fc0ab047000 ---p 0000c000 08:01 5505472 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa159.cpython-35m-x86_64-linux-gnu.so
7fc0ab047000-7fc0ab048000 r--p 0000b000 08:01 5505472 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa159.cpython-35m-x86_64-linux-gnu.so
7fc0ab048000-7fc0ab04a000 rw-p 0000c000 08:01 5505472 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/asa159.cpython-35m-x86_64-linux-gnu.so
7fc0ab04a000-7fc0ab088000 r-xp 00000000 08:01 22675703 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fc0ab088000-7fc0ab287000 ---p 0003e000 08:01 22675703 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fc0ab287000-7fc0ab288000 r--p 0003d000 08:01 22675703 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fc0ab288000-7fc0ab289000 rw-p 0003e000 08:01 22675703 /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fc0ab289000-7fc0ab3b2000 r-xp 00000000 08:01 22675529 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fc0ab3b2000-7fc0ab5b1000 ---p 00129000 08:01 22675529 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fc0ab5b1000-7fc0ab5b2000 r--p 00128000 08:01 22675529 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fc0ab5b2000-7fc0ab5b4000 rw-p 00129000 08:01 22675529 /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fc0ab5b4000-7fc0ab5d4000 r-xp 00000000 08:01 5505478 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so
7fc0ab5d4000-7fc0ab7d3000 ---p 00020000 08:01 5505478 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so
7fc0ab7d3000-7fc0ab7d4000 r--p 0001f000 08:01 5505478 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so
7fc0ab7d4000-7fc0ab7d8000 rw-p 00020000 08:01 5505478 /home/luminous/.local/lib/python3.5/site-packages/FisherExact/statlib/fexact.cpython-35m-x86_64-linux-gnu.so
7fc0ab7d8000-7fc0ab7e9000 r-xp 00000000 08:01 58723685 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/mvn.cpython-35m-x86_64-linux-gnu.so
7fc0ab7e9000-7fc0ab9e8000 ---p 00011000 08:01 58723685 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/mvn.cpython-35m-x86_64-linux-gnu.so
7fc0ab9e8000-7fc0ab9ea000 rw-p 00010000 08:01 58723685 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/mvn.cpython-35m-x86_64-linux-gnu.so
7fc0ab9ea000-7fc0abae1000 rw-p 00000000 00:00 0
7fc0abae1000-7fc0abae3000 rw-p 00031000 08:01 58723685 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/mvn.cpython-35m-x86_64-linux-gnu.so
7fc0abae3000-7fc0abb23000 rw-p 00000000 00:00 0
7fc0abb23000-7fc0abb2d000 r-xp 00000000 08:01 58723679 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/statlib.cpython-35m-x86_64-linux-gnu.so
7fc0abb2d000-7fc0abd2c000 ---p 0000a000 08:01 58723679 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/statlib.cpython-35m-x86_64-linux-gnu.so
7fc0abd2c000-7fc0abd2e000 rw-p 00009000 08:01 58723679 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/statlib.cpython-35m-x86_64-linux-gnu.so
7fc0abd2e000-7fc0abd30000 rw-p 00026000 08:01 58723679 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/statlib.cpython-35m-x86_64-linux-gnu.so
7fc0abd30000-7fc0abe70000 rw-p 00000000 00:00 0
7fc0abe70000-7fc0abed4000 r-xp 00000000 08:01 58723696 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/_stats.cpython-35m-x86_64-linux-gnu.so
7fc0abed4000-7fc0ac0d4000 ---p 00064000 08:01 58723696 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/_stats.cpython-35m-x86_64-linux-gnu.so
7fc0ac0d4000-7fc0ac0d9000 rw-p 00064000 08:01 58723696 /home/luminous/.local/lib/python3.5/site-packages/scipy/stats/_stats.cpython-35m-x86_64-linux-gnu.so
7fc0ac0d9000-7fc0ac15a000 rw-p 00000000 00:00 0
7fc0ac15a000-7fc0ac173000 r-xp 00000000 08:01 58723581 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/lsoda.cpython-35m-x86_64-linux-gnu.so
7fc0ac173000-7fc0ac372000 ---p 00019000 08:01 58723581 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/lsoda.cpython-35m-x86_64-linux-gnu.so
7fc0ac372000-7fc0ac374000 rw-p 00018000 08:01 58723581 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/lsoda.cpython-35m-x86_64-linux-gnu.so
7fc0ac374000-7fc0ac377000 rw-p 00048000 08:01 58723581 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/lsoda.cpython-35m-x86_64-linux-gnu.so
7fc0ac377000-7fc0ac392000 r-xp 00000000 08:01 58723583 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_dop.cpython-35m-x86_64-linux-gnu.so
7fc0ac392000-7fc0ac591000 ---p 0001b000 08:01 58723583 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_dop.cpython-35m-x86_64-linux-gnu.so
7fc0ac591000-7fc0ac593000 rw-p 0001a000 08:01 58723583 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_dop.cpython-35m-x86_64-linux-gnu.so
7fc0ac593000-7fc0ac595000 rw-p 00044000 08:01 58723583 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_dop.cpython-35m-x86_64-linux-gnu.so
7fc0ac595000-7fc0ac5c6000 r-xp 00000000 08:01 58723579 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/vode.cpython-35m-x86_64-linux-gnu.so
7fc0ac5c6000-7fc0ac7c5000 ---p 00031000 08:01 58723579 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/vode.cpython-35m-x86_64-linux-gnu.so
7fc0ac7c5000-7fc0ac7c7000 rw-p 00030000 08:01 58723579 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/vode.cpython-35m-x86_64-linux-gnu.so
7fc0ac7c7000-7fc0ac7c8000 rw-p 00000000 00:00 0
7fc0ac7c8000-7fc0ac7cb000 rw-p 00082000 08:01 58723579 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/vode.cpython-35m-x86_64-linux-gnu.so
7fc0ac7cb000-7fc0ac7e5000 r-xp 00000000 08:01 58723577 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_quadpack.cpython-35m-x86_64-linux-gnu.so
7fc0ac7e5000-7fc0ac9e5000 ---p 0001a000 08:01 58723577 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_quadpack.cpython-35m-x86_64-linux-gnu.so
7fc0ac9e5000-7fc0ac9e6000 rw-p 0001a000 08:01 58723577 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_quadpack.cpython-35m-x86_64-linux-gnu.so
7fc0ac9e6000-7fc0ac9e9000 rw-p 00054000 08:01 58723577 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_quadpack.cpython-35m-x86_64-linux-gnu.so
7fc0ac9e9000-7fc0aca29000 rw-p 00000000 00:00 0
7fc0aca29000-7fc0aca3f000 r-xp 00000000 08:01 58723578 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_odepack.cpython-35m-x86_64-linux-gnu.so
7fc0aca3f000-7fc0acc3e000 ---p 00016000 08:01 58723578 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_odepack.cpython-35m-x86_64-linux-gnu.so
7fc0acc3e000-7fc0acc3f000 rw-p 00015000 08:01 58723578 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_odepack.cpython-35m-x86_64-linux-gnu.so
7fc0acc3f000-7fc0acc40000 rw-p 00000000 00:00 0
7fc0acc40000-7fc0acc43000 rw-p 0003a000 08:01 58723578 /home/luminous/.local/lib/python3.5/site-packages/scipy/integrate/_odepack.cpython-35m-x86_64-linux-gnu.so
7fc0acc43000-7fc0acc4d000 r-xp 00000000 08:01 58724709 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_nnls.cpython-35m-x86_64-linux-gnu.so
7fc0acc4d000-7fc0ace4d000 ---p 0000a000 08:01 58724709 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_nnls.cpython-35m-x86_64-linux-gnu.so
7fc0ace4d000-7fc0ace4e000 rw-p 0000a000 08:01 58724709 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_nnls.cpython-35m-x86_64-linux-gnu.so
7fc0ace4e000-7fc0ace50000 rw-p 00022000 08:01 58724709 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_nnls.cpython-35m-x86_64-linux-gnu.so
7fc0ace50000-7fc0ace53000 r-xp 00000000 08:01 58724715 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_zeros.cpython-35m-x86_64-linux-gnu.so
7fc0ace53000-7fc0ad052000 ---p 00003000 08:01 58724715 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_zeros.cpython-35m-x86_64-linux-gnu.so
7fc0ad052000-7fc0ad053000 rw-p 00002000 08:01 58724715 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_zeros.cpython-35m-x86_64-linux-gnu.so
7fc0ad053000-7fc0ad093000 rw-p 00000000 00:00 0
7fc0ad093000-7fc0ad0ba000 r-xp 00000000 08:01 58724739 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lsq/givens_elimination.cpython-35m-x86_64-linux-gnu.so
7fc0ad0ba000-7fc0ad2b9000 ---p 00027000 08:01 58724739 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lsq/givens_elimination.cpython-35m-x86_64-linux-gnu.so
7fc0ad2b9000-7fc0ad2bd000 rw-p 00026000 08:01 58724739 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lsq/givens_elimination.cpython-35m-x86_64-linux-gnu.so
7fc0ad2bd000-7fc0ad2dc000 r-xp 00000000 08:01 58724710 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_minpack.cpython-35m-x86_64-linux-gnu.so
7fc0ad2dc000-7fc0ad4db000 ---p 0001f000 08:01 58724710 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_minpack.cpython-35m-x86_64-linux-gnu.so
7fc0ad4db000-7fc0ad4dc000 rw-p 0001e000 08:01 58724710 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_minpack.cpython-35m-x86_64-linux-gnu.so
7fc0ad4dc000-7fc0ad4de000 rw-p 0004e000 08:01 58724710 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_minpack.cpython-35m-x86_64-linux-gnu.so
7fc0ad4de000-7fc0ad4f4000 r-xp 00000000 08:01 58724712 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_slsqp.cpython-35m-x86_64-linux-gnu.so
7fc0ad4f4000-7fc0ad6f4000 ---p 00016000 08:01 58724712 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_slsqp.cpython-35m-x86_64-linux-gnu.so
7fc0ad6f4000-7fc0ad6f5000 rw-p 00016000 08:01 58724712 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_slsqp.cpython-35m-x86_64-linux-gnu.so
7fc0ad6f5000-7fc0ad6f7000 rw-p 00040000 08:01 58724712 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_slsqp.cpython-35m-x86_64-linux-gnu.so
7fc0ad6f7000-7fc0ad714000 r-xp 00000000 08:01 58724725 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_cobyla.cpython-35m-x86_64-linux-gnu.so
7fc0ad714000-7fc0ad914000 ---p 0001d000 08:01 58724725 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_cobyla.cpython-35m-x86_64-linux-gnu.so
7fc0ad914000-7fc0ad915000 rw-p 0001d000 08:01 58724725 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_cobyla.cpython-35m-x86_64-linux-gnu.so
7fc0ad915000-7fc0ad917000 rw-p 00046000 08:01 58724725 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_cobyla.cpython-35m-x86_64-linux-gnu.so
7fc0ad917000-7fc0ad923000 r-xp 00000000 08:01 58724731 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/moduleTNC.cpython-35m-x86_64-linux-gnu.so
7fc0ad923000-7fc0adb22000 ---p 0000c000 08:01 58724731 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/moduleTNC.cpython-35m-x86_64-linux-gnu.so
7fc0adb22000-7fc0adb23000 rw-p 0000b000 08:01 58724731 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/moduleTNC.cpython-35m-x86_64-linux-gnu.so
7fc0adb23000-7fc0adb40000 r-xp 00000000 08:01 58724707 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lbfgsb.cpython-35m-x86_64-linux-gnu.so
7fc0adb40000-7fc0add40000 ---p 0001d000 08:01 58724707 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lbfgsb.cpython-35m-x86_64-linux-gnu.so
7fc0add40000-7fc0add41000 rw-p 0001d000 08:01 58724707 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lbfgsb.cpython-35m-x86_64-linux-gnu.so
7fc0add41000-7fc0add44000 rw-p 00051000 08:01 58724707 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_lbfgsb.cpython-35m-x86_64-linux-gnu.so
7fc0add44000-7fc0add84000 rw-p 00000000 00:00 0
7fc0add84000-7fc0addaf000 r-xp 00000000 08:01 58724720 /home/luminous/.local/lib/python3.5/site-packages/scipy/optimize/_group_columns.cpython-35m-x86_64-linux-gnu.soAborted (core dumped)

OverflowError: Python int too large to convert to C long

Running Monte Carlo simulations for more than 2x3:

  pval = fisher_exact(freqs[:, 0:3], simulate_pval=True)

gives an overflow error:

  OverflowError: Python int too large to convert to C long

Running Fisher Exact without simulations for more than 2x3 gives the error:

  Call-back cb_f2pystop_in_prterr__user__routines failed.
  capi_return is NULL

P-value result is different from R fisher test

Hello,
I'm testing this code and comparing with R's fisher test result.
But, the p-value result is different.

Is there a reason or miss implemetation?
or
doesn't matter in fisher test?

I made a simple test code.

import FisherExact
import numpy as np

from rpy2 import robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.numpy2ri import numpy2rpy

ary = np.array([
    [1, 3, 1, 4],
    [3, 5, 1, 3,]
])

stats = importr("stats")
matrix = numpy2rpy(ary)
robjects.r("set.seed(0)")

# R's p-value
p_value1 = stats.fisher_test(matrix)[0][0]

# this repo's p-value
p_value2 = FisherExact.fisher_exact(
    ary,
    alternative="two-sided",
    hybrid=False,
    workspace=200000,
    seed=0
)

"""
p_value1: 0.7932841152655332
p_value2: 0.4857142857142828
"""

Thank you.

Not so much an issue as help for Mac users

If you try this on a Mac and get an error like so
Traceback (most recent call last):
File "Fisher.py", line 3, in <module>
import statlib.fexact as f

Then you need to recompile by typing ./recompile.sh in your terminal as Emmanuel helped me figure out. But first you'll probably need to install a fortran compiler. You'll know for sure if you run the ./recompile.sh command in your terminal and get an error abort not finding a compiler such as pgfortran.

The easiest place I found to get a fortran compiler was here under MacOS. After downloading the right version for your system, you'll need to unpack it and then click on it to install and lower your security setting on your Mac to allow any software for a few minutes. You can verify it is installed works by typing your terminal
gfortran --version

Now the the ./recompile.sh command should run to completion and then python Fisher.py should run in your terminal without an error.

Problem using a 3x3 matrix

Hi, I am using the following matrix:

3 3

159 4 80
3 25 0
30 0 108

And I obtained the pvalue=0

Why is that?

Is not possible to use mxm matrices?

Thanks.

New release 1.4.3 ?

Would it be possible to create a new release based on the latest revision and publish it on PyPi ?

Segmentation fault (core dumped)

This simple example fails with the Segmentation fault (core dumped)

Python 3.9.5 (default, Jun 4 2021, 12:28:51)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.30.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import FisherExact

In [2]: FisherExact.fisher_exact([[38, 0, 49], [37, 0, 52]])
capi_return is NULL
Call-back cb_f2pystop_in_prterr__user__routines failed.
Segmentation fault (core dumped)

how can I fix this error?

Code fails for python 3.4.3

Hi,

I just ran into this error while trying to run the test with Monte Carlo simulation on python 3.4.3 -
File "/usr/lib64/python3.4/site-packages/FisherExact/Fisher.py", line 130, in fisher_exact
tmp_res = _fisher_sim(c, replicate, seed, workspace)
File "/usr/lib64/python3.4/site-packages/FisherExact/Fisher.py", line 243, in _fisher_sim
for i in xrange(2, n + 1):
NameError: name 'xrange' is not defined

I guess 'xrange' is no longer part of python 3 if I am not mistaken.

Thanks,

segfault is workspace is not big enough, should fail and show warning

This simple example fails with the defualt workspace

import FisherExact
fisher_exact = FisherExact.fisher_exact
fisher_exact([[1088, 126, 342, 516, 594, 578, 528, 378, 272, 160, 68, 40, 22, 4, 2], 
[12, 1, 5, 4, 5, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0]])

But when I increase it to 13000 it works

import FisherExact
fisher_exact = FisherExact.fisher_exact
fisher_exact([[1088, 126, 342, 516, 594, 578, 528, 378, 272, 160, 68, 40, 22, 4, 2], 
[12, 1, 5, 4, 5, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0]],
workspace=13000)

In R if I use a workspace which is not big enough it just fails and say that the wrokspace is not big enough, but it does not give a segfault.

Thanks!

How to cite?

Hi, any idea how to cite your package?

Thanks.

capi_return is NULL/Call-back cb_f2pystop_in_prterr__user__routines failed

Hello -

Thanks so much for developing this module :)

When I invoke fisher_exact def (running python 2.7 on mac - FisherExact installed with pip, gfotran is installed) I get the following errors, and then a python segmentation fault:

...
Call-back cb_f2pystop_in_prterr__user__routines failed.
capi_return is NULL
Call-back cb_f2pystop_in_prterr__user__routines failed.
capi_return is NULL
Call-back cb_f2pystop_in_prterr__user__routines failed.
capi_return is NULL
Call-back cb_f2pystop_in_prterr__user__routines failed.
Segmentation fault: 11

Here is my contingency table (2x113):

p_row = [89, 66, 33, 32, 28, 15, 16, 21, 12, 20, 17, 0, 3, 6, 3, 1, 7, 7, 10, 7, 6, 6, 5, 3, 2, 1, 0, 13, 7, 5, 0, 11, 3, 3, 1, 1, 0, 0, 0, 6, 5, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
c_row = [90, 58, 44, 22, 18, 17, 15, 14, 13, 12, 12, 10, 9, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

from FisherExact import Fisher
Fisher.fisher_exact([p_row, c_row])

Thanks so much for and advice you might have!

The function documentation in the README is wrong

In the README, under "Use as a module", the documentation says for table: "A 2x2 contingency table. Elements should be non-negative integers". However, in the code, it says "A mxn contingency table. Elements should be non-negative integers." There might be other similar errors.

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.