【比较基因组】McScan jcvi比较两个基因组共线性细节记录

软件的安装

Python版McScan(jcvi工具包):https://github.com/tanghaibao/jcvi

以前只有python2,现在已有python3版本,建议用py3。安装可用pip:

pip install jcvi
##或开发版
pip install git+git://github.com/tanghaibao/jcvi.git

pip可能会安装很慢。建议还是用conda,要快很多,最好新建环境。

conda install -c bioconda jcvi

这时,你已经能使用命令,表面上安装成功了,实际上可能还缺少很多依赖。比如last,latex,dvipng等。否则在后面运行过程,可能遇到如下错误:

##未安装last
/bin/bash: lastdb: command not found
##未安装latex、dvipng
RuntimeError: Failed to process string with tex because latex could not be found

只有一个个解决,有的可以直接conda(如last),有些则需要编译,若有root权限,倒也好办。

conda install -c bioconda last
sudo yum install -y  texlive texlive-latex texlive-xetex texlive-collection-latexrecommended
sudo yum install dvipng

基因组的准备

若是已知物种,直接可从公共数据库中下载gff和cds序列,jcvi提供了下载方式:

$ python -m jcvi.apps.fetch
Usage:
    python -m jcvi.apps.fetch ACTION


Available ACTIONs:
        bisect | Determine the version of the accession by querying entrez
       ensembl | Retrieve genomes and annotations from ensembl
        entrez | Fetch records from entrez using a list of GenBank accessions
     phytozome | Retrieve genomes and annotations from phytozome
    phytozome9 | Retrieve genomes and annotations from phytozome version 9.0 (legacy)
           sra | Retrieve files from SRA via the sra-instant FTP

比如从Phytozome下载,要提前注册好,如下命令提示输入账号密码。

python -m jcvi.apps.fetch phytozome Vvinifera,Ppersica

下载后无需解压。

自己准备的基因组数据也只需gff3和cds.fa(蛋白序列也可)。

gff3只保留染色体水平的ID,如:

grep '^chr' Vvinifera_145_Genoscope.12X.gene.gff3 > apricot.filter.gff3

gff3文件转化bed文件时注意type和key类型对应gff中第三列和第九列信息。type一般为mRNA,但是key注意你的gff文件是取Name还是ID。如:

python -m jcvi.formats.gff bed --type=mRNA --key=Name Vvinifera_145_Genoscope.12X.gene.gff3 -o grape.bed
python -m jcvi.formats.gff bed --type=mRNA --key=ID Ppersica_298_v2.1.gene.gff3 -o peach.bed

若后续作图仍报错,可尝试去除fasta ID中多余的描述信息(我自己不用也可跑通)。如:

# clean headers to remove description fiedls from Phytozome FASTA files.
python -m jcvi.formats.fasta format --sep="|" Vvinifera_145_cds.fa.gz grape.cds
python -m jcvi.formats.fasta format --sep="|" Ppersica_139_cds.fa.gz peach.cds

一些细节

  • 结果文件
    last比对结果,last.filtered比对过滤串联重复和低分比对结果,anchors: 高质量的共线性块,lifted.anchors增加额外锚点的最终共线性区块,simple简化的anchors文件。anchors文件中每个共线性区块以###分隔, 第一和第二列分别是两基因组的基因ID,第三列BLAST的bit score,越大可靠性越高。

  • 调图细节
    两个配置文件seqid(展示染色体),layout(序列位置)。
    seqid文件中,基因组的染色体编号与其gff3文件一致(按大小顺序写,而非gff文件染色体顺序,转化bed时软件会排序)。如:

chr1,chr2,chr3,chr4,chr5,chr6,chr7,chr8,chr9,chr10,chr11,chr12,chr13,chr14,chr15,chr16,chr17,chr18,chr19
Pp01,Pp02,Pp03,Pp04,Pp05,Pp06,Pp07,Pp08

layout文件绘制一些选项,若要个性化,多多修改尝试(尤其时三个物种比较时)。如:

# y, xstart, xend, rotation, color, label, va,  bed
 .6,     .1,    .8,       0,      red, Grape, top, grape.bed
 .4,     .1,    .8,       0,      blue, Peach, bottom, peach.bed
# edges
e, 0, 1, grape.peach.anchors.simple

若要突出显示某一共线性区块,可以在anchors.simple文件对应的区块前添加g*(g代表绿色,也可以改成其他颜色,如红色r)。

建议和示例

建议先用示例数据跑一遍,也很快。再换自己的数据,报错对照着寻找原因,总能解决。

示例代码:

# 准备数据(输入帐号密码)
python -m jcvi.apps.fetch phytozome Vvinifera,Ppersica

#去掉chr以外的序列 
grep '^chr' Vvinifera_145_Genoscope.12X.gene.gff3 > apricot.filter.gff3  

#gff convert to bed
python -m jcvi.formats.gff bed --type=mRNA --key=Name Vvinifera_145_Genoscope.12X.gene.gff3 -o grape.bed
python -m jcvi.formats.gff bed --type=mRNA --key=Name Ppersica_298_v2.1.gene.gff3 -o peach.bed

#reformat fasta
python -m jcvi.formats.fasta format Vvinifera_145_Genoscope.12X.cds.fa.gz grape.cds
python -m jcvi.formats.fasta format Ppersica_298_v2.1.cds.fa.gz peach.cds

#identify blocks
python -m jcvi.compara.catalog ortholog grape peach --no_strip_names

#plot dotplot
python -m jcvi.graphics.dotplot grape.peach.anchors

# get synteny
python -m jcvi.compara.synteny screen --minspan=30 --simple grape.peach.anchors grape.peach.anchors.new

##prepare for seqid and layout file

#  plot synteny
python -m jcvi.graphics.karyotype seqid layout

image.png

Ref:
https://www.jianshu.com/p/a748d3a5421d
https://www.cnblogs.com/zhanmaomao/p/12525411.html
https://sr-c.github.io/2019/01/11/jcvi-MCscan/

原文地址:https://www.cnblogs.com/jessepeng/p/15449595.html