轉(zhuǎn)錄組入門(1):軟件準(zhǔn)備

系統(tǒng)準(zhǔn)備

windows10: Unbuntu on windows10

微軟的良心

軟件準(zhǔn)備

我的習(xí)慣:

  • 家目錄下創(chuàng)建src文件夾,用于存放軟件包
  • 家目錄下創(chuàng)建biosoft文件夾,用于安裝軟件

為了提高下載速度,我們需要替換/etc/apt/source.list中默認(rèn)鏡像源。方法參考自中國科學(xué)技術(shù)大學(xué)開源鏡像站

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

選擇合適的鏡像站,讓你的速度飛起來

sratookit

功能: 下載,操作,驗(yàn)證NCBI SRA中二代測(cè)序數(shù)據(jù)
網(wǎng)址:https://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?view=software
步驟:

cd src
wget https://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/2.8.2-1/sratoolkit.2.8.2-1-ubuntu64.tar.gz
tar -zxvf sratoolkit.2.8.2-1-ubuntu64.tar.gz
mv sratoolkit.2.8.2-1-ubuntu64 ~/biosoft
# 加入環(huán)境變量
echo 'PATH=$PATH:~/biosoft/sratoolkit.2.8.2-1-ubuntu64/bin' >> ~/.bashrc
# 測(cè)試
prefetch -v
# 嘗試下載,默認(rèn)存放在家目錄下的ncbi文件夾中
prefetch -c SRR390728

閱讀官方文章進(jìn)一步了解:

  1. 如何開啟ascp加速下載
  2. vdb-config更改基本設(shè)置

fastqc

功能: 可視化展示二代測(cè)序數(shù)據(jù)質(zhì)量
網(wǎng)站:http://www.bioinformatics.babraham.ac.uk/projects/fastqc/
步驟:

# 判斷系統(tǒng)是否安裝java
java -version
# 安裝java, 請(qǐng)改成openjdk-9-jdk,下面的是錯(cuò)誤演示
sudo apt install  openjdk-9-jre-headless
# 驗(yàn)證
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
# 添加環(huán)境變量, 我用sed修改
sed -i '/^PATH/s/\(.*\)/\1:~\/biosoft\/FastQC\//' ~/.bashrc
source ~/.bashrc
fastqc -v
# FastQC v0.11.5

拓展:

  1. 了解fastqc結(jié)果中各個(gè)圖的含義
  2. 掌握如何從fastqc的結(jié)果中提取數(shù)據(jù)
  3. 學(xué)習(xí)sed的用法,http://dongweiming.github.io/sed_and_awk/

samtools

SAM: 存放高通量測(cè)序比對(duì)結(jié)果的標(biāo)準(zhǔn)格式
功能: Reading/writing/editing/indexing/viewing SAM/BAM/CRAM format
網(wǎng)站: http://samtools.sourceforge.net/
安裝:

cd src
#  prerequsite
## system requirement
sudo apt install autoconf libz-dev libbz2-dev liblzma-dev libssl-dev

### zlib2
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && make && sudo make install && cd .. && rm -rf zlib-1.2.11

### bzip2
wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar -zxvf bzip2-1.0.6.tar.gz && cd bzip2-1.0.6 && make && sudo make install && cd .. && rm -rf  bzip2-1.0.6

### curses
sudo apt-get install libncurses5-dev 

### htslib
git clone https://github.com/samtools/htslib.git
cd htslib
autoreconf

# building samtools
git clone https://github.com/samtools/samtools.git
cd samtools
autoconf -Wno-syntax
./configure 
make && make install prefix=$HOME/biosoft/samtools

## add PATH
sed  '/^PATH/s/\(.*\)/\1:~\/biosoft\/samtools\/bin/' .bashrc -i
source ~/.bashrc
samtools --help

順便安裝bcftools

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

因?yàn)橛玫氖莋ithub,所以以后更新就用下面命令

cd htslib; git pull
cd ../bcftools; git pull
make clean
make

吐槽: 編譯的時(shí)候需要安裝好多前置包,真麻煩!

HISAT2

功能: 將測(cè)序結(jié)果比對(duì)到參考基因組上
網(wǎng)站: http://ccb.jhu.edu/software/hisat2/index.shtml
安裝:

cd src
wget ftp://ftp.ccb.jhu.edu/pub/infphilo/hisat2/downloads/hisat2-2.1.0-source.zip
unzip hisat2-2.1.0-source.zip
# 編譯hisat2
cd hisat2-2.1.0
make
rm -f *.h *.cpp 
cd ../
mv hisat2-2.1.0 ~/biosoft/hisat2
# add to PATH
sed  '/^PATH/s/\(.*\)/\1:~\/biosoft\/hisat2/' ~/.bashrc -i
source ~/.bashrc
# test
hisat2 -h

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

  • HISAT2支持--sra-acc <SRA accession number>,也就是可以集成SRATOOLS的,但是需要安裝額外包,可以看文章自己折騰。

HTSeq

功能: 根據(jù)比對(duì)結(jié)果統(tǒng)計(jì)基因count

