{"id":300,"date":"2024-10-21T08:20:21","date_gmt":"2024-10-21T00:20:21","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=300"},"modified":"2025-10-11T20:16:19","modified_gmt":"2025-10-11T12:16:19","slug":"samtools-flagstat-%e7%bb%93%e6%9e%9c%e8%a7%a3%e8%af%bb","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2024\/10\/21\/samtools-flagstat-%e7%bb%93%e6%9e%9c%e8%a7%a3%e8%af%bb\/","title":{"rendered":"samtools flagstat \u7ed3\u679c\u89e3\u8bfb"},"content":{"rendered":"<h3>Samtools flagstat<\/h3>\n<pre><code>samtools flagstat EXAMPLE.bam &gt; EXAMPLE.tsv\ncat EXAMPLE.tsv\n\n288643764 + 0 in total (QC-passed reads + QC-failed reads)\n288352428 + 0 primary\n0 + 0 secondary\n291336 + 0 supplementary\n153911191 + 0 duplicates\n153911191 + 0 primary duplicates\n288570589 + 0 mapped (99.97% : N\/A)\n288279253 + 0 primary mapped (99.97% : N\/A)\n288352428 + 0 paired in sequencing\n144176214 + 0 read1\n144176214 + 0 read2\n287241680 + 0 properly paired (99.61% : N\/A)\n288249748 + 0 with itself and mate mapped\n29505 + 0 singletons (0.01% : N\/A)\n352742 + 0 with mate mapped to a different chr\n275146 + 0 with mate mapped to a different chr (mapQ&gt;=5)\n\n# \u6279\u91cf\u8fd0\u884c\u4ee3\u7801\uff1a\nfor f in *.sort.markdup.bam; do\n    samtools flagstat &quot;$f&quot; &gt; &quot;${f%.sort.markdup.bam}.tsv&quot;\ndone\n\n# \u8f93\u51fa\u672a\u6bd4\u5bf9\u4e0a\u7684 reads \u4e3a FASTQ\nsamtools fastq -f 4 -F 2304 input.sort.markdup.bam &gt; input.unmapped.fastq\n# \u63d0\u53d6\u5e8f\u5217\uff0c\u628a\u8fd9\u4e2a\u6587\u4ef6\u5bfc\u5165BLAST\u67e5\u770b\u5bfc\u81f4\u6c61\u67d3\u7684\u7269\u79cd\nsamtools fastq -f 4 -F 2304 input.sort.markdup.bam &gt; input.unmapped.fastq<\/code><\/pre>\n<p>\u4ece\u7b2c\u4e00\u884c\u81f3\u7b2c\u5341\u4e00\u884c\u5206\u522b\u8868\u793a\uff1a<\/p>\n<ol>\n<li>QC pass\u7684reads\u7684\u6570\u91cf\u4e3a2499971\uff0c\u672a\u901a\u8fc7QC\u7684reads\u6570\u91cf\u4e3a0\uff0c\u610f\u5473\u7740\u4e00\u5171\u67092499971\u6761reads\uff1b<br \/>\n\u91cd\u590dreads\u7684\u6570\u91cf\uff0cQC pass\u548cfailed<\/li>\n<li>\u6bd4\u5bf9\u5230\u53c2\u8003\u57fa\u56e0\u7ec4\u4e0a\u7684reads\u6570\u91cf\uff1b<\/li>\n<li>paired reads\u6570\u636e\u6570\u91cf\uff1b<\/li>\n<li>read1\u7684\u6570\u91cf\uff1b<\/li>\n<li>read2 \u7684\u6570\u91cf\uff1b<\/li>\n<li>\u6b63\u786e\u5730\u5339\u914d\u5230\u53c2\u8003\u5e8f\u5217\u7684reads\u6570\u91cf\uff1b<\/li>\n<li>\u4e00\u5bf9reads\u90fd\u6bd4\u5bf9\u5230\u4e86\u53c2\u8003\u5e8f\u5217\u4e0a\u7684\u6570\u91cf\uff0c\u4f46\u662f\u5e76\u4e0d\u4e00\u5b9a\u6bd4\u5bf9\u5230\u540c\u4e00\u6761\u67d3\u8272\u4f53\u4e0a\uff1b<\/li>\n<li>\u4e00\u5bf9reads\u4e2d\u53ea\u6709\u4e00\u6761\u4e0e\u53c2\u8003\u5e8f\u5217\u76f8\u5339\u914d\u7684\u6570\u91cf\uff1b<\/li>\n<li>\u4e00\u5bf9reads\u6bd4\u5bf9\u5230\u4e0d\u540c\u67d3\u8272\u4f53\u7684\u6570\u91cf\uff1b<\/li>\n<li>\u4e00\u5bf9reads\u6bd4\u5bf9\u5230\u4e0d\u540c\u67d3\u8272\u4f53\u7684\u4e14\u6bd4\u5bf9\u8d28\u91cf\u503c\u5927\u4e8e5\u7684\u6570\u91cf\u3002<\/li>\n<\/ol>\n<h3>Samtools depth \u6d4b\u5e8f\u6df1\u5ea6\u7edf\u8ba1<\/h3>\n<pre><code># samptools depth\uff1a \u8f93\u51fafastq\u6570\u636e\u6bd4\u5bf9\u5230\u67d3\u8272\u4f53\u7684\u4f4d\u70b9\u6df1\u5ea6\u5927\u4e8e0\u7684\u6df1\u5ea6\u4fe1\u606f\u3002\n# samtools depth -a\uff1a\u8f93\u51fafastq\u6570\u636e\u6bd4\u5bf9\u5230\u67d3\u8272\u4f53\u7684\u6240\u6709\u4f4d\u70b9\u7684\u6d4b\u5e8f\u6df1\u5ea6\u4fe1\u606f\uff0c\u5305\u542b0\u6df1\u5ea6\u4f4d\u70b9\u3002\n# samtools depth -aa\uff1a\u8f93\u51fafasta\u6587\u4ef6\u4e2d\u6240\u6709\u67d3\u8272\u4f53\u4e0a\u4f4d\u70b9\u7684\u6df1\u5ea6\u4fe1\u606f\uff0c\u5305\u542bfastq\u6570\u636e\u6ca1\u6709\u6bd4\u5bf9\u5230\u7684\u67d3\u8272\u4f53\u3002\n\nsamtools depth test.sorted.bam &gt; depth.txt  \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Samtools flagstat samtools flagstat EXAMPLE.bam &gt; EX&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-300","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":5,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"predecessor-version":[{"id":629,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/300\/revisions\/629"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}