Skip to content

SAMtools #
Find similar titles

Structured data

Category
Analysis
Software

SAMtools (samtools) #

SAM #

SAM (Sequence Alignment/Map) 형식은 커다란 시퀀스 얼라인먼트를 저장하는 파일 포맷으로, 대부분의 시퀀싱 리드 매핑 프로그램들이 결과 포맷으로 사용하고 있다. SAM 파일은 시퀀싱 리드가 참조 유전체 서열의 어느 위치에 어떻게 매핑되었고 어떠한 서열로 이루어져 있는지 등, 매핑과 관련된 많은 정보를 담고 있으므로 대부분 파일 용량이 크다. 따라서, 파일 용량을 줄이기 위해서는 binary 형태인 BAM 포맷으로 변환하여 저장한다.

SAM 은 다양한 얼라인먼트 정보를 저장하고 있으며, index 파일을 생성해서 유전체 위치를 효과적으로 검색을 할 수도 있고, 전체의 얼라인먼트를 읽지 않아도 대부분 작업을 할 수 있습니다.

SAM format #

Col Field Description
1 QNAME Query template/pair NAME
2 FLAG bitwise FLAG
3 RNAME Reference sequence NAME
4 POS 1-based leftmost POSition/coordinate of clipped sequence
5 MAPQ MAPping Quality (Phred-scaled)
6 CIAGR extended CIGAR string
7 MRNM Mate Reference sequence NaMe (‘=’ if same as RNAME)
8 MPOS 1-based Mate POSistion
9 TLEN inferred Template LENgth (insert size)
10 SEQ query SEQuence on the same strand as the reference
11 QUAL query QUALity (ASCII-33 gives the Phred base quality)
12 OPT variable OPTional fields in the format TAG:VTYPE:VALUE

SAMtool #

SAM 포맷의 파일을 가지고 여러 가지 기능을 수행할 수 있는 커맨드 기반의 프로그램이다. SAMtools 로 분석하기 위해서는 SAM의 binary 형태인 BAM 으로 변환해야 한다. SAMtools 는 SAM 파일 안에서 얼라인먼트를 다루기 위한 다양한 프로그램을 제공합니다 (ex. sort, view, index, stats 등).

SAMtool 명령어 #

Col Field Description
1 view SAM<->BAM conversion
2 sort sort alignment file
3 mpileup multi-way pileup
4 depth compute the depth
5 faidx index/extract FASTA
6 tview text alignment viewer
7 index index alignment
8 idxstats BAM index stats (r595 or later)
9 fixmate fix mate information
10 flagstat simple stats
11 calmd recalculate MD/NM tags and '=' bases
12 merge merge sorted alignments
13 rmdup remove PCR duplicates
14 reheader replace BAM header
15 cat concatenate BAMs
16 targetcut cut fosmid regions (for fosmid pool only)
17 phase phase heterozygotes

SAM workflow #

  • SAM 파일을 binary 형태인 BAM 파일로 전환

    • samtools view를 이용해서 변환한다.

      samtools view -Sb -h -@ [threads] [SAM] -o [BAM]
      
      -S : input file 포맷 자동으로 확인함.
      -b : output file 포맷 BAM
      -h : SAM file header 출력 (사용하지 않으면, 매핑 결과부터 전환)
      -@ : 사용할 multi-core 수
      -o : samtools view의 결과 파일 (사용하지 않으면, STDOUT)
      
  • Data processing을 간소화하기 위한 sorting

    • 시퀀싱 리드 매핑 결과를 참조 유전체 서열의 포지션 별로 정렬하는 프로그램이다.
    • samtools sort를 이용해서 변환한다.

      samtools sort -@ [threads] -o [sorted.bam] [BAM]
      
      -o : samtools sort의 결과 파일 (사용하지 않으면, STDOUT)
      -@ : 사용할 multi-core 수
      
  • sorted.bam file 내의 매핑 결과를 빠르게 접근하기 위한 index

    samtool index -b -@ [threads] [sorted.bam] [out.index]
    
    -b : BAM file의 index (.bai 파일 생성)
    -@ : 사용할 multi-core 수
    

References #

  • SAMtools Website 1
  • SAMtools GitHub 2
  • Li, Heng, et al.: The sequence alignment/map format and SAMtools. Bioinformatics 2009, 2078-2079. 3

Incoming Links #

Related Articles #

Related Bioinformaticses #

Suggested Pages #

0.0.1_20210630_7_v33