Difference between revisions of "SeqShop: Sequence Mapping and Assembly Practical, June 2014"

From Genome Analysis Wiki
Jump to navigationJump to search
Line 212: Line 212:
 
This file is created by you to configure GotCloud for your data.
 
This file is created by you to configure GotCloud for your data.
  
* Default values are provided in ${GC}/gotcloud/bin/gotcloudDefaults.conf
+
* Default values are provided in ${GC}/bin/gotcloudDefaults.conf
 
** Most values should be left as the defaults
 
** Most values should be left as the defaults
 
* Specify values in your configuration file as:
 
* Specify values in your configuration file as:
Line 220: Line 220:
 
* Does not have access to environment variables
 
* Does not have access to environment variables
 
* '#' indicates a comment
 
* '#' indicates a comment
* Keys to override:
 
{|class="wikitable" cellpadding=5
 
|-
 
! Key Name !! Description
 
|-
 
| colspan=2 style="text-align:center"| Index File Settings - pointing GotCloud to your data
 
|-
 
| INDEX_FILE || Path to the FASTQ index file that you created
 
* Alternatively, this can be specified on the command-line as <code>--index_file</code>
 
|-
 
| FASTQ_PREFIX || Prefix to be added to the FASTQ files in INDEX_FILE
 
* Not required
 
|-
 
| BAM_INDEX || Path to the BAM index file
 
* to be created by alignment
 
* to be used for snp calling
 
|-
 
| colspan=2 style="text-align:center"| Reference File Settings - telling GotCloud where to find your reference files
 
|-
 
| REF_DIR || Path to your reference files
 
* You don't have to use this, you can specify the full path for each file
 
|-
 
| REF || Path/filename of the FASTA reference file
 
* If different than default: $(REF_DIR)/human.g1k.v37.fa
 
|-
 
| DBSNP_VCF || Path/filename of the DBSNP file
 
* If different than default: $(REF_DIR)/dbsnp_135.b37.vcf.gz
 
|-
 
| HM3_VCF || Path/filename of the HapMap3 file
 
* If different than default: $(REF_DIR)/hapmap_3.3.b37.sites.vcf.gz
 
|-
 
| OMNI_VCF || Path/filename of the OMNI file
 
* If different than default: $(REF_DIR)/1000G_omni2.5.b37.sites.PASS.vcf.gz
 
|-
 
| INDEL_PREFIX || Path/filename base of the indels file
 
* If different than default: $(REF_DIR)/1kg.pilot_release.merged.indels.sites.hg19
 
|}
 
  
 
Let's look at the configuration file I created for this test:
 
Let's look at the configuration file I created for this test:
  more ${GC}/inputs/gotcloud.conf
+
  more ${IN}/gotcloud.conf
  
It already points to your align file.
+
; If your input/reference are at a different path, what would you change?
 +
<ul>
 +
<div class="mw-collapsible mw-collapsed" style="width:200px">
 +
<li>Answer:</li>
 +
<div class="mw-collapsible-content">
 +
<ul>
 +
<li>Change <code>IN_DIR</code> & <code>REF_DIR</code></li>
 +
[[File:gcConf.png|500px]]
 +
</div>
 +
</div>
 +
</ul>
 +
</ul>
  
 
== Run GotCloud Align ==
 
== Run GotCloud Align ==

Revision as of 20:18, 14 June 2014

Introduction

See the introductory slides for an intro to this tutorial.

Goals of This Session

  • What we want to learn
    • Basic sequence data file formats (FASTQ, BAM)
    •  How to generate aligned sequences that are ready for variant calling from raw sequence reads
    •  How to evaluate the quality of sequence data
    •  How to visualize sequence data to examine the reads aligned to particular genomic positions


Login to the seqshop-server Linux Machine

This section will appear redundantly in each session. If you are already logged in or know how to log in to the server, please skip this section

  1. Login to the windows machine
    • The username/password for the Windows machine should be written on the right-hand monitor
  2. Start xming so you can open external windows on our Linux machine
    • Start->Enter "Xming" in the search and select "Xming" from the program list
    • Nothing will happen, but Xming was started.
    • View Screenshot
    • Xming.png

  3. Open putty
    • Start->Enter "putty" in the search and select "PuTTY" from the program list
    • View Screenshot
    • PuttyS.png

  4. Configure PuTTY in the PuTTY Configuration window
    • Host Name: seqshop-server.sph.umich.edu
    • View Screenshot
    • Seqshop.png

    • Setup to allow you to open external windows:
      • In the left pannel: Connection->SSH->X11
        • Add a check mark in the box next to Enable X11 forwarding
        • View Screenshot
        • SeqshopX11.png

    • Click Open
    • If it prompts about a key, click OK
  5. Enter your provided username & password as provided


