Quality of Mapping Exercise

From wiki
Revision as of 18:52, 6 May 2017 by Rf (talk | contribs) (Rf moved page I2rda mqx to Quality of Mapping)
Jump to: navigation, search

Aims

Concerns controlling mapping quality

In this part you will learn to:

  • mark duplicated read pairs
  • check the fragment size distribution
  • check the read coverage over the gene body
  • check if we have enough data

You will use the following software tools:

The data set you'll be using is downloaded from ENA (http://www.ebi.ac.uk/ena/data/view/SRP019027). The reads belong to sample SRR769316. The data set is tailored with respect to the time allocated for the exercise. Reads were aligned to the first 20 Mb of chromosome 19 of the mouse reference genome (GRCm38/mm10) using TopHat.

You will use the following files:

  • SRR769316.bam: aligned reads
  • mm10_chr19-1-20000000_Ensembl.bed: Ensembl mouse gene models

Data

The data is available in the directory 05_Mapping_quality:

cd /home/training/Data/05_Mapping_quality_control/

Try to have a look at the file SRR769316.bam using less:

less SRR769316.bam

BAM files are binary files and thus not human-readable. To be able to read a BAM file you can either convert it to a human-readable SAM file, or you can directly view it using samtools:

samtools view SRR769316.bam | less -S

where:

  • -S: chop long lines instead of folding them

You can navigate through a line by using the [Right arrow] and [Left arrow] keys. You can navigate through the file line by line using the [Up arrow] and [Down arrow] keys, or page by page using the [Enter] key, [Space] bar and [B] key. You can exit the file using the [Q] key.

Marking duplicates

Picard MarkDuplicates marks all duplicate read pairs in our dataset:

java -jar $PICARD/MarkDuplicates.jar I=SRR769316.bam \
O=SRR769316_duplicates_marked.bam M=SRR769316_duplicates.metrics.csv

where:

  • I=: input SAM or BAM file to analyze
  • O=: the output file to write marked records to
  • M=: file to write duplication metrics to

MarkDuplicates creates two files, i.e. a BAM file with all duplicate records flagged, and a file containing the duplication metrics. Open the file SRR769316_duplicates.metrics.csv with gnumeric:

gnumeric SRR769316_duplicates.metrics.csv &
  • What is the duplicate rate of sample SRR769316?

Checking the fragment size distribution

RSeQC's inner_distance.py script calculates the inner distance (or insert size) between two paired RNA reads:

inner_distance.py -i SRR769316.bam \ -r Reference/mm10_chr19-1-20000000_Ensembl.bed -o SRR769316

where:

  • -i: alignment file in BAM or SAM format
  • -r: reference gene model in BED format
  • -o: prefix of output file(s)

The file with reference gene models is used to correct for any introns that are present between the reads.

The script first determines the genomic (DNA) size between two paired reads: D_size = read2_start - read1_end, then

  • if two paired reads map to the same exon: inner distance = D_size
  • if two paired reads map to different exons: inner distance = D_size - intron_size
  • if two paired reads map to non-exonic region (such as intron and intergenic region): inner distance = D_size

The inner distance might be a negative value if the two reads overlapped.

Open the plot:

xpdf SRR769316.inner_distance_plot.pdf &
  • Knowing that the read length is 99 bases what is the mean length of the fragments?

Checking the read coverage over the gene body RSeQC's geneBody_coverage.py script reports the read coverage of all genes in the percentile of their length:

geneBody_coverage.py -i SRR769316.bam \ -r Reference/mm10_chr19-1-20000000_Ensembl.bed \ -o SRR769316

Open the plot:

xpdf SRR769316.geneBodyCoverage.pdf &
  • Is there a 3' or 5' bias?
  • How would you explain the bell shaped curve?

Checking if we have enough data RSeQC's junction_annotation.py script compares detected splice junctions to reference gene models:

junction_annotation.py -i SRR769316.bam \
-r Reference/mm10_chr19-1-20000000_Ensembl.bed -o SRR769316

Splicing annotation is performed at two levels: splice event level and splice junction level. All detected junctions can be grouped into 3 exclusive categories:

  1. annotated: Known junction. Both 5’ and 3' splice site are present in the reference gene model.
  2. complete_novel: Complete new junction. Neither of the two splice sites is present in the reference gene model.
  3. partial_novel: Partially new junction. Only one of the splice sites is present in the reference gene model.

Open the plots:

xpdf SRR769316.splice_*.pdf &

Is the data mostly supporting known or novel junctions?

RSeQC's junction_saturation.py script checks for saturation by resampling 5%, 10%, 15%, ..., 95% of total alignments, and then detects splice junctions from each subset and compares them to reference gene model:

junction_saturation.py -i SRR769316.bam \
-r Reference/mm10_chr19-1-20000000_Ensembl.bed -o SRR769316 -v 5

where:

  • -v: minimum number of supporting reads to call a junction (default=1)

This shows if more sequencing will enable the discovery of new events.

Open the plot:

xpdf SRR769316.junctionSaturation_plot.pdf &

Do you think more sequencing is needed?

Some issues are only detectable in the context of the genome:

  • Duplicate reads
  • Fragment size distribution
  • Gene coverage
  • Completeness of data