Welcome to the blog


My thoughts and ideas

Bioinformatics Best Practices | Griffith Lab

RNA-seq Bioinformatics

Introduction to bioinformatics for RNA sequence analysis

Bioinformatics Best Practices


This best practices guide provides a basic overview of useful practices and tools for managing bioinformatics environments and analysis development.

Managing Your Analysis with Notebooks

Similar to the use of a laboratory notebook, taking notes about the procedures and analysis you performed is critical to reproducible science. There are a number of scientific computing notebooks available, but the most popular by far is the Jupyter Notebook.

Jupyter supports interactive data science and scientific computer across a small number of languages, although the most popular use of Jupyter is with Python, as the Jupyter notebook is built upon the Python-based iPython Notebook.

Example notebooks

A live version of Jupyter is available to try online, and provides several example notebooks in a few different languages. You can also check out a real analysis of Guide to Pharmacology gene family data for incorporation into the Drug-Gene Interaction Database.

Versioning Code with Git and GitHub

Git is a distributed version control system that allows users to make changes to code while simultaneously documenting those changes and preserving a history, allowing code to be rolled back to a previous version quickly and safely. GitHub is a freemium, online repository hosting service. You may use GitHub to track projects, discuss issues, document applications, and review code. GitHub is one of the best ways to share your projects, and should be used from the very onset of a project. Some forethought should be given in creating and managing a repository, however, as GitHub is not a good place to share very large or sensitive data files. See the 10-minute introduction to using GitHub.

Managing Your Compute Environment

One of the most challenging aspects of bioinformatics workflows is reproducibility. In addition to documenting your analysis with a notebook, providing a copy of your compute environment limits variability in results, allowing for future reproduction of results. A world of options exist to handle this, although some of the most common options are presented.

AWS Elastic Cloud Computing is a useful service for creating entire virtual machines that can easily be copied and distributed. This option does require a paid account with Amazon, and the costs of storing the images and running instances may add up over time, especially if every analysis is stored in a separate image. Additionally, this option does not isolate the analysis environment from the system environment, potentially leading to changes in analysis output as system libraries are updated over time. The RNA-seq wiki makes heavy use of AWS as a distribution platform.

VirtualBox is a general-purpose full virtualizer that allows you to emulate a computer, complete with virtual disks, a virtual operating system, and any data and applications stored therein. It has the advantage of creating machines that are stored and run on local hardware (e.g. your personal workstation), but the extra overhead of running a virtual computer on top of a host operating system can considerably slow performance of tools stored on the virtual machine, and thus is best used for testing or demonstration purposes.

Docker packages apps and their dependencies into containers which may be docked to a docker engine running on a computer. Docker engines are available on all major operating systems, and allow software to remain infrastructure independent while sharing a filespace and system resources with other docked containers. This is a much more efficient approach than guest virtual machines, and containers may be docked locally or on cloud-based infrastructure.

Conda is a language-agnostic package, dependency and environment management system. It is included in the data-science-focused distribution of Conda, Anaconda. Anaconda is based on Python and R packages for the analysis of scientific, large-scale data. Bioinformaticians also commonly use Bioconda, which add channels to Conda with bioinformatics tools (such as the popular sequence alignment tool BWA).

AWS Setup | Griffith Lab

RNA-seq Bioinformatics

Introduction to bioinformatics for RNA sequence analysis

AWS Setup

This tutorial explains how Amazon cloud instances were configured for the course. This exercise is not to be completed by the students but is provided as a reference for future course developers that wish to conduct their hands on exercises on Amazon AWS.

Before proceeding with below, first check to see if there are any Proposed Improvements to incorporate.

Create AWS account

A helpful tutorial can be found here: https://github.com/genome/gms/wiki/Developers-guide-to-installing-the-GMS-on-an-AWS-instance

  1. Create a new gmail account to use for the course
  2. Use the above email account to set up a new AWS/Amazon user account. Note: Any AWS account needs to be linked to an actual person and credit card account.
  3. Optional - Set up an IAM account. Give this account full EC2 but no other permissions. This provides an account that can be shared with other instructors but does not have access to billing and other root account privelages.
  4. Request limit increase for limit types you will be using. You need to be able to spin up at least one instance of the desired type for every student and TA/instructor. See: http://aws.amazon.com/about-aws/whats-new/2014/06/19/amazon-ec2-service-limits-report-now-available/. Note: You need to request an increase for each instance type and region you might use.
  5. Sign into AWS Management Console: http://aws.amazon.com/console/
  6. Go to EC2 services