You should now be logged into a terminal on the seqshop-server and be able to access the test files.

  • If you need another terminal, repeat from step 3.

Login to the seqshop Machine

So you can each run multiple jobs at once, we will have you run on 4 different machines within our seqshop setup.

  • You can only access these machines after logging onto seqshop-server

3 users logon to:

ssh -X seqshop1

3 users logon to:

ssh -X seqshop2

2 users logon to:

ssh -X seqshop3

2 users logon to:

ssh -X seqshop4

Setup your run environment

This will setup some environment variables to point you to

  • GotCloud program
  • Tutorial input files
  • Setup an output directory
source /home/mktrost/seqshop/setup.txt

View setup.txt

Setup.png


Alternatively, if you would like to change the output directory, copy the file, make the modifications and source your own file:

cp /home/mktrost/seqshop/setup.txt ~/setup.txt
nedit ~/setup.txt
source ~/setup.txt

(You can use your favorite editor instead of nedit. I typically use emacs, but nedit is more like Windows.)

Examining Raw Sequence Reads

FASTQ : standard file format provided to you by those who did the sequencing.

For more information on the FASTQ format, see: http://en.wikipedia.org/wiki/FASTQ_format

For this tutorial, we will use FASTQs for 4 1000 Genome samples

  • Subset of FASTQs - should map to chromosome 22 36000000-37000000
ls ${IN}/fastq/

There are 24 fastq files: combination of single-end & paired-end.

Can you tell which files are single-end and which are paired-end?
  • View answer:
    • Paired-end files have a _1.fastq or _2.fastq extension
    • This convention isn't mandatory, but something similar is common
    • Fastqsm.png


Look at a couple of FASTQs:

less -S ${IN}/fastq/HG00551.SRR190851_1.fastq

less is a Linux command that allows you to look at a file.

  • -S option prevents line wrap.
  • Use the arrow (up/down/left/right) keys to scroll through the file.
  • Use zless if the file is compressed.

Use 'q' to exit out of less

q
Do you remember the parts of a FASTQ?
  • No, remind me:
  • Fastq.png


Look at the paired read:

less -S ${IN}/fastq/HG00551.SRR190851_2.fastq 
Do you notice something in common?
  • View answer:
    • Paired-end reads have matching read names with a different extensions
    • This convention isn't mandatory, but something similar is common
    • Fastq3.png

GotCloud Alignment Pipeline

AlignDiagram.png

Why GotCloud?

  • Easy to learn & run
    • All-in-one sequence analysis pipeline
    • You don’t have to know the details of individual component
  • Robust parallelization
    •  Automatic partition of multi-sample jobs
    •  Reliable and fault-tolerant parallelization via GNU make
      • Restart from where it stopped upon unexpected crash
  • Cloud & Cluster-friendly
    • Supports multiple clusters such as MOSIX, Slurm, & SGE
    • Amazon instances allow running large-scale jobs without having your own cluster

Sequence Processing Recommendations

  • Be consistent within a project
    • Process all samples with same pipeline
      • Batch effect may arise if different pipelines are used due to pipeline differences
    •  Use the same configuration within a project

Examining GotCloud Align Input Files

Sequence Data Files : FASTQs

We already looked at those in: Examining Raw Sequence Reads

Reference Files

Reference files can be downloaded with GotCloud or from other sources

For alignment, you need:

  1. Reference genome FASTA file
  2. VCF (variant call format) files with chromosomes/positions
    • dbsnp - used to skip known variants when recalibrating
    • hapmap - used for sample contamination/sample swap validation

Take a look at the chromosome 22 reference files included for this tutorial:

ls ${REF}
  • View Screenshot
  • RefDir.png

Let's read the reference FASTA file (all reference bases for the chromosome):

less ${REF}/human.g1k.v37.chr22.fa
Where is the reference sequence?
  • Answer:
    • The ends of a chromosome are 'N' - unknown bases
    • Let's look at 5 lines of the file starting at line 300,000
    • tail -n+300000 ${REF}/human.g1k.v37.chr22.fa |head -n 5 Fasta.png

GotCloud FASTQ Index File

