{"id":673,"date":"2026-02-06T10:46:04","date_gmt":"2026-02-06T02:46:04","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=673"},"modified":"2026-04-16T20:17:56","modified_gmt":"2026-04-16T12:17:56","slug":"%e4%bd%bf%e7%94%a8-mosdepth-%e7%bb%9f%e8%ae%a1-wes-wgs-%e6%b5%8b%e5%ba%8f%e6%b7%b1%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2026\/02\/06\/%e4%bd%bf%e7%94%a8-mosdepth-%e7%bb%9f%e8%ae%a1-wes-wgs-%e6%b5%8b%e5%ba%8f%e6%b7%b1%e5%ba%a6\/","title":{"rendered":"\u4f7f\u7528 mosdepth \u7edf\u8ba1 WES\/WGS \u6d4b\u5e8f\u6df1\u5ea6"},"content":{"rendered":"<p>github\u94fe\u63a5\uff1a<a href=\"https:\/\/github.com\/brentp\/mosdepth\">https:\/\/github.com\/brentp\/mosdepth<\/a><\/p>\n<p>\u5355\u6837\u672c\u8fd0\u884c<\/p>\n<pre><code>mosdepth -n --fast-mode -t 4 EXAMPLE EXAMPLE.bam<\/code><\/pre>\n<h3>\u6279\u91cf\u8fd0\u884c\u811a\u672c<\/h3>\n<h4>run_mosdepth.sh:<\/h4>\n<pre><code>#!\/bin\/bash\n\n# \u9ed8\u8ba4\u53c2\u6570\nTHREADS=8\nBY_FILE=&quot;&quot;\n\n# \u89e3\u6790\u547d\u4ee4\u884c\u53c2\u6570\uff08\u652f\u6301 --by\uff09\nwhile [[ $# -gt 0 ]]; do\n    case $1 in\n        --by)\n            BY_FILE=&quot;$2&quot;\n            shift 2\n            ;;\n        *)\n            echo &quot;Unknown option: $1&quot; &gt;&amp;2\n            exit 1\n            ;;\n    esac\ndone\n\n# \u5982\u679c\u63d0\u4f9b\u4e86 --by\uff0c\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728\nif [[ -n &quot;$BY_FILE&quot; ]]; then\n    if [[ ! -f &quot;$BY_FILE&quot; ]]; then\n        echo &quot;Error: --by file &#039;$BY_FILE&#039; does not exist.&quot; &gt;&amp;2\n        exit 1\n    fi\n    echo &quot;Running in WES mode with target regions: $BY_FILE&quot;\nelse\n    echo &quot;Running in WGS mode (no --by provided)&quot;\nfi\n\n# \u67e5\u627e\u5f53\u524d\u76ee\u5f55\u4e0b\u6240\u6709 *bqsr.bam \u6587\u4ef6\nshopt -s nullglob  # \u907f\u514d\u65e0\u5339\u914d\u65f6\u8fd4\u56de\u5b57\u9762 &quot;*bqsr.bam&quot;\nfor bam in .\/*bqsr.bam; do\n    [[ ! -f &quot;$bam&quot; ]] &amp;&amp; continue\n\n    prefix=$(basename &quot;$bam&quot; .bam)\n\n    # \u5224\u65ad\u662f\u5426\u5df2\u5b8c\u6210\uff1a\u53ea\u8981\u5b58\u5728 global.dist.txt \u5c31\u8df3\u8fc7\n    if [[ -f &quot;${prefix}.mosdepth.global.dist.txt&quot; ]]; then\n        echo &quot;Skipping $bam (already processed)&quot;\n        continue\n    fi\n\n    echo &quot;Processing $bam ...&quot;\n\n    # \u6784\u5efa mosdepth \u547d\u4ee4\n    CMD=&quot;mosdepth -n --fast-mode -t $THREADS&quot;\n    if [[ -n &quot;$BY_FILE&quot; ]]; then\n        CMD=&quot;$CMD --by \\&quot;$BY_FILE\\&quot;&quot;\n    fi\n    CMD=&quot;$CMD \\&quot;$prefix\\&quot; \\&quot;$bam\\&quot;&quot;\n\n    # \u6267\u884c\u547d\u4ee4\n    eval $CMD\n\n    if [[ $? -eq 0 &amp;&amp; -f &quot;${prefix}.mosdepth.global.dist.txt&quot; ]]; then\n        echo &quot;\u2713 Finished $bam&quot;\n    else\n        echo &quot;\u2717 ERROR: mosdepth failed on $bam&quot; &gt;&amp;2\n    fi\ndone\n\necho &quot;All done.&quot;<\/code><\/pre>\n<h4>\u4f7f\u7528<\/h4>\n<pre><code># WES \u6a21\u5f0f\nnohup .\/run_mosdepth.sh --by AgilentV6_GRCh38_ex_region.sort.filtered.bed &gt; run_mosdepth.log 2&gt;&amp;1 &amp;\n\n# WGS \u6a21\u5f0f\nnohup .\/run_mosdepth.sh &gt; run_mosdepth.log 2&gt;&amp;1 &amp;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>github\u94fe\u63a5\uff1ahttps:\/\/github.com\/brentp\/mosdepth \u5355\u6837\u672c\u8fd0\u884c mosde&#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-673","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\/673","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=673"}],"version-history":[{"count":3,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/673\/revisions"}],"predecessor-version":[{"id":689,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/673\/revisions\/689"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}