Samtools: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 31: Line 31:


Usage:  samtools <command> [options]}}
Usage:  samtools <command> [options]}}
== General usage == <!--T:3-->
SAMtools provides various (sub)tools for manipulating alignments in the SAM/BAM format. While working with high-throughput sequencing data, you will probably have to deal with SAM/BAM file formats. The most common task would be to convert your SAM (Sequence Alignment/Map) files to BAM (binary form of SAM) files. BAM files are compressed versions of SAM files and are much smaller in size. BAM files are also easy to manipulate and are ideal for storing large nucleotide sequence alignments. In recent years, an even more compressed CRAM version has been widely preferred for storage.
=== Converting a SAM file to a BAM file ===
Prior to converting, verify if your files carry a header section with character “@”. You can inspect the header section using the view command:
{{Command|samtools view -H my_sample.sam}}
To convert a SAM file with a header section to a bam file:
{{Command|samtools view -bo my_sample.bam my_sample.sam}}
Alternatively, samtools also supports the following format:
{{Command|samtools view -b my_sample.sam -o my_sample.sam}}
If header files are absent you can use the reference fasta file used to map the reads
{{Command|samtools view -bt ref_seq.fa -o my_sample.bam my_sample.sam}}
=== Sorting and indexing BAM files ===
You may also have to sort and index bam files for many downstream applications
{{Commands
|samtools sort my_sample.bam -o my_sample_sorted.bam
|samtools index my_sample_sorted.bam}}
You can also convert SAM files directly to a sorted BAM file
{{Commnd|samtools view -b my_sample.sam | samtools sort -o my_sample_sorted.bam}}
With sorted bam files and its respective index file with extension .bai you are all set for any downstream process such as variant calling, feature counts etc.
cc_staff
20

edits

Navigation menu