Start with existing community AMI

  1. Launch a fresh Ubuntu Image. Choose an instance type of m5.2xlarge. Increase root volume (e.g., 32GB) and add a second volume (e.g., 250gb). Review and Launch. If necessary, create a new key pair, name and save somewhere safe. Select ‘View Instances’. Take note of public IP address of newly launched instance.
  2. Change permissions on downloaded key pair with chmod 400 [instructor-key].pem
  3. Login to instance with ubuntu user:

ssh -i [instructor-key].pem ubuntu@[public.ip.address]

Perform basic linux configuration

Set up additional storage for workspace

We may need to run a setup script to mount a workspace folder on ephemeral (or EBS) storage. This can not really be done ahead of time in the saved AMI. See https://raw.githubusercontent.com/griffithlab/rnabio.org/master/assets/setup/preinstall.sh. This script has been provided in the home directory of the AMI. It just needs to be run at first launch of the student instance. Copy/download the preinstall.sh script to the ubuntu home directory and create the necessary dirs and links as below. But, do not run bash preinstall.sh until later when actually spinning up student/instructor instance. NOTE: This may or may not be necessary depending on how you set up volumes and type of instance you choose. For example, if you setup an extra EBS volume (instead of relying on ephemeral storage) and mount this drive (for storing working data) and you create the appropriate fstab entries then create an AMI, new instances may just be ready to go. See https://github.com/griffithlab/rnabio.org/blob/master/assets/setup/setup_mounts.sh

cd ~
ln -s /workspace workspace

Install any desired informatics tools

Install TABIX (GEMINI pre-req)

sudo apt-get install tabix

Install GEMINI

mkdir -p $WORKSPACE/lib/gemini
mkdir -p $HOME/bin
wget https://raw.github.com/arq5x/gemini/master/gemini/scripts/gemini_install.py
sudo python gemini_install.py $HOME $WORKSPACE/lib/gemini


# Install prerequisites
sudo apt install graphviz libgmp3-dev
wget https://github.com/broadinstitute/picard/releases/download/2.14.1/picard.jar

wget ftp://ftp.broadinstitute.org/pub/crd/ALLPATHS/Release-LG/latest_source_code/LATEST_VERSION.tar.gz
tar -xvzf LATEST_VERSION.tar.gz
cd allpathslg-52488/
ln -s /usr/bin/gcc-4.8 gcc
ln -s /usr/bin/g++-4.8 g++
./configure --prefix=$TOOLS/allpathslg-52488/
make install

Install MUMmer

wget http://downloads.sourceforge.net/project/mummer/mummer/3.23/MUMmer3.23.tar.gz
tar -zxvf MUMmer3.23.tar.gz
cd MUMmer3.23
make check
make install

Install sniffles

wget https://github.com/fritzsedlazeck/Sniffles/archive/master.tar.gz -O Sniffles.tar.gz
tar -xzvf Sniffles.tar.gz
cd Sniffles-master/
mkdir -p build/
cd build/
cmake ..

Install NGM-LR

wget https://github.com/philres/ngmlr/releases/download/v0.2.6/ngmlr-0.2.6-beta-linux-x86_64.tar.gz
tar -xvzf ngmlr-0.2.6-beta-linux-x86_64.tar.gz

Install BWA

git clone https://github.com/lh3/bwa.git
cd bwa


git clone https://github.com/fritzsedlazeck/SURVIVOR.git

Install salmon

wget https://github.com/COMBINE-lab/salmon/releases/download/v0.11.3/salmon-0.11.3-linux_x86_64.tar.gz
tar -xvzf salmon-0.11.3-linux_x86_64.tar.gz

Install bedtools

git clone https://github.com/arq5x/bedtools2.git
cd bedtools2
sudo make install

Install bcftools

wget https://github.com/samtools/bcftools/releases/download/1.9/bcftools-1.9.tar.bz2
tar -xvjf bcftools-1.9.tar.bz2
cd bcftools-1.9/
./configure --prefix=$HOME
make install

Install trinity (with gmap, bowtie2, emacs)

sudo apt-get install gmap bowtie2 emacs25

