基于vcf文件计算位点频谱SFS——easySFS

位点频谱(site frequency sperum)是使用遗传数据进行群体历史研究的基础数据,easySFS.py将可以将划分好群体的snp.vcf文件转换为SFS,该脚本输出可适用于fastsimcoal2 ∂ a ∂ i \partial a\partial i ai两个进行群体历史研究的主流方法。

1 获取投影值

easySFS.py以投影的方式构建数据矩阵,在构建SFS时,我们需要给参数-proj提供投影参数值,因此我们需要先使用--preview功能获得(投影值,独立位点)列表,从而选取合适的投影值。

python easySFS.py -i example_files\sims.vcf -p example_files\sims_pops.txt --preview

输出如下:

  Processing 3 populations - ['pop1', 'pop2', 'pop3']
  Sampling one snp per locus (CHROM)

    Running preview mode. We will print out the results for # of segregating sites
    for multiple values of projecting down for each population. The dadi
    manual recommends maximizing the # of seg sites for projections, but also
    a balance must be struck between # of seg sites and sample size.

    For each population you should choose the value of the projection that looks
    best and then rerun easySFS with the `--proj` flag.

pop1
(2, 110)        (3, 165)        (4, 204)        (5, 234)        (6, 258)        (7, 274)        (8, 288)

pop2
(2, 117)        (3, 175)        (4, 218)        (5, 252)        (6, 280)        (7, 302)        (8, 319)

pop3
(2, 107)        (3, 161)        (4, 200)        (5, 232)        (6, 259)        (7, 277)        (8, 294)

“……recommends maximizing the # of seg sites for projections……”,一般情况下,选择对应独立位点数最多的投影值,即--proj 8,8,8

1 计算SFS

python easySFS.py -i example_files\sims.vcf -p example_files\sims_pops.txt --proj 8,8,8

输出文件包含两大类:
∂ a ∂ i \partial a\partial i ai:
pop1-8.sfspop2-8.sfspop3-8.sfs:1- d d d 的SFS,samples_size = 8;
pop1-pop2.sfspop1-pop2-pop3.sfs、……:2- d d d、3- d d d的SFS。
fastsimcoal2
pop1_MAFpop0.obs、……:1- d d d 的SFS;
sims_jointMAFpop1_0.obssims_MSFS.obs、……: 2- d d d、3- d d d的SFS。

END

  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
基于vcf文件鉴定单核苷酸变异的代码可以使用Python编写,主要包含以下步骤: 1. 解析vcf文件:使用vcfpy等Python库解析vcf文件,获取每个位点的信息,包括染色体位置、参考碱基、变异碱基等。 ```python import vcfpy # 读取vcf文件 vcf_reader = vcfpy.Reader.from_path("sample.vcf") # 遍历每个位点 for record in vcf_reader: chrom = record.CHROM # 染色体位置 ref = record.REF # 参考碱基 alt = record.ALT[0] # 变异碱基 ``` 2. 筛选单核苷酸变异:根据参考碱基和变异碱基的长度是否相同来判断是否为单核苷酸变异。 ```python if len(ref) == 1 and len(alt) == 1: # 单核苷酸变异 else: # 非单核苷酸变异 ``` 3. 鉴定变异类型:根据参考碱基和变异碱基的不同,鉴定变异类型,包括突变、同义突变、错义突变等。 ```python if ref == 'A' and alt == 'G': # A->G 突变 elif ref == 'C' and alt == 'T': # C->T 突变 elif ref == 'G' and alt == 'A': # G->A 突变 elif ref == 'T' and alt == 'C': # T->C 突变 elif ref == alt: # 同义突变 else: # 错义突变 ``` 4. 输出结果:根据变异类型输出结果,可以将结果保存到文件中。 ```python if ref == 'A' and alt == 'G': print("A->G 突变") elif ref == 'C' and alt == 'T': print("C->T 突变") elif ref == 'G' and alt == 'A': print("G->A 突变") elif ref == 'T' and alt == 'C': print("T->C 突变") elif ref == alt: print("同义突变") else: print("错义突变") ``` 以上是基于vcf文件鉴定单核苷酸变异的简单代码示例,具体根据需要进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Odd_guy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值