参考资料地址
https://hail.is/docs/0.2/getting_started.html
hail 是啥?
官方文档的介绍是
Hail is an open-source library for scalable data exploration and analysis, with a particular emphasis on genomics. the GWAS tutorial for a simple genomics example.
Hail 是一个开源库,用于scalable(什么意思)数据探索和分析,尤其关注基因组学数据, GWAS教程是其中一个简单的例子
Hail Overview
Hail is a library for analyzing structured tabular and matrix data. Hail contains a collection of primitives on data in parallel, as well as a suit of functionality for processing genetic data.
首先按照文档尝试在课题组服务器上安装
conda creative -n hail python=3.7
conda activate hail
pip install hail
没有遇到报错
再尝试
import hail as hl
mt = hl.balding_nichols_model(n_populations=3, n_samples=50, n_variants=100)
mt.count()
也没有遇到报错,应该是安装成功了
尝试在自己windows电脑上安装
pip install hail
然后导入模块的时候提示
import hail as hl
mportError: C extension: numpy.core.multiarray failed to import not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
而且搞得我pandas还用不了了
import pandas as pd
AttributeError: type object 'pandas._libs.tslibs.conversion._TSObject' has no attribute '__reduce_cython__'
暂时还不知道什么原因,还是先卸载吧,在linux系统先用着
pip uninstall hail
hail 帮助文档中也没有提windows安装的事儿
我先卸载了我用pip安装的pandas
pip uninstall pandas
然后下载pandas源码进行手动安装
https://pypi.org/project/pandas/#files
解压出来进入到这个目录执行
python setup.py build_ext --inplace --force
目录下会生成一个pandas文件夹
然后再执行
pip install hail
结果会安装pandas,找到这个新安装的pandas文件下路径,用刚刚手动编译获得的文件夹替换
一系列操作之后 。。。。。。
image.png
居然没有遇到报错
再试一下
mt = hl.balding_nichols_model(n_populations=3, n_samples=50, n_variants=100)
输出了一大串
image.png
暂时没看懂啥意思
再运行
mt.count()
也没有报错,输出结果
(100, 50)
接下来试着在自己win10系统电脑重复接下来的例子。
首先是重复
- 1、GWAS分析的曼哈顿图(manhattan)
- 2、Q-Q plot
- 3、主成分分析的图
import hail as hl
mt = hl.import_vcf('data/1kg.vcf.bgz')
table = (hl.import_table('data/1kg_annotations.txt', impute=True).key_by('Sample'))
mt = mt.annotate_cols(pheno = table[mt.s])
mt = hl.variant_qc(mt)
mt = mt.filter_rows(mt.variant_qc.AF[1] > 0.01)
mt = mt.filter_rows(mt.variant_qc.p_value_hwe > 1e-6)
gwas = hl.linear_regression_rows(y=mt.pheno.CaffeineConsumption,x=mt.GT.n_alt_alleles(),covariates=[1.0])
最后一步在自己的电脑上运行了一晚上也没有出结果,电脑还自己关机了,不知道为啥。看来GWAS的运算还挺吃计算能力的。但是放到自己课题组服务器运行的话自己又没办法获得结果图片,因为结果图是以网页的形式展示的,自己远程连接没有办法看到网页,正常情况应该会有一个将图片保存到本地的函数吧,可能自己还没有找到。
第一次使用hail这个东西没有运行出最后的结果,但是获得了一份数据,应该可以利用这份数据尝试其他分析GWAS的工具。
欢迎大家关注我的公众号
小明的数据分析笔记本
公众号二维码.jpg










网友评论