所需文件:
fasta格式的基因组序列文件GRCh38.fa
gtf或gff格式的基因注释文件GRCh38.gtf
1 安装gffread软件
我一般是通过conda安装
conda install bioconda::gffread
2 提取转录本序列、CDS和蛋白序列
使用代码gffread -h
可以参考所有可用参数
2.1 获取转录本序列
gffread GRCh38.gtf -g GRCh38.fa -w GRCh38.transcripts.fa
获取转录本格式如下
head GRCh38.transcripts.fa
>ENST00000608838
ACAGGAATTCATATCGGGGTGATCACTCAGAAGAAAAGGTGAATACCGGATGTTGTAAGCTATTGAACTG
CCACAAGTGATATCTTTACACACCATTCTGCTGTCATTGGGTAGCTTTGAACCCCAAAAATGTTGGAAGA
ATAATGTAGGACATTGCAGAAGACGATGTTTAGATACTGAAAGGTACATACTTCTTTGTAGGAACAAGCT
ATCATGCTGCATTTCTATAATATCACATGAATATACTCGACGACCAGCATTTCCTGTGATTCACCTAGAG
2.2 获取CDS序列
# 获取CDS序列
gffread GRCh38.gtf -g GRCh38.fa -x GRCh38.cds.fa
获取CDS格式如下
head GRCh38.cds.fa
>ENST00000382410
ATGAATATCCTGATGCTGACCTTCATTATCTGTGGGTTGCTAACTCGGGTGACCAAAGGTAGCTTTGAAC
CCCAAAAATGTTGGAAGAATAATGTAGGACATTGCAGAAGACGATGTTTAGATACTGAAAGGTACATACT
TCTTTGTAGGAACAAGCTATCATGCTGCATTTCTATAATATCACATGAATATACTCGACGACCAGCATTT
CCTGTGATTCACCTAGAGGATATAACATTGGATTATAGTGATGTGGACTCTTTTACTGGTTCCCCAGTAT
CTATGTTGAATGATCTGATAACATTTGACACAACTAAATTTGGAGAAACCATGACACCTGAGACCAATAC
TCCTGAGACTACTATGCCACCATCTGAGGCCACTACTCCCGAGACTACTATGCCACCATCTGAGACTGCT
ACTTCCGAGACTATGCCACCACCTTCTCAGACAGCTCTTACTCATAATTAA
>ENST00000382398
ATGAAGTCCCTACTGTTCACCCTTGCAGTTTTTATGCTCCTGGCCCAATTGGTCTCAGGTAATTGGTATG
2.3 获取蛋白序列
# 获取蛋白序列
gffread GRCh38.gtf -g GRCh38.fa -y GRCh38.protein.fa
获取蛋白序列格式如下
head GRCh38.protein.fa
>ENST00000382410
MNILMLTFIICGLLTRVTKGSFEPQKCWKNNVGHCRRRCLDTERYILLCRNKLSCCISIISHEYTRRPAF
PVIHLEDITLDYSDVDSFTGSPVSMLNDLITFDTTKFGETMTPETNTPETTMPPSEATTPETTMPPSETA
TSETMPPPSQTALTHN
>ENST00000382398
MKSLLFTLAVFMLLAQLVSGNWYVKKCLNDVGICKKKCKPEEMHVKNGWAMCGKQRDCCVPADRRANYPV
FCVQTKTTRISTVTATTATTTLMMTTASMSSMAPTPVSPTG
>ENST00000382388
MGLFMIIAILLFQKPTVTEQLKKCWNNYVQGHCRKICRVNEVPEALCENGRYCCLNIKELEACKKITKPP
RPKPATLALTLQDYVTIIENFPSLKTQST
3 获取基因启动子序列
这里获取基因启动子序列的主要思路:根据转录起始位置ATG
前1000至后500(大家可根据需要自行修改),然后使用bedtools软件提取序列
3.1 获取启动子区域
sed 's/"/\t/g' GRCh38.gtf | awk 'BEGIN{OFS=FS="\t"}{if($3=="gene") {if($7=="+") {start=$4-1000; end=$4+500;} else {if($7=="-") start=$5-500; end=$5+1000; } if(start<0) start=0; print $1,start,end,$14,$10,$7;}}' >GRCh38.promoter.bed
获取启动子区域如下 (这个bed文件也可以用于ChIP-seq类型的数据分析确定peak是否在启动子区域)
head GRCh38.promoter.bed
chr20 86250 87750 DEFB125 ENSG00000178591 +
chr20 141369 142869 DEFB126 ENSG00000125788 +
chr20 156470 157970 DEFB127 ENSG00000088782 +
chr20 189181 190681 DEFB128 ENSG00000185982 -
chr20 226258 227758 DEFB129 ENSG00000125903 +
chr20 256736 258236 DEFB132 ENSG00000186458 +
chr20 266186 267686 AL034548.1 ENSG00000272874 +
chr20 290278 291778 C20orf96 ENSG00000196476 -
chr20 295968 297468 ZCCHC3 ENSG00000247315 +
chr20 347724 349224 NRSN2-AS1 ENSG00000225377 -
3.2 安装bedtools
依然使用conda安装
conda install bioconda::gffread
3.3 使用bcftools提取序列
-name: 输出基因名字(bed文件的第四列)
-s: 考虑到正反链(对于启动子区域,是否考虑链的信息关系不太大)
bedtools getfasta -name -s -fi GRCh38.fa -bed GRCh38.promoter.bed >GRCh38.promoter.fa
获取启动子序列信息如下:
head GRCh38.promoter.fa | cut -c 1-60
>DEFB125::chr20:86250-87750(+)
ATAATTTGAAGTGAGGTAATGTGATTCCTCTAGTTTTGTTCTTTTTGCTTAGGATGGCTT
>DEFB126::chr20:141369-142869(+)
AATATTCAAGAGAATGCCAAGAAAGCTACAAGAACAAATAGCAGGTCAGTCGTTGCCTGG
>DEFB127::chr20:156470-157970(+)
ATATCCGTCACCTCAAACATTTATCATTTGTATTGGGAACATTCAAAATCCTCTCTTCTA
>DEFB128::chr20:189181-190681(-)
AAAAAAGAAAAAGAACTCCAAGTCTAATAAGACCAGAGACCTGCCCTTTATGGGTCTGCA
>DEFB129::chr20:226258-227758(+)
GAGTGGAAGGTGGGAGGAGGGAGAGGATGAGGAAAAATAACTAATGGACACTAGGCTTAA
如果不想要坐标信息,可对序列名字做一下简化
cut -d ':' -f 1 GRCh38.promoter.fa >GRCh38.promoter.simplename.fa
head GRCh38.promoter.simplename.fa | cut -c 1-60
>DEFB125
ATAATTTGAAGTGAGGTAATGTGATTCCTCTAGTTTTGTTCTTTTTGCTTAGGATGGCTT
>DEFB126
AATATTCAAGAGAATGCCAAGAAAGCTACAAGAACAAATAGCAGGTCAGTCGTTGCCTGG
>DEFB127
ATATCCGTCACCTCAAACATTTATCATTTGTATTGGGAACATTCAAAATCCTCTCTTCTA
>DEFB128
AAAAAAGAAAAAGAACTCCAAGTCTAATAAGACCAGAGACCTGCCCTTTATGGGTCTGCA
>DEFB129
GAGTGGAAGGTGGGAGGAGGGAGAGGATGAGGAAAAATAACTAATGGACACTAGGCTTAA
4 获取基因gDNA序列
4.1 获取基因gDNA区域
提取基因序列的操作也类似于提取启动子序列。这里要注意GFF文件的序列位置是从1
开始,而bed
文件的位置是从0
开始,前闭后开,所以要对序列的起始位置进行-1的操作。
type="gene"
sed 's/"/\t/g' GRCh38.gtf | awk -v type="${type}" 'BEGIN{OFS=FS="\t"}{if($3==type) {print $1,$4-1,$5,$14,".",$7}}' >GRCh38.gene.bed
head GRCh38.gene.bed
chr20 87249 97094 DEFB125 . +
chr20 142368 145751 DEFB126 . +
chr20 157469 159163 DEFB127 . +
chr20 187852 189681 DEFB128 . -
chr20 227257 229886 DEFB129 . +
chr20 257735 261096 DEFB132 . +
4.2 获取基因gDNA序列
bedtools getfasta -name -s -fi GRCh38.fa -bed GRCh38.gene.bed >GRCh38.gene.fa
# 查看序列
head GRCh38.gene.fa | cut -c 1-60
>DEFB125::chr20:87249-97094(+)
ACAGGAATTCATATCGGGGTGATCACTCAGAAGAAAAGGTGAATACCGGATGTTGTAAGC
>DEFB126::chr20:142368-145751(+)
GCCATACACTTCAGCAGAGTTTGCAACTTCTCTTCTAAGTCTTTATCCTTCCCCCAAGGC
>DEFB127::chr20:157469-159163(+)
CTCTGAGGAAGGTAGCATAGTGTGCAGTTCACTGGACCAAAAGCTTTGGCTGCACCTCTT
>DEFB128::chr20:187852-189681(-)
GGCACACAGACCACTGGACAAAGTTCTGCTGCCTCTTTCTCTTGGGAAGTCTGTAAATAT
5 获取非编码RNA的序列
在GTF文件中有转录本类型的注释,包含下面这些注释类型
ntisense_RNA
lincRNA
miRNA
misc_RNA
processed_pseudogene
processed_transcript
protein_coding
rRNA
scaRNA
sense_intronic
sense_overlapping
snoRNA
snRNA
TEC
transcribed_processed_pseudogene
transcribed_unitary_pseudogene
transcribed_unprocessed_pseudogene
unitary_pseudogene
unprocessed_pseudogene
在gff文件中筛选lincRNA
,之后用gffread提取
grep 'transcript_biotype "lincRNA"' GRCh38.gtf >GRCh38.lincRNA.gtf
gffread GRCh38.lincRNA.gtf -g GRCh38.fa -w GRCh38.lincRNA.fa
head GRCh38.lincRNA.fa | cut -c 1-60
>ENST00000608495
GTCGCACGCGCTGGCCAAACGGGCGCACCAGACACTTTTCAGGGCCCTGCCAAAGACCTC
CTGGCGTCCCAGACACAAGAGATCCAGGCCAAGACTCACACTTCACAAGATACACAGACA
GGAACAGGAAATTCCATGAAACTTCCATTTACCCAATTAGCCGGACTCACTGAGCCCCAG
TCAACCAACTCCTACTAAAATTAAAAAGTAATGTGTGGTATAGATTGGAATAATAGACAT
AAACGATGGGAGGCGGAGAGGGGTGAGGGTTGAAAAATTACCTATTGGGTGCAACATTCA
AATGGGGCACTAGAAGCCCACTCCACCACTATGCAATATATGTATTTGTACCCCGTAAAT