1. GBrowse的安装
GBrowse安装说明文档:http://gmod.org/wiki/GBrowse_2.0_Install_HOWTO
GBrowse的安装很少有能顺利安装成功的。需要不断的摸索,看文档,并搜索相关错误,google看别人是怎么解决的。有管一些我安装过程遇到的困难如下:
1.1 安装 io-lib和Bio-SCF, io-lib是安装Bio-SCF所必须的。在这一步容易出问题,导致无法安装。
$ wget http://downloads.sourceforge.net/project/staden/io_lib/1.13.0/io_lib-1.13.0.tar.gz $ make -j 8 $ sudo make install $ wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-SCF-1.03.tar.gz $ tar zxf Bio-SCF-1.03.tar.gz $ cd Bio-SCF-1.03 $ perl Makefile.PL $ make $ sudo make install
1.2 安装Bio::Graphics
当使用CPAN安装的时候test错误,使用手工安装,不用进行test。
2. Gbrowse的配置
2.1 Gbrowse文件
安装好Gbrowse后,须知道几个主要的文件存放位置,默认如下:
GBrowse-2.54/ 解压的GBrowse安装目录,其中bin目录下有很多重要的程序,比如创建Gbrowse2的用户的程序等。
/etc/gbrowse2/ 存放Gbrowse的配置文件,有全局的配置文件 GBrowse.conf 和 自己建立的一个物种的配置文件 species.conf;
/var/www/html/gbrowse2/ 存放gbrowse2的一些网页文件,比如gbrowse2的使用教程等;
/var/www/cgi-bin/gb2/ gbrowse2的web程序可执行文件,
/var/lib/gbrowse2/ gbrowse2的数据库目录和用户目录等。需要修改数据库目录的用户拥有者,以便于导入数据。
$ sudo chown chenlianfu /var/lib/gbrowse2/databases/
2.2 /etc/gbrowse2/GBrowse.conf 几个可能需要需要定制的配置:
1. max_render_processes = 12 设置渲染需要的最大CPU线程数 2. image widths = 450 640 800 1024 1280 1440 设置基因组浏览器显示的宽度,可选的值,在perference项中进行设置时可选的值 default width = 1024 默认的值 3. show sources = 1 默认下开启下拉菜单 数据源 ,以利于转移到其它物种的基因组浏览中。 4. #include "themes/warm_colors" 基因组浏览器的3个主题,此为默认的主题。 # #include "themes/transparent_colors" # #include "themes/solid_gray_colors" 5. default source = yeast 设置基因组浏览器中默认的物种,即http://host/cgi-bin/gb2/gbrowse/默认所访问的物种。 6. [lentinula_edodes] 设置所要建立的物种的基因组浏览器的配置文件路径 description = Lentinula edodes Genome path = lentinula_edodes.conf 7. 在GBrowse.conf同目录下有个languages的文件夹,其中gbrowse2默认使用zh.pm模块,于是GBrowse的显示文字默认是繁体中文,可以使用其目录下的其它语言模块代替。
2.3 Data Source Sections的配置
对所需要浏览基因组的物种,则需要建立一个专门的配置文件,比如本文中的 /etc/gbrowse2/lentinula_edodes.conf 文件。
[GENERAL] 全局设置 restrict = require user chenlianfu hzaumycology 设置该基因组浏览器的访问权限,只有chenlianfu和hzaumycology能访问。使用命令gbrowse_create_account.pl来创建gbrowse用户 description = Lentinula edodes Genome Database 对数据库的描述 database = gene_Prediction_EVM 数据库的名字,这个一定要有,不然会提示错误。当然如果将只有一个数据库,并放入到GENERAL中,则不需要该项 initial landmark = scaffold_1:20000..40000 初始访问数据库时候显示的区域 default tracks = Genes_EVM 初始访问数据库时候显示的tracks Genes_Augustus metadata = 对数据库的一些描述 -description Lentinula edodes Genome (strain: W1-26) -maintainer Lianfu Chen-created 2013-05-28 -modified 2013-05-28 -authority hzaumycology -coordinates http://www.hzaumycology.com/ -coordinates_version 1 -source Scaffold -testrange scaffold_1:103361..105454 -species Lentinula edodes W1-26 example = scaffold_1 给出的几个例子用于选择 scaffold_1000:2164..4463 ################################# # database definitions 数据库设置。 ################################# [gene_Prediction_EVM:database] 第一个数据库。该数据库稍微特殊些,在全局中使用该数据库,需要将fasta文件和scaffold信息导入到该数据库。 db_adaptor = Bio::DB::SeqFeature::Store 数据库的读取方法 db_args = -adaptor DBI::mysql 使用mysql数据库 -dsn lentinula_edodes_EVM mysql数据库中的数据库名 -user chenlianfu mysql数据库的可写用户 -password 1234567 用户的密码 search options = default 该数据库中的搜索选项 [gene_Prediction_Augustus:database] 另外的一个数据库。将不同的基因注释放入不同的数据库,然后放入不同的tracks,有利于阅读和使用基因组。 db_adaptor = Bio::DB::SeqFeature::Store db_args = -adaptor DBI::mysql -dsn lentinula_edodes_Augustus -user chenlianfu -password 1234567 search options = default ######################## # Default glyph settings 默认的glyph设置 ######################## [TRACK DEFAULTS] glyph = generic glyph的默认类型 height = 10 glyph的高度 r = black font2color = blue label density = 25 当labels比该数目多的时候,则关闭labels的显示以节约空间 bump density = 100 当features的数目多于该值的时候, 则不在垂直方向上显示features,它们都被限制在了一个水平线上。 link = AUTO 点击feature的时候,链接到feature的信息文档中。 ################## TRACK CONFIGURATION #################### # the remainder of the sections configure individual tracks 设置track ########################################################### #[Genes_EVM:overview] 将该track置于overview中,而不是detail中,此时,分类自动成为overview。好处是在整体上看到该track的特征,但是细节上就没法放大了。 #[Genes_EVM:region] 同上。 [Genes_EVM] track名 database = gene_Prediction_EVM track所用到的数据库 feature = gene track所用的feature glyph = gene track的glyph starnd_arrow = 1 glyph具有方向性;有些glyph内在就具有或不具方向性,设置该值则不影响。 bgcolor = peachpuff 颜色 decorate_introns = 1 intron显示方法 label_transcripts = 1 draw_translation = 1 category = Genes track所属的分类,对应着gbrowse2的“Select Tracks"的分类 label_transcripts = 1 visible = 1 初始访问数据库时候显示该tracks key = Genes Predictions Intergrated by EVM track在浏览器中的名称 citation = EVM was used to integrate the genes prediction results of Augustus, SNAP and GeneMarkES ;PASA was used to add UTR annotations and Alternatively spliced isoforms. 该track的介绍。 [Genes_Augustus] database = gene_Prediction_Augustus #feature = gene:AUGUSTUS feature为gff3文件的type:source。这样做的话,就可以不必建多个mysql数据库,只需要把source设置好即可。 feature = gene glyph = gene bgcolor = peachpuff decorate_introns = 1 label_transcripts = 1 draw_translation = 1 category = Genes label_transcripts = 1 key = Genes Predicted by Augustus
3. Gbrowse的数据的导入
3.1 EVM将多个基因组预测结果进行融合后,使用PASA加上5’和3’端非翻译区后,得到最终基因组注释结果。将该文件导入到mysql数据库 gene_Prediction_EVM 中。由于该最终的注释结果文件中mRNA的Nama的值包含的字符过长,需要进行缩短,以利于阅读;该文件中的genes也需要进行排序。因此编写程序提取出适合于gbrowse导入的gff3文件。可用于导入到gbrowse2的gff3文件有一些特点:
首先,每个scaffold、chromosome或contig之前要有一行指定其feature和name。比如:
scaffold_1 . scaffold 1 322871 . . . Name=scaffold_1
这样gbrowse才能识别scaffod_1是属于scaffold类型,并有个Name是scaffold_1。才会将其在基因组浏览器中显现出来。而正常的gff3文件是没有这样一行的。
gff3文件中mRNA中的Name有些太长,在基因组浏览器中的图片中占空间太大,需要重命名得简洁些;gff3文件中intron的可以去掉;gff3文件中将feature为transcript的改变为mRNA;去掉注释行等。以上这些都会影响gborows的显示结果。
使用如下命令来将基因预测信息导入到数据库中:
$ perl parse_evm_pasa_gff3.pl LEdodesGGTrinity.gene_structures_post_PASA_updates.26576.gff3 genome.fasta 该perl程序生成适合于导入gbrowse2的gff3文件gbrowse.gff3 和 protein.fasta文件.后者为预测的蛋白组文件。 $ mysql -h localhost -u root -p mysql > CREATE DATABASE gene_Prediction_EVM; 创建一个名为 gene_Prediction_EVM 的 mysql数据库 EOF mysql > Bye $ /usr/local/bin/bp_seqfeature_load.pl -c -a DBI::mysql -d gene_Prediction_EVM -u root -p password genome.fasta gbrowse.gff3 该程序能将gff3文件或fasta文件导入到数据库。其参数: -c 清空数据库 -a 导入的数据库类型 -d mysql数据库对应的数据库名称 -u mysql数据库用户名 -p mysql数据库密码 该程序导入的时间有点长,依据feature的数目,时间长短不一。对于1.2万个基因的注释,需要约10分钟导入完成。
3.2 将Augustus的基因预测信息导入
perl prepare_Augustus_gff3_for_gbrowse2.pl Agustus.gff3 > gbrowse2.gff3 $ mysql -h localhost -u root -p mysql > CREATE DATABASE gene_Prediction_Augustus; 创建一个名为 gene_Prediction_Augustus 的 mysql数据库 EOF mysql > Bye $ /usr/local/bin/bp_seqfeature_load.pl -c -a DBI::mysql -d gene_Prediction_Augustus-u root -p password genome.fasta gbrowse2.gff3
3.3 其它SNAP和PASA的基因预测信息导入和上面2中一致。不赘述。
4. NGS数据的导入
4.1 安装Bio::DB::Sam。需要有samtools安装,并且该samtools的安装和正常安装不一样。
$ wget http://garr.dl.sourceforge.net/project/samtools/samtools/0.1.19/samtools-0.1.19.tar.bz2 $ tar jxf samtools-0.1.19.tar.bz2 $ cd samtools-0.1.19 $ perl -p -i -e 's/CFLAGS.*/CFLAGS= -g -Wall -O2 -fPIC #-m64 #-arch ppc/' Makefile $ make -j 8 $ make clean 如果之前已经安装过samtools的话,需要修改makefile,再重新安装 $ make install $ wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/Bio-SamTools-1.38.tar.gz $ tar zxf Bio-SamTools-1.38.tar.gz $ cd Bio-SamTools-1.38 $ perl Build.pl $ ./Build $ sudo ./Build install
4.2 修改data source配置文件
[NGS_Genome:database] db_adaptor = Bio::DB::Sam # 数据库的读取方法 db_args = -fasta genome.fasta # 基因组的fasta文件 -bam bowtie2.bam # NGS reads的比对结果 search options = default [GenomeReadCoverageXyplot] feature = coverage # 基因组测序的reads的coverage glyph = wiggle_xyplot # 使用峰图来显示reads的覆盖度 database = NGS_Genome height = 50 fgcolor = black bicolor_pivot = 20 # 设定一个颜色变换的coverage值 pos_color = blue # 当coverage > 以上设置的数值,s使用蓝色 neg_color = red # 当coverage < 以上设置的该数值,s使用红色 category = GenomeReads label = 0 # labels on wiggle tracks are redundant key = Coverage (xyplot) of Genome NGS data [GenomeReadCoverageDensity] feature = coverage glyph = wiggle_density # 使用密度来显示reads的覆盖度,覆盖度越高则线条颜色越深 database = NGS_Genome height = 30 bgcolor = blue bicolor_pivot = 5 # 小于该值,则线条无颜色 pos_color = blue neg_color = red category = GenomeReads label = 0 key = Coverage (density plot) of Genome NGS data [GenomeReads] # reads比对到基因组的图形显示 feature = match glyph = segments draw_target = 1 show_mismatch = 1 mismatch_color = red database = NGS_Genome bgcolor = blue fgcolor = white height = 5 label density = 50 bump = fast category = GenomeReads key = Reads of Genome NGS data [GenomeReadsPair] # reads pair比对到基因组的图形显示 feature = read_pair glyph = segments database = NGS_Genome draw_target = 1 show_mismatch = 1 bgcolor = sub { my $f = shift; return $f->attributes('M_UNMAPPED') ? 'red' : 'green'; } fgcolor = green height = 3 label = sub {shift->display_name} label density = 50 bump = fast connector = dashed balloon hover = sub { my $f = shift; return '' unless $f->type eq 'match'; return 'Read: '.$f->display_name.' : '.$f->flag_str; } category = GenomeReads key = Read Pairs of Genome NGS data [GenomeReadsMappingQuality] # reas比对到基因组的Mapping质量图,高质量使用深蓝色表示,低质量使用浅蓝色显示 feature = match glyph = segments draw_target = 1 show_mismatch = 1 mismatch_color = red database = NGS_Genome bgcolor = sub { my $feature = shift; my $blueness = 255 - int($feature->qual * 2.40); my $colour = chr(35) . sprintf("%X", $blueness) . sprintf("%X", $blueness) . "FF"; return $colour; } fgcolor = black height = 5 label density = 50 bump = fast category = GenomeReads key = Reads' Mapping Quality of Genome NGS data
4.3 将Bam文件放置到配置文件中对应的位置。
若在track中提示该错误:
Track rending error: No index file for bam file; try opeing file with -autoindex at /usr/local/lib64/perl5/Bio/DB/Sam.pm line 2064
则表示缺少bam文件对应的index文件。该文件以bai为后缀,使用samtools生成
$ samtools index geonme.bam