To play around with a few samtools
commands, first change directories into the directory containing all BAM files.
$ cd ~/unix_workshop/rnaseq/results/STAR/bams
$ samtools view -b -h -F 4 Mov10_oe_1_Aligned.sortedByCoord.out.bam > Mov10_oe_1_Aligned.onlyAligned.bam
$ bamtofastq -o Mov10_oe_1_Mapped.fastq --no-unaligned Mov10_oe_1_Aligned.onlyMapped.bam
$ samtools index Mov10_oe_1_Aligned.sortedByCoord.out.bam
$samtools view Mov10_oe_1_Aligned.sortedByCoord.out.bam chr1:200000-500000
$ samtools view -s 0.5 -b Mov10_oe_1_Aligned.sortedByCoord.out.bam > Mov10_oe_1_subsample.bam
$ samtools flagstat Mov10_oe_1_Aligned.sortedByCoord.out.bam
$ samtools view -h Mov10_oe_1_Aligned.sortedByCoord.out.bam | head -n 5 | samtools fillmd -e - ~/unix_workshop/rnaseq/reference_data/chr1.fa