...
Code Block |
---|
language | bash |
---|
title | Setup for samtools exercises |
---|
|
mkdir -p $SCRATCH/core_ngs/samtools
cd $SCRATCH/core_ngs/samtools
cp $CORENGS/yeastcatchup/for_stuffsamtools/*.bam* . |
References
Handy links
- The SAM format specification
- especially section 1.4 - alignment section fields
- Manual for SAMTools
- especially the 1st section on samtools view.
...
Code Block |
---|
|
module load biocontainers # takes a while
module load samtools
cd $SCRATCH/core_ngs/samtools
samtools view yeast_chip_pe.sort.bam | head |
With all the line wrapping, it looks pretty ugly. Still, you can pick out the CIGAR string in column 6. Let's select just that column with cut:
Code Block |
---|
|
samtools view yeast_chip_pe.sort.bam | cut -f 6 | head -20 |
...
Code Block |
---|
|
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | head -20 |
...
Code Block |
---|
|
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | head |
...
Code Block |
---|
language | bash |
---|
title | Count reads that mappedi with indels |
---|
|
samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | wc -l |
...
Code Block |
---|
language | bash |
---|
title | Count all mapped reads |
---|
|
samtools view -c -F 0x4 yeast_chip_pe.sort.bam |
There should be 547664 mapped alignments.
...
Code Block |
---|
language | bash |
---|
title | One-liner for calculating BAM alignment rate |
---|
|
echo "`samtools view -F 0x4 -c yeast_chip_pe.sort.bam` `samtools view -F 0x4 yeast_chip_pe.sort.bam | cut -f 6 | grep -P '[ID]' | wc -l`" | awk '{ print 100 * $2/$1,"%" }' |
...