分享

(伪)从零开始学转录组:软件安装

 公彦栋 2017-10-23

生信技能树的转录组学习开班了, 第一个任务是安装软件, 于是我花了一个下午时间和Linux斗智斗勇。

系统准备

windows10: Unbuntu on windows10. 至于如何win10上开启Linux子系统,百度会有无数教程的。

建议搭配cmder,界面更好看,用的更开心。

但是直接在cmder里启动ubuntu不能使用方向键,需要做一些修改,即在cmder的setting的startup的command line添加

%windir%\system32\bash.exe ~ -cur_console:p:n

软件准备(conda)

1.下载miniconda https:///miniconda.html Linux Python2.7

cd srcwget https://repo./miniconda/Miniconda2-latest-Linux-x86_64.shbash Miniconda2-latest-Linux-x86_64.sh

根据提示,最后会安装到~/miniconda2下。
2.添加bioconda channel, 目前还没有国内源

conda config --add channels https://mirrors.tuna./anaconda/pkgs/free/conda config --add channels https://mirrors.tuna./anaconda/cloud/conda-forge/conda config --add channels https://mirrors.tuna./anaconda/cloud/msys2/conda config --add channels biocondaconda config --set show_channel_urls yes

3.用conda安装软件sratoolkit,fastqc,hisat2,samtools,htseq-count, 与网络有着密切的关系
查询可供安装的软件, https://bioconda./recipes.html#recipes

conda create -n biostar sra-tools fastqc hisat2 samtools htseq

拓展: 了解conda的命令

注:conda只有一个问题,就是看网络条件,国内源似乎还在制作中。


R语言和Rstudio就看下面的讲解。

软件准备(麻烦的编译篇)

我的习惯:

  • 家目录下创建src文件夹,用于存放软件包

  • 家目录下创建biosoft文件夹,用于安装软件

为了提高下载速度,我们需要替换/etc/apt/source.list中默认镜像源。方法参考自中国科学技术大学开源镜像站

# 备份cd /etc/apt/sudo cp source.list source.list.bk# 替换sudo sed -i 's/http/https/g' sources.listsudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' sources.listsudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' sources.list# 更新sudo apt-get updatesudo apt-get upgrade

选择合适的镜像站,让你的速度飞起来

sratookit

功能: 下载,操作,验证NCBI SRA中二代测序数据
网址:https://trace.ncbi.nlm./Traces/sra/sra.cgi?view=software
步骤:

cd srcwget https://ftp-trace.ncbi.nlm./sra/sdk/2.8.2-1/sratoolkit.2.8.2-1-ubuntu64.tar.gztar -zxvf sratoolkit.2.8.2-1-ubuntu64.tar.gzmv sratoolkit.2.8.2-1-ubuntu64 ~/biosoft# 加入环境变量echo 'PATH=$PATH:~/biosoft/sratoolkit.2.8.2-1-ubuntu64/bin' >> ~/.bashrc# 测试prefetch -v# 尝试下载,默认存放在家目录下的ncbi文件夹中prefetch -c SRR390728

阅读官方文章进一步了解:

  1. 如何开启ascp加速下载

  2. vdb-config更改基本设置

fastqc

功能: 可视化展示二代测序数据质量
网站:http://www.bioinformatics./projects/fastqc/
步骤:

# 判断系统是否安装javajava -version# 安装java, 请改成openjdk-9-jdk,下面的是错误演示sudo apt install  openjdk-9-jre-headless# 验证java -version# openjdk version '9-internal'# OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)# OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)# 安装fastqccd srcwget http://www.bioinformatics./projects/fastqc/fastqc_v0.11.5.zipunzip fastqc_v0.11.5.zipmv FastQC/ ~/biosoft/cd ~/biosoft/FastQC/chmod 770 fastqc# 添加环境变量, 我用sed修改sed -i '/^PATH/s/\(.*\)/\1:~\/biosoft\/FastQC\//' ~/.bashrcsource ~/.bashrcfastqc -v# FastQC v0.11.5

拓展:

  1. 了解fastqc结果中各个图的含义

  2. 掌握如何从fastqc的结果中提取数据

  3. 学习sed的用法,http://dongweiming./sed_and_awk/

samtools

SAM: 存放高通量测序比对结果的标准格式
功能: Reading/writing/editing/indexing/viewing SAM/BAM/CRAM format
网站: http://samtools./
安装:

cd src#  prerequsite## system requirementsudo apt install autoconf libz-dev libbz2-dev liblzma-dev libssl-dev### zlib2wget http:///zlib-1.2.11.tar.gztar -zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && make && sudo make install && cd .. && rm -rf zlib-1.2.11### bzip2wget http:///1.0.6/bzip2-1.0.6.tar.gztar -zxvf bzip2-1.0.6.tar.gz && cd bzip2-1.0.6 && make && sudo make install && cd .. && rm -rf  bzip2-1.0.6### cursessudo apt-get install libncurses5-dev ### htslibgit clone https://github.com/samtools/htslib.gitcd htslibautoreconf# building samtoolsgit clone https://github.com/samtools/samtools.gitcd samtoolsautoconf -Wno-syntax./configure make && make install prefix=$HOME/biosoft/samtools## add PATHsed  '/^PATH/s/\(.*\)/\1:~\/biosoft\/samtools\/bin/' .bashrc -isource ~/.bashrcsamtools --help

顺便安装bcftools

cd srcgit clone https://github.com/samtools/bcftools.gitmake && make install prefix=$HOME/biosoft/bcftoolsmake cleansed  '/^PATH/s/\(.*\)/\1:~\/biosoft\/bcftools\/bin/' .bashrc -isource ~/.bashrcebcftools -h

因为用的是github,所以以后更新就用下面命令

cd htslib; git pullcd ../bcftools; git pullmake cleanmake

吐槽: 编译的时候需要安装好多前置包,真麻烦!

HISAT2

功能: 将测序结果比对到参考基因组上
网站: http://ccb./software/hisat2/index.shtml
安装:

cd srcwget ftp://ftp.ccb./pub/infphilo/hisat2/downloads/hisat2-2.1.0-source.zipunzip hisat2-2.1.0-source.zip# 编译hisat2cd hisat2-2.1.0makerm -f *.h *.cpp cd ../mv hisat2-2.1.0 ~/biosoft/hisat2# add to PATHsed  '/^PATH/s/\(.*\)/\1:~\/biosoft\/hisat2/' ~/.bashrc -isource ~/.bashrc# testhisat2 -h

吐槽: 居然没有make install !!!
拓展:

  • HISAT2支持--sra-acc ,也就是可以集成SRATOOLS的,但是需要安装额外包,可以看文章自己折腾。

HTSeq

功能: 根据比对结果统计基因count

# prerequsitessudo apt-get install python-pippip install --upgrade pipsudo apt-get install build-essential python2.7-dev python-numpy python-matplotlib## 验证, 保证无报错python -V## pythonpython>>> import numpy >>> import matplotlib ## install HTSeqpip install htseq## 验证python>>> import HTSeq

教程:

  1. http://www-huber./users/anders/HTSeq/doc/tour.html#tour

推荐:

  1. 推荐安装一个ipython,学习ipython如何使用

  2. 将软件包安装到当前用户目录下pip install --user xxx

R

Ubuntu 14.04的自带R版本跟不上时代的变化,然后自己编译的坑有太多,所以先用Linux处理数据,然后在Windows下分析数据。这样就很轻松了。一些需要编译的软件包,还可以用RTools。
R:https://cran./
Rstudio: https://www./

二进制版本: R官方提供了Ubuntu最新版本更新方法,如下

# 添加Secure APTsudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9# 添加deb到source.listvi source.listdeb https://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu xenial/deb https://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe# 更新并安装sudo apt-get updatesudo apt-get install r-base# (optional)如果要自己编译Rsudo apt-get install r-base-dev# 测试which R/usr/bin/R

安装之后建议修改一下R包镜像源,提高下载速度。

vi ~/.Rprofileoptions('repos' = c(CRAN='https://mirrors.tuna./CRAN/'))options(BioC_mirror='https://mirrors.tuna./bioconductor')

编译部分:新手阶段不要轻易尝试,如果你能顺利搞定,你的Linux能力已经过关了

如何处理./configure中出现的问题:

  • configure: error: No F77 compiler found

    sudo apt-get install gfortran
  • configure: error: —with-readline=yes (default) and headers/libs are not available

    # 其实可以--with-readlines=no, 但是还是把东西装了吧install libreadline-dev
  • configure: error: —with-x=yes (default) and X11 headers/libs are not available

    # 因为是CLI模式,不需要GUI./configure --with-x=no
  • configure: error: pcre >= 8.20 library and headers are required

    sudo apt-get install libpcre3 libpcre3-dev

