{"id":245,"date":"2024-08-05T18:52:52","date_gmt":"2024-08-05T10:52:52","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=245"},"modified":"2024-08-23T18:07:37","modified_gmt":"2024-08-23T10:07:37","slug":"infercnv-uphyloplot2-%e6%9e%84%e5%bb%ba%e5%8d%95%e7%bb%86%e8%83%9e%e8%bf%9b%e5%8c%96%e6%a0%91","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2024\/08\/05\/infercnv-uphyloplot2-%e6%9e%84%e5%bb%ba%e5%8d%95%e7%bb%86%e8%83%9e%e8%bf%9b%e5%8c%96%e6%a0%91\/","title":{"rendered":"InferCNV + UPhyloplot2 \u6784\u5efa\u5355\u7ec6\u80de\u8fdb\u5316\u6811"},"content":{"rendered":"<h3>1. \u4e0b\u8f7dUPhyloplot2\u8f6f\u4ef6<\/h3>\n<h5>UPhyloplot2 Github\u5b98\u7f51\uff1a <a href=\"https:\/\/github.com\/harbourlab\/UPhyloplot2\">https:\/\/github.com\/harbourlab\/UPhyloplot2<\/a><\/h5>\n<h5>\u53c2\u8003\u6587\u6863\uff1a <a href=\"https:\/\/www.jianshu.com\/p\/38280bda882a\">https:\/\/www.jianshu.com\/p\/38280bda882a<\/a><\/h5>\n<h3>2. \u8fd0\u884c InferCNV<\/h3>\n<pre><code># \u6784\u5efainfercnv_obj\u8f6f\u4ef6\u62a5\u7684\u63d0\u793a\uff1a\n# Please use &quot;options(scipen = 100)&quot; before running infercnv if you are using the analysis_mode=&quot;subclusters&quot; option or you may encounter an error while the hclust is being generated.\n# \u4e00\u5b9a\u8981\u8bbe\u5b9a\u4e3arandom_trees\u8fd0\u884c\uff0c\u5426\u5219\u81ea\u52a8\u9009\u62e9Leiden clustering\uff0c\u4f46\u662f\u8fd9\u6837\u8fd0\u884c\u5de8\u6162\uff0c\u8dd11\u4e2a\u6811\u7684\u5206\u652f\u5c31\u898110h\uff0c\u5e94\u7528\u540e\u53f0R nohup\u8fd0\u884c\noptions(scipen = 100)\ninfercnv_obj = infercnv::run(infercnv_obj,\n                             cutoff=0.1, # cutoff=1 works well for Smart-seq2, and cutoff=0.1 works well for 10x Genomics\n                             out_dir=&quot;InferCNV_MPT01_UPhyloplot2&quot;,\n                             cluster_by_groups=FALSE, \n                             analysis_mode=&quot;subclusters&quot;, #\u9ed8\u8ba4\u662f&quot;samples&quot;\n                             denoise=TRUE,\n                             write_expr_matrix = T,\n                             HMM=TRUE,\n                             plot_steps=T,\n                             scale_data=T,\n                             noise_filter=0.12,\n                             HMM_type=&#039;i6&#039;,\n                             num_threads=8,\n                             hclust_method=&#039;ward.D2&#039;,\n                             tumor_subcluster_partition_method=&#039;random_trees&#039;,\n                             tumor_subcluster_pval=0.05)\n<\/code><\/pre>\n<h3>3. InferCNV\u8dd1\u5b8c\u540e\u7684\u6570\u636e\u9884\u5904\u7406<\/h3>\n<p>\u8f93\u51fa\u7ed3\u679c\u6709\u51e0\u4e2a\u6587\u4ef6\u5728\u540e\u9762\u753b\u8fdb\u5316\u6811\u4f1a\u7528\u5230\uff1a<\/p>\n<ol>\n<li>\u753b\u8fdb\u5316\u6811\u9700\u8981: 17_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.cell_groupings\uff08\u5305\u542b\u4e86\u6839\u636eCNV\u5206\u7c7b\u7684\u7ed3\u679c\uff0c\u4e00\u5171\u4e24\u5217\uff0c\u4e00\u5217\u662f\u7c7b\u522b\u540d\u79f0\uff0c \u51718\u7c7b\uff0c\u4f46\u662f\u6709\u4e00\u7c7b\u662f\u53c2\u8003\u7ec6\u80de\uff0c\u6240\u4ee5\u8981\u53bb\u6389\u53c2\u8003\uff0c\u5269\u4e0b7\u7c7b\uff1b\u53e6\u4e00\u5217\u662f\u7ec6\u80de\u7f16\u53f7\u3002\uff09<\/li>\n<li>\u6ce8\u91ca\u8fdb\u5316\u6811\u7684\u5206\u652f\u9700\u8981:<br \/>\n\u2460 HMM_CNV_predictions.HMMi6.rand_trees.hmm_mode-subclusters.Pnorm_0.5.pred_cnv_regions.dat<br \/>\n\u2461 HMM_CNV_predictions.HMMi6.rand_trees.hmm_mode-subclusters.Pnorm_0.5.pred_cnv_genes.dat<\/li>\n<li>\u6ce8\u610f\u8fd9\u4e24\u4e2a\u6587\u4ef6\u91ccstate\u7684\u610f\u4e49\uff1a<br \/>\nState 1: 0x: complete loss<br \/>\nState 2: 0.5x: loss of one copy<br \/>\nState 3: 1x: neutral<br \/>\nState 4: 1.5x: addition of one copy<br \/>\nState 5: 2x: addition of two copies<br \/>\nState 6: 3x: essentially a placeholder for &gt;2x copies but modeled as 3x<\/li>\n<\/ol>\n<pre><code># \u53bb\u6389\u753b\u8fdb\u5316\u6811\u9700\u8981\u7684\u6587\u4ef6\u7684\u53c2\u8003\u7ec6\u80de\u7684\u884c\nsed &#039;\/^all_references\/d&#039; &lt;  17_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.cell_groupings &gt; trimmed_infercnv.cell_groupings\n\n# \u5904\u7406\u540e\u6dfb\u52a0header: cell_group_name  cell\ncat 17_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.cell_groupings| grep &quot;all_observations&quot; &gt; trimmed_infercnv.cell_groupings\n\n# \u53bb\u6389\u6ce8\u91ca\u8fdb\u5316\u6811\u9700\u8981\u7684\u6587\u4ef6\u7684\u53c2\u8003\u7ec6\u80de\u7684\u884c\n# genes.dat\u6587\u4ef6\u5904\u7406\u540e\u6dfb\u52a0header: cell_group_name   gene_region_name    state   gene    chr start   end\n# regions.dat\u6587\u4ef6\u5904\u7406\u540e\u6dfb\u52a0header: cell_group_name cnv_name    state   chr start   end\n\ncat 17_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_genes.dat|grep &quot;all_observations&quot; &gt; trimmed_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_genes.dat\n\ncat 17_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_regions.dat|grep &quot;all_observations&quot; &gt; trimmed_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_regions.dat<\/code><\/pre>\n<h3>4. \u7ed8\u56fe<\/h3>\n<p>\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u5c06\u4e3b\u7a0b\u5e8fuphyloplot2.py\u548c\u6587\u4ef6\u5939Inputs\u653e\u5728\u4e00\u8d77\uff0c\u4e0a\u9762\u63d0\u5230cell_groupings\u6587\u4ef6\u653e\u5230Inputs\u6587\u4ef6\u5939\u91cc\u9762\u3002UPhyloplot2 \u5c06\u751f\u6210\u4e00\u4e2a\u201coutput.svg\u201d\u77e2\u91cf\u56fe\u5f62\u56fe\u3002\u6b64\u5916\uff0c\u5b83\u5c06\u751f\u6210\u4e00\u4e2a\u540d\u4e3a\u201cCNV_files\u201d\u7684\u65b0\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u6bcf\u4e2a\u8f93\u5165\u7684 CNV \u6587\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u7b2c 1 \u5217\u4e2d\u7531 inferCNV \u6807\u8bc6\u7684\u4e9a\u514b\u9686 ID\u3001\u7b2c 2 \u5217\u4e2d\u6bcf\u4e2a\u4e9a\u514b\u9686\u7684\u7ec6\u80de\u767e\u5206\u6bd4\u4ee5\u53ca\u6807\u8bb0\u4e9a\u514b\u9686\u7684\u5b57\u6bcd\u7b2c 3 \u5217\u4e2d\u7684 output.svg \u6587\u4ef6\u3002<\/p>\n<pre><code class=\"language-python\"># \u5728\u6587\u4ef6\u5939\u4e0b\u76f4\u63a5\u8fd0\u884c\u5373\u53ef\npython uphyloplot2.py\n<\/code><\/pre>\n<h3>5. \u6ce8\u91ca\u56fe\u7247<\/h3>\n<p>\u7b5b\u9009\u6bcf\u4e2a\u514b\u9686\u72ec\u7279\u7684CNV\u533a\u57df<\/p>\n<pre><code class=\"language-python\"># unique_cnv_region_for_cellgroup.py\nimport pandas as pd\n\n# Load the data into a pandas DataFrame\nfile_path = &#039;.\/trimmed_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_regions.dat&#039;\ndf = pd.read_csv(file_path, sep=&#039;\\t&#039;)\n\n# Extract unique CNV regions for each cell group\nunique_cnv_regions = df.groupby(&#039;cell_group_name&#039;)[&#039;cnv_name&#039;].unique().reset_index()\n\n# Convert the unique CNV regions to a dictionary for easy viewing\nunique_cnv_dict = unique_cnv_regions.set_index(&#039;cell_group_name&#039;).to_dict()[&#039;cnv_name&#039;]\n\n# Print the unique CNV regions for each cell group\nfor cell_group, cnv_regions in unique_cnv_dict.items():\n    print(f&quot;Cell Group: {cell_group}&quot;)\n    print(f&quot;Unique CNV Regions: {&#039;, &#039;.join(cnv_regions)}&quot;)\n    print()<\/code><\/pre>\n<p>\u7b5b\u9009\u6bcf\u4e2a\u514b\u9686\u72ec\u7279\u7684CNV \u57fa\u56e0<\/p>\n<pre><code class=\"language-python\"># unique_cnv_gene_for_cellgroup.py\nimport pandas as pd\n\n# Load the data into a pandas DataFrame\nfile_path = &#039;.\/trimmed_HMM_predHMMi6.rand_trees.hmm_mode-subclusters.pred_cnv_genes.dat&#039;\ndf = pd.read_csv(file_path, sep=&#039;\\t&#039;)\n\n# Extract unique CNV regions for each cell group\nunique_cnv_genes = df.groupby(&#039;cell_group_name&#039;)[&#039;gene&#039;].unique().reset_index()\n\n# Convert the unique CNV regions to a dictionary for easy viewing\nunique_cnv_dict = unique_cnv_genes.set_index(&#039;cell_group_name&#039;).to_dict()[&#039;gene&#039;]\n\n# Print the unique CNV regions for each cell group\nfor cell_group, cnv_genes in unique_cnv_dict.items():\n    print(f&quot;Cell Group: {cell_group}&quot;)\n    print(f&quot;Unique CNV Genes: {&#039;, &#039;.join(cnv_genes)}&quot;)\n    print()<\/code><\/pre>\n<pre><code class=\"language-bash\"># \u8fd0\u884c\u5e76\u8f93\u51fa\u7ed3\u679c\uff1a\npython unique_cnv_region_for_cellgroup.py &gt; unique_cnv_region_for_cellgroup.txt\n\npython unique_cnv_gene_for_cellgroup.py &gt; unique_cnv_gene_for_cellgroup.txt<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u4e0b\u8f7dUPhyloplot2\u8f6f\u4ef6 UPhyloplot2 Github\u5b98\u7f51\uff1a https:\/\/github&#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-245","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\/245","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=245"}],"version-history":[{"count":10,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":284,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions\/284"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}