生信人

找回密码
立即注册
搜索
热搜: 活动 交友 discuz
发新帖

0

收听

12

听众

279

主题
发表于 2022-7-1 14:53:10 | 查看: 882| 回复: 0
samtools使用案例演示
  1. mkdir 52.samtools;cd 52.samtools;
  2. cp ../52.bwa/mgh78578.sam all.sam

  3. #1 sam文件验证
  4. samtools quickcheck *.sam  && echo 'all ok' || echo 'fail!'

  5. #2 sam和bam格式转换
  6. samtools view -O bam -o all.bam all.sam  
  7. samtools view all.bam -o all.sam
  8. #转换成cram格式,很少用
  9. samtools view -O cram -o all.cram all.sam -T MGH78578.fasta

  10. #3 bam排序
  11. samtools sort -@ 4 -m 12G -O bam -o all.sorted.bam all.sam  

  12. #4 排序后建立索引
  13. samtools index all.sorted.bam  

  14. #5 比对结果统计
  15. samtools stats all.sorted.bam

  16. #6 按照flag值进行统计
  17. samtools flagstat all.sorted.bam

  18. #7 按不同染色体统计
  19. samtools idxstats all.sorted.bam

  20. #8 统计目标区域覆盖度
  21. samtools bedcov test.bed all.sorted.bam

  22. #9 统计每个位点测序深度depth
  23. samtools depth all.sorted.bam

  24. #10计算覆盖比率
  25. samtools coverage all.sorted.bam

  26. #11 按照染色体拆分bam
  27. bamtools split -in all.sorted.bam -reference
  28. 拆成双端和单端
  29. bamtools split -in all.sorted.bam -paired -stub un

  30. #12 合并bam
  31. samtools cat -o cat.bam all.sorted.REF_contig_1_pilon.bam all.sorted.REF_contig_2_pilon.bam all.sorted.REF_contig_3_pilon.bam all.sorted.REF_unmapped.bam
  32. samtools merge merge.bam all.sorted.REF_contig_1_pilon.bam all.sorted.REF_contig_2_pilon.bam all.sorted.REF_contig_3_pilon.bam all.sorted.REF_unmapped.bam
  33. #13 统计bam并绘图  
  34. samtools stats all.sorted.bam >all.stats  
  35. plot-bamstats -p test all.stats

  36. #14 重新打乱
  37. samtools collate all.sorted.bam -o all.shuffle.bam

  38. #15 过滤数据
  39. #将没有比对上的reads筛选出来
  40. samtools view -f 4 all.sorted.bam

  41. #16 保留比对上的reads输出出来
  42. samtools veiw -F 4 all.sorted.bam

  43. #17 输出fastq格式
  44. samtools fastq all.sorted.bam -1 A.1.fq.gz -2 A.2.fq.gz
  45. #输出fasta格式
  46. samtools fasta all.sorted.bam -1 A.1.fa.gz -2 A.2.fa.gz

  47. #18 文本方式查看结果tview  
  48. samtools tview all.sorted.bam  
  49. samtools tview all.sorted.bam ref.fna  

  50. #19 bam转换为bed格式
  51. bedtools bamtobed -i all.sorted.bam

  52. #20 mpileup
  53. samtools mpileup --reference ../data/mgh78578.fasta  all.sorted.bam
复制代码
您需要登录后才可以回帖 登录 | 立即注册

QQ|Archiver|手机版|小黑屋|生信人

GMT+8, 2024-5-3 06:27 , Processed in 0.051010 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表