# prerequsites
sudo apt-get install python-pip
pip install --upgrade pip
sudo apt-get install build-essential python2.7-dev python-numpy python-matplotlib
## 驗(yàn)證, 保證無報(bào)錯(cuò)
python -V
## python
python
>>> import numpy 
>>> import matplotlib 

## install HTSeq
pip install htseq

## 驗(yàn)證
python
>>> import HTSeq

教程:

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

推薦:

  1. 推薦安裝一個(gè)ipython,學(xué)習(xí)ipython如何使用
  2. 將軟件包安裝到當(dāng)前用戶目錄下pip install --user xxx

R

Ubuntu 14.04的自帶R版本跟不上時(shí)代的變化,然后自己編譯的坑有太多,所以先用Linux處理數(shù)據(jù),然后在Windows下分析數(shù)據(jù)。這樣就很輕松了。一些需要編譯的軟件包,還可以用RTools。
R:https://cran.r-project.org/
Rstudio: https://www.rstudio.com/

二進(jìn)制版本: R官方提供了Ubuntu最新版本更新方法,如下

# 添加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

安裝之后建議修改一下R包鏡像源,提高下載速度。

vi ~/.Rprofile
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
options(BioC_mirror="https://mirrors.tuna.tsinghua.edu.cn/bioconductor")

編譯部分:新手階段不要輕易嘗試,如果你能順利搞定,你的Linux能力已經(jīng)過關(guān)了

如何處理./configure中出現(xiàn)的問題:

  • configure: error: No F77 compiler found
sudo apt-get install gfortran
  • configure: error: --with-readline=yes (default) and headers/libs are not available
# 其實(shí)可以--with-readlines=no, 但是還是把東西裝了吧
install libreadline-dev
  • configure: error: --with-x=yes (default) and X11 headers/libs are not available
# 因?yàn)槭荂LI模式,不需要GUI
./configure --with-x=no
  • configure: error: pcre >= 8.20 library and headers are required
sudo apt-get install libpcre3 libpcre3-dev

: 上面安裝其他軟件時(shí)用到的包,其實(shí)也有一部分是R所需要的,如果出錯(cuò)的話,也是谷歌+必應(yīng)+百度一個(gè)一個(gè)解決。

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

最后配置成功后會(huì)出現(xiàn)如下結(jié)果:

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

這些警告無傷大雅,畢竟CLI看不了PDF。

make

然后我發(fā)現(xiàn)一個(gè)錯(cuò)誤

error: jni.h: No such file or directory

原因是之前的openjdk-9-jre-headless無頭, 不完整,所以需要重新安裝一個(gè)完整的

# 先卸載
sudo apt-get remove openjdk-9-jre-headless
# 后安裝最完整java環(huán)境
sudo apt-get install openjdk-9-jdk

然后重新make && make install
我以為自己不會(huì)遇到問題了,結(jié)果

installing doc ...
/usr/bin/install: 無法獲取'NEWS.pdf' 的文件狀態(tài)(stat): 沒有那個(gè)文件或目錄
/usr/bin/install: 無法獲取'NEWS.pdf' 的文件狀態(tài)(stat): 沒有那個(gè)文件或目錄
Makefile:121: recipe for target 'install-sources2' failed

MDZZ!本來就沒有考慮到x11模塊,不能搞pdf,你和我說報(bào)錯(cuò)!于是我默默去百度一下,給出的方法是忽略錯(cuò)誤

make install -i

謝天謝地,終于通過了!??!添加環(huán)境變量測(cè)試一下吧

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

一點(diǎn)經(jīng)驗(yàn)

以后在Ubuntu安裝軟件之前,先保證如下被安裝了。

## build-essential
sudo apt-get install build-essential
## java
sudo apt install  openjdk-9-jdk

## 各種包
sudo apt install autoconf libz-dev libbz2-dev liblzma-dev libssl-dev

### zlib2
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz && cd zlib-1.2.11 && make && sudo make install && cd .. && rm -rf zlib-1.2.11

### bzip2
wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar -zxvf bzip2-1.0.6.tar.gz && cd bzip2-1.0.6 && make && sudo make install && cd .. && rm -rf  bzip2-1.0.6

### curses
sudo apt-get install libncurses5-dev
  • R編譯需要的Java必須是完全體,所以必須是 openjdk-9-jdk,不然無限報(bào)錯(cuò)
  • make -i 可以忽略系統(tǒng)報(bào)錯(cuò),繼續(xù)走下去,很多時(shí)候一點(diǎn)小錯(cuò)是沒有關(guān)系的
  • 如果./configure --prefix=/path/to/where寫錯(cuò)了,然后最后安裝的地方錯(cuò)了, 不能簡單的把軟件包挪個(gè)位置就行了,至少要把目錄內(nèi)的R-3.4.1/bin/RR-3.4.1/lib/R/bin/R的路徑進(jìn)行修改。
  • make得要好好學(xué)習(xí),有些時(shí)候不能./configure && make && make install prefix=/path/to/where一套走下來,有點(diǎn)作者可能沒有定義install
  • 我們遇到的問題基本上無數(shù)前人已經(jīng)填坑了,所以谷歌百度必應(yīng)總能找到
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容