The FASTQ index file is created by you to tell GotCloud about each of your FASTQ files:

  • Where to find it
  • Sample name
    • Each sample can have multiple FASTQs
    • Each FASTQ is for a single sample
  • Run identifier
    • For recalibration we need to know which reads were in the same run.

FASTQ Index Format:

  • Tab delimited
  • Starts with a header line
  • One line per single-end read
  • One line per paired-end read (only 1 line per pair).

Let's look a look at the index file I prepared for this tutorial:

less -S ${IN}/align.index 
Which samples had multiple Runs?
  • Need a reminder of the format?
  • Fqindex.png

  • Answer:
    • HG00553 & HG00640
    • They have multiple unique values in the RGID field
    • FqindexRG.png


How do you point Gotcloud to your index file?

  • Command-line --index_file option
or
  • Configuration file INDEX_FILE setting.

The command-line setting takes precedence over the configuration file setting.

GotCloud Configuration File

This file is created by you to configure GotCloud for your data.

  • Default values are provided in ${GC}/bin/gotcloudDefaults.conf
    • Most values should be left as the defaults
  • Specify values in your configuration file as:
KEY = value
  • Use $(KEY) to refer to another key's value
  • If a KEY is specified twice, the later value is used
  • Does not have access to environment variables
  • '#' indicates a comment

Let's look at the configuration file I created for this test:

more ${IN}/gotcloud.conf
If your input/reference are at a different path, what would you change?
  • Answer:
    • Change IN_DIR & REF_DIR
    • GcConf.png

Run GotCloud Align

Now that we have all of our input files, we need just a simple command to run

${GC}/gotcloud/gotcloud align --conf ${GC}/inputs/gotcloud.conf --numcs 2
  • --numcs means to run 2 samples at a time.
    • Depends on your system

GcalignStart.png

This should take < 4 minutes to run.

It should end with a line like: Processing finished in 133 secs with no errors reported

If you cancelled GotCloud part way through, just rerun your GotCloud command and it will pick up where it left off.

Examining GotCloud Align Output

Let's look at the output directory:

ls ${OUTPUT}

GcalignOutM.png

Let's look at the BAMs (aligned reads that are ready for variant calling):

ls ${OUTPUT}/bams

GcalignOutBAMm.png

BAM Files:

  • Binary Sequence Alignment/Map (SAM) Format
  • Maps reads to Chromosome/Position
  • For a detailed explanation of the SAM/BAM format, see:
  • Consists of:
    • Header
      • Starts with '@'
      • Records - one for each sequence read

Let's examine a BAM file:

samtools view -h ${OUTPUT}/bams/

BAM.png

Let's take a look at our quality control output directory:

ls ${OUTPUT}/QCFiles 

GcalignOutQCm.png

Check for sample contamination:

  • *.selfSM : Main output file containing the contamination estimate.
    • If you are only interested in checking sample contamination:
      • Check the 'FREEMIX' column for genotype-free estimate of contamination
      • Check the 'CHIPMIX' column for contamination estimates with external genotypes (if provided)
  • *.selfRG : Same output to .*selfSM, but separated by readGroup (which might be helpful for library-level examination)
  • *.depthSM : depth distribution of reads covering the marker position of the input VCF, across all readGroups.
  • *.depthRG : depth distribution of reads covering the marker position of the input VCF, per readGroups.
less -S ${OUTPUT}/QCFiles/HG00551.genoCheck.selfSM

Contam1.png

Next, let's look at some quality control metrics:

cat ${OUTPUT}/QCFiles/HG00551.qplot.stats
  • 99.16% mapping rate
  • 94.01% high quality bases
  • 7x coverage
  • 31.3% A, 31.3% T
  • 18.7% C, 18.7% G


Generate the pdf's of our quality metrics:

Rscript ${OUTPUT}/QCFiles/HG00551.qplot.R
Rscript ${OUTPUT}/QCFiles/HG00553.qplot.R
Rscript ${OUTPUT}/QCFiles/HG00640.qplot.R
Rscript ${OUTPUT}/QCFiles/HG00641.qplot.R

Examine the PDF:

evince  ${OUTPUT}/QCFiles/HG00551.qplot.pdf&

The first plot: Empirical vs reported Phred score does not look as good as we would like.

  • This is due to the small region used for recalibration

Look at the PDF I produced when I ran the whole genome:

evince ${GC}/example/HG00551.wg.qplot.pdf&

See: QPLOT: Diagnose sequencing quality for more info on how to use QPLOT results.