Fishers排列检验的实现
项目描述
这是什么
Fisher排列检验的实现。
该检验在以下出版物中描述
Fisher, R. A. (1935). 实验设计。1935. Oliver and Boyd, Edinburgh。
Ernst, M. D. (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_1 |
experiment_2 |
experiment_3 |
group_names |
---|---|---|---|
1.4 |
3 |
2.5 |
condition_2 |
2 |
5 |
2 |
condition_1 |
5.6 |
3 |
17 |
condition_2 |
9 |
6.5 |
2 |
condition_1 |
17 |
5 |
13.0 |
condition_1 |
17 |
2 |
13.0 |
condition_3 |
12 |
8 |
18.7 |
condition_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
ASCII艺术图显示了排列的平均差异分布。ASCII艺术图由Morgan Fouesneau的绘图包[AP](https://github.com/mfouesneau/asciiplot)完成。
如果可能的组合数大于n_combinations_max,则随机抽取n_combinations_max大小的子样本进行直方图计算。
如果detailed为False,则只返回(双向)p值,即数据与ref_data不同的概率
如果detailed为True,则在字典中返回单侧p值和平均差异的直方图数据
hist_data:所有排列的平均差异分布
克里斯托夫·莫尔,图像和数据分析设施/核心设施,德国神经退行性疾病研究中心(DZNE)在亥姆霍兹协会德国神经退行性疾病研究中心(DZNE)
项目详情
permutation_test-0.18.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bc0bbf9c487b16c574f7995533be27cb273c7c53d571679b608d1318d91d50db |
|
MD5 | 24385268c2a3b2a6929ad0ac3def938d |
|
BLAKE2b-256 | aa690e9e474bcf163bcdd229ed8cfd6af36a49cc3794f7e9da4d4ce2c6b28c59 |