: 上面安装其他软件时用到的包,其实也有一部分是R所需要的,如果出错的话,也是谷歌+必应+百度一个一个解决。

./configure --with-x=no --prefix=$HOME/biosoft/R3.4.1

最后配置成功后会出现如下结果:

R is now configured for x86_64-pc-linux-gnu  Source directory:          .  Installation directory:    /usr/local  C compiler:                gcc  -g -O2  Fortran 77 compiler:       f95  -g -O2  Default C++ compiler:      g++   -g -O2  C++98 compiler:            g++  -g -O2  C++11 compiler:            g++ -std=gnu++11 -g -O2  C++14 compiler:            g++ -std=gnu++14 -g -O2  C++17 compiler:  Fortran 90/95 compiler:    gfortran -g -O2  Obj-C compiler:  Interfaces supported:  External libraries:        readline, curl  Additional capabilities:   NLS  Options enabled:           shared BLAS, R profiling  Capabilities skipped:      PNG, JPEG, TIFF, cairo, ICU  Options not enabled:       memory profiling  Recommended packages:      yesconfigure: WARNING: you cannot build info or HTML versions of the R manualsconfigure: WARNING: you cannot build PDF versions of the R manualsconfigure: WARNING: you cannot build PDF versions of vignettes and help pages

这些警告无伤大雅,毕竟CLI看不了PDF。

make

然后我发现一个错误

error: jni.h: No such file or directory

原因是之前的openjdk-9-jre-headless无头, 不完整,所以需要重新安装一个完整的

# 先卸载sudo apt-get remove openjdk-9-jre-headless# 后安装最完整java环境sudo apt-get install openjdk-9-jdk

然后重新make && make install
我以为自己不会遇到问题了,结果

installing doc .../usr/bin/install: 无法获取'NEWS.pdf' 的文件状态(stat): 没有那个文件或目录/usr/bin/install: 无法获取'NEWS.pdf' 的文件状态(stat): 没有那个文件或目录Makefile:121: recipe for target 'install-sources2' failed

MDZZ!本来就没有考虑到x11模块,不能搞pdf,你和我说报错!于是我默默去百度一下,给出的方法是忽略错误

make install -i

谢天谢地,终于通过了!!!添加环境变量测试一下吧

sed '/^PATH/s/\(.*\)/\1:~\/biosoft\/R-3\.4\.1\/bin\//' .bashrc -iR> .libPath()[1] '/home/xzg/biosoft/R-3.4.1/lib/R/library'# 安装Hadley大神的包压压惊install.packages('tidyverse')

真麻烦!我要去Y叔的小密圈问下,看看他有没有其他更好的方法

一点经验

以后在Ubuntu安装软件之前,先保证如下被安装了。

## build-essentialsudo apt-get install build-essential## javasudo apt install  openjdk-9-jdk## 各种包sudo apt install autoconf libz-dev libbz2-dev liblzma-dev libssl-dev### zlib2wget http:///zlib-1.2.11.tar.gztar -zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && make && sudo make install && cd .. && rm -rf zlib-1.2.11### bzip2wget http:///1.0.6/bzip2-1.0.6.tar.gztar -zxvf bzip2-1.0.6.tar.gz && cd bzip2-1.0.6 && make && sudo make install && cd .. && rm -rf  bzip2-1.0.6### cursessudo apt-get install libncurses5-dev
  • R编译需要的Java必须是完全体,所以必须是 openjdk-9-jdk,不然无限报错

  • make -i 可以忽略系统报错,继续走下去,很多时候一点小错是没有关系的

  • 如果./configure --prefix=/path/to/where写错了,然后最后安装的地方错了, 不能简单的把软件包挪个位置就行了,至少要把目录内的R-3.4.1/bin/RR-3.4.1/lib/R/bin/R的路径进行修改。

  • make得要好好学习,有些时候不能./configure && make && make install prefix=/path/to/where一套走下来,有点作者可能没有定义install

  • 我们遇到的问题基本上无数前人已经填坑了,所以谷歌百度必应总能找到, 如果你想偷懒,那你可以加入我的小密圈,向我提问。


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多