Posts
My thoughts and ideas
Welcome to the blog
My thoughts and ideas
Introduction to bioinformatics for RNA sequence analysis
First, make sure your environment is set up correctly.
Tools needed for this analysis are: samtools, bam-readcount, HISAT2, stringtie, gffcompare, htseq-count, flexbar, R, ballgown, fastqc and picard-tools. In the following installation example, the installs are local and will work whether you have root (i.e. admin) access or not. However, if root is available some binaries can/will be copied to system-wide locations (e.g., ~/bin/).
Set up tool installation location:
cd $RNA_HOME
mkdir student_tools
cd student_tools
Installation type: build C++ binary from source code using make
. Citation: PMID: 19505943.
The following tool is installed by downloading a compressed archive using wget
, decompressing it using bunzip2
, unpacking the archive using tar
, and building the source code using make
to run compiler commands in the “Makefile” provided with the tool. When make
is run without options, it attempts the “default goal” in the make file which is the first “target” defined. In this case the first “target” is :all
. Once the build is complete, we test that it worked by attempting to execute the samtools
binary. Remember that the ./
in ./samtools
tells the commandline that you want to execute the samtools
binary in the current directory. We do this because there may be other samtools
binaries in our PATH. Try which samtools
to see the samtools binary that appears first in our PATH and therefore will be the one used when we specify samtools
without specifying a particular location of the binary.
cd $RNA_HOME/student_tools/
wget https://github.com/samtools/samtools/releases/download/1.14/samtools-1.14.tar.bz2
bunzip2 samtools-1.14.tar.bz2
tar -xvf samtools-1.14.tar
cd samtools-1.14
make
./samtools
Installation type: build C++ binary from source code using cmake
and make
. Citation: PMID: 34341766.
Installation of the bam-readcount tool involves “cloning” the source code with a code version control system called git
. The code is then compiled using cmake
and make
. cmake
is an application for managing the build process of software using a compiler-independent method. It is used in conjunction with native build environments such as make
(cmake ref). Note that bam-readcount relies on another tool, samtools, as a dependency. An environment variable is used to specify the path to the samtools install.
cd $RNA_HOME/student_tools/
export SAMTOOLS_ROOT=$RNA_HOME/student_tools/samtools-1.14
git clone https://github.com/genome/bam-readcount
cd bam-readcount
mkdir build
cd build
cmake ..
make
./bin/bam-readcount
Installation type: download a precompiled binary. Citation: PMID: 31375807.
The hisat2
aligner is installed below by simply downloading an archive of binaries using wget
, unpacking them with unzip
, and testing the tool to make sure it executes without error on the current system. This approach relies on understanding the architecture of your system and downloading the correct precompiled binary. The uname -m
command lists the current system architecture.
uname -m
cd $RNA_HOME/student_tools/
curl -s https://cloud.biohpc.swmed.edu/index.php/s/oTtGWbWjaxsQ2Ho/download > hisat2-2.2.1-Linux_x86_64.zip
unzip hisat2-2.2.1-Linux_x86_64.zip
cd hisat2-2.2.1
./hisat2 -h
Installation type: download a precompiled binary. Citation: PMID: 25690850.
The stringtie
reference guided transcript assembly and abundance estimation tool is installed below by simply downloading an archive with wget
, unpacking the archive with tar
, and executing stringtie
to confirm it runs without error on our system.
cd $RNA_HOME/student_tools/
wget http://ccb.jhu.edu/software/stringtie/dl/stringtie-2.1.6.Linux_x86_64.tar.gz
tar -xzvf stringtie-2.1.6.Linux_x86_64.tar.gz
cd stringtie-2.1.6.Linux_x86_64
make release
./stringtie -h
Installation type: download a precompiled binary. Citation: PMID: 25690850.
The gffcompare
tool for comparing transcript annotations is installed below by simply downloading an archive with wget
, unpacking it with tar
, and executing gffcompare
to ensure it runs without error on our system.
cd $RNA_HOME/student_tools/
wget http://ccb.jhu.edu/software/stringtie/dl/gffcompare-0.12.1.Linux_x86_64.tar.gz
tar -xzvf gffcompare-0.12.1.Linux_x86_64.tar.gz
cd gffcompare-0.12.1.Linux_x86_64/
./gffcompare
Installation type: use python setup script. Citation: PMID: 25260700.
The htseq-count read counting tools is installed below by downloading an archive with wget
, unpacking the archive using tar
and running a setup script written in Python. After setup, chmod
is used to change permissions of the htseq-count
file to be executable.
cd $RNA_HOME/student_tools/
git clone https://github.com/htseq/htseq.git
cd htseq/
git fetch --all --tags
git checkout release_0.13.5
python setup.py build
python setup.py install
chmod +x scripts/htseq-count
./scripts/htseq-count -h
Installation type: dowload a precompiled binary. Citation: PMID: 19289445.
Note, this tool is currently only installed for the gtf_to_fasta tool used in kallisto section.
cd $RNA_HOME/student_tools/
wget http://genomedata.org/rnaseq-tutorial/tophat-2.1.1.Linux_x86_64.tar.gz
tar -zxvf tophat-2.1.1.Linux_x86_64.tar.gz
cd tophat-2.1.1.Linux_x86_64/
./gtf_to_fasta
Installation type: download a precompiled binary. Citation: PMID: 27043002.
The kallisto alignment free expression estimation tool is installed below simply by downloading an archive with wget
, unpacking the archive with tar
, and testing the binary to ensure it runs on our system.
cd $RNA_HOME/student_tools/
wget https://github.com/pachterlab/kallisto/releases/download/v0.44.0/kallisto_linux-v0.44.0.tar.gz
tar -zxvf kallisto_linux-v0.44.0.tar.gz
cd kallisto_linux-v0.44.0/
./kallisto
Installation type: download precompiled binary. Citation: s-andrews/FastQC.
cd $RNA_HOME/student_tools/
wget http://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.9.zip
unzip fastqc_v0.11.9.zip
cd FastQC/
chmod 755 fastqc
./fastqc --help
Installation type: use pip. Citation: PMID: 27312411.
Multiqc, a tool for assembling QC reports is a python package that can be installed using the python package manager pip
.
pip3 install multiqc
export PATH=/home/ubuntu/.local/bin:$PATH
multiqc --help
Installation type: download java jar file. Citation: broadinstitute/picard.
Picard is a rich tool kit for BAM file manipulation that is installed below simply by downloading a jar file. The jar file is tested using Java, a dependency that must also be installed (it should already be present in many systems).
cd $RNA_HOME/student_tools/
wget https://github.com/broadinstitute/picard/releases/download/2.26.4/picard.jar -O picard.jar
java -jar $RNA_HOME/student_tools/picard.jar
Installation type: download precompiled binary. Citation: PMID: 24832523.
cd $RNA_HOME/student_tools/
wget https://github.com/seqan/flexbar/releases/download/v3.5.0/flexbar-3.5.0-linux.tar.gz
tar -xzvf flexbar-3.5.0-linux.tar.gz
cd flexbar-3.5.0-linux/
export LD_LIBRARY_PATH=$RNA_HOME/student_tools/flexbar-3.5.0-linux:$LD_LIBRARY_PATH
./flexbar
Installation type: compile from source code using cmake
and make
. Citation: bioRXiv: 10.1101/436634v2.
cd $RNA_HOME/student_tools/
git clone https://github.com/griffithlab/regtools
cd regtools/
mkdir build
cd build/
cmake ..
make
./regtools
Installation type: use pip. Citation: PMID: 22743226.
pip3 install RSeQC
read_GC.py
Installation type: download precompiled binary. Citation: PMID: 22576172.
cd $RNA_HOME/student_tools/
mkdir bedops_linux_x86_64-v2.4.40
cd bedops_linux_x86_64-v2.4.40
wget -c https://github.com/bedops/bedops/releases/download/v2.4.40/bedops_linux_x86_64-v2.4.40.tar.bz2
tar -jxvf bedops_linux_x86_64-v2.4.40.tar.bz2
./bin/bedops
./bin/gff2bed
Installation type: download precompiled binary.
cd $RNA_HOME/student_tools/
mkdir gtfToGenePred
cd gtfToGenePred
wget -c http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/gtfToGenePred
chmod a+x gtfToGenePred
./gtfToGenePred
Installation type: download precompiled binary.
cd $RNA_HOME/student_tools/
mkdir genePredToBed
cd genePredToBed
wget -c http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/genePredToBed
chmod a+x genePredToBed
./genePredToBed
pip3 install git+https://github.com/betsig/how_are_we_stranded_here.git
check_strandedness
cd ~/bin
wget `download_link`
tar -xzvf cellranger-6.1.2.tar.gz
sudo apt-get install tabix
cd ~/bin
git clone https://github.com/lh3/bwa.git
cd bwa
make
cd ~/bin
wget https://github.com/arq5x/bedtools2/releases/download/v2.30.0/bedtools-2.30.0.tar.gz
tar -zxvf bedtools-2.30.0.tar.gz
cd bedtools2
make
cd ~/bin
wget https://github.com/samtools/bcftools/releases/download/1.14/bcftools-1.14.tar.bz2
bunzip2 bcftools-1.14.tar.bz2
tar -xvf bcftools-1.14.tar
cd bcftools-1.14
make
./bcftools
cd ~/bin
wget https://github.com/samtools/htslib/releases/download/1.14/htslib-1.14.tar.bz2
bunzip2 htslib-1.14.tar.bz2
tar -xvf htslib-1.14.tar
cd htslib-1.14
make
./htslib
cd ~/bin
git clone https://github.com/brentp/peddy
cd peddy
pip install -r requirements.txt
pip install --editable .
peddy
cd ~/bin
wget https://github.com/brentp/slivar/releases/download/v0.2.7/slivar
chmod +x ./slivar
cd ~/bin
wget https://github.com/quinlan-lab/STRling/releases/download/v0.5.1/strling
chmod +x ./strling
git clone --recursive https://github.com/freebayes/freebayes.git
cd freebayes
meson build/ --buildtype debug
cd build
ninja
ninja test
./freebayes
sudo apt-get remove r-base-core
sudo apt-get remove r-base
wget -c https://cran.r-project.org/src/base/R-4/R-4.0.0.tar.gz
tar -xf R-4.0.0.tar.gz
cd R-4.0.0
./configure
make -j9
sudo make install
Note, if X11 libraries are not available you may need to use --with-x=no
during config, on a regular linux system you would not use this option.
Also, linking the R-patched bin
directory into your PATH
may cause weird things to happen, such as man pages or git log
to not display. This can be circumvented by directly linking the R*
executables (R
, RScript
, RCmd
, etc.) into a PATH
directory.
Installation type: add new base R libraries to an R installation.
For this tutorial we require:
launch R (enter R
at linux command prompt) and type the following at an R command prompt. NOTE: This has been pre-installed for you, so these commands can be skipped.
#R
#install.packages(c("devtools","dplyr","gplots","ggplot2"),repos="http://cran.us.r-project.org")
#quit(save="no")
Installation type: add bioconductor libraries to an R installation. Citation: PMID: 15461798.
For this tutorial we require:
launch R (enter R
at linux command prompt) and type the following at an R command prompt. If prompted, type “a” to update all old packages. NOTE: This has been pre-installed for you, so these commands can be skipped.
#R
#source("http://bioconductor.org/biocLite.R")
#biocLite(c("genefilter","ballgown","edgeR","GenomicRanges","rhdf5","biomaRt"))
#quit(save="no")
Installation type: R package installation from a git repository. Citation: PMID: 28581496.
#R
#install.packages("devtools")
#devtools::install_github("pachterlab/sleuth")
#quit(save="no")
Assignment: Install bedtools on your own. Make sure you install it in your tools folder. Download, unpack, compile, and test the bedtools software. Citation: PMID: 20110278.
cd $RNA_HOME/student_tools/
$RNA_HOME/student_tools/bedtools2/bin/bedtools
Solution: When you are ready you can check your approach against the Solutions
To use the locally installed version of each tool without having to specify complete paths, you could add the install directory of each tool to your ‘$PATH’ variable
PATH=$RNA_HOME/student_tools/genePredToBed:$RNA_HOME/student_tools/gtfToGenePred:$RNA_HOME/student_tools/bedops_linux_x86_64-v2.4.39/bin:$RNA_HOME/student_tools/samtools-1.11:$RNA_HOME/student_tools/bam-readcount/bin:$RNA_HOME/student_tools/hisat2-2.2.1:$RNA_HOME/student_tools/stringtie-2.1.4.Linux_x86_64:$RNA_HOME/student_tools/gffcompare-0.12.1.Linux_x86_64:$RNA_HOME/student_tools/htseq-release_0.12.4/scripts:$RNA_HOME/student_tools/tophat-2.1.1.Linux_x86_64:$RNA_HOME/student_tools/kallisto_linux-v0.44.0:$RNA_HOME/student_tools/FastQC:$RNA_HOME/student_tools/flexbar-3.5.0-linux:$RNA_HOME/student_tools/regtools/build:/home/ubuntu/bin/bedtools2/bin:$PATH
export LD_LIBRARY_PATH=$RNA_HOME/student_tools/flexbar-3.5.0-linux:$LD_LIBRARY_PATH
echo $PATH
You can make these changes permanent by adding the above lines to your .bashrc file use a text editor to open your bashrc file. For example:
vi ~/.bashrc
If you would like to learn more about how to use vi, try this tutorial/game: VIM Adventures
NOTE: If you are worried your .bashrc is messed up you can redownload as follows:
cd ~
wget -N https://raw.githubusercontent.com/griffithlab/rnabio.org/master/assets/setup/.bashrc
source ~/.bashrc
Some useful tools are available as official ubuntu packages. These can be installed using the linux package management system apt
. Most bioinformatic tools (especially the latest versions) are not available as official packages. Nevertheless, here is how you would update your apt
library, upgrade existing packages, and install an Ubuntu tool called tree
.
#sudo apt-get update
#sudo apt-get upgrade
#sudo apt-get install tree
#tree
Sometimes you might not have root access in order to be able to install the tools as described above or you might not want to deal with figuring out a way to install all of the dependencies necessary for a tool to run. One alternative way to use tools is to use a docker image for that tool. Before we can do this, we must first install docker.
First we’ll want to update apt-get
and remove any old docker images that might exist on our ubuntu install.
sudo apt-get update
sudo apt-get remove docker docker-engine docker.io containerd runc
Next we’ll want to make sure that some dependencies that docker needs are available.
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
Then we’ll need to add Docker’s official GPG key and verify that we now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
Next, we’ll use the following command to set up the stable repository.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Now that we’ve set up the dependencies for docker, we can finally install it.
sudo apt-get install docker-ce docker-ce-cli containerd.io
We can now test our docker install.
sudo docker run hello-world
Notice that we had to use sudo
to run the docker container. If you tried to run the above command, then you would get an error of permission denied
. In order to not have to use root access everytime we want to use docker, we can add the ubuntu user to the docker group. We’ll then have to reboot to instance in order for this change to take place.
sudo usermod -a -G docker ubuntu
sudo reboot
After reboot, you should now be able to run docker run hello-world
without using sudo
before it.
Some tools have complex dependencies that are difficult to reproduce across systems or make work in the same environment with tools that require different versions of the same dependencies. Container systems such as Docker and Singularity allow you to isolate a tool’s environment giving you almost complete control over dependency issues. For this reason, many tool developers have started to distribute their tools as docker images. Many of these are placed in container image repositories such as DockerHub. Here is an example tool installation using docker
.
Install samtools:
docker pull biocontainers/samtools:v1.9-4-deb_cv1
docker run -t biocontainers/samtools:v1.9-4-deb_cv1 samtools --help
Install pvactools for personalized cancer vaccine designs:
#docker pull griffithlab/pvactools:latest
#docker run -t griffithlab/pvactools:latest pvacseq --help
Some systems do not allow docker
to be run for various reasons. Sometimes singularity
is used instead. The equivalent to the above but using singularity looks like the following:
#singularity pull docker://griffithlab/pvactools:latest
#singularity run docker://griffithlab/pvactools:latest pvacseq -h
Note that if you encounter errors with /tmp space usage or would like to control where singularity stores its temp files, you can set the environment variables:
#export SINGULARITY_CACHEDIR=/media/workspace/.singularity
#export TMPDIR=/media/workspace/temp