美文网首页Linux与生物信息组学
结构变异SV的鉴定--smartie-sv与bayestyper

结构变异SV的鉴定--smartie-sv与bayestyper

作者: 群体遗传学 | 来源:发表于2020-05-08 16:48 被阅读0次

    最近一直在折腾结构变异SV的鉴定,SV的鉴定软件虽然很多,但是在最近的两篇基因组文章里面,主要用的是smartie-sv和bayesTyper,其中smartie-sv主要用于基因组间的比较,也可以用于三代数据的比较;bayesTyper主要用于二代数据的SV鉴定,适用于群体,速度较快。

    参考文献:
    [1] Genome assembly of a tropical maize inbred line provides insights into structural variation and crop improvement
    [2] Eight high-quality genomes reveal pan-genome architecture and ecotype differentiation of Brassica napus

    smartie-sv的安装

    • smartie-sv的详细信息在这里.

    1. smartie-sv的安装,需要依赖htslib和blasr

    $ git clone --recursive https://github.com/zeeev/smartie-sv.git #获取samrtie-sv
    $ cd smartie-sv && make
    

    2. hstlib的安装

    $ git clone https://github.com/samtools/htslib.git
    $ autoconf 
    $ ./configure
    $ make
    $ make install
    

    3. blasr的安装

    $ wget https://github.com/PacificBiosciences/blasr/archive/master.zip -O blasr.zip
    $ unzip blasr.zip
    $ mv blasr-master/ blasr
    $ cd blasr
    $ make -j 8
    

    4. smartie-sv的配置

    smartie-sv需要用到htslib的bgzip、htsfile、tabix,以及blasr的blasr、sawriter,所以我们需要把5个可执行文件链接到smartie-sv的bin文件夹下,以便smartie-sv对其的调用。

    $ cd smartie-sv/bin
    $ ln -s ../../htslib/bin/bgzip ./
    $ ln -s ../../htslib/bin/htsfile ./
    $ ln -s ../../htslib/bin/tabix ./
    $ ln -s ../../blasr/alignment/bin/blasr ./
    $ln -s ../../blasr/alignment/bin/sawriter ./
    
    bin目录.png

    5. smartie-sv的使用

    smartie-sv的使用在官方的README.md有示例,它支持snakename的命令。

    $ bin/sawriter target.fasta #利用sawriter对基因组进行index
    # 本地运行时
    $ snakemake -s Snakefile -w 50 -p -k -j 20
    

    6. 运行结果

    # Snakefile内容,在安装目录"smartie-sv/pipeline/Snakefile"位置,定义call SV等方法,便于流程使用
    shell.prefix("source config.sh; set -eo pipefail ; ")
    
    configfile: "config.json"
    
    def _get_target_files(wildcards):
        return config["targets"][wildcards.target]
    
    def _get_query_files(wildcards):
            return config["queries"][wildcards.query]
    
    rule dummy:
         input: expand("variants/{target}-{query}.svs.bed", target=config["targets"], query=config["queries"])
    
    rule callSVs:
         message: "Calling SVs"
         input  : SAM="mappings/{target}-{query}-aligned.sam", TARGET=_get_target_files, PG=config["install"] + "/bin/printgaps"
         output : "variants/{target}-{query}.svs.bed"
         shell  : """
                cat {input.SAM} | {input.PG} {input.TARGET} variants/{wildcards.target}-{wildcards.query}
         """
    
    rule runBlasr:
         message: "Aligning query to target"
         input:   BL=config["install"] + "/bin/blasr", TARGET=_get_target_files, QUERY=_get_query_files
         output:  "mappings/{target}-{query}-aligned.sam", "unmappings/{target}-{query}-unaligned.fasta"
         shell:   """
                  {input.BL} -clipping hard -alignContigs -sam -minMapQV 30 -nproc 6 -minPctIdentity 50 -unaligned {output[1]} {input.QUERY} {input.TARGET} -out {output[0]}
         """
    

    我们需要修改的只有文件"config.json",主要包含smartie-sv的目录,参考基因组文件和比对基因组文件,以json格式存在。

    {
    "install":"smartie-sv",             #最好写绝对路径
    "targets":{"zs11":"Darmor.fa"},
    "queries":{"Darmor":"Darmor.fa"},
    }
    

    最后生成三个文件夹,mappings、unmappings和variants,sv信息主要在variants文件


    结果文件.png

    其中zs11-Darmor.svs.bed包含SV的信息,以bed格式存在。


    zs11-Darmor.svs.bed.png

    bayesTyper的安装

    • bayesTyper的详细信息在这里.
    • Platypus的详细信息在这里.
    • Manta的详细信息在这里.

    bayesTyper的官网文档推荐使用三种方法鉴定变异(GATK、Platypus和manta),然后利用bayesTyperTools对变异文件进行合并,然后利用bayesTyper的cluster进行cluster,最后利用bayesTyper的genotype进行基因分型。

    1. bayesTyper安装

    bayesTyper的安装非常简单,安装完成后会在bin目录下生成bayesTyper 和bayesTyperTools两个可执行文件

    $ git clone https://github.com/bioinformatics-centre/BayesTyper.git
    $ cd BayesTyper && make -j 4
    

    2. Platypus的安装

    $ git clone https://github.com/andyrimmer/Platypus.git
    $ cd Platypus && make -j 4
    # 使用platypus的只需运行bin目录下的Platypus.py
    $ python bin/Platypus.py --bamFiles=BAM.bam --refFile=REF.fa --output=variants.vcf
    

    3. manta的安装:

    manta采用的是cmake的方式,所以要另外新建一个安装目录,另外manta需采用python 2.7 版本,以及需要Cython模块。安装成功后会在bin目录下生成三个文件,configManta.py、configManta.py.ini和runMantaWorkflowDemo.py,我们主要用的就是configManta.py。

    $ git clone https://github.com/Illumina/manta.git
    $ make manta_build && cd manta_build
    $ ../manta-1.6.0/configure --prefix=`pwd`
    $ make -C /public/home/guocc/software/manta_build
    $ make -j4 install
    

    4. bayesTyper的使用

    在官方文档中,鉴定变异的主要流程分为2大部分:

    4.1:Generation of variant candidates(候选变异的生成)

    以比对完的bam文件(推荐以bwa的mem)为起始,分为一下几个步骤:

    • 4.1.1 用GATK的HaplotypeCaller模块鉴定候选位点。
    • 4.1.2 用Platypus鉴定小的以及中等的变异
    • 4.1.3 用manta鉴定大的结构变异
    • 4.1.4 利用bayesTyperTools的combine功能对以上三种方法的结果进行合并,合并命令为:
    $ bayesTyperTools combine -v GATK:<gatk_sample1>.vcf,GATK:<gatk_sample2>.vcf,PLATYPUS:<platypus_sample1>.vcf,PLATYPUS:<platypus_sample2>.vcf,MANTA:<manta_sample1>.vcf,...,prior:<prior>.vcf -o <candiate_variants_prefix> -z
    

    注意这里-v参数后面接的是字符串,为gatk:sample.vcf格式,各个样品间用“,”分隔,参数-z 表示以压缩格式gz输出。
    bayesTyper的combine格式需要一个参数文件–contigs.txt,里面包含基因组的所有contig信息。格式为##contig=<ID=8,length=146364022>.

    4.2 Genotyping based on variant candidates(基于候选变异的基因分型)

    4.2.1 计算测序数据的 k-mers

    • 这里主要用的KMC3来对比对后的bam文件进行kmer的统计,参数为(-k55 -ci1 -fbam)
    • 计算完kmer后,用bayesTyperTools makeBloom -k <kmc_output_prefix> -p <num_threads>生成bayesTyper需要的前提文件。
    • kmc生成的为<sample_id>.kmc_pre<sample_id>.kmc_suf两个文件,bayesTyperTools makeBloom生成的为<sample_id>.bloomMeta<sample_id>.bloomData两个文件,这里一定要在同一文件下运行,且前缀名一致。

    4.2.2 鉴定变异的cluster

    运行命令:

    $ bayesTyper cluster -v <candiate_variants_prefix>.vcf.gz -s <samples>.tsv -g <ref_build>_canon.fa -d <ref_build>_decoy.fa -p <num_threads>
    
    • 所有的结果都会按cluster分成很多个unit,存在独立的文件
    • 文件<sample>.tsv包含的信息为<sample_id><sex><kmc_output_prefix>.
    • cluster的结果输出在bayestyper_cluster_data目录

    4.2.3 对cluster进行genotype

    bayesTyper genotype -v bayestyper_unit_<unit_id>/variant_clusters.bin -c bayestyper_cluster_data -s <samples>.tsv -g <ref_build>_canon.fa -d <ref_build>_decoy.fa -o bayestyper_unit_<unit_id>/bayestyper -z -p <num_threads>
    

    4.2.4 利用bcftools对结果进行合并

    bcftools concat -O z -o <output_prefix>.vcf.gz bayestyper_unit_1/bayestyper.vcf.gz bayestyper_unit_2/bayestyper.vcf.gz ...
    

    此贴为记录我的爬坑之路,因为之前百度都没有找到任何与这两个软件相关的信息,所以很是头疼。希望能帮到大家,供大家参考。
    以上就是全部步骤,最后两步还没跑通,等跑通后再做分享。


    ![image.png](https://img.haomeiwen.com/i18925383/84b8f660f7f679fa.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240 =100x30)

    相关文章

      网友评论

        本文标题:结构变异SV的鉴定--smartie-sv与bayestyper

        本文链接:https://www.haomeiwen.com/subject/eeofnhtx.html