Difference between revisions of "TrioCaller"

From Genome Analysis Wiki
Jump to navigationJump to search
 
(178 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Introduction ==
+
== Introduction ==
  
We will illustrate how TrioCaller works in sequence data including trios and unrelated samples. We will start from the scratch and walk through all necessary steps  
+
We will illustrate how TrioCaller works in sequence data including trios and unrelated samples. We will walk through all necessary steps to move from raw sequence data to called genotypes.  
from raw sequence data to called genotypes. If you are new to sequence data, please be patient to go through every step. If you are experienced, you may jump to the section of
+
If you are new to sequence data, please review every step. If you are experienced, you may directly jump to [http://genome.sph.umich.edu/wiki/TrioCaller#Genotype_Refinement_Using_Linkage_Disequilibrium_Information_.28TrioCaller.29 TrioCaller] specific section.  
[http://genome.sph.umich.edu/wiki/TrioCaller#Genotype_Refinement_Using_Linkage_Disequilibrium_Information  TrioCaller].  
 
  
 
We will start with a set of short sequence reads and associated base quality scores (stored in a fastq file), find the most likely genomic location for each read (producing a BAM file), generate an initial list of polymorphic sites and genotypes (stored in a VCF file) and use haplotype information to refine these genotypes (resulting in an updated VCF file).
 
We will start with a set of short sequence reads and associated base quality scores (stored in a fastq file), find the most likely genomic location for each read (producing a BAM file), generate an initial list of polymorphic sites and genotypes (stored in a VCF file) and use haplotype information to refine these genotypes (resulting in an updated VCF file).
  
=== Example Dataset ===
+
=== Note ===
  
Our dataset consists of 40 individuals, which have been sequenced at an average depth of 3x.
+
If you are interested in ''de novo'' mutations or are working on one or two families with deep sequence data (>30X), you should first consider our sister program, [http://genome.sph.umich.edu/wiki/Polymutt Polymutt], which ignores linkage disequilibrium information but can handle more complex pedigrees.
  
To conserve time and disk-space, our analysis will focus on a small region on chromosome 20. We will first map reads for a single individual (labeled SAMPLE1), combine the results with mapped reads from the other 30 individuals to generate a list of polymorphic sites and estimate accurate genotypes at each of these sites.
+
=== Download  ===
  
The example dataset we'll be using is included in this tar-ball [http://www.sph.umich.edu/csg/abecasis/downloads/TrioCaller-2012-01-28.tar.gz) [TrioCaller-2012-01-28.tar.gz].
+
Before downloading the program, we appreciate if you could email [mailto:weichen.mich@gmail.com weichen.mich@gmail.com] (Subject: TrioCaller, with/without a little descriptive information (e.g. Affiliation, depth, the number of samples and family structure). We will notify you if there is any update. 
  
=== Required Software ===
+
'''A recent extension of TrioCaller: [http://genome.sph.umich.edu/wiki/FamLDCaller FamLDCaller] is coming soon with major updates (better processing function,  handling general families and reference panels). Please try the beta version below. Contact weichen.mich@gmail.com for any questions.''' 
  
In order to run this exercise, you should have BWA ([http://bio-bwa.sourceforge.net available from Sourceforge]), samtools ([http://samtools.sourceforge.net also from Sourceforge]) and thunderVCF ([[UMAKE|included in the UMAKE pipeline download]]) installed. The examples are tested in in bwa 0.6.1, samtools 0.1.18, TrioCaller 0.1.1. The previous version might be not working at certain steps. We assume all executables are under folder bin.
+
[[Binary file:]]  [http://www.pitt.edu/~wec47/Files/FamLDCaller FamLDCaller].  [Last update: 08/15/2014]
 +
 
 +
 
 +
'''TrioCaller''' : the version we used in the paper.
 +
<br>
 +
[[Binary file only:]] [http://csg.sph.umich.edu/weich/TrioCaller.06262012.binary.tgz TrioCaller.06262012.binary.tgz].
 +
 
 +
[[Binary file with example datasets&nbsp;:]] [http://csg.sph.umich.edu/weich/TrioCaller.06262012.tgz TrioCaller.06262012.tgz].
 +
 
 +
[http://genome.sph.umich.edu/wiki/TrioCaller:Archive Archive].
 +
 
 +
'''
 +
 
 +
== An example from sequence data to genotypes ==
 +
'''
 +
 
 +
The example dataset demonstrated here is also included. Our dataset consists of 40 individuals, including 10 parent-offspring trios and 10 unrelated individuals. The average sequence depth is ~3x. README.txt describes the structure of the package. Pipeline.csh (C shell) and pipeline.bash (bash shell) are two scripts for you to run all commands listed here in batch.
 +
 
 +
To conserve time and disk-space, our analysis will focus on a small region on chromosome 20 around position 2,000,000. We will first map reads for a single individual (labeled SAMPLE1). Then we combine the results with mapped reads from all individuals to generate a list of polymorphic sites and estimate accurate genotypes at each of these sites.
 +
 
 +
=== Required Software  ===
 +
 
 +
In addition to TrioCaller, you will need BWA ([http://bio-bwa.sourceforge.net available from Sourceforge]) and samtools ([http://samtools.sourceforge.net also from Sourceforge]) installed to run this exercise. The examples are tested in in bwa 0.6.1, samtools 0.1.18, TrioCaller 0.1.1; we expect newer versions should also work. We assume all executables are in your path.
  
 
== Building an Index for Short Read Alignment ==
 
== Building an Index for Short Read Alignment ==
Line 26: Line 47:
 
The sequence index is typically not compatible across different BWA versions. To rebuild the sequence index, issue the following commands:
 
The sequence index is typically not compatible across different BWA versions. To rebuild the sequence index, issue the following commands:
  
 +
<source lang="bash">
 +
  #Remove any earlier reference files
 
   rm ref/human_g1k_v37_chr20.fa.*
 
   rm ref/human_g1k_v37_chr20.fa.*
 +
 +
  #Rebuild the reference
 
   bin/bwa index -a is ref/human_g1k_v37_chr20.fa
 
   bin/bwa index -a is ref/human_g1k_v37_chr20.fa
 +
</source>
  
 
== Mapping Reads to The Genome ==
 
== Mapping Reads to The Genome ==
  
There are many different tools for mapping DNA sequence reads. One of the most commonly used tools is BWA, developed by Heng Li and Richard Durbin at the Sanger Center. As with other read mappers, BWA first builds an index of the reference genome and then uses this index to quickly assign each sequence read to a genomic location.
+
Next, we will use BWA to find the most likely sequence location for each read using the <code>bwa aln</code> command. This command requires two parameters, one corresponding to the reference genome, the other corresponding to a fastq file containing reads to be mapped.  
 
 
To learn more about BWA, you should visit the BWA website at http://bio-bwa.sourceforge.net
 
 
 
Here, we will simply use BWA to find the most likely sequence location for each read using the <code>bwa aln</code> command. This command requires two parameters, one corresponding to the reference genome, the other corresponding to a fastq file containing reads to be mapped.  
 
  
 
   bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/SAMPLE1.fastq > bwa.sai/SAMPLE1.sai
 
   bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/SAMPLE1.fastq > bwa.sai/SAMPLE1.sai
Line 41: Line 63:
 
The file SAMPLE1.fastq contains DNA sequence reads for sample SAMPLE1.  
 
The file SAMPLE1.fastq contains DNA sequence reads for sample SAMPLE1.  
  
A fastq file consists of a series of multi-line records. Each record starts with a read name, followed by a DNA sequencing, a separator line, and a set of per base quality scores. Base quality scores estimate the probability of error at each sequenced base (a base quality of 10 denotes an error probability of 10%, base quality 20 denotes 1% error probability and base quality 30 denotes 0.1% error probability). These error probabilities are each encoded in a single character (for compactness) and can be decoded using an [http://www.google.com/search?q=ascii+table] - you should look up the ascii code for each base and subtract 33 to get base quality. By inspecting the FastQ file you should be able to learn about the length of reads being mapped and their base qualities (is base quality typically higher at the start or end of each read).
+
A fastq file consists of a series of multi-line records. Each record starts with a read name, followed by a DNA sequencing, a separator line, and a set of per base quality scores. Base quality scores estimate the probability of error at each sequenced base (a base quality of 10 denotes an error probability of 10%, base quality 20 denotes 1% error probability and base quality 30 denotes 0.1% error probability). These error probabilities are each encoded in a single character for compactness and can be decoded using an [http://www.google.com/search?q=ascii+table ASCII table] (simply look up the ascii code for each base and subtract 33 to get base quality). By inspecting the FastQ file you should be able to learn about the length of reads being mapped and their base qualities. For example, try to figure out if base quality is typically higher at the start or end of each read...
  
 
=== Converting Alignments to BAM format ===
 
=== Converting Alignments to BAM format ===
Line 48: Line 70:
  
 
   bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:SAMPLE1" ref/human_g1k_v37_chr20.fa bwa.sai/SAMPLE1.sai fastq/SAMPLE1.fastq | \
 
   bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:SAMPLE1" ref/human_g1k_v37_chr20.fa bwa.sai/SAMPLE1.sai fastq/SAMPLE1.fastq | \
    samtools view -uhS - | samtools sort -m 2000000000 - bams/SAMPLE1
+
  bin/samtools view -uhS - | bin/samtools sort -m 2000000000 - bams/SAMPLE1
  
 
You can check the use of parameters in the bwa manual. The result BAM file uses a compact binary format to represent the  
 
You can check the use of parameters in the bwa manual. The result BAM file uses a compact binary format to represent the  
Line 54: Line 76:
 
of the file using the <code>samtools view</code> command, like so:
 
of the file using the <code>samtools view</code> command, like so:
  
   bin/samtools view bams/SAMPLE.bam | more
+
   bin/samtools view bams/SAMPLE1.bam | more
  
The text representation of the alignemt produced by <code>samtools view</code> describes
+
The text representation of the alignment produced by <code>samtools view</code> describes
 
the alignment of one read per line. The most interesting fields are column 1 (the read  
 
the alignment of one read per line. The most interesting fields are column 1 (the read  
 
name), columns 3 and 4 (the alignment position), column 5 (the CIGAR string, describing  
 
name), columns 3 and 4 (the alignment position), column 5 (the CIGAR string, describing  
Line 75: Line 97:
  
 
If you reached this far, rejoice! The mapping process is almost done. We will now create  
 
If you reached this far, rejoice! The mapping process is almost done. We will now create  
and index for the file, which makes it convenient to quickly extract reads from any  
+
an index for the file, which makes it convenient to quickly extract reads from any  
 
genome location. We do this with the <code>samtools index</code> command, like so:
 
genome location. We do this with the <code>samtools index</code> command, like so:
  
Line 82: Line 104:
 
=== Browsing Alignment Results ===
 
=== Browsing Alignment Results ===
  
You can view the contents of the alignment at any location using the <code>samtools view</code>
+
You can now view the contents of the alignment at any location using the <code>samtools view</code>
 
and <code>samtools tview</code> commands. While the <code>tview</code> generates prettier output,
 
and <code>samtools tview</code> commands. While the <code>tview</code> generates prettier output,
 
it is not compatible with all screens. For example, to view reads overlapping  
 
it is not compatible with all screens. For example, to view reads overlapping  
 
starting at position 2,100,000 on chromosome 20, we could run:
 
starting at position 2,100,000 on chromosome 20, we could run:
  
   samtools tview bams/SAMPLE1.bam ref/human_g1k_v37_chr20.fa
+
   bin/samtools tview bams/SAMPLE1.bam ref/human_g1k_v37_chr20.fa
  
 
Then, type "g 20:2100000"
 
Then, type "g 20:2100000"
Line 93: Line 115:
 
So let's recap: we have mapped reads to genome, converted them from a BWA specific format to a more  
 
So let's recap: we have mapped reads to genome, converted them from a BWA specific format to a more  
 
commonly used format used by many different programs, sorted and indexed the results.
 
commonly used format used by many different programs, sorted and indexed the results.
 +
In most cases, the next step would be to remove duplicate reads and to ensure that base quality scores are properly calibrated. To save time, we'll skip those steps now.
 +
 +
Till now, we only finished read mapping for one sample SAMPLE1. We need to repeat this step for other samples (SAMPL2 - SAMPLE40). You can try something like:
 +
 +
For c shell
 +
 +
  foreach file (`ls fastq/SAMPLE*.fastq | cut -f 2 -d '/' | cut -f 1 -d '.'`)
 +
  echo $file
 +
  bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/$file.fastq > bwa.sai/$file.sai
 +
  bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:$file" ref/human_g1k_v37_chr20.fa bwa.sai/$file.sai fastq/$file.fastq | \
 +
    bin/samtools view -uhS - | bin/samtools sort -m 2000000000 - bams/$file
 +
  bin/samtools index bams/$file.bam
 +
  end
 +
 +
For bash shell
 +
 +
for file in `ls fastq/SAMPLE*.fastq | cut -f 2 -d '/' | cut -f 1 -d '.'`;
 +
  do echo $file;
 +
  bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/$file.fastq > bwa.sai/$file.sai;
 +
  bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:$file" ref/human_g1k_v37_chr20.fa bwa.sai/$file.sai fastq/$file.fastq | \
 +
    bin/samtools view -uhS - | samtools sort -m 2000000000 - bams/$file;
 +
  bin/samtools index bams/$file.bam;
 +
done
 +
  
In most cases, the next step would be to remove duplicate reads and to ensure that base quality scores are properly calibrated. To save time, we'll skip those steps now.
+
Once we finish the read mapping step and generate bam files for all samples, we can step to variant calling and genotype inference.
  
 
== Calling variants and Inferring genotypes ==
 
== Calling variants and Inferring genotypes ==
Line 103: Line 149:
 
the next few steps are much simpler.
 
the next few steps are much simpler.
  
The first thing we'll do is use samtools to generate an initial list of variant sites, using the <code>mpileup</code> command. This command looks at the bases aligned to each location and flags locations taht are likely to vary. By default, the results are stored in BCF file, which can be converted into the more widely used VCF format using bcftools (a companion set of tools distributed with samtools).
+
The first thing we'll do is use samtools to generate an initial list of variant sites, using the <code>mpileup</code> command. This command looks at the bases aligned to each location and flags locations that are likely to vary. By default, the results are stored in BCF file, which can be converted into the more widely used VCF format using bcftools (a companion set of tools distributed with samtools).
  
   bin/samtools mpileup -r 20:42000000-44000000 -Iuf ref/human_g1k_v37_chr20.fa bams/NA*bam | bcftools view -bvcg - > mpileup/chr20.bcf
+
 
 +
   bin/samtools mpileup -Iuf ref/human_g1k_v37_chr20.fa bams/SAMPLE*bam | bin/bcftools view -bvcg - > result/chr20.mpileup.bcf
  
   bin/bcftools view mpileup/chr20.bcf  | sed s/AF1/AF/g | grep -v AF=1 > mpileup/chr20.vcf
+
   bin/bcftools view result/chr20.mpileup.bcf  > result/chr20.mpileup.vcf
  
  
The VCF format is a simple text format. It starts with several header lines, which all start with the two '##' characters, and is followed by a single line per marker that provides both summary information about the marker and genotypes for each individual. You can review the contents of the VCF file using the 'more' command:
+
The [http://www.1000genomes.org/node/101 VCF format] is a simple text format. It starts with several header lines, which all start with the two '##' characters, and is followed by a single line per marker that provides both summary information about the marker and genotypes for each individual. You can review the contents of the VCF file using the 'more' command:
  
   more mpileup/chr20.vcf
+
   more result/chr20.mpileup.vcf
  
 
Here are some questions for you to investigate:
 
Here are some questions for you to investigate:
Line 118: Line 165:
 
* How many variant sites were detected in this dataset? Try a command like this one:
 
* How many variant sites were detected in this dataset? Try a command like this one:
  
  grep -vE ^# chr20.vcf | wc -l
+
  grep -vE ^# result/chr20.mpileup.vcf | wc -l
  
 
(The grep command line excludes all lines beginning with # and then the wc command counts the number of lines in the file).
 
(The grep command line excludes all lines beginning with # and then the wc command counts the number of lines in the file).
Line 126: Line 173:
 
!-->
 
!-->
  
=== Genotype Refinement Using Linkage Disequilibrium Information ===
+
<!--
 +
 
 +
Wei: I commented this out because generating GLF requires an old version of samtools that most people don't have. Goncalo
 +
 
 +
=== Alternative way to call variants ===
 +
Bcftools assumes all samples are unrelated. The better way to call variants is to consider family constraints imposed by parent-offspring trio.  An alternative approach for current step is to use
 +
another program [http://genome.sph.umich.edu/wiki/Polymutt Polymutt]. It consists of two steps, but the input [bam file] and output files [vcf file] are same as above.  For more information,
 +
click the link.
 +
 
 +
Convert bam files to glf files (It is a single line of command)
 +
 
 +
  bin/samtools view -bh bams/SAMPLE1.bam | bin/samtools calmd -Abr - ref/human_g1k_v37_chr20.fa 2 - | \
 +
  bin/samtools mpileup -g -f ref/human_g1k_v37_chr20.fa - > bams/SAMPLE1.glf
 +
 
 +
Take glf files and output vcf files.
 +
 
 +
  bin/polymutt -p polymutt.ped -d polymutt.dat -g polymutt.glfindex --vcf result/chr20.polymutt.vcf
 +
 
 +
!-->
 +
 
 +
=== Genotype Refinement Using Linkage Disequilibrium Information (TrioCaller) ===
 +
 
 +
The initial set of genotype calls is generated examining a single individual at a time. These calls are typically quite good for deep sequencing data, but much less accurate for low pass sequence data. In either case, they can be greatly improved by models that combine information across sites and individuals and consider the contraints imposed by parent-offspring trios.
 +
 
 +
Note: The current version only supports SNP data, so please '''filter indels''' before running TrioCaller. It supports VCF 4.0 and 4.1 formats with the '''exception of dropped missing trailing fields''' (e.g. use complete missing notation ./.:.:.:.,.,. rather than ./. for the genotype field)
 +
 
 +
Here is a summary of the TrioCaller command line options (these are also listed whenever you run the program with no parameters):
 +
 
 +
<source lang="text">
 +
Available Options
 +
  Shotgun Sequences: --vcf [], --pedfile []
 +
      Markov Sampler: --seed [], --burnin [], --rounds []
 +
          Haplotyper: --states [],  --errorRate [], --compact
 +
            Phasing: --randomPhase , --inputPhased, --refPhased
 +
        Output Files: --prefix [], --phase,  --interimInterval []
 +
 
 +
 
 +
Explanation of Options
 +
                --vcf:   Standard VCF file (4.0 and above).       
 +
            --pedfile:    Pedigree file in MERLIN format.
 +
                --seed:    Seed for sampling, default 123456.
 +
              --burnin:    The number of rounds ignored at the beginning of sampling.
 +
              --rounds:    The total number of iterations.
 +
              --states:    The number of haplotyes used in the state space. The default is the maximum number:  2*(number of founders -1).
 +
          --errorRate:    The pre-defined base error rate. Default 0.01.
 +
        --randomPhase:    The initial haplotypes are inferred from the single marker. Default option.
 +
        --inputPhased:   The initial haplotypes are directly from input VCF file (with "|" as separator in the genotype column).
 +
          --refPhased:   The initial haplotypes are built on reference alleles from VCF file.
 +
              --prefix:    The prefix of output file 
 +
    --interimInterval:    The number of rounds for interim outputs
 +
</source>
 +
 
 +
Note: The pedigree files require complete trio structures (all three members of the trio exist in the file). For parent-offspring pair, create a "fake" parent in the pedigree file or code them as unrelated individuals. The order of the names in the pedigree file is NOT necessary to be consistent with that in .vcf file. The computation will be intensive if the number of samples are large.
 +
You can use option "--states" to reduce the computation cost (e.g. start with "--states 50")
 +
 
 +
To complete our example analysis, we could run:
 +
 
 +
  bin/TrioCaller --vcf result/chr20.mpileup.vcf --pedfile ped/triocaller.ped --states 50 --rounds 10 --prefix result/chr20.triocaller
 +
 
 +
The format of output file is same as the input file. Again, you can review the contents of the updated VCF file using the more command:
  
The initial set of genotype calls is generated examining a single individual at a time. These calls are typically quite good for deep sequencing data, but much less accurate for low pass sequence data. In either case, they can be greatly improved by models that combine information across sites and individuals.
+
  more  result/chr20.triocaller.vcf
  
Here is how that might work:
+
All right. Congratulations! You have come to the end and learned basic skills for accurate genotype calling in trios.
  
  bin/TrioCaller --shotgun mpileup/chr20.vcf --pedfile example.ped  --dosage -r 20 --prefix triocaller/chr20.triocaller
+
If you have any question or comment, feel free to contact Wei Chen at [mailto:weichen.mich@gmail.com weichen.mich@gmail.com] or Goncalo Abecasis at [mailto:goncalo@umich.edu goncalo@umich.edu]
  
Again, you can review the contents of the updated VCF file using the more command:
+
== Citation  ==
  
  more triocaller/chr20.triocaller.vcf
+
Chen W, Li B, Zeng Z, Sanna S, Sidore C, Busonero F, Kang HM, Li Y, Abecasis GR. &nbsp;Genotype calling and haplotyping in parent-offspring trios. Genome Res.&nbsp;2013 Jan;23(1):142-51&nbsp;[http://genome.cshlp.org/content/early/2012/11/26/gr.142455.112.long LINK]

Latest revision as of 18:01, 19 May 2015

Introduction

We will illustrate how TrioCaller works in sequence data including trios and unrelated samples. We will walk through all necessary steps to move from raw sequence data to called genotypes. If you are new to sequence data, please review every step. If you are experienced, you may directly jump to TrioCaller specific section.

We will start with a set of short sequence reads and associated base quality scores (stored in a fastq file), find the most likely genomic location for each read (producing a BAM file), generate an initial list of polymorphic sites and genotypes (stored in a VCF file) and use haplotype information to refine these genotypes (resulting in an updated VCF file).

Note

If you are interested in de novo mutations or are working on one or two families with deep sequence data (>30X), you should first consider our sister program, Polymutt, which ignores linkage disequilibrium information but can handle more complex pedigrees.

Download

Before downloading the program, we appreciate if you could email weichen.mich@gmail.com (Subject: TrioCaller, with/without a little descriptive information (e.g. Affiliation, depth, the number of samples and family structure). We will notify you if there is any update. 

A recent extension of TrioCaller: FamLDCaller is coming soon with major updates (better processing function, handling general families and reference panels). Please try the beta version below. Contact weichen.mich@gmail.com for any questions.

Binary file: FamLDCaller. [Last update: 08/15/2014]


TrioCaller : the version we used in the paper.
Binary file only: TrioCaller.06262012.binary.tgz.

Binary file with example datasets : TrioCaller.06262012.tgz.

Archive.

An example from sequence data to genotypes

The example dataset demonstrated here is also included. Our dataset consists of 40 individuals, including 10 parent-offspring trios and 10 unrelated individuals. The average sequence depth is ~3x. README.txt describes the structure of the package. Pipeline.csh (C shell) and pipeline.bash (bash shell) are two scripts for you to run all commands listed here in batch.

To conserve time and disk-space, our analysis will focus on a small region on chromosome 20 around position 2,000,000. We will first map reads for a single individual (labeled SAMPLE1). Then we combine the results with mapped reads from all individuals to generate a list of polymorphic sites and estimate accurate genotypes at each of these sites.

Required Software

In addition to TrioCaller, you will need BWA (available from Sourceforge) and samtools (also from Sourceforge) installed to run this exercise. The examples are tested in in bwa 0.6.1, samtools 0.1.18, TrioCaller 0.1.1; we expect newer versions should also work. We assume all executables are in your path.

Building an Index for Short Read Alignment

To quickly place short reads along the genome, BWA and other read mappers typically build a word index for the genome. This index lists the location of particular short words along the genome and can be used to seed and then extend particular matches.

The sequence index is typically not compatible across different BWA versions. To rebuild the sequence index, issue the following commands:

  #Remove any earlier reference files
  rm ref/human_g1k_v37_chr20.fa.*

  #Rebuild the reference
  bin/bwa index -a is ref/human_g1k_v37_chr20.fa

Mapping Reads to The Genome

Next, we will use BWA to find the most likely sequence location for each read using the bwa aln command. This command requires two parameters, one corresponding to the reference genome, the other corresponding to a fastq file containing reads to be mapped.

 bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/SAMPLE1.fastq > bwa.sai/SAMPLE1.sai

The file SAMPLE1.fastq contains DNA sequence reads for sample SAMPLE1.

A fastq file consists of a series of multi-line records. Each record starts with a read name, followed by a DNA sequencing, a separator line, and a set of per base quality scores. Base quality scores estimate the probability of error at each sequenced base (a base quality of 10 denotes an error probability of 10%, base quality 20 denotes 1% error probability and base quality 30 denotes 0.1% error probability). These error probabilities are each encoded in a single character for compactness and can be decoded using an ASCII table (simply look up the ascii code for each base and subtract 33 to get base quality). By inspecting the FastQ file you should be able to learn about the length of reads being mapped and their base qualities. For example, try to figure out if base quality is typically higher at the start or end of each read...

Converting Alignments to BAM format

The .sai alignment format is specific to BWA, so the first thing to do is to convert the alignment to a more standard format that will be compatible with downstream analysis tools. We can do this with a combination of the bwa samse command and samtools view and samtoosl sort commands.

 bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:SAMPLE1" ref/human_g1k_v37_chr20.fa bwa.sai/SAMPLE1.sai fastq/SAMPLE1.fastq | \
 bin/samtools view -uhS - | bin/samtools sort -m 2000000000 - bams/SAMPLE1

You can check the use of parameters in the bwa manual. The result BAM file uses a compact binary format to represent the alignment of each short read to the genome. You can view the contents of the file using the samtools view command, like so:

 bin/samtools view bams/SAMPLE1.bam | more

The text representation of the alignment produced by samtools view describes the alignment of one read per line. The most interesting fields are column 1 (the read name), columns 3 and 4 (the alignment position), column 5 (the CIGAR string, describing any gaps in the alignment), and columns 10 and 11 (with the sequence and quality score). In this representation, all alignments are automatically converted to the forward strand.

Indexing the BAM file

If you reached this far, rejoice! The mapping process is almost done. We will now create an index for the file, which makes it convenient to quickly extract reads from any genome location. We do this with the samtools index command, like so:

 bin/samtools index bams/SAMPLE1.bam

Browsing Alignment Results

You can now view the contents of the alignment at any location using the samtools view and samtools tview commands. While the tview generates prettier output, it is not compatible with all screens. For example, to view reads overlapping starting at position 2,100,000 on chromosome 20, we could run:

  bin/samtools tview bams/SAMPLE1.bam ref/human_g1k_v37_chr20.fa

Then, type "g 20:2100000"

So let's recap: we have mapped reads to genome, converted them from a BWA specific format to a more commonly used format used by many different programs, sorted and indexed the results. In most cases, the next step would be to remove duplicate reads and to ensure that base quality scores are properly calibrated. To save time, we'll skip those steps now.

Till now, we only finished read mapping for one sample SAMPLE1. We need to repeat this step for other samples (SAMPL2 - SAMPLE40). You can try something like:

For c shell

 foreach file (`ls fastq/SAMPLE*.fastq | cut -f 2 -d '/' | cut -f 1 -d '.'`)
  echo $file
  bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/$file.fastq > bwa.sai/$file.sai
  bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:$file" ref/human_g1k_v37_chr20.fa bwa.sai/$file.sai fastq/$file.fastq | \
    bin/samtools view -uhS - | bin/samtools sort -m 2000000000 - bams/$file
  bin/samtools index bams/$file.bam
 end

For bash shell

for file in `ls fastq/SAMPLE*.fastq | cut -f 2 -d '/' | cut -f 1 -d '.'`;
 do echo $file;
 bin/bwa aln -q 15 ref/human_g1k_v37_chr20.fa fastq/$file.fastq > bwa.sai/$file.sai;
 bin/bwa samse -r "@RG\tID:ILLUMINA\tSM:$file" ref/human_g1k_v37_chr20.fa bwa.sai/$file.sai fastq/$file.fastq | \
   bin/samtools view -uhS - | samtools sort -m 2000000000 - bams/$file;
 bin/samtools index bams/$file.bam;
done


Once we finish the read mapping step and generate bam files for all samples, we can step to variant calling and genotype inference.

Calling variants and Inferring genotypes

Initial set of variant calls

You probably thought the initial mapping process was quite convoluted ... you'll be glad to know that the next few steps are much simpler.

The first thing we'll do is use samtools to generate an initial list of variant sites, using the mpileup command. This command looks at the bases aligned to each location and flags locations that are likely to vary. By default, the results are stored in BCF file, which can be converted into the more widely used VCF format using bcftools (a companion set of tools distributed with samtools).


  bin/samtools mpileup -Iuf ref/human_g1k_v37_chr20.fa bams/SAMPLE*bam | bin/bcftools view -bvcg - > result/chr20.mpileup.bcf
  bin/bcftools view result/chr20.mpileup.bcf  > result/chr20.mpileup.vcf


The VCF format is a simple text format. It starts with several header lines, which all start with the two '##' characters, and is followed by a single line per marker that provides both summary information about the marker and genotypes for each individual. You can review the contents of the VCF file using the 'more' command:

  more result/chr20.mpileup.vcf

Here are some questions for you to investigate:

  • How many variant sites were detected in this dataset? Try a command like this one:
  grep -vE ^# result/chr20.mpileup.vcf | wc -l

(The grep command line excludes all lines beginning with # and then the wc command counts the number of lines in the file).


Genotype Refinement Using Linkage Disequilibrium Information (TrioCaller)

The initial set of genotype calls is generated examining a single individual at a time. These calls are typically quite good for deep sequencing data, but much less accurate for low pass sequence data. In either case, they can be greatly improved by models that combine information across sites and individuals and consider the contraints imposed by parent-offspring trios.

Note: The current version only supports SNP data, so please filter indels before running TrioCaller. It supports VCF 4.0 and 4.1 formats with the exception of dropped missing trailing fields (e.g. use complete missing notation ./.:.:.:.,.,. rather than ./. for the genotype field)

Here is a summary of the TrioCaller command line options (these are also listed whenever you run the program with no parameters):

Available Options
   Shotgun Sequences: --vcf [], --pedfile [] 
      Markov Sampler: --seed [], --burnin [], --rounds [] 
          Haplotyper: --states [],  --errorRate [], --compact
             Phasing: --randomPhase , --inputPhased, --refPhased
        Output Files: --prefix [], --phase,  --interimInterval []


Explanation of Options
                 --vcf:	   Standard VCF file (4.0 and above).        
             --pedfile:    Pedigree file in MERLIN format.
                --seed:    Seed for sampling, default 123456.
              --burnin:    The number of rounds ignored at the beginning of sampling.
              --rounds:    The total number of iterations.
              --states:    The number of haplotyes used in the state space. The default is the maximum number:  2*(number of founders -1).
           --errorRate:    The pre-defined base error rate. Default 0.01.
         --randomPhase:    The initial haplotypes are inferred from the single marker. Default option.
         --inputPhased:	   The initial haplotypes are directly from input VCF file (with "|" as separator in the genotype column).
           --refPhased:	   The initial haplotypes are built on reference alleles from VCF file.
              --prefix:    The prefix of output file   
     --interimInterval:    The number of rounds for interim outputs

Note: The pedigree files require complete trio structures (all three members of the trio exist in the file). For parent-offspring pair, create a "fake" parent in the pedigree file or code them as unrelated individuals. The order of the names in the pedigree file is NOT necessary to be consistent with that in .vcf file. The computation will be intensive if the number of samples are large. You can use option "--states" to reduce the computation cost (e.g. start with "--states 50")

To complete our example analysis, we could run:

 bin/TrioCaller --vcf result/chr20.mpileup.vcf --pedfile ped/triocaller.ped --states 50 --rounds 10 --prefix result/chr20.triocaller

The format of output file is same as the input file. Again, you can review the contents of the updated VCF file using the more command:

  more  result/chr20.triocaller.vcf

All right. Congratulations! You have come to the end and learned basic skills for accurate genotype calling in trios.

If you have any question or comment, feel free to contact Wei Chen at weichen.mich@gmail.com or Goncalo Abecasis at goncalo@umich.edu

Citation

Chen W, Li B, Zeng Z, Sanna S, Sidore C, Busonero F, Kang HM, Li Y, Abecasis GR.  Genotype calling and haplotyping in parent-offspring trios. Genome Res. 2013 Jan;23(1):142-51 LINK