cd $DATA
wget http://genomedata.org/seq-tec-workshop/trinity.tar.gz
tar -xvzf trinity.tar.gz

wget https://github.com/trinityrnaseq/trinityrnaseq/archive/Trinity-v2.5.1.tar.gz
tar -xvzf Trinity-v2.5.1.tar.gz
cd trinityrnaseq-Trinity-v2.5.1/Chrysalis/
rm Makefile
wget http://genomedata.org/seq-tec-workshop/Makefile
cd ..

Install mosdepth

# prereq -- htslib
wget https://github.com/samtools/htslib/releases/download/1.9/htslib-1.9.tar.bz2
tar -xvjf htslib-1.9.tar.bz2
cd htslib-1.9/
./configure --prefix=$HOME
make && make install

# mosdepth
wget https://github.com/brentp/mosdepth/releases/download/v0.2.3/mosdepth
chmod +x mosdepth

Install freebayes

git clone --recursive git://github.com/ekg/freebayes.git
cd freebayes/
make && sudo make install

Install samblaster

git clone git://github.com/GregoryFaust/samblaster.git
cd samblaster
cp samblaster $HOME/bin/.

Install funseq

## prereqs
# Parallel::ForkManager
sudo cpanm Parallel::ForkManager

wget http://vat.gersteinlab.org/data/vat-2.0.1_64bit.zip
unzip vat-2.0.1_64bit.zip
wget http://genomedata.org/seq-tec-workshop/funseq/.vatrc
cp vat/* $HOME/bin

# TFMpvalue-sc2py
# originally from http://bioinfo.lifl.fr/tfm-pvalue/TFM-Pvalue.tar.gz, mirrored to genomedata due to patched install
wget http://genomedata.org/seq-tec-workshop/funseq/TFM-Pvalue.tar.gz
tar -xvzf TFM-Pvalue.tar.gz
cd TFM-Pvalue/
wget http://genomedata.org/seq-tec-workshop/funseq/Makefile -O Makefile
wget http://genomedata.org/seq-tec-workshop/funseq/TFMpvalue.cpp -O TFMpvalue.cpp
cp TFMpvalue-sc2pv $HOME/bin

# bigWigAverageOverBed
cd $HOME/bin
wget http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigAverageOverBed
chmod +x bigWigAverageOverBed

## funseq2
cd $HOME
git clone https://github.com/khuranalab/FunSeq2_DC
cd $HOME/bin
ln -s $HOME/FunSeq2_DC/funseq2.sh funseq2

Install NCBI SRA toolkit and NCBI E-Utilities

sudo cpanm HTML::Entities
sudo cpanm LWP::Simple
sudo cpanm XML::Simple
cd /home/ubuntu/bin/
wget ftp://ftp.ncbi.nlm.nih.gov/entrez/entrezdirect/edirect.tar.gz
tar -zxvf edirect.tar.gz
wget http://ftp-trace.ncbi.nlm.nih.gov/sra/sdk/current/sratoolkit.current-ubuntu64.tar.gz
tar -zxvf sratoolkit.current-ubuntu64.tar.gz
export PATH=/home/ubuntu/bin/sratoolkit.2.9.2-ubuntu64/bin:$PATH
export PATH=/home/ubuntu/bin/edirect:$PATH
#For testing
fastq-dump -X 5 -Z SRR925811
esearch -db sra -query PRJNA40075  | efetch --format runinfo | cut -d ',' -f 1 | grep SRR | head -5 | xargs fastq-dump -X 10 --split-files

Download data files

mkdir -p data/fasta/GRCh38
cd data/fasta/GRCh38
wget ftp://ftp.ensembl.org/pub/release-86/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa.gz
gunzip Homo_sapiens.GRCh38.dna_sm.primary_assembly.fa.gz
wget ftp://ftp.ensembl.org/pub/release-86/fasta/homo_sapiens/dna/Homo_sapiens.GRCh38.dna_sm.chromosome.22.fa.gz
gunzip Homo_sapiens.GRCh38.dna_sm.chromosome.22.fa.gz
wget http://tools.thermofisher.com/downloads/ERCC92.fa
mkdir ../GRCh37
cd ../GRCh37
wget ftp://ftp.ensembl.org/pub/release-75/fasta/homo_sapiens/dna/Homo_sapiens.GRCh37.75.dna_sm.primary_assembly.fa.gz
gunzip Homo_sapiens.GRCh37.75.dna_sm.primary_assembly.fa.gz
wget ftp://ftp.ensembl.org/pub/release-75/fasta/homo_sapiens/dna/Homo_sapiens.GRCh37.75.dna_sm.chromosome.22.fa.gz
gunzip Homo_sapiens.GRCh37.75.dna_sm.chromosome.22.fa.gz
cd ../..
mkdir -p annotations/GRCh38
cd annotations/GRCh38
wget ftp://ftp.ensembl.org/pub/release-86/gtf/homo_sapiens/Homo_sapiens.GRCh38.86.gtf.gz
gunzip Homo_sapiens.GRCh38.86.gtf.gz
cat Homo_sapiens.GRCh38.86.gtf | awk '($1 == 22)' > chr22.gtf
wget http://genomedata.org/seq-tec-workshop/ERCC92_fix.gtf
cat chr22.gtf ERCC92_fix.gtf > chr22_with_ERCC92.gtf
mkdir ../GRCH37
cd ../GRCH37
wget ftp://ftp.ensembl.org/pub/release-75/gtf/homo_sapiens/Homo_sapiens.GRCh37.75.gtf.gz
gunzip Homo_sapiens.GRCh37.75.gtf.gz

Set up Apache web server

We will start an apache2 service and serve the contents of the students home directories for convenience. This allows easy download of files to their local hard drives, direct loading in IGV by url, etc. Note that when launching instances a security group will have to be selected/modified that allows http access via port 80.

<Directory /home/ubuntu/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

* Edit vhost file
sudo vim /etc/apache2/sites-available/000-default.conf

Save a snapshot of workspace volume

To create a snapshot of the extra workspace volume, navigate to volumes, right-click, and choose Create Snapshot. Take note of the snapshot id for reference later (e.g., snap-154dc64c)

Save a public AMI

Finally, save the instance as a new AMI by right clicking the instance and clicking on “Create Image”. Enter an appropriate name and description and then save. If desired you may choose at this time to include the workspace snapshot in the AMI to avoid having to explicitly attach it later at launching of AMI instances. Change the permissions of the AMI to “public” if you would like it to be listed under the Community AMIs. Copy the AMI to any additional regions where you would like it to appear in Community AMI searches.

Current Public AMIs:

Create IAM account

From AWS Console select Services -> IAM. Go to Users, Create User, specify a user name, and Create. Download credentials to a safe location for later reference if needed. Select the new user and go to Security Credentials -> Manage Password -> ‘Assign a Custom Password’. Go to Groups -> Create a New Group, specify a group name and Next. Attach a policy to the group. In this case we give all EC2 privileges but no other AWS privileges by specifying “AmazonEC2FullAccess”. Hit Next, review and then Create Group. Select the Group -> Add Users to Group, select your new user to add it to the new group.

Launch student instance

  1. Go to AWS console. Login. Select EC2.
  2. Launch Instance, search for “cshl_seqtec_2017_v2” in Community AMIs and Select.
  3. Choose “m4.2xlarge” instance type.
  4. Select one instance to launch (e.g., one per student and instructor), and select “Protect against accidental termination”
  5. Make sure that you see two snapshots (e.g., the 32GB root volume and 80GB EBS volume you set up earlier)
  6. Create a tag with name=StudentName
  7. Choose existing security group call “SSH_HTTP_8081_IN_ALL_OUT”. Review and Launch.
  8. Choose an existing key pair (either CSHL.pem)
  9. View instances and wait for them to finish initiating.
  10. Find your instance in console and select it, then hit connect to get your public.ip.address.
  11. Login to node ssh -i cshl_2017.pem ubuntu@[public.ip.address].
  12. Optional - set up DNS redirects (see below)

Set up a dynamic DNS service

Rather than handing out ip addresses for each student instance to each student you can instead set up DNS records to redirect from a more human readable name to the IP address. After spinning up all student instances, use a service like http://dyn.com (or http://entrydns.net, http://dyn.com/, etc.) to create hostnames like rna01.dyndns.org, rna02.dyndns.org, etc that point to each public IP address of student instances.

Host necessary files for the course

Currently, all miscellaneous data files, annotations, etc. are hosted on an ftp server at the Genome Institute. In the future more data files could be pre-loaded onto the EBS snapshot.

After course reminders