用于过滤变量的python包。
pyvariantfilter的Python项目详细描述
PyvariantFilter
通用的python包,用于根据继承模式过滤生殖系遗传变异。
在您的数据集中找到常染色体显性、常染色体再接、x连锁再接、x连锁显性、从头和复合杂合子变体。
通过应用自定义python过滤函数,根据变量的注释过滤变量。
将带vep注释的vcf转换为pandas数据帧。
快速启动
frompyvariantfilter.familyimportFamilyfrompyvariantfilter.variant_setimportVariantSet# Create a Family object describing the relationships between samples as well as their sex and affected statusmy_family=Family('FAM001')my_family.read_from_ped_file(ped_file_path='test_data/NA12878.ped',family_id='FAM001',proband_id='NA12878i')# Associate a VariantSet object with a the Family object we just createdmy_variant_set=VariantSet()my_variant_set.add_family(my_family)# Read variants from a standard VCF and apply initial filtering functionmy_variant_set.read_variants_from_vcf('test_data/NA12878.trio.vep.vcf',proband_variants_only=True,filter_func=import_filter,args=(new_family.get_proband_id(),))# Get candidate compound hetsmy_variant_set.get_candidate_compound_hets()# Filter the compound hets by phasing them using parental informationmy_variant_set.filter_compound_hets()# Flatten the compound hets to a dictionary with each compound het as a keymy_variant_set.get_filtered_compound_hets_as_dict()# Create Pandas Dataframedf=my_variant_set.to_df()# Filter to view variants matching any inheritiance model.df[['variant_id','worst_consequence','inheritance_models','csq_SYMBOL']][df['inheritance_models']!=''].head()
其中filter_func参数从vcf()中读取_variants_类似于下面的函数。
defimport_filter(variant,proband_id):ifvariant.has_alt(proband_id)andvariant.passes_gt_filter(proband_id)andvariant.passes_filter():freq_filter=variant.filter_on_numerical_transcript_annotation_lte(annotation_key='gnomAD_AF',ad_het=0.01,ad_hom_alt=0.01,x_male=0.01,x_female_het=0.01,x_female_hom=0.01,compound_het=0.01,y=0.01,mt=0.01,)csq_filter=Falseifvariant.get_worst_consequence()in{'transcript_ablation':None,'splice_acceptor_variant':None,'splice_donor_variant':None,'stop_gained':None,'frameshift_variant':None,'stop_lost':None,'start_lost':None}:csq_filter=Trueifcsq_filterandfreq_filter:returnTruereturnFalse
输入要求
当使用从vcf函数读取的variantset类时,需要分解(分割多等位变量)和vep注释的vcf。
gatk和鸭嘴兽vcf都受支持。
在分析前,使用vt和vep和以下命令对vcf进行预处理。
只有当你想找到复合的het时,用vep注释才是必要的。
# split multiallellics and normalise
cat input.vcf | vt decompose -s - | vt normalize -r reference.fasta - > input.norm.vcf
# Annotate with VEP
vep --verbose --format vcf --everything --fork 1 --species homo_sapiens --assembly GRCh37 --input_file input.norm.vcf \
--output_file input.norm.vep.vcf --force_overwrite --cache --dir vep_cache_location \
--fasta reference.fasta --offline --cache_version 94 -no_escape --shift_hgvs 1 --exclude_predicted --vcf --refseq --flag_pick \
--custom gnomad.genomes.vcf.gz,gnomADg,vcf,exact,0,AF_POPMAX \
--custom gnomad.exomes.vcf.gz,gnomADe,vcf,exact,0,AF_POPMAX \
继承模型
这里的很多规则都是从双子座软件改编而来的,值得一看。https://gemini.readthedocs.io/en/latest/
常染色体显性
变体必须在常染色体上。
所有受影响的样本必须是杂合子或缺失的,例如…。请参阅允许受影响样本中除先证者外的纯合子交替基因型的宽松选择。
如果该变异不在低渗透基因中,则所有未受影响的样本必须是纯合子参考或具有缺失的基因型。
常染色体累及
变体必须在常染色体上。
所有受影响的样本必须是等位基因的纯合子。可能不见了。
没有未受影响的样本可以是替代等位基因的纯合子。可能不见了。
x-连接接收
变体必须在X染色体上。
所有受影响的女性样本必须是等位基因的纯合子或缺失。
没有未受影响的女性样本可以是替代等位基因的纯合子。
所有受影响的男性样本必须有变异或缺失。
没有未受影响的男性样本可以有这种变体。
x连锁显性
变体必须在X染色体上。
受影响男性样本的女儿必须受到影响。
受影响的男性的儿子不能受到影响。
受影响的男性样本必须具有变体或缺失。
受影响的女性样本必须杂合子或缺失。
未受影响的样本不得具有变体。
从头开始
变体必须在先证者中,而不是在父母中的任何一方。
家长的GQ值必须高于Min_Parental_GQ。
家长的dp值必须高于家长的最小深度。
父项的alt/ref比率必须低于最大父项alt/ref比率。
复合杂合子
任何未受影响的样本都不能有这对变体。可以使用allow_hets_in_uneffected参数进行调整。
所有受影响的样本都必须有一对变异或缺失基因型数据。可以使用check-infected参数进行调整。
a)其中一对必须继承自母亲,另一对必须继承自父亲。
b)如果include_de novo为真,则一对可以是从头开始的,另一对可以是从任何一个父代继承的,或者两者都可以是从头开始的。没有最低要求,例如新呼叫的深度。
安装
要求
- python 3.6或更高版本
- 皮萨姆0.15.0
- 熊猫0.23.4
安装thE包
pip install pyvariantfilter
或
git clone https://github.com/josephhalstead/pyvariantfilter.git
示例
有关使用库进行WES和WGS分析的一些示例,请参见笔记本文件夹。
测试
python tests.py