鱼群置换试验的实现

permutation_test的Python项目详细描述


它是什么

fisher置换检验的实现。

以下出版物介绍了该测试:

  • 费舍尔,R.A.(1935)。实验设计。1935年。奥利弗和博伊德,爱丁堡。
  • 恩斯特,医学博士(2004)。排列方法:精确推断的基础。统计科学,19(4),676-685

如何安装

使用pip安装:

$ pip install permutation_test

命令行脚本用法

示例:

permtest [path/to/data.csv] [groups_colname] [reference_group_name] -t [test_group_name]

使用“帮助”获取有关参数的信息:

$ permtest -h

usage: permtest [-h] [-t TESTGROUP]
            input_filepath treatment_column_name referencegroup

positional arguments:
  input_filepath        e.g. path/to/my/data.csv, path to csv file with data
  treatment_column_name
                        name of column in the csv table that specifies the
                        group
  referencegroup        name of the reference group as named in the csv table

optional arguments:
  -h, --help            show this help message and exit
  -t TESTGROUP, --testgroup TESTGROUP
                        name of the test group as named in th csv table. If
                        not defined, test group is determined automatically.
   -a ALPHA, --alpha ALPHA
                         significance level alpha (between 0 and 1) If not
                         defined, alpha is set to 0.05.
   -m MULTI_COMP_CORR, --multi_comp_corr MULTI_COMP_CORR
                         perform multiple comparison correction with benjamini
                         hochberg procedure yes/no, If not defined, correction
                         is performed.

csv文件中的数据结构规范

  • csv应该包含逗号分隔的值。一个或多个列应包含测量数据。
  • 所有列都需要有一个名称,在第一行中指定。
  • 一列包含组的名称

示例my_data.csv

experiment_1experiment_2experiment_3group_names
1.432.5condition_2
252condition_1
5.6317condition_2
96.52condition_1
17513.0condition_1
17213.0condition_3
12818.7condition_3

要对所有实验执行测试,其中condition_1是引用,而condition_2是 测试数据,运行以下命令:

$ permtest my_data.csv group_names condition_1 -t condition_2

通常,将输出保存在文本文件中很方便:

$ permtest my_data.csv group_names condition_1 -t condition_2 > my_test_result.txt

python库使用示例

>>> import permutation_test as p
>>> data = [1,2,2,3,3,3,4,4,5]
>>> ref_data = [3,4,4,5,5,5,6,6,7]

>>> p_value = p.permutation_test(data, ref_data)
taking random subsample of size 20000 from 48620 possible permutations
nr of mean diffs: 20000


 Distribution of mean differences
                                       │
                                    *  ┼+1.73038
                                       │  *
                                       │
                                 *     │      *
                                       │
                              *        │         *
                                       │
                                       │
                          *            │             *
                                       │
                                       │
                       *               │                *
                                       │
                    *                  │                   *
                                       │
                *                      │                       *
         *   *                         ┼+0.037                    *   *
───┼*****─***─**─***─**─**─***─**─**─**┼**─***─**─***─**─**─***─**─***─*****┼───
    -2.38713                           │                            +2.39919
mean difference of tested dataset: -2.0
p_value: 0.00345
p_lower_than (probability that mean of test data is not lower than mean of ref data): 0.00345
p_value_greater_than (probability that mean of test data is not greater than mean of ref data): 0.9998
0.0034500000000000121

asccii艺术情节显示了排列的平均差的分布。 ascii艺术绘图是通过[ap](https://github.com/mfouesneau/asciiplot)完成的,这是一个由morgan fouesneau设计的绘图包。

如果可能的组合数大于n_max, 取大小n_组合最大的随机子样本进行直方图计算。

如果detailed为false,则只返回(双面)p_值, 即,数据与参考数据无差异的概率

如果detailed为真,则为 平均差异以dict返回:

历史数据:所有排列的平均差分布 p_值:双面p_值(数据不存在的概率 不同于参考数据) p_值_小于:数据均值不等于 低于参考数据的平均值 p_值_大于:数据均值的概率为 不大于参考数据的平均值

克里斯托夫·莫尔, 图像和数据分析设备/核心设备, 赫尔姆霍兹-格梅因沙夫的Deutsches Zentrum Für神经退行性Erkrankungen E.V.(DZNE) 赫尔姆霍兹协会德国神经退行性疾病中心(DZNE)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面如何在JavaGUI中为按钮创建各种颜色?   使用MSCAPI的RSA密钥包装的java使用   java Spring数据Redis JedisConnectionException:意外的流结束   java饼图未显示预期输出   java hystrixCommand注释commandKey的用途是什么   windows java可以从cmd运行jar,但不能通过双击来运行   java在单击按钮时遍历XML节点   java试图使用日期(int,int,int)构造函数   带有Buildship 2子项目的java不作为项目依赖项链接   java jsonrpc4j:如何从服务器获取列表<SomeObject>?   用于Java应用程序的内存设置MaxDirectMemory和MaxHeapMemory   java如何从以下类型格式化日期   javayoutube。搜索列表搜索不返回任何内容   java My参数在方法中不起作用,因为泛型存在问题   java如何将Map<Key1Type,Val1Type>转换为Map<Key1Type,Val2Type>   JavaJUnit测试:测试用例的改进,测试数组列表的长度?   java如何在Android中解析带有属性值的xml数据?   使用Hibernate对枚举类型进行Java8bean验证