常見NGS分析相關檔案格式- Common NGS data analysis-related files

常見NGS分析相關檔案格式- Common NGS data analysis-related files
Photo by Ilya Pavlov / Unsplash

這邊會以NGS常出現的檔案來介紹: fasta, FASTQ, sam, bam, bai, bed, bim, fam, vcf, bcf, gff/gtf, GWAS summary statistics.

fasta
最常見的就是 - fasta file或是 fasta 是最常見的NGS sequencer 輸出檔案。
fasta 檔案中一定是以 ">"開頭,在 ">"後可以打上sample名稱或是基因名稱,換行之後,就是核苷酸或是蛋白質序列資訊,結尾有可能會是".fa", ".fas"或".fasta"。

>NC_003075.7:10707344-10709015 Arabidopsis thaliana chromosome 4, partial sequence
TCGTCATCATCGACAATAAATGGCATGAAAACAACCAGCACACATTACTATATAAACCGATTCATCTAGTAAGTCCAAAGTCACACAAACATTAAACAATCTAAACACACAACAATCCAAAAGAAAAAAGAAAAAAAAAAAAAATGGCTTCAAATTCAGCACTTCTCATGAAAACAATCTTCCTCGTACTCATTTTTGTCTCTTTTGCAA

fasta檔案">"之後接的會是與序列相關的名稱,除了名稱也可以加入其他細節,如上面的例子。

FASTQ
FASTQ 和 .fasta 檔案類似,FASTQ 多紀錄定序資料的quality score.
以常用的illumina sequencer 舉例,定序產出的資料就是.fasta-q。
在illumina網站上有著詳細的FASTQ檔案格式介紹,在這邊就簡單地將網站資訊 (ref2)整理如下:

  1. 每個序列都會有著一段"identifier"。identifier 包含了定序的資訊、定序機器序號、flowcell ID、跑檢體的位置(在flow中的位置)以及讀取方向(R1, R2)。
  2. 序列已A, C, T, G 和 N 表示。 並且使用(+)表示分行。
  3. quality score 表示如下:
    @<instrument>:<run number>:<flowcell ID>:<lane>:<tile>:<x-pos>

sam, bam and bai
sam 全名是 Sequence Alignment Map (SAM), bam 全名是Binary Alignment Map (BAM),sam 和 bam檔案裡面是紀錄了alignment的資訊。bam 檔案是binary格式,沒有辦法直接閱讀,需要使用特定工具才能打開,例如:samtools. samtools view file.bam bai 是 bam file "index"檔案,可以幫助更快速找到ban裡面的基因位置。
sam 以及 bam 都會有alignment 和 alignment quality的資訊。而各個資訊會有相關的簡稱或以特殊代號表示方式記錄在檔案中。下圖為sam檔案格式,簡單介紹幾個tag, i.e. @HD 檔案基本資料, 下面又會細分 VN, SO, GO, SS 表示為不同的alignment方式。 @SQ 和ref 相關的資訊,又細分為 SN (ref name), LN (ref sequence length), AH, An, AS, DS, M5, SP, Tp, UR.
而sam檔案會產出共11欄資訊,分別為 QNAME FLAG RNAME POS MAPQ CIGAR RNEXT PNEXT TLEN SEQ QUAL (下面有更詳細表格解釋)

(ref3)
fig1. . sam file overview
fig2. columns information in sam

在分析過程中,這些資訊都可以幫助我們更快速了解資料是如何處理,也可以利用資訊過濾分析過程中不需要的序列。QNAME和RNAME必須要相同,POS的範圍是1- @SQ LN的範圍。bam 也和 sam 相同,但裡面的資訊會有不同如下圖:

fig3. bam flag information

bed, bim and fam
這三種檔案在處理genetics上很常出現,尤其是使用PLINK這個工具,應該說這三個檔案為PLINK主要使用的輸出/輸入檔案。bim主要是記錄SNP的名稱(id)以及位置。在進行分析時,bed, bim, fam 這三種檔案都是必須同時搭配使用。

fig5. bim file overview

bim檔案裡面為:
1. Chromosome code (either an integer or 'X'/'Y'/'XY'/'MT'; '0' indicates unknown)
2. Variant identifier
3. Position in morgans or centi-morgans (safe to use dummy value of '0')
4. Base-pair coordinate (1-based; limited to 231-2)
5. Allele 1 (corresponding to clear bits in .bed; usually minor)
6. Allele 2 (corresponding to set bits in .bed; usually major)

.bed (PLINK binary biallelic genotype table)。另外,bed 等同於PLINK舊版中的ped。格式上如下圖所示:

fig6. bed file overview

bed 檔案中的數字代表的是genotype codes, 分別為:
00 - Homozygous for the first allele in .bim file
01 - Missing genotype
10 - Heterozygous
11 - Homozygous for second allele in .bim file

最後.fam (PLINK sample information file),檔案內容如下:
1. Family ID ('FID')
2. Within-family ID ('IID'; cannot be '0')
3. Within-family ID of father ('0' if father isn't in dataset)
4. Within-family ID of mother ('0' if mother isn't in dataset)
5. Sex code ('1' = male, '2' = female, '0' = unknown)
6. Phenotype value ('1' = control, '2' = case, '-9'/'0'/non-numeric = missing data if case/control)

vcf and bcf
variant call format (vcf) 檔案會在alignment之後才會出現在分析中。vcf 檔案紀錄了 genetic variations, 裡面有包含SNP, indels. vcf 很特別的其中一個特點就是 - header。header 前方會標記『##』,裡面記錄了產生vcf的工具以及flags,如果有合併檔案或是過濾genetic都會被記錄在header.
vcf 會記錄所有samples 並且會有flag標註variations 的quality,而flag可以當作過濾資料的資訊。bcf 就是binary格式的vcf,但沒有header。如果想要知道flag的資訊可以參考下方ref7

fig7. vcf and bcf overview

GFF (General Feature Format)/ GTF (General Transfer Format)
這個檔案使用在做gene annotate分析上使用,這兩個檔案會記錄基因,以及基因的位置資料,做 Annotation時可以用來辨認基因資料。

GWAS summary statistics
GWAS summary statistics 是GWAS資料的結果,檔案裡面記錄了GWAS分析之後與trait相關性高的genetic 變異,以及相關性的統計資料,GWAS summary statistics常使用在post-GWAS 分析,也就是Polygenic Risk Score (PRS) models.
期刊發表的GWAS summary statistics會上傳在:GWAS catalog(https://www.ebi.ac.uk/gwas/home)


ref:
1. https://knowledge.illumina.com/software/general/software-general-reference_material-list/000002211
2. https://help.basespace.illumina.com/files-used-by-basespace/fastq-files
3. https://samtools.github.io/hts-specs/SAMv1.pdf
4. https://www.cog-genomics.org/plink/1.9/formats#bed
5. https://www.cog-genomics.org/plink/1.9/formats#bim
6. https://www.cog-genomics.org/plink/1.9/formats#fam
7. https://en.wikipedia.org/wiki/Variant_Call_Format
8. https://www.ebi.ac.uk/gwas/docs/summary-statistics-format