学习笔记-2-samtools的安装和使用

1.安装samtools环境
sudo apt install samtools
samtools
samtools view

(安装完成)

2. SAM格式转为BAM格式

为参考基因组建立索引,生成了prefix.fai文件

samtools faidx GCA_000012525.1_ASM1252v1_genomic.fna
less GCA_000012525.1_ASM1252v1_genomic.fna.fai
1.png
2.png
SAM2BAM
sam文件转为bam文件

samtools view -bhS -t GCA_000012525.1_ASM1252v1_genomic.fna.fai -o PCC7942_bwa.bam PCC7942_bwa.sam #(最后这个sam文件用自己目录的sam文件名)

3.png

(改为samtools view -bhS -t GCA_000012525.1_ASM1252v1_genomic.fna.fai -o PCC7942_bwa.bam test _bwa_P7942_bwa.sam
查看less PCC7942_bwa.bam

为bam文件排序,sort只能为bam文件排序,而不能为sam;不同版本samtools sort命令的-o参数不同

samtools sort PCC7942_bwa.bam -o PCC7942_bwa.bam.sorted
samtools index PCC7942_bwa.bam.sorted

统计比对结果
samtools depth PCC7942_bwa.bam.sorted>depth.txt
less depth.txt
samtools flagstat PCC7942_bwa.bam.sorted
26.png
3. 查看比对结果
(1)samtools tview

samtools tview PCC7942_bwa.bam.sorted GCA_000012525.1_ASM1252v1_genomic.fna

27.png

g, 输入:CP000100.1:1000
28.png

(2) artemis

https://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/014/698/905/GCA_014698905.1_ASM1469890v1/GCA_014698905.1_ASM1469890v1_genomic.gff.gz
Open, GCA_000012525.1_ASM1252v1_genomic.fna文件

a1.png

Read an entry, GCA_000012525.1_ASM1252v1_genomic.gff


33.png

Read Bam/vcf, PCC7942_bwa.bam.sorted (必须是排序、索引后的bam)


35.png

37.png
38.png

4. BAM2BCF

samtools mpileup -f GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted >bcf.txt
less bcf.txt

211.png

212.png

samtools mpileup -gf GCA_000012525.1_ASM1252v1_genomic.fna PCC7942_bwa.bam.sorted>PCC7942_bwa.bcf
less PCC7942_bwa.bcf

213.png

214.png

你可能感兴趣的:(学习笔记-2-samtools的安装和使用)