(How to) Create a snippet of reads corresponding to a genomic interval
- Installed GATK tools
- Reference genome
- Coordinate-sorted, aligned and indexed BAM
Download example data
- Use the advanced tutorial bundle's human_g1k_v37_decoy.fasta as reference
- tutorial_6517.tar.gz contains four files: 6517_2Mbp_input.bam and .bai covering reads aligning to 10:90,000,000-92,000,000 and 6517_1Mbp_output.bam and .bai covering 10:91,000,000-92,000,000
- This How to is referenced in a tutorial on (How to) Generate an unmapped BAM (uBAM).
- See this tutorial to coordinate-sort and index a BAM.
- See here for command line parameters accepted by all GATK tools.
- For applying interval lists, e.g. to whole exome data, see When should I use L to pass in a list of intervals.
Create a snippet of reads corresponding to a genomic interval using PrintReads
PrintReads merges or subsets sequence data. The tool automatically applies MalformedReadFilter and BadCigarFilter to filter out certain types of reads that cause problems for downstream GATK tools, e.g. reads with mismatching numbers of bases and base qualities or reads with CIGAR strings containing the N operator.
- To create a test snippet of RNA-Seq data that retains reads with Ns in CIGAR strings, use
Subsetting reads corresponding to a genomic interval using PrintReads requires reads that are aligned to a reference genome, coordinate-sorted and indexed. Place the
.bai index in the same directory as the
java -Xmx8G -jar /path/GenomeAnalysisTK.jar \ -T PrintReads \ -R /path/human_g1k_v37_decoy.fasta \ #reference fasta -L 10:91000000-92000000 \ #desired genomic interval chr:start-end -I 6517_2Mbp_input.bam \ #input -o 6517_1Mbp_output.bam
This creates a subset of reads from the input file,
6517_2Mbp_input.bam, that align to the interval defined by the
-L option, here a 1 Mbp region on chromosome 10. The tool creates two new files,
6517_1Mbp_output.bam and corresponding index
- For paired reads, the tool does not account for reads whose mate aligns outside of the defined interval. To filter these lost mate reads, use RevertSam's
To process large files, also designate a temporary directory.
TMP_DIR=/path/shlee #sets environmental variable for temporary directory