{"id":634,"date":"2025-10-15T10:52:34","date_gmt":"2025-10-15T02:52:34","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=634"},"modified":"2025-10-15T20:32:34","modified_gmt":"2025-10-15T12:32:34","slug":"%e4%bd%bf%e7%94%a8-numbat-%e8%bf%9b%e8%a1%8c%e5%8d%95%e7%bb%86%e8%83%9e%e6%81%b6%e6%80%a7%e7%bb%86%e8%83%9e%e9%89%b4%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2025\/10\/15\/%e4%bd%bf%e7%94%a8-numbat-%e8%bf%9b%e8%a1%8c%e5%8d%95%e7%bb%86%e8%83%9e%e6%81%b6%e6%80%a7%e7%bb%86%e8%83%9e%e9%89%b4%e5%ae%9a\/","title":{"rendered":"\u4f7f\u7528 Numbat \u8fdb\u884c\u5355\u7ec6\u80de\u6076\u6027\u7ec6\u80de\u9274\u5b9a"},"content":{"rendered":"<p><strong>Numbat\u5b98\u7f51\uff1a<\/strong> <a href=\"https:\/\/kharchenkolab.github.io\/numbat\/articles\/numbat.html\">https:\/\/kharchenkolab.github.io\/numbat\/articles\/numbat.html<\/a><\/p>\n<ul>\n<li><strong>\u5176\u5b83\u4f9d\u8d56\u5305\uff1a<\/strong>\n<ol>\n<li>cellsnp-lite\uff1a<a href=\"https:\/\/github.com\/single-cell-genetics\/cellsnp-lite\">https:\/\/github.com\/single-cell-genetics\/cellsnp-lite<\/a><\/li>\n<li>Eagle2\uff1a<a href=\"https:\/\/alkesgroup.broadinstitute.org\/Eagle\/\">https:\/\/alkesgroup.broadinstitute.org\/Eagle\/<\/a><\/li>\n<li>samtools<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h2>1. \u5b89\u88c5\u53ca\u53c2\u8003\u6587\u4ef6\u4e0b\u8f7d<\/h2>\n<p>Numbat \u5b89\u88c5\uff1a<\/p>\n<pre><code>install.packages(&#039;numbat&#039;, dependencies = TRUE)\n\ndevtools::install_github(&quot;https:\/\/github.com\/kharchenkolab\/numbat&quot;)\n\n# \u6ce8\u610f\u8fd8\u8981\u4e0b\u8f7dgithub\u5b98\u7f51\u7684\u5305\uff0c\u91cc\u9762\u6709\u4e2a\u5355\u72ec\u7684\u811a\u672c\u4f1a\u7528\u6765\u63d0\u53d6snp<\/code><\/pre>\n<p>Eagle v2.4.1\uff1a<\/p>\n<pre><code>http:\/\/data.broadinstitute.org\/alkesgroup\/Eagle\/downloads\/<\/code><\/pre>\n<p>\u53c2\u8003\u6587\u4ef6\uff1a<\/p>\n<pre><code># 1000G SNP VCF\n# hg38\nwget https:\/\/sourceforge.net\/projects\/cellsnp\/files\/SNPlist\/genome1K.phase3.SNP_AF5e2.chr1toX.hg38.vcf.gz\n# hg19\nwget https:\/\/sourceforge.net\/projects\/cellsnp\/files\/SNPlist\/genome1K.phase3.SNP_AF5e2.chr1toX.hg19.vcf.gz\n\n# 1000G Reference Panel (paste link in browser to download if wget isn\u2019t working)\n# hg38\nwget http:\/\/pklab.med.harvard.edu\/teng\/data\/1000G_hg38.zip\n# hg19\nwget http:\/\/pklab.med.harvard.edu\/teng\/data\/1000G_hg19.zip\n<\/code><\/pre>\n<h2>2. Preparing data<\/h2>\n<p>\u5bf9\u6bcf\u4e2a\u5355\u7ec6\u80de\u6837\u672c\u8fdb\u884c\u4e00\u6b21pileup<\/p>\n<ul>\n<li>\u6a21\u677fsh\u6587\u4ef6\uff1a<br \/>\nEXAMPLE_Run_pileup_and_phase.sh <\/li>\n<\/ul>\n<pre><code>Rscript \/home\/zhoukaiwen\/software\/numbat-1.4.2\/inst\/bin\/pileup_and_phase.R \\\n--label EXAMPLE \\\n--samples EXAMPLE \\\n--bams \/groups\/phyllodes\/home\/share\/Results\/scRNA\/cellranger_count_new\/EXAMPLE\/outs\/possorted_genome_bam.bam \\\n--barcodes \/groups\/phyllodes\/home\/share\/Results\/scRNA\/cellranger_count_new\/EXAMPLE\/outs\/filtered_feature_bc_matrix\/barcodes.tsv \\\n--outdir EXAMPLE \\\n--gmap \/home\/zhoukaiwen\/software\/Eagle_v2.4.1\/tables\/genetic_map_hg38_withX.txt.gz \\\n--snpvcf \/home\/zhoukaiwen\/database\/numbat_reference\/genome1K.phase3.SNP_AF5e2.chr1toX.hg38.vcf \\\n--paneldir \/home\/zhoukaiwen\/database\/numbat_reference\/1000G_hg38 \\\n--ncores 4<\/code><\/pre>\n<ul>\n<li>\u6839\u636e\u6a21\u677f\u6587\u4ef6\u4e3a\u6bcf\u4e2a\u6837\u672c\u751f\u6210\u4e00\u4e2a\u811a\u672c\uff08\u9700\u8981\u6709\u4e00\u4e2a\u53ebsample_id.txt\u7684\u6587\u4ef6\uff0c\u91cc\u9762\u5305\u542b\u4e86\u6240\u6709\u7684\u6837\u672c\u540d\uff09\uff1a<br \/>\nCreate_Run_pileup_and_phase_Script.sh<\/li>\n<\/ul>\n<pre><code>#!\/bin\/bash\n\n# \u8bfb\u53d6sample_id.txt\u4e2d\u7684\u6bcf\u4e2a\u6837\u672cID\nwhile IFS= read -r sample_id; do\n    if [[ -n &quot;$sample_id&quot; ]]; then\n        # \u751f\u6210\u65b0\u7684sh\u6587\u4ef6\u540d\n        new_file=&quot;${sample_id}_Run_pileup_and_phase.sh&quot;\n\n        # \u590d\u5236\u5e76\u66ff\u6362\u5185\u5bb9\n        sed &quot;s\/EXAMPLE\/${sample_id}\/g&quot; EXAMPLE_Run_pileup_and_phase.sh &gt; &quot;$new_file&quot;\n\n        echo &quot;Generated: $new_file&quot;\n    fi\ndone &lt; sample_id.txt\n\necho &quot;All scripts generated successfully!&quot;<\/code><\/pre>\n<ul>\n<li>\u751f\u6210\u6279\u91cf\u8fd0\u884c\u4e0a\u8ff0\u751f\u6210\u7684sh\u7684\u811a\u672c\uff1a<br \/>\nRun_All_Run_pileup_and_phase.sh<\/li>\n<\/ul>\n<pre><code>echo &#039;#!\/bin\/bash&#039; &gt; Run_All_Run_pileup_and_phase.sh\necho &#039;# \u6279\u91cf\u8fd0\u884c\u6240\u6709pileup\u548cphase\u811a\u672c&#039; &gt;&gt; Run_All_Run_pileup_and_phase.sh\necho &#039;&#039; &gt;&gt; Run_All_Run_pileup_and_phase.sh\n\n# \u6dfb\u52a0\u6bcf\u4e2a\u811a\u672c\u7684\u8fd0\u884c\u547d\u4ee4\nfor script in Run_pileup_and_phase_FETB*.sh; do\n    echo &quot;echo \\&quot;\u5f00\u59cb\u8fd0\u884c: $script\\&quot;&quot; &gt;&gt; Run_All_Run_pileup_and_phase.sh\n    echo &quot;bash $script&quot; &gt;&gt; Run_All_Run_pileup_and_phase.sh\n    echo &quot;echo \\&quot;\u5b8c\u6210: $script\\&quot;&quot; &gt;&gt; Run_All_Run_pileup_and_phase.sh\n    echo &quot;echo \\&quot;----------------------------------------\\&quot;&quot; &gt;&gt; Run_All_Run_pileup_and_phase.sh\n    echo &quot;&quot; &gt;&gt; Run_All_Run_pileup_and_phase.sh\ndone\n\necho &#039;echo &quot;\u6240\u6709\u811a\u672c\u8fd0\u884c\u5b8c\u6210!&quot;&#039; &gt;&gt; Run_All_Run_pileup_and_phase.sh<\/code><\/pre>\n<h2>3. Running Numbat<\/h2>\n<ul>\n<li>\u6a21\u677f\u6587\u4ef6\uff1a<br \/>\nEXAMPLE_Run_Numbat.main.R<\/li>\n<\/ul>\n<pre><code>library(Seurat)\nlibrary(numbat)\nlibrary(qs)\nlibrary(data.table)\n\nmessage(&quot;Loading File...&quot;)\nseu_obj &lt;- qread(&quot;\/groups\/phyllodes\/home\/share\/Results\/transfer\/16samples_Merged_AllCells_Annotated_Final.qs&quot;)\nseu_obj &lt;- subset(seu_obj,orig.ident==&quot;EXAMPLE&quot;)\n\n#All_matrix &lt;- GetAssayData(seu_obj,slot = &quot;counts&quot;)\n#All_matrix &lt;- as.data.frame(All_matrix)\n#All_matrix &lt;- round(All_matrix,digits = 0)\n#qsave(All_matrix,&quot;All_matrix.qs&quot;)\nAll_matrix &lt;- qread(&quot;All_matrix.qs&quot;)\n\n#All_data &lt;- GetAssayData(seu_obj,slot = &quot;data&quot;)\n#All_data &lt;- as.data.frame(All_data)\n#qsave(All_data,&quot;All_data.qs&quot;)\nAll_data &lt;- qread(&quot;All_data.qs&quot;)\n\nreference_cells &lt;- c(&quot;SELL+_CD4+_Tn&quot;,&quot;FOXP3+_Treg&quot;,&quot;CD4+_Tem&quot;,&quot;ANXA1+_CD4+_Tcm&quot;,\n                     &quot;CXCL13+_Tfh&quot;,&quot;CD8+_MAIT&quot;,&quot;GZMK+_CD8+_Tem&quot;,&quot;ZNF683+CXCR6-_CD8+_Trm&quot;,\n                     &quot;ZNF683+CXCR6+_CD8+_Trm&quot;,&quot;KLRG1+_CD8+_Temra\/Teff&quot;,&quot;SELL+_CD8+_Tn\/Tcm&quot;,&quot;RSAD2+GZMK+_CD8+_Tem&quot;,\n                     &quot;GZMK+PDCD1+_CD8+_Tex&quot;,&quot;Proliferating_CD8+_T&quot;, &quot;CD56dimCD16hi_NKT&quot;,&quot;CD56brightCD16lo_NK&quot;,\n                     &quot;CD56dimCD16hi_NK&quot;,&quot;IL41+KIT+_NK&quot;,&quot;Bn&quot;,&quot;Bm&quot;,\n                     &quot;ASCs&quot;,&quot;Bgc&quot;,&quot;ASC-like&quot;,&quot;Unknown_B&quot;,\n                     &quot;Macrophages&quot;,&quot;CD1C+_cDC2&quot;,&quot;MKI67+_Proliferating_mono\/macro&quot;,&quot;Monocytes&quot;,&quot;MastCells&quot;)\n\nreference_cell_id &lt;- rownames(subset(seu_obj@meta.data,CellType_Minor %in% reference_cells))\ntumor_cell_id &lt;- rownames(subset(seu_obj@meta.data,!(CellType_Minor %in% reference_cells)))\n\ntumor_matrix &lt;- All_matrix[,tumor_cell_id]\nreference_matrix &lt;- All_data[,reference_cell_id]\n\ndf_allele &lt;- fread(&quot;gunzip -c EXAMPLE\/EXAMPLE_allele_counts.tsv.gz&quot;)\n\nsuffix_num &lt;- strsplit(colnames(tumor_matrix),&quot;_&quot;)[[1]][2]\ndf_allele$cell &lt;- paste0(df_allele$cell,&quot;_&quot;,suffix_num)\n\nrm(list=c(&quot;All_data&quot;,&quot;All_matrix&quot;,&quot;seu_obj&quot;))\n\nmessage(&quot;Start run_numbat&quot;)\nout = run_numbat(\n  as.matrix(tumor_matrix), # gene x cell integer UMI count matrix \n  as.matrix(reference_matrix), # reference expression profile, a gene x cell type normalized expression level matrix\n  df_allele, # allele dataframe generated by pileup_and_phase script\n  genome = &quot;hg38&quot;,\n  t = 1e-5,\n  ncores = 4,\n  plot = TRUE,\n  out_dir = &#039;.\/EXAMPLE_numbat&#039;\n)<\/code><\/pre>\n<ul>\n<li>\u4e3a\u6bcf\u4e2a\u6837\u672c\u751f\u6210\u4e00\u4e2aR\u811a\u672c<br \/>\nCreate_Run_numbat.sh<\/li>\n<\/ul>\n<pre><code>#!\/bin\/bash\n\n# \u8bfb\u53d6sample_id.txt\u4e2d\u7684\u6bcf\u4e2a\u6837\u672cID\nwhile IFS= read -r sample_id; do\n    if [[ -n &quot;$sample_id&quot; ]]; then\n        # \u751f\u6210\u65b0\u7684sh\u6587\u4ef6\u540d\n        new_file=&quot;${sample_id}_Run_Numbat.main.R&quot;\n\n        # \u590d\u5236\u5e76\u66ff\u6362\u5185\u5bb9\n        sed &quot;s\/EXAMPLE\/${sample_id}\/g&quot; EXAMPLE_Run_Numbat.main.R &gt; &quot;$new_file&quot;\n\n        echo &quot;Generated: $new_file&quot;\n    fi\ndone &lt; sample_id.txt\n\necho &quot;All scripts generated successfully!&quot;<\/code><\/pre>\n<ul>\n<li>\u6279\u91cf\u8fd0\u884cR\u7684\u811a\u672c<\/li>\n<\/ul>\n<pre><code>echo &#039;#!\/bin\/bash&#039; &gt; Run_All_Run_numbat.sh\necho &#039;# \u6279\u91cf\u8fd0\u884c\u6240\u6709pileup\u548cphase\u811a\u672c&#039; &gt;&gt; Run_All_Run_numbat.sh\necho &#039;&#039; &gt;&gt; Run_All_Run_numbat.sh\nfor script in FETB*_Run_Numbat.main.R; do\n    echo &quot;echo \\&quot;\u5f00\u59cb\u8fd0\u884c: $script\\&quot;&quot; &gt;&gt; Run_All_Run_numbat.sh\n    echo &quot;Rscript .\/$script&quot; &gt;&gt; Run_All_Run_numbat.sh\n    echo &quot;echo \\&quot;\u5b8c\u6210: $script\\&quot;&quot; &gt;&gt; Run_All_Run_numbat.sh\n    echo &quot;echo \\&quot;----------------------------------------\\&quot;&quot; &gt;&gt; Run_All_Run_numbat.sh\n    echo &quot;&quot; &gt;&gt; Run_All_Run_numbat.sh\ndone<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Numbat\u5b98\u7f51\uff1a https:\/\/kharchenkolab.github.io\/numbat\/articl&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-634","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/comments?post=634"}],"version-history":[{"count":3,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/634\/revisions"}],"predecessor-version":[{"id":637,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/634\/revisions\/637"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}