shi-yong-GATK-zhao-SNP.html 93 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. <!DOCTYPE html>
  2. <html lang="en" data-default-color-scheme=auto>
  3. <head><!-- hexo injector head_begin start -->
  4. <script defer src="https://api.limour.top/vue/0d2f95c1-755d-436b-adf8-eee12a80ed32/script.js"></script>
  5. <!-- hexo injector head_begin end -->
  6. <meta charset="UTF-8">
  7. <link rel="apple-touch-icon" sizes="76x76" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  8. <link rel="icon" href="https://img.limour.top/2023/08/29/64ee07361815a.webp">
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  10. <meta http-equiv="x-ua-compatible" content="ie=edge">
  11. <meta name="theme-color" content="#2f4154">
  12. <meta name="author" content="Limour">
  13. <meta name="keywords" content="">
  14. <meta name="description" content="配置环境 基础编程环境 GitHub 下载加速 可能需要用到的加速服务 SRA工具 1234567conda create -n sra_tools -c bioconda sra-toolsconda activate sra_toolsconda install -c conda-forge lftp -yconda install -c conda-forge pigz -y # 或许">
  15. <title>【学习】使用GATK4.0找SNP - Limour&#39;s Blog</title>
  16. <link rel="stylesheet" href="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" />
  17. <link rel="stylesheet" href="https://jscdn.limour.top/npm/github-markdown-css@4.0.0/github-markdown.min.css" />
  18. <link rel="stylesheet" href="https://jscdn.limour.top/npm/hint.css@2.7.0/hint.min.css" />
  19. <!-- 主题依赖的图标库,不要自行修改 -->
  20. <!-- Do not modify the link that theme dependent icons -->
  21. <link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">
  22. <link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">
  23. <link rel="stylesheet" href="/css/main.css" />
  24. <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  25. <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  26. <link rel="stylesheet" href="/theme-inject/custom.css">
  27. <link rel="stylesheet" href="/theme-inject/iconfont.css">
  28. <script id="fluid-configs">
  29. var Fluid = window.Fluid || {};
  30. Fluid.ctx = Object.assign({}, Fluid.ctx)
  31. var CONFIG = {"hostname":"hexo.limour.top","root":"/","version":"1.9.7","typing":{"enable":false,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":"§"},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":false,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};
  32. if (CONFIG.web_analytics.follow_dnt) {
  33. var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
  34. Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
  35. }
  36. </script>
  37. <script src="/js/utils.js" ></script>
  38. <script src="/js/color-schema.js" ></script>
  39. <link rel="canonical" href="https://hexo.limour.top/shi-yong-GATK-zhao-SNP"/>
  40. <meta name="generator" content="Hexo 7.1.1"><link rel="alternate" href="/atom.xml" title="Limour's Blog" type="application/atom+xml">
  41. <link rel="alternate" href="/rss2.xml" title="Limour's Blog" type="application/rss+xml">
  42. </head>
  43. <body>
  44. <header>
  45. <div class="header-inner" style="height: 70vh;">
  46. <nav id="navbar" class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar">
  47. <div class="container">
  48. <a class="navbar-brand" href="/">
  49. <strong>Limour&#39;s Blog</strong>
  50. </a>
  51. <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
  52. data-target="#navbarSupportedContent"
  53. aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
  54. <div class="animated-icon"><span></span><span></span><span></span></div>
  55. </button>
  56. <!-- Collapsible content -->
  57. <div class="collapse navbar-collapse" id="navbarSupportedContent">
  58. <ul class="navbar-nav ml-auto text-center">
  59. <li class="nav-item">
  60. <a class="nav-link" href="https://hexo.limour.top/" target="_self">
  61. <i class="iconfont icon-home-fill"></i>
  62. <span>Home</span>
  63. </a>
  64. </li>
  65. <li class="nav-item">
  66. <a class="nav-link" href="/archives/" target="_self">
  67. <i class="iconfont icon-archive-fill"></i>
  68. <span>Archive1</span>
  69. </a>
  70. </li>
  71. <li class="nav-item">
  72. <a class="nav-link" href="https://occdn.limour.top/archives/" target="_self">
  73. <i class="iconfont icon-archive-fill"></i>
  74. <span>Archive2</span>
  75. </a>
  76. </li>
  77. <li class="nav-item">
  78. <a class="nav-link" href="https://b.limour.top/archives/" target="_self">
  79. <i class="iconfont icon-archive-fill"></i>
  80. <span>Archive3</span>
  81. </a>
  82. </li>
  83. <li class="nav-item">
  84. <a class="nav-link" href="https://od.limour.top/" target="_self">
  85. <i class="iconfont icon-onedrive"></i>
  86. <span>Alist</span>
  87. </a>
  88. </li>
  89. <li class="nav-item">
  90. <a class="nav-link" href="https://orcid.org/0000-0001-8897-1685" target="_self">
  91. <i class="iconfont icon-orcid"></i>
  92. <span>Orcid</span>
  93. </a>
  94. </li>
  95. <li class="nav-item">
  96. <a class="nav-link" href="/links/" target="_self">
  97. <i class="iconfont icon-link-fill"></i>
  98. <span>Links</span>
  99. </a>
  100. </li>
  101. <li class="nav-item">
  102. <a class="nav-link" href="/atom.xml" target="_self">
  103. <i class="iconfont icon-rss"></i>
  104. <span>RSS</span>
  105. </a>
  106. </li>
  107. <li class="nav-item" id="search-btn">
  108. <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
  109. <i class="iconfont icon-search"></i>
  110. </a>
  111. </li>
  112. <li class="nav-item" id="color-toggle-btn">
  113. <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
  114. <i class="iconfont icon-dark" id="color-toggle-icon"></i>
  115. </a>
  116. </li>
  117. </ul>
  118. </div>
  119. </div>
  120. </nav>
  121. <div id="banner" class="banner" parallax=true
  122. style="background: url('https://img.limour.top/2023/08/29/64ee08e108638.webp') no-repeat center center; background-size: cover;">
  123. <div class="full-bg-img">
  124. <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
  125. <div class="banner-text text-center fade-in-up">
  126. <div class="h2">
  127. <span id="subtitle">【学习】使用GATK4.0找SNP</span>
  128. </div>
  129. <div class="mt-3">
  130. <span class="post-meta mr-2">
  131. <i class="iconfont icon-author" aria-hidden="true"></i>
  132. Limour
  133. </span>
  134. <span class="post-meta">
  135. <i class="iconfont icon-date-fill" aria-hidden="true"></i>
  136. <time datetime="2023-09-24 18:49" pubdate>
  137. September 24, 2023 pm
  138. </time>
  139. </span>
  140. </div>
  141. <div class="mt-1">
  142. <span class="post-meta mr-2">
  143. <i class="iconfont icon-chart"></i>
  144. 3.5k words
  145. </span>
  146. <span class="post-meta mr-2">
  147. <i class="iconfont icon-clock-fill"></i>
  148. 30 mins
  149. </span>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </header>
  157. <main>
  158. <div class="container-fluid nopadding-x">
  159. <div class="row nomargin-x">
  160. <div class="side-col d-none d-lg-block col-lg-2">
  161. </div>
  162. <div class="col-lg-8 nopadding-x-md">
  163. <div class="container nopadding-x-md" id="board-ctn">
  164. <div id="board">
  165. <article class="post-content mx-auto">
  166. <h1 id="seo-header">【学习】使用GATK4.0找SNP</h1>
  167. <p id="updated-time" class="note note-info" style="">
  168. Last updated on March 19, 2024 pm
  169. </p>
  170. <div class="markdown-body">
  171. <p><img src="https://img.limour.top/2023/09/26/651299352bcf0.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt=""></p>
  172. <h2 id="配置环境">配置环境</h2>
  173. <ul>
  174. <li><a href="/-ji-lu--an-zhuang-sheng-xin-de-dai-ma-bian-xie-huan-jing">基础编程环境</a></li>
  175. <li><a href="/-fu-ke-GitHub-wen-jian-jia-su">GitHub 下载加速</a></li>
  176. <li><a href="/-ji-lu-SOCKS5-zhuan-QUIC">可能需要用到的加速服务</a></li>
  177. </ul>
  178. <h3 id="SRA工具">SRA工具</h3>
  179. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">conda create -n sra_tools -c bioconda sra-tools</span><br><span class="line">conda activate sra_tools</span><br><span class="line">conda install -c conda-forge lftp -y</span><br><span class="line">conda install -c conda-forge pigz -y <span class="comment"># 或许换成 pbgzip 更好,此时将 -p 换成 -n 来指定线程数</span></span><br><span class="line">conda install -c bioconda pbgzip -y</span><br><span class="line">prefetch</span><br><span class="line"><span class="comment"># vdb-config -i # 设置 HTTP 代理</span></span><br></pre></td></tr></table></figure>
  180. <h3 id="GATK4">GATK4</h3>
  181. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">conda create -n GATK4 -c bioconda gatk4</span><br><span class="line">conda activate GATK4</span><br><span class="line">conda install -c bioconda samtools -y</span><br><span class="line">conda install -c bioconda bwa -y</span><br><span class="line">conda install -c bioconda pbgzip -y <span class="comment"># 并行版bgzip,bgzip是修改过的gzip,更适合生信领域</span></span><br><span class="line">conda install -c bioconda tabix -y <span class="comment"># 操作VCF文件,与bgzip配套</span></span><br><span class="line"><span class="comment"># conda install -c bioconda fastqc -y # 改用fastp了</span></span><br><span class="line"><span class="comment"># conda install -c bioconda trimmomatic -y # 改用fastp了</span></span><br><span class="line">conda install -c bioconda fastp -y</span><br><span class="line"><span class="comment"># conda install -c bioconda bcftools -y # 用于重命名染色体</span></span><br><span class="line"><span class="comment"># ln -s $CONDA_PREFIX/lib/libgsl.so $CONDA_PREFIX/lib/libgsl.so.25 # 无效,放弃</span></span><br><span class="line"><span class="comment"># conda create -n GATK4-VEP -c bioconda ensembl-vep -y # 根正苗红的突变注释软件,不懂有什么奇怪依赖,解析环境半天</span></span><br></pre></td></tr></table></figure>
  182. <ul>
  183. <li>BWA是DNA比对工具(不会跨外显子比对),<a href="/STAR--yi-jian-jiao-ben">STAR</a>是RNA比对工具</li>
  184. <li><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/37345954">找SNP不推荐用RNAseq的数据</a></li>
  185. <li><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/601469194b5e">各种比对工具的说明</a></li>
  186. </ul>
  187. <h2 id="准备数据">准备数据</h2>
  188. <h3 id="参考数据">参考数据</h3>
  189. <ul>
  190. <li><a target="_blank" rel="noopener" href="https://www.ncbi.nlm.nih.gov/genome/browse">NCBI上各物种的参考序列</a>,可以找到RefSeq,比如Human是GCF_000001405</li>
  191. <li>知道序号后可以到<a target="_blank" rel="noopener" href="https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/">FTP</a>上下载相应的<code>genomic.fna.gz</code>文件</li>
  192. <li>比如GCF_000001405,依次进入<code>000/001/405</code>即可找到对应的文件</li>
  193. </ul>
  194. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/405/GCF_000001405.40_GRCh38.p14/GCF_000001405.40_GRCh38.p14_genomic.fna.gz -O GRCh38.p14.fna.gz</span><br><span class="line">conda run -n sra_tools pigz -d GRCh38.p14.fna.gz <span class="comment"># 得到 GRCh38.p14.fna</span></span><br><span class="line"><span class="comment"># 创建索引</span></span><br><span class="line">samtools faidx GRCh38.p14.fna <span class="comment"># 得到 GRCh38.p14.fna.fai</span></span><br><span class="line"><span class="comment"># 查看一段序列</span></span><br><span class="line">samtools faidx GRCh38.p14.fna NC_000001.11:1000000-1000200</span><br><span class="line"><span class="comment"># 创建比对索引</span></span><br><span class="line">bwa index GRCh38.p14.fna <span class="comment"># 会自动在 bwtsw, is or rb2 三种算法中选择合适的</span></span><br><span class="line"><span class="comment"># 创建dict</span></span><br><span class="line">gatk CreateSequenceDictionary -R GRCh38.p14.fna</span><br></pre></td></tr></table></figure>
  195. <ul>
  196. <li>最后得到的RefSeq目录结构如下</li>
  197. </ul>
  198. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># conda create -n linux -c conda-forge tree</span></span><br><span class="line"><span class="comment"># conda run -n linux tree -f -h --du</span></span><br><span class="line">[8.5G] .</span><br><span class="line">├── [ 79K] ./GRCh38.p14.dict</span><br><span class="line">├── [3.1G] ./GRCh38.p14.fna</span><br><span class="line">├── [ 21K] ./GRCh38.p14.fna.amb</span><br><span class="line">├── [ 90K] ./GRCh38.p14.fna.ann</span><br><span class="line">├── [3.1G] ./GRCh38.p14.fna.bwt</span><br><span class="line">├── [ 26K] ./GRCh38.p14.fna.fai</span><br><span class="line">├── [786M] ./GRCh38.p14.fna.pac</span><br><span class="line">└── [1.5G] ./GRCh38.p14.fna.sa</span><br></pre></td></tr></table></figure>
  199. <h3 id="已知SNP">已知SNP</h3>
  200. <ul>
  201. <li><a target="_blank" rel="noopener" href="https://gatk.broadinstitute.org/hc/en-us/articles/360035890811-Resource-bundle">GATK官网提供了一些数据</a></li>
  202. <li><a target="_blank" rel="noopener" href="https://ftp.ncbi.nlm.nih.gov/snp/latest_release/VCF/">NCBI提供了dbSNP</a></li>
  203. <li><code>lftp ftp://gsapubftp-anonymous@ftp.broadinstitute.org/bundle/</code>,密码空,直接回车</li>
  204. <li>下载和参考数据相对应的<a target="_blank" rel="noopener" href="https://gist.github.com/Limour-dev/2d9c0250714bec1ce5c5989363bbfa12">indels.hg38.vcf</a></li>
  205. </ul>
  206. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">wget https://ftp.ncbi.nlm.nih.gov/snp/latest_release/VCF/GCF_000001405.40.gz -O GRCh38.dbSNP.ncbi.vcf.gz</span><br></pre></td></tr></table></figure>
  207. <h4 id="转换染色体名称到NCBI的参考文件">转换染色体名称到NCBI的参考文件</h4>
  208. <ul>
  209. <li><code>assembly_report.txt</code> 在下载NCBI参考数据FTP目录下</li>
  210. </ul>
  211. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/405/GCF_000001405.40_GRCh38.p14/GCF_000001405.40_GRCh38.p14_assembly_report.txt -O GRCh38.p14_assembly_report.txt </span><br><span class="line">grep -e <span class="string">&#x27;^[^#]&#x27;</span> GRCh38.p14_assembly_report.txt | awk -F<span class="string">&#x27;\t&#x27;</span> <span class="string">&#x27;&#123; print $NF, $7 &#125;&#x27;</span> | sed <span class="string">&#x27;s/\r / /g&#x27;</span> &gt; rename_file.txt</span><br><span class="line">conda create -n something_fuck -c conda-forge mamba</span><br><span class="line">conda activate something_fuck</span><br><span class="line">mamba install -c bioconda bcftools</span><br><span class="line">bcftools annotate --rename-chrs rename_file.txt -o Homo_sapiens_assembly38.known_indels.ncbi.vcf Homo_sapiens_assembly38.known_indels.vcf</span><br><span class="line">bcftools annotate --rename-chrs rename_file.txt -o hapmap_3.3.hg38.ncbi.vcf hapmap_3.3.hg38.vcf</span><br><span class="line">bcftools annotate --rename-chrs rename_file.txt -o Mills_and_1000G_gold_standard.indels.hg38.ncbi.vcf Mills_and_1000G_gold_standard.indels.hg38.vcf</span><br><span class="line">conda run -n GATK4 pbgzip -n 4 *.ncbi.vcf <span class="comment"># 似乎一次只压缩一个,多运行几次</span></span><br></pre></td></tr></table></figure>
  212. <h4 id="建立索引">建立索引</h4>
  213. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano knownSitesIndex.sh &amp;&amp; <span class="built_in">chmod</span> +x knownSitesIndex.sh</span><br><span class="line">./knownSitesIndex.sh</span><br></pre></td></tr></table></figure>
  214. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#设置knownSites数据存放目录</span></span><br><span class="line">knownSites=/home/jovyan/upload/knownSites</span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$knownSites</span>/*.ncbi.vcf.gz</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">gatk IndexFeatureFile \</span><br><span class="line"> -I <span class="variable">$file</span></span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  215. <ul>
  216. <li>最后得到的knownSites目录结构如下</li>
  217. </ul>
  218. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[ 25G] .</span><br><span class="line">├── [ 25G] ./GRCh38.dbSNP.ncbi.vcf.gz</span><br><span class="line">├── [4.2M] ./GRCh38.dbSNP.ncbi.vcf.gz.tbi</span><br><span class="line">├── [ 79K] ./GRCh38.p14_assembly_report.txt</span><br><span class="line">├── [ 61M] ./hapmap_3.3.hg38.ncbi.vcf.gz</span><br><span class="line">├── [2.1M] ./hapmap_3.3.hg38.ncbi.vcf.gz.tbi</span><br><span class="line">├── [ 58M] ./Homo_sapiens_assembly38.known_indels.ncbi.vcf.gz</span><br><span class="line">├── [2.1M] ./Homo_sapiens_assembly38.known_indels.ncbi.vcf.gz.tbi</span><br><span class="line">├── [ 20M] ./Mills_and_1000G_gold_standard.indels.hg38.ncbi.vcf.gz</span><br><span class="line">├── [2.0M] ./Mills_and_1000G_gold_standard.indels.hg38.ncbi.vcf.gz.tbi</span><br><span class="line">└── [ 23K] ./rename_file.txt</span><br></pre></td></tr></table></figure>
  219. <h3 id="测序数据">测序数据</h3>
  220. <ul>
  221. <li>WGS的DNA测序数据</li>
  222. <li>以<a target="_blank" rel="noopener" href="https://www.ncbi.nlm.nih.gov/sra/SRX247249">SRX247249</a>做学习的示例数据,感谢<a target="_blank" rel="noopener" href="https://web.archive.org/web/20220930070928/http://www.biotrainee.com/thread-1376-1-1.html">曾老师</a>指路</li>
  223. <li>下载方式见<a href="/cong-ENI-shu-ju-ku-xia-zai-fastq-wen-jian#%E4%BB%8E-NCBI-%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%8B%E8%BD%BD">SRA文件转FASTQ文件</a></li>
  224. <li>也可以到<a target="_blank" rel="noopener" href="https://www.ebi.ac.uk/ena/browser/view/SRX247249">ENA数据库</a>上下载</li>
  225. </ul>
  226. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">conda run -n sra_tools prefetch --option-file SRR_Acc_List.txt</span><br><span class="line">nano 11.sh &amp;&amp; <span class="built_in">chmod</span> +x 11.sh</span><br><span class="line">./11.sh</span><br></pre></td></tr></table></figure>
  227. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate sra_tools</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置SRA根目录, pwd是当前目录</span></span><br><span class="line">ROOTDIR=`<span class="built_in">pwd</span>`</span><br><span class="line"><span class="comment">#设置rawData存放目录</span></span><br><span class="line">rawData=/home/jovyan/upload/rawData/<span class="variable">$TASKN</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$rawData</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">cd</span> <span class="variable">$ROOTDIR</span></span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> `<span class="built_in">cat</span> SRR_Acc_List.txt`</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line"><span class="built_in">mkdir</span> <span class="variable">$rawData</span>/<span class="variable">$file</span></span><br><span class="line"><span class="built_in">cd</span> <span class="variable">$rawData</span>/<span class="variable">$file</span></span><br><span class="line">fasterq-dump --split-3 <span class="variable">$ROOTDIR</span>/<span class="variable">$file</span> -e 6</span><br><span class="line">pigz -p 6 *</span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  228. <h3 id="rawData质控">rawData质控</h3>
  229. <ul>
  230. <li><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/28802083">原始数据质量判断​</a></li>
  231. <li><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/28924793">原始数据过滤工具</a></li>
  232. </ul>
  233. <h4 id="质量判断(可跳过)">质量判断(可跳过)</h4>
  234. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano qc.sh &amp;&amp; <span class="built_in">chmod</span> +x qc.sh</span><br><span class="line">./qc.sh</span><br></pre></td></tr></table></figure>
  235. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置rawData存放目录</span></span><br><span class="line">rawData=/home/jovyan/upload/rawData/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置qc结果的输出目录</span></span><br><span class="line">QCDIR=/home/jovyan/upload/rawData/<span class="variable">$TASKN</span><span class="string">&quot;_fastqc&quot;</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$QCDIR</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$rawData</span>/*</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">SAMPLE=<span class="variable">$&#123;file##*/&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">mkdir</span> <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line">fastqc -o <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span> --threads=6 `<span class="built_in">ls</span> <span class="variable">$rawData</span>/<span class="variable">$SAMPLE</span>/*`</span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  236. <ul>
  237. <li>对于PE而言,正向和反向reads的测量过程是独立的,将当成两次SE来处理</li>
  238. <li>最后的报告中:</li>
  239. <li>Q20的碱基要在95%以上(最差不低于90%)</li>
  240. <li>Q30要求大于85%(最差也不要低于80%)</li>
  241. <li>对于人类来说,GC含量应该在40%左右</li>
  242. </ul>
  243. <h4 id="fastp一键质控">fastp一键质控</h4>
  244. <ul>
  245. <li><a target="_blank" rel="noopener" href="https://github.com/OpenGene/fastp">fastp的详细说明</a>; <a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/33601691">中文介绍</a></li>
  246. </ul>
  247. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano qc.sh &amp;&amp; <span class="built_in">chmod</span> +x qc.sh</span><br><span class="line">./qc.sh</span><br></pre></td></tr></table></figure>
  248. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置rawData存放目录</span></span><br><span class="line">rawData=/home/jovyan/upload/rawData/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置qc结果的输出目录</span></span><br><span class="line">QCDIR=/home/jovyan/upload/rawData/<span class="variable">$TASKN</span><span class="string">&quot;_fastp&quot;</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$QCDIR</span></span><br><span class="line"><span class="comment">#设置cleanData的存放目录</span></span><br><span class="line">CLEAN=/home/jovyan/upload/cleanData/<span class="variable">$TASKN</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$CLEAN</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$rawData</span>/*</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">SAMPLE=<span class="variable">$&#123;file##*/&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">mkdir</span> <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$CLEAN</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">mkdir</span> <span class="variable">$CLEAN</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">cd</span> <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line">fastp -c -w 4 \</span><br><span class="line">-o <span class="variable">$CLEAN</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/out.R1.fq.gz&quot;</span> \</span><br><span class="line">-O <span class="variable">$CLEAN</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/out.R2.fq.gz&quot;</span> \</span><br><span class="line">-h <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/fastp.html&quot;</span> \</span><br><span class="line">-j <span class="variable">$QCDIR</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/fastp.json&quot;</span> \</span><br><span class="line">-i `<span class="built_in">ls</span> <span class="variable">$rawData</span>/<span class="variable">$SAMPLE</span>/*_1.fastq.gz` \</span><br><span class="line">-I `<span class="built_in">ls</span> <span class="variable">$rawData</span>/<span class="variable">$SAMPLE</span>/*_2.fastq.gz`</span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  249. <ul>
  250. <li>最后得到的cleanData目录结构如下</li>
  251. </ul>
  252. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[ 23G] .</span><br><span class="line">├── [9.1G] ./SRR799559</span><br><span class="line">│ ├── [4.4G] ./SRR799559/out.R1.fq.gz</span><br><span class="line">│ └── [4.7G] ./SRR799559/out.R2.fq.gz</span><br><span class="line">├── [7.0G] ./SRR799560</span><br><span class="line">│ ├── [3.4G] ./SRR799560/out.R1.fq.gz</span><br><span class="line">│ └── [3.5G] ./SRR799560/out.R2.fq.gz</span><br><span class="line">└── [7.4G] ./SRR799561</span><br><span class="line"> ├── [3.6G] ./SRR799561/out.R1.fq.gz</span><br><span class="line"> └── [3.8G] ./SRR799561/out.R2.fq.gz</span><br></pre></td></tr></table></figure>
  253. <h2 id="数据比对">数据比对</h2>
  254. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano bwa_and_markdup.sh &amp;&amp; <span class="built_in">chmod</span> +x bwa_and_markdup.sh</span><br><span class="line">./bwa_and_markdup.sh</span><br></pre></td></tr></table></figure>
  255. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置cleanData的存放目录</span></span><br><span class="line">CLEAN=/home/jovyan/upload/cleanData/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"><span class="comment">#设置Read Group信息,见 https://gatk.broadinstitute.org/hc/en-us/articles/360035890671-Read-groups</span></span><br><span class="line">RGroup_PL=ILLUMINA <span class="comment"># 所用的测序平台:ILLUMINA,SLX,SOLEXA,SOLID,454,LS454,COMPLETE,PACBIO,IONTORRENT,CAPILLARY,HELICOS或UNKNOWN。CG测序为COMPLETE</span></span><br><span class="line">RGroup_SM=<span class="variable">$TASKN</span> <span class="comment"># 样本ID,同一个样本可能有多个lane,此时用样本ID相关联</span></span><br><span class="line">RGroup=<span class="string">&#x27;PL:&#x27;</span><span class="variable">$RGroup_PL</span><span class="string">&#x27;\tSM:&#x27;</span><span class="variable">$RGroup_SM</span></span><br><span class="line"><span class="comment">#设置BAM的存放目录</span></span><br><span class="line">BAM=/home/jovyan/upload/BAM/<span class="variable">$TASKN</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$BAM</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$CLEAN</span>/*</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">SAMPLE=<span class="variable">$&#123;file##*/&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">mkdir</span> <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">&#x27;@RG\tID:&#x27;</span><span class="variable">$SAMPLE</span><span class="string">&#x27;\t&#x27;</span><span class="variable">$RGroup</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#1 比对</span></span><br><span class="line">bwa mem -t 4 -M -R <span class="string">&#x27;@RG\tID:&#x27;</span><span class="variable">$SAMPLE</span><span class="string">&#x27;\t&#x27;</span><span class="variable">$RGroup</span> <span class="variable">$RefSeq</span> `<span class="built_in">ls</span> <span class="variable">$CLEAN</span>/<span class="variable">$SAMPLE</span>/*` \</span><br><span class="line">| samtools view -Sb - &gt; <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/raw.bam&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#2 排序</span></span><br><span class="line">samtools <span class="built_in">sort</span> -@ 4 -m 4G -O bam -o <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.bam&quot;</span> <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/raw.bam&quot;</span></span><br><span class="line"><span class="built_in">rm</span> <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/raw.bam&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#3 标记PCR重复</span></span><br><span class="line">gatk MarkDuplicates -I <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.bam&quot;</span> \</span><br><span class="line">-O <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.bam&quot;</span> \</span><br><span class="line">-M <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup_metrics.txt&quot;</span></span><br><span class="line"><span class="built_in">rm</span> <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.bam&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="comment">#4 创建比对索引文件</span></span><br><span class="line">samtools index <span class="variable">$BAM</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.bam&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  256. <ul>
  257. <li>最后得到的BAM目录结构如下</li>
  258. </ul>
  259. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[ 30G] .</span><br><span class="line">├── [ 11G] ./SRR799559</span><br><span class="line">│ ├── [ 11G] ./SRR799559/sorted.markdup.bam</span><br><span class="line">│ ├── [4.5M] ./SRR799559/sorted.markdup.bam.bai</span><br><span class="line">│ └── [3.7K] ./SRR799559/sorted.markdup_metrics.txt</span><br><span class="line">├── [8.8G] ./SRR799560</span><br><span class="line">│ ├── [8.8G] ./SRR799560/sorted.markdup.bam</span><br><span class="line">│ ├── [3.9M] ./SRR799560/sorted.markdup.bam.bai</span><br><span class="line">│ └── [3.7K] ./SRR799560/sorted.markdup_metrics.txt</span><br><span class="line">└── [9.6G] ./SRR799561</span><br><span class="line"> ├── [9.5G] ./SRR799561/sorted.markdup.bam</span><br><span class="line"> ├── [4.1M] ./SRR799561/sorted.markdup.bam.bai</span><br><span class="line"> └── [3.7K] ./SRR799561/sorted.markdup_metrics.txt</span><br></pre></td></tr></table></figure>
  260. <h3 id="同样本合并">同样本合并</h3>
  261. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano merge.sh &amp;&amp; <span class="built_in">chmod</span> +x merge.sh</span><br><span class="line">./merge.sh</span><br></pre></td></tr></table></figure>
  262. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置BAM的存放目录</span></span><br><span class="line">BAM=/home/jovyan/upload/BAM/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置merge后的数据存放目录</span></span><br><span class="line">MERGEDBAM=/home/jovyan/upload/merged/<span class="variable">$TASKN</span>/SAMPLE1</span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$MERGEDBAM</span></span><br><span class="line"> </span><br><span class="line">samtools merge <span class="variable">$MERGEDBAM</span><span class="string">&quot;/sorted.markdup.bam&quot;</span> \</span><br><span class="line">`find <span class="string">&quot;<span class="variable">$BAM</span>&quot;</span> -name <span class="string">&quot;sorted.markdup.bam&quot;</span> -<span class="built_in">type</span> f -<span class="built_in">exec</span> <span class="built_in">readlink</span> -f &#123;&#125; \;`</span><br><span class="line">samtools index <span class="variable">$MERGEDBAM</span><span class="string">&quot;/sorted.markdup.bam&quot;</span></span><br></pre></td></tr></table></figure>
  263. <ul>
  264. <li>最后得到的MERGED目录结构如下</li>
  265. </ul>
  266. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[ 21G] .</span><br><span class="line">└── [ 21G] ./SAMPLE1</span><br><span class="line"> ├── [ 21G] ./SAMPLE1/sorted.markdup.bam</span><br><span class="line"> └── [6.8M] ./SAMPLE1/sorted.markdup.bam.bai</span><br></pre></td></tr></table></figure>
  267. <h3 id="局部重比对">局部重比对</h3>
  268. <ul>
  269. <li>具体见<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/29485987">黄树嘉博士的相关介绍</a></li>
  270. <li>因为本文是GATK 4.0的HaplotypeCaller模块,自带局部重比对,故用到的时候再写</li>
  271. </ul>
  272. <h3 id="BQSR">BQSR</h3>
  273. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano BQSR.sh &amp;&amp; <span class="built_in">chmod</span> +x BQSR.sh</span><br><span class="line">./BQSR.sh</span><br></pre></td></tr></table></figure>
  274. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置merged数据存放目录</span></span><br><span class="line">MERGED=/home/jovyan/upload/merged/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"><span class="comment">#设置knownSites数据存放目录</span></span><br><span class="line">knownSites=/home/jovyan/upload/knownSites</span><br><span class="line">knownSites=$(<span class="built_in">echo</span> $(<span class="built_in">ls</span> <span class="variable">$knownSites</span>/*.ncbi.vcf.gz | sed <span class="string">&#x27;s/^/--known-sites /&#x27;</span> | <span class="built_in">tr</span> <span class="string">&#x27;\n&#x27;</span> <span class="string">&#x27; &#x27;</span>))</span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$knownSites</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$MERGED</span>/*</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">SAMPLE=<span class="variable">$&#123;file##*/&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"> </span><br><span class="line">gatk BaseRecalibrator <span class="variable">$knownSites</span> \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -I <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.bam&quot;</span> \</span><br><span class="line"> -O <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/recal_data.table&quot;</span></span><br><span class="line"> </span><br><span class="line">gatk ApplyBQSR \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -I <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.bam&quot;</span> \</span><br><span class="line"> --bqsr-recal-file <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/recal_data.table&quot;</span> \</span><br><span class="line"> -O <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.BQSR.bam&quot;</span></span><br><span class="line"> </span><br><span class="line">samtools index <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.BQSR.bam&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  275. <ul>
  276. <li>最后得到的MERGED目录结构如下</li>
  277. </ul>
  278. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[ 54G] .</span><br><span class="line">└── [ 54G] ./SAMPLE1</span><br><span class="line"> ├── [2.5M] ./SAMPLE1/recal_data.table</span><br><span class="line"> ├── [ 21G] ./SAMPLE1/sorted.markdup.bam</span><br><span class="line"> ├── [6.8M] ./SAMPLE1/sorted.markdup.bam.bai</span><br><span class="line"> ├── [8.8M] ./SAMPLE1/sorted.markdup.BQSR.bai</span><br><span class="line"> ├── [ 33G] ./SAMPLE1/sorted.markdup.BQSR.bam</span><br><span class="line"> └── [7.6M] ./SAMPLE1/sorted.markdup.BQSR.bam.bai</span><br></pre></td></tr></table></figure>
  279. <h2 id="两步法变异检测">两步法变异检测</h2>
  280. <h3 id="HaplotypeCaller">HaplotypeCaller</h3>
  281. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano HaplotypeCaller.sh &amp;&amp; <span class="built_in">chmod</span> +x HaplotypeCaller.sh</span><br><span class="line">./HaplotypeCaller.sh</span><br></pre></td></tr></table></figure>
  282. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"> </span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置BQSR数据存放目录</span></span><br><span class="line">MERGED=/home/jovyan/upload/merged/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"> </span><br><span class="line"><span class="keyword">for</span> file <span class="keyword">in</span> <span class="variable">$MERGED</span>/*</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$file</span></span><br><span class="line">SAMPLE=<span class="variable">$&#123;file##*/&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span></span><br><span class="line"> </span><br><span class="line">gatk --java-options <span class="string">&quot;-Xmx4g&quot;</span> HaplotypeCaller -ERC GVCF \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -I <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/sorted.markdup.BQSR.bam&quot;</span> \</span><br><span class="line"> -O <span class="variable">$MERGED</span><span class="string">&quot;/&quot;</span><span class="variable">$SAMPLE</span><span class="string">&quot;/HC.g.vcf.gz&quot;</span></span><br><span class="line"> </span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure>
  283. <h3 id="CombineGVCFs">CombineGVCFs</h3>
  284. <h4 id="单样本">单样本</h4>
  285. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">VCFPATH=<span class="variable">$MERGED</span><span class="string">&#x27;/SAMPLE1&#x27;</span></span><br></pre></td></tr></table></figure>
  286. <h4 id="多样本">多样本</h4>
  287. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano CombineGVCFs.sh &amp;&amp; <span class="built_in">chmod</span> +x CombineGVCFs.sh</span><br><span class="line">./CombineGVCFs.sh</span><br></pre></td></tr></table></figure>
  288. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"> </span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置BQSR数据存放目录</span></span><br><span class="line">MERGED=/home/jovyan/upload/merged/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"><span class="comment">#设置最后输出的路径</span></span><br><span class="line">VCFPATH=/home/jovyan/upload/VCF/<span class="variable">$TASKN</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$VCFPATH</span></span><br><span class="line"> </span><br><span class="line">variant=$(<span class="built_in">echo</span> $(<span class="built_in">ls</span> <span class="variable">$MERGED</span>/*/HC.g.vcf.gz | sed <span class="string">&#x27;s/^/--variant /&#x27;</span> | <span class="built_in">tr</span> <span class="string">&#x27;\n&#x27;</span> <span class="string">&#x27; &#x27;</span>))</span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$variant</span></span><br><span class="line"> </span><br><span class="line">gatk CombineGVCFs $<span class="variable">$variant</span> \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span><span class="string">&#x27;/HC.g.vcf.gz&#x27;</span></span><br></pre></td></tr></table></figure>
  289. <h3 id="GenotypeGVCFs">GenotypeGVCFs</h3>
  290. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano GenotypeGVCFs.sh &amp;&amp; <span class="built_in">chmod</span> +x GenotypeGVCFs.sh</span><br><span class="line">./GenotypeGVCFs.sh</span><br></pre></td></tr></table></figure>
  291. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"> </span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置BQSR数据存放目录</span></span><br><span class="line">MERGED=/home/jovyan/upload/merged/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"><span class="comment">#设置最后输出的路径</span></span><br><span class="line">VCFPATH=<span class="variable">$MERGED</span><span class="string">&#x27;/SAMPLE1&#x27;</span></span><br><span class="line"><span class="built_in">mkdir</span> -p <span class="variable">$VCFPATH</span></span><br><span class="line"> </span><br><span class="line">gatk --java-options <span class="string">&quot;-Xmx4g&quot;</span> GenotypeGVCFs \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -V <span class="variable">$VCFPATH</span><span class="string">&#x27;/HC.g.vcf.gz&#x27;</span> \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span><span class="string">&#x27;/HC.vcf.gz&#x27;</span></span><br></pre></td></tr></table></figure>
  292. <ul>
  293. <li>最后得到的结果如下</li>
  294. </ul>
  295. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">├── [6.8G] ./HC.g.vcf.gz</span><br><span class="line">├── [5.0M] ./HC.g.vcf.gz.tbi</span><br><span class="line">├── [127M] ./HC.vcf.gz</span><br><span class="line">├── [2.0M] ./HC.vcf.gz.tbi</span><br></pre></td></tr></table></figure>
  296. <h2 id="VQSR">VQSR</h2>
  297. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">nano VQSR.sh &amp;&amp; <span class="built_in">chmod</span> +x VQSR.sh</span><br><span class="line">./VQSR.sh</span><br></pre></td></tr></table></figure>
  298. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="built_in">source</span> activate GATK4</span><br><span class="line"> </span><br><span class="line"><span class="comment">#任务名</span></span><br><span class="line">TASKN=SRX247249</span><br><span class="line"><span class="comment">#设置BQSR数据存放目录</span></span><br><span class="line">MERGED=/home/jovyan/upload/merged/<span class="variable">$TASKN</span></span><br><span class="line"><span class="comment">#设置RefSeq的存放目录</span></span><br><span class="line">RefSeq=/home/jovyan/data/refseq/GRCh38.p14.fna</span><br><span class="line"><span class="comment">#设置最后输出的路径</span></span><br><span class="line">VCFPATH=<span class="variable">$MERGED</span><span class="string">&#x27;/SAMPLE1&#x27;</span></span><br><span class="line"><span class="comment">#设置knownSites数据存放目录</span></span><br><span class="line">knownSites=/home/jovyan/upload/knownSites</span><br><span class="line"> </span><br><span class="line">gatk VariantRecalibrator \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -V <span class="variable">$VCFPATH</span><span class="string">&#x27;/HC.vcf.gz&#x27;</span> \</span><br><span class="line"> --resource:hapmap,known=<span class="literal">false</span>,training=<span class="literal">true</span>,truth=<span class="literal">true</span>,prior=15.0 <span class="variable">$knownSites</span>/hapmap_3.3.hg38.ncbi.vcf.gz \</span><br><span class="line"> --resource:dbsnp,known=<span class="literal">true</span>,training=<span class="literal">false</span>,truth=<span class="literal">false</span>,prior=2.0 <span class="variable">$knownSites</span>/GRCh38.dbSNP.ncbi.vcf.gz \</span><br><span class="line"> -an QD -an MQ -an MQRankSum -an ReadPosRankSum -an FS -an SOR \</span><br><span class="line"> -mode SNP \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span>/snp.recal \</span><br><span class="line"> --tranches-file <span class="variable">$VCFPATH</span>/snp.tranches \</span><br><span class="line"> --rscript-file <span class="variable">$VCFPATH</span>/snp.plots.R</span><br><span class="line"> </span><br><span class="line">gatk ApplyVQSR \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -V <span class="variable">$VCFPATH</span><span class="string">&#x27;/HC.vcf.gz&#x27;</span> \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span><span class="string">&#x27;/snp.VQSR.vcf.gz&#x27;</span> \</span><br><span class="line"> --truth-sensitivity-filter-level 99.0 \</span><br><span class="line"> --tranches-file <span class="variable">$VCFPATH</span>/snp.tranches \</span><br><span class="line"> --recal-file <span class="variable">$VCFPATH</span>/snp.recal \</span><br><span class="line"> -mode SNP</span><br><span class="line"> </span><br><span class="line">gatk VariantRecalibrator \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -V <span class="variable">$VCFPATH</span><span class="string">&#x27;/snp.VQSR.vcf.gz&#x27;</span> \</span><br><span class="line"> --resource:dbindel,known=<span class="literal">true</span>,training=<span class="literal">false</span>,truth=<span class="literal">false</span>,prior=2.0 <span class="variable">$knownSites</span>/Homo_sapiens_assembly38.known_indels.ncbi.vcf.gz \</span><br><span class="line"> --resource:mills,known=<span class="literal">true</span>,training=<span class="literal">true</span>,truth=<span class="literal">true</span>,prior=12.0 <span class="variable">$knownSites</span>/Mills_and_1000G_gold_standard.indels.hg38.ncbi.vcf.gz \</span><br><span class="line"> -an QD -an MQ -an MQRankSum -an ReadPosRankSum -an FS -an SOR \</span><br><span class="line"> -mode INDEL --max-gaussians 6 \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span>/snp.indel.recal \</span><br><span class="line"> --tranches-file <span class="variable">$VCFPATH</span>/snp.indel.tranches \</span><br><span class="line"> --rscript-file <span class="variable">$VCFPATH</span>/snp.indel.plots.R</span><br><span class="line"> </span><br><span class="line">gatk ApplyVQSR \</span><br><span class="line"> -R <span class="variable">$RefSeq</span> \</span><br><span class="line"> -V <span class="variable">$VCFPATH</span><span class="string">&#x27;/snp.VQSR.vcf.gz&#x27;</span> \</span><br><span class="line"> -O <span class="variable">$VCFPATH</span><span class="string">&#x27;/snp.indel.VQSR.vcf.gz&#x27;</span> \</span><br><span class="line"> --truth-sensitivity-filter-level 99.0 \</span><br><span class="line"> --tranches-file <span class="variable">$VCFPATH</span>/snp.indel.tranches \</span><br><span class="line"> --recal-file <span class="variable">$VCFPATH</span>/snp.indel.recal \</span><br><span class="line"> -mode INDEL</span><br></pre></td></tr></table></figure>
  299. <ul>
  300. <li>最后得到的结果如下</li>
  301. </ul>
  302. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">├── [2.7M] ./snp.plots.R</span><br><span class="line">├── [6.2M] ./snp.plots.R.pdf</span><br><span class="line">├── [199M] ./snp.recal</span><br><span class="line">├── [7.5M] ./snp.recal.idx</span><br><span class="line">├── [ 584] ./snp.tranches</span><br><span class="line">├── [7.5K] ./snp.tranches.pdf</span><br><span class="line">├── [151M] ./snp.VQSR.vcf.gz</span><br><span class="line">├── [2.0M] ./snp.VQSR.vcf.gz.tbi</span><br><span class="line">├── [2.8M] ./snp.indel.plots.R</span><br><span class="line">├── [6.2M] ./snp.indel.plots.R.pdf</span><br><span class="line">├── [ 35M] ./snp.indel.recal</span><br><span class="line">├── [256K] ./snp.indel.recal.idx</span><br><span class="line">├── [ 595] ./snp.indel.tranches</span><br><span class="line">├── [153M] ./snp.indel.VQSR.vcf.gz</span><br><span class="line">├── [2.0M] ./snp.indel.VQSR.vcf.gz.tbi</span><br></pre></td></tr></table></figure>
  303. <ul>
  304. <li>SNP内容示例</li>
  305. </ul>
  306. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># tabix snp.VQSR.vcf.gz NC_000001.11 | head -n 5</span></span><br><span class="line">NC_000001.11 16378 . T C 35.32 VQSRTrancheSNP99.90to100.00 AC=2;AF=1.00;AN=2;DP=2;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=20.00;QD=17.66;SOR=2.303;VQSLOD=-1.018e+01;culprit=MQ GT:AD:DP:GQ:PL 1/1:0,2:2:6:47,6,0</span><br><span class="line">NC_000001.11 17020 . G A 59.32 VQSRTrancheSNP99.90to100.00 AC=2;AF=1.00;AN=2;DP=2;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=31.66;QD=29.66;SOR=0.693;VQSLOD=-5.480e+00;culprit=MQ GT:AD:DP:GQ:PL 1/1:0,2:2:6:71,6,0</span><br><span class="line">NC_000001.11 17385 . G A 60.32 VQSRTrancheSNP99.90to100.00 AC=2;AF=1.00;AN=2;DP=2;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=32.28;QD=30.16;SOR=2.303;VQSLOD=-2.357e+00;culprit=MQ GT:AD:DP:GQ:PL 1/1:0,2:2:6:72,6,0</span><br><span class="line">NC_000001.11 20254 . G A 64.64 VQSRTrancheSNP99.90to100.00 AC=1;AF=0.500;AN=2;BaseQRankSum=2.37;DP=8;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=24.89;MQRankSum=-2.030e-01;QD=8.08;ReadPosRankSum=-1.611e+00;SOR=1.034;VQSLOD=-1.317e+01;culprit=MQ GT:AD:DP:GQ:PGT:PID:PL:PS 0|1:5,3:8:72:1|0:20250_T_C:72,0,126:20250</span><br><span class="line">NC_000001.11 39230 . G A 83.64 VQSRTrancheSNP99.90to100.00 AC=1;AF=0.500;AN=2;BaseQRankSum=-1.078e+00;DP=15;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=26.72;MQRankSum=2.20;QD=5.58;ReadPosRankSum=-1.917e+00;SOR=1.022;VQSLOD=-1.362e+01;culprit=MQ GT:AD:DP:GQ:PL 0/1:10,5:15:91:91,0,239</span><br></pre></td></tr></table></figure>
  307. <h2 id="变异注释">变异注释</h2>
  308. <h3 id="安装-VEP">安装 VEP</h3>
  309. <ul>
  310. <li><a target="_blank" rel="noopener" href="http://www.ensembl.org/info/docs/tools/vep/index.html">VEP官网地址</a></li>
  311. </ul>
  312. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">sudo docker pull ensemblorg/ensembl-vep</span><br><span class="line">sudo docker run --<span class="built_in">rm</span> -t -i -v ~/upload:/data:z ensemblorg/ensembl-vep <span class="built_in">pwd</span></span><br><span class="line">sudo docker run --<span class="built_in">rm</span> -t -i -v ~/upload:/data:z ensemblorg/ensembl-vep <span class="built_in">ls</span> -al /opt/vep/</span><br><span class="line">sudo <span class="built_in">mkdir</span> -p ~/upload/vep &amp;&amp; sudo <span class="built_in">chmod</span> 777 ~/upload/vep</span><br><span class="line">sudo docker run --<span class="built_in">rm</span> -t -i -v ~/upload:/data:z -v ~/upload/vep:/opt/vep/.vep:z ensemblorg/ensembl-vep INSTALL.pl</span><br><span class="line"><span class="comment"># sudo docker run --rm -t -i -v ~/upload:/data:Z ensemblorg/ensembl-vep cat INSTALL.pl &gt; INSTALL.pl</span></span><br><span class="line"><span class="comment"># 自行分析 INSTALL.pl,构造下载后的结构,以下是104版本的</span></span><br><span class="line"><span class="comment"># 太慢了,手动下载,请各显神通,下载地址来自上一步的输出</span></span><br><span class="line">wget https://ftp.ensembl.org/pub/release-104/variation/indexed_vep_cache/homo_sapiens_vep_104_GRCh38.tar.gz -O ~/upload/vep</span><br><span class="line">tar -zxvf homo_sapiens_vep_104_GRCh38.tar.gz</span><br></pre></td></tr></table></figure>
  313. <h3 id="进行注释">进行注释</h3>
  314. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> -p ~/upload/VEP/SRX247249 &amp;&amp; <span class="built_in">chmod</span> -R 777 ~/upload/VEP/SRX247249</span><br><span class="line"><span class="comment"># mv ~/data/refseq ~/upload</span></span><br><span class="line"><span class="comment"># chmod -R 777 ~/upload/refseq</span></span><br><span class="line"><span class="comment"># chmod -R 777 ~/upload/vep</span></span><br><span class="line"><span class="comment"># chmod -R 777 ~/upload/merged/SRX247249</span></span><br><span class="line">sudo docker run --<span class="built_in">rm</span> -t -i -v ~/upload:/data:z ensemblorg/ensembl-vep \</span><br><span class="line"> vep --fasta /data/refseq/GRCh38.p14.fna \</span><br><span class="line"> --format vcf --vcf --fork 4 --hgvs --force_overwrite --everything \</span><br><span class="line"> --offline --dir_cache /data/vep \</span><br><span class="line"> -i /data/merged/SRX247249/SAMPLE1/snp.indel.VQSR.vcf.gz \</span><br><span class="line"> -o /data/merged/SRX247249/SAMPLE1/snp.indel.VQSR.VEP.vcf</span><br><span class="line"><span class="comment"># sudo chmod 777 ~/upload/merged/SRX247249/SAMPLE1/snp.indel.VQSR.VEP.vcf</span></span><br><span class="line"><span class="comment"># pbgzip -n 4 snp.indel.VQSR.VEP.vcf</span></span><br><span class="line"><span class="comment"># tabix -p vcf snp.indel.VQSR.VEP.vcf.gz</span></span><br></pre></td></tr></table></figure>
  315. <ul>
  316. <li>最后得到的结果如下</li>
  317. </ul>
  318. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">├── [346M] ./snp.indel.VQSR.VEP.vcf.gz</span><br><span class="line">├── [210K] ./snp.indel.VQSR.VEP.vcf.gz_summary.html</span><br><span class="line">├── [1.6M] ./snp.indel.VQSR.VEP.vcf.gz.tbi</span><br><span class="line">├── [8.2K] ./snp.indel.VQSR.VEP.vcf.gz_warnings.txt</span><br></pre></td></tr></table></figure>
  319. <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># tabix snp.indel.VQSR.VEP.vcf.gz NC_000001.11 | head -n 2</span></span><br><span class="line">NC_000001.11 16378 . T C 35.32 VQSRTrancheSNP99.90to100.00 AC=2;AF=1.00;AN=2;DP=2;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=20.00;QD=17.66;SOR=2.303;VQSLOD=-1.018e+01;culprit=MQ;CSQ=C|downstream_gene_variant|MODIFIER|DDX11L1|ENSG00000223972|Transcript|ENST00000450305|transcribed_unprocessed_pseudogene||||||||||rs148220436|2708|1||SNV|HGNC|HGNC:37102|YES||||||||||||||||||||||||||||||||||||||||||||,C|downstream_gene_variant|MODIFIER|DDX11L1|ENSG00000223972|Transcript|ENST00000456328|processed_transcript||||||||||rs148220436|1969|1||SNV|HGNC|HGNC:37102||||1|||||||||||||||||||||||||||||||||||||||||,C|intron_variant&amp;non_coding_transcript_variant|MODIFIER|WASH7P|ENSG00000227232|Transcript|ENST00000488147|unprocessed_pseudogene||8/10|ENST00000488147.1:n.1067+229A&gt;G|||||||rs148220436||-1||SNV|HGNC|HGNC:38034|YES||||||||||||||||||||||||||||||||||||||||||||,C|downstream_gene_variant|MODIFIER|MIR6859-1|ENSG00000278267|Transcript|ENST00000619216|miRNA||||||||||rs148220436|991|-1||SNV|HGNC|HGNC:50039|YES||||||||||||||||||||||||||||||||||||||||||||,C|regulatory_region_variant|MODIFIER|||RegulatoryFeature|ENSR00000344266|CTCF_binding_site||||||||||rs148220436||||SNV|||||||||||||||||||||||||||||||||||||||||||||||,C|regulatory_region_variant|MODIFIER|||RegulatoryFeature|ENSR00001164745|promoter_flanking_region||||||||||rs148220436||||SNV||||||||||||||||||||||||||||||||||||||||||||||| GT:AD:DP:GQ:PL 1/1:0,2:2:6:47,6,0</span><br><span class="line">NC_000001.11 17020 . G A 59.32 VQSRTrancheSNP99.90to100.00 AC=2;AF=1.00;AN=2;DP=2;ExcessHet=0.0000;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=31.66;QD=29.66;SOR=0.693;VQSLOD=-5.480e+00;culprit=MQ;CSQ=A|downstream_gene_variant|MODIFIER|DDX11L1|ENSG00000223972|Transcript|ENST00000450305|transcribed_unprocessed_pseudogene||||||||||rs199740902|3350|1||SNV|HGNC|HGNC:37102|YES||||||||||||||||||||||||||||||||||||||||||||,A|downstream_gene_variant|MODIFIER|DDX11L1|ENSG00000223972|Transcript|ENST00000456328|processed_transcript||||||||||rs199740902|2611|1||SNV|HGNC|HGNC:37102||||1|||||||||||||||||||||||||||||||||||||||||,A|non_coding_transcript_exon_variant|MODIFIER|WASH7P|ENSG00000227232|Transcript|ENST00000488147|unprocessed_pseudogene|7/11||ENST00000488147.1:n.746C&gt;T||746|||||rs199740902||-1||SNV|HGNC|HGNC:38034|YES||||||||||||||||||||||||||||||||||||||||||||,A|downstream_gene_variant|MODIFIER|MIR6859-1|ENSG00000278267|Transcript|ENST00000619216|miRNA||||||||||rs199740902|349|-1||SNV|HGNC|HGNC:50039|YES|||||||||||||||||||||||||||||||||||||||||||| GT:AD:DP:GQ:PL 1/1:0,2:2:6:71,6,0</span><br></pre></td></tr></table></figure>
  320. </div>
  321. <hr/>
  322. <div>
  323. <div class="post-metas my-3">
  324. <div class="post-meta">
  325. <i class="iconfont icon-tags"></i>
  326. <a href="/tags/GATK/" class="print-no-link">#GATK</a>
  327. <a href="/tags/SNP/" class="print-no-link">#SNP</a>
  328. <a href="/tags/WGS/" class="print-no-link">#WGS</a>
  329. </div>
  330. </div>
  331. <div class="license-box my-3">
  332. <div class="license-title">
  333. <div>【学习】使用GATK4.0找SNP</div>
  334. <div>https://hexo.limour.top/shi-yong-GATK-zhao-SNP</div>
  335. </div>
  336. <div class="license-meta">
  337. <div class="license-meta-item">
  338. <div>Author</div>
  339. <div>Limour</div>
  340. </div>
  341. <div class="license-meta-item license-meta-date">
  342. <div>Posted on</div>
  343. <div>September 24, 2023</div>
  344. </div>
  345. <div class="license-meta-item license-meta-date">
  346. <div>Updated on</div>
  347. <div>March 19, 2024</div>
  348. </div>
  349. <div class="license-meta-item">
  350. <div>Licensed under</div>
  351. <div>
  352. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  353. <span class="hint--top hint--rounded" aria-label="BY - Attribution">
  354. <i class="iconfont icon-by"></i>
  355. </span>
  356. </a>
  357. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  358. <span class="hint--top hint--rounded" aria-label="NC - Non-commercial">
  359. <i class="iconfont icon-nc"></i>
  360. </span>
  361. </a>
  362. <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  363. <span class="hint--top hint--rounded" aria-label="SA - Share-alike">
  364. <i class="iconfont icon-sa"></i>
  365. </span>
  366. </a>
  367. </div>
  368. </div>
  369. </div>
  370. <div class="license-icon iconfont"></div>
  371. </div>
  372. <div class="post-prevnext my-3">
  373. <article class="post-prev col-6">
  374. <a href="/The-Academy-System-Civilization-From-Hundreds-of-Millions-of-Years-Ago" title="【设定】亿万年前的学院制文明">
  375. <i class="iconfont icon-arrowleft"></i>
  376. <span class="hidden-mobile">【设定】亿万年前的学院制文明</span>
  377. <span class="visible-mobile">Previous</span>
  378. </a>
  379. </article>
  380. <article class="post-next col-6">
  381. <a href="/dan-xi-bao-zui-jia-shi-jian-de-liu-cheng" title="【复习】单细胞最佳实践的流程">
  382. <span class="hidden-mobile">【复习】单细胞最佳实践的流程</span>
  383. <span class="visible-mobile">Next</span>
  384. <i class="iconfont icon-arrowright"></i>
  385. </a>
  386. </article>
  387. </div>
  388. </div>
  389. <article id="comments" lazyload>
  390. <div id="waline"></div>
  391. <script type="text/javascript">
  392. Fluid.utils.loadComments('#waline', function() {
  393. Fluid.utils.createCssLink('https://cdn.staticfile.org/waline/2.15.5/waline.min.css')
  394. Fluid.utils.createScript('https://cdn.staticfile.org/waline/2.15.5/waline.min.js', function() {
  395. var options = Object.assign(
  396. {"serverURL":"https://comments.limour.top","path":"window.location.pathname","meta":["nick","mail","link"],"requiredMeta":["nick"],"lang":"zh-CN","emoji":["https://jscdn.limour.top/gh/walinejs/emojis/weibo"],"dark":"html[data-user-color-scheme=\"dark\"]","wordLimit":0,"pageSize":10},
  397. {
  398. el: '#waline',
  399. path: window.location.pathname
  400. }
  401. )
  402. Waline.init(options);
  403. Fluid.utils.waitElementVisible('#waline .vcontent', () => {
  404. var imgSelector = '#waline .vcontent img:not(.vemoji)';
  405. Fluid.plugins.imageCaption(imgSelector);
  406. Fluid.plugins.fancyBox(imgSelector);
  407. })
  408. });
  409. });
  410. </script>
  411. <noscript>Please enable JavaScript to view the comments</noscript>
  412. </article>
  413. </article>
  414. </div>
  415. </div>
  416. </div>
  417. <div class="side-col d-none d-lg-block col-lg-2">
  418. <aside class="sidebar" style="margin-left: -1rem">
  419. <div id="toc">
  420. <p class="toc-header">
  421. <i class="iconfont icon-list"></i>
  422. <span>Table of Contents</span>
  423. </p>
  424. <div class="toc-body" id="toc-body"></div>
  425. </div>
  426. </aside>
  427. </div>
  428. </div>
  429. </div>
  430. <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
  431. <i class="iconfont icon-arrowup" aria-hidden="true"></i>
  432. </a>
  433. <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
  434. aria-hidden="true">
  435. <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
  436. <div class="modal-content">
  437. <div class="modal-header text-center">
  438. <h4 class="modal-title w-100 font-weight-bold">Search</h4>
  439. <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
  440. <span aria-hidden="true">&times;</span>
  441. </button>
  442. </div>
  443. <div class="modal-body mx-3">
  444. <div class="md-form mb-5">
  445. <input type="text" id="local-search-input" class="form-control validate">
  446. <label data-error="x" data-success="v" for="local-search-input">Keyword</label>
  447. </div>
  448. <div class="list-group" id="local-search-result"></div>
  449. </div>
  450. </div>
  451. </div>
  452. </div>
  453. </main>
  454. <footer>
  455. <div class="footer-inner">
  456. <div class="footer-content">
  457. <a target="_blank" rel="nofollow noopener" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=43130202000203"><img src="https://img.limour.top/2023/08/27/64eadeb81d6a0.webp" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload>湘公网安备43130202000203号 </a> <a target="_blank" rel="nofollow noopener" href="https://beian.miit.gov.cn/">湘ICP备20008299号 </a> <a target="_blank" rel="nofollow noopener" href="https://icp.gov.moe/?keyword=20210128">萌ICP备20210128号</a> <br> <a href="https://www.foreverblog.cn/" target="_blank"> <img src="https://img.foreverblog.cn/logo_en_default.png" srcset="https://jscdn.limour.top/gh/Limour-dev/Sakurairo_Vision/load_svg/inload.svg" lazyload alt="" style="width:auto;height:24px"> </a> <br> <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/limour-blog/limour-blog.github.io" target="_blank" rel="nofollow noopener"><span>SRC</span></a> <i class="iconfont icon-love"></i> <a href="https://web.archive.org/web/20231130095837/https://effectiveacceleration.tech/" target="_blank" rel="nofollow noopener"><span>e/Acc</span></a>
  458. </div>
  459. </div>
  460. </footer>
  461. <!-- Scripts -->
  462. <script src="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.js" ></script>
  463. <link rel="stylesheet" href="https://jscdn.limour.top/npm/nprogress@0.2.0/nprogress.min.css" />
  464. <script>
  465. NProgress.configure({"showSpinner":false,"trickleSpeed":100})
  466. NProgress.start()
  467. window.addEventListener('load', function() {
  468. NProgress.done();
  469. })
  470. </script>
  471. <script src="https://jscdn.limour.top/npm/jquery@3.6.4/dist/jquery.min.js" ></script>
  472. <script src="https://jscdn.limour.top/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js" ></script>
  473. <script src="/js/events.js" ></script>
  474. <script src="/js/plugins.js" ></script>
  475. <script src="/js/img-lazyload.js" ></script>
  476. <script>
  477. Fluid.utils.createScript('https://jscdn.limour.top/npm/tocbot@4.20.1/dist/tocbot.min.js', function() {
  478. var toc = jQuery('#toc');
  479. if (toc.length === 0 || !window.tocbot) { return; }
  480. var boardCtn = jQuery('#board-ctn');
  481. var boardTop = boardCtn.offset().top;
  482. window.tocbot.init(Object.assign({
  483. tocSelector : '#toc-body',
  484. contentSelector : '.markdown-body',
  485. linkClass : 'tocbot-link',
  486. activeLinkClass : 'tocbot-active-link',
  487. listClass : 'tocbot-list',
  488. isCollapsedClass: 'tocbot-is-collapsed',
  489. collapsibleClass: 'tocbot-is-collapsible',
  490. scrollSmooth : true,
  491. includeTitleTags: true,
  492. headingsOffset : -boardTop,
  493. }, CONFIG.toc));
  494. if (toc.find('.toc-list-item').length > 0) {
  495. toc.css('visibility', 'visible');
  496. }
  497. Fluid.events.registerRefreshCallback(function() {
  498. if ('tocbot' in window) {
  499. tocbot.refresh();
  500. var toc = jQuery('#toc');
  501. if (toc.length === 0 || !tocbot) {
  502. return;
  503. }
  504. if (toc.find('.toc-list-item').length > 0) {
  505. toc.css('visibility', 'visible');
  506. }
  507. }
  508. });
  509. });
  510. </script>
  511. <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>
  512. <script>Fluid.plugins.codeWidget();</script>
  513. <script>
  514. Fluid.utils.createScript('https://jscdn.limour.top/npm/anchor-js@4.3.1/anchor.min.js', function() {
  515. window.anchors.options = {
  516. placement: CONFIG.anchorjs.placement,
  517. visible : CONFIG.anchorjs.visible
  518. };
  519. if (CONFIG.anchorjs.icon) {
  520. window.anchors.options.icon = CONFIG.anchorjs.icon;
  521. }
  522. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  523. var res = [];
  524. for (var item of el) {
  525. res.push('.markdown-body > ' + item.trim());
  526. }
  527. if (CONFIG.anchorjs.placement === 'left') {
  528. window.anchors.options.class = 'anchorjs-link-left';
  529. }
  530. window.anchors.add(res.join(', '));
  531. Fluid.events.registerRefreshCallback(function() {
  532. if ('anchors' in window) {
  533. anchors.removeAll();
  534. var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
  535. var res = [];
  536. for (var item of el) {
  537. res.push('.markdown-body > ' + item.trim());
  538. }
  539. if (CONFIG.anchorjs.placement === 'left') {
  540. anchors.options.class = 'anchorjs-link-left';
  541. }
  542. anchors.add(res.join(', '));
  543. }
  544. });
  545. });
  546. </script>
  547. <script>Fluid.plugins.imageCaption();</script>
  548. <script src="/js/local-search.js" ></script>
  549. <!-- 主题的启动项,将它保持在最底部 -->
  550. <!-- the boot of the theme, keep it at the bottom -->
  551. <script src="/js/boot.js" ></script>
  552. <noscript>
  553. <div class="noscript-warning">Blog works best with JavaScript enabled</div>
  554. </noscript>
  555. <!-- hexo injector body_end start -->
  556. <script defer src="/theme-inject/timeliness.js"></script>
  557. <!-- hexo injector body_end end --></body>
  558. </html>