系统准备

windows10: Unbuntu on windows10
image.png
微软的良心

软件准备

我的习惯:

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

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

  1. # 备份
  2. cd /etc/apt/
  3. sudo cp source.list source.list.bk
  4. # 替换
  5. sudo sed -i 's/http/https/g' sources.list
  6. sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' sources.list
  7. sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' sources.list
  8. # 更新
  9. sudo apt-get update
  10. sudo apt-get upgrade

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

sratookit

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

  1. cd src
  2. wget https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.8.2-1/sratoolkit.2.8.2-1-ubuntu64.tar.gz
  3. tar -zxvf sratoolkit.2.8.2-1-ubuntu64.tar.gz
  4. mv sratoolkit.2.8.2-1-ubuntu64 ~/biosoft
  5. # 加入环境变量
  6. echo 'PATH=$PATH:~/biosoft/sratoolkit.2.8.2-1-ubuntu64/bin' >> ~/.bashrc
  7. # 测试
  8. prefetch -v
  9. # 尝试下载,默认存放在家目录下的ncbi文件夹中
  10. prefetch -c SRR390728

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

  1. 如何开启ascp加速下载
  2. vdb-config更改基本设置

    fastqc

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

    判断系统是否安装java

    java -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)

安装fastqc

cd src wget http://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.5.zip unzip fastqc_v0.11.5.zip mv FastQC/ ~/biosoft/ cd ~/biosoft/FastQC/ chmod 770 fastqc

添加环境变量, 我用sed修改

sed -i ‘/^PATH/s/(.*)/\1:~\/biosoft\/FastQC\//‘ ~/.bashrc source ~/.bashrc fastqc -v

FastQC v0.11.5

  1. 拓展:
  2. 1. 了解fastqc结果中各个图的含义
  3. 1. 掌握如何从fastqc的结果中提取数据
  4. 1. 学习sed的用法,[http://dongweiming.github.io/sed_and_awk/](https://link.jianshu.com/?t=http://dongweiming.github.io/sed_and_awk/)
  5. <a name="loCyd"></a>
  6. ### samtools
  7. SAM: 存放高通量测序比对结果的标准格式<br />功能: Reading/writing/editing/indexing/viewing SAM/BAM/CRAM format<br />网站: [http://samtools.sourceforge.net/](https://link.jianshu.com/?t=http://samtools.sourceforge.net/)<br />安装:
  8. ```bash
  9. cd src
  10. # prerequsite
  11. ## system requirement
  12. sudo apt install autoconf libz-dev libbz2-dev liblzma-dev libssl-dev
  13. ### zlib2
  14. wget http://zlib.net/zlib-1.2.11.tar.gz
  15. tar -zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && make && sudo make install && cd .. && rm -rf zlib-1.2.11
  16. ### bzip2
  17. wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
  18. tar -zxvf bzip2-1.0.6.tar.gz && cd bzip2-1.0.6 && make && sudo make install && cd .. && rm -rf bzip2-1.0.6
  19. ### curses
  20. sudo apt-get install libncurses5-dev
  21. ### htslib
  22. git clone https://github.com/samtools/htslib.git
  23. cd htslib
  24. autoreconf
  25. # building samtools
  26. git clone https://github.com/samtools/samtools.git
  27. cd samtools
  28. autoconf -Wno-syntax
  29. ./configure
  30. make && make install prefix=$HOME/biosoft/samtools
  31. ## add PATH
  32. sed '/^PATH/s/\(.*\)/\1:~\/biosoft\/samtools\/bin/' .bashrc -i
  33. source ~/.bashrc
  34. samtools --help

顺便安装bcftools

  1. cd src
  2. git clone https://github.com/samtools/bcftools.git
  3. make && make install prefix=$HOME/biosoft/bcftools
  4. make clean
  5. sed '/^PATH/s/\(.*\)/\1:~\/biosoft\/bcftools\/bin/' .bashrc -i
  6. source ~/.bashrce
  7. bcftools -h

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

  1. cd htslib; git pull
  2. cd ../bcftools; git pull
  3. make clean
  4. make

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

HISAT2

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

  1. cd src
  2. wget ftp://ftp.ccb.jhu.edu/pub/infphilo/hisat2/downloads/hisat2-2.1.0-source.zip
  3. unzip hisat2-2.1.0-source.zip
  4. # 编译hisat2
  5. cd hisat2-2.1.0
  6. make
  7. rm -f *.h *.cpp
  8. cd ../
  9. mv hisat2-2.1.0 ~/biosoft/hisat2
  10. # add to PATH
  11. sed '/^PATH/s/\(.*\)/\1:~\/biosoft\/hisat2/' ~/.bashrc -i
  12. source ~/.bashrc
  13. # test
  14. hisat2 -h

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

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

    HTSeq

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

    prerequsites

    sudo apt-get install python-pip pip install —upgrade pip sudo apt-get install build-essential python2.7-dev python-numpy python-matplotlib

验证, 保证无报错

python -V

python

python

import numpy import matplotlib

install HTSeq

pip install htseq

验证

python

import HTSeq ``` 教程:

  1. http://www-huber.embl.de/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.r-project.org/
    Rstudio: https://www.rstudio.com/
    二进制版本: R官方提供了Ubuntu最新版本更新方法,如下 ```bash

    添加Secure APT

    sudo apt-key adv —keyserver keyserver.ubuntu.com —recv-keys E084DAB9

    添加deb到source.list

    vi source.list deb 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 update sudo apt-get install r-base

(optional)如果要自己编译R

sudo apt-get install r-base-dev

  1. 安装之后建议修改一下R包镜像源,提高下载速度。
  2. ```bash
  3. vi ~/.Rprofile
  4. options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
  5. options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")

编译部分:新手阶段不要轻易尝试,如果你能顺利搞定,你的Linux能力已经过关了
如何处理./configure中出现的问题:

  • configure: error: No F77 compiler found

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

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

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

    1. sudo apt-get install libpcre3 libpcre3-dev

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

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

    最后配置成功后会出现如下结果: ```bash 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: yes

configure: WARNING: you cannot build info or HTML versions of the R manuals configure: WARNING: you cannot build PDF versions of the R manuals configure: WARNING: you cannot build PDF versions of vignettes and help pages

  1. 这些警告无伤大雅,毕竟CLI看不了PDF
  2. ```bash
  3. make

然后我发现一个错误

  1. error: jni.h: No such file or directory

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

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

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

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

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

  1. make install -i

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

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