{"id":711,"date":"2024-06-25T23:33:50","date_gmt":"2024-06-25T15:33:50","guid":{"rendered":"https:\/\/linguopeng.top\/?p=711"},"modified":"2024-06-26T10:42:21","modified_gmt":"2024-06-26T02:42:21","slug":"%e8%b7%9f%e7%9d%80imeta%e5%ad%a6%e5%81%9a%e5%9b%be%ef%bd%9ccirclize%e7%bb%98%e5%88%b6%e7%8e%af%e7%8a%b6%e7%83%ad%e5%9b%be%e5%b1%95%e7%a4%ba%e7%bb%86%e8%8f%8c%e5%8a%9f%e8%83%bd%e8%81%9a%e7%b1%bb","status":"publish","type":"post","link":"https:\/\/linguopeng.top\/?p=711","title":{"rendered":"\u8ddf\u7740iMeta\u5b66\u505a\u56fe\uff5ccirclize\u7ed8\u5236\u73af\u72b6\u70ed\u56fe\u5c55\u793a\u7ec6\u83cc\u529f\u80fd\u805a\u7c7b\u5206\u6790"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># \u519c\u5fc3\u751f\u4fe1\u5de5\u4f5c\u5ba4\n# 2022-11-16\n# \u4ee3\u7801\u7f16\u5199\u53ca\u6ce8\u91ca\uff1a\u519c\u5fc3\u751f\u4fe1\u5de5\u4f5c\u5ba4\n# \n# \u70ed\u56fe (Heat map) \u53ef\u4ee5\u5728\u5fae\u751f\u7269\u7ec4\u7814\u7a76\u4e2d\u5c55\u793a\u5c55\u793a\u7ec6\u83cc\u529f\u80fd\u805a\u7c7b\u5206\u6790\u7684\u7ed3\u679c\uff0c\u800c\u73af\u72b6\u70ed\u56fe\u662f\u70ed\u56fe\u7684\u4e00\u79cd\u8868\u73b0\u5f62\u5f0f\u3002\n# \u672c\u671f\u6211\u4eec\u6311\u90092022\u5e746\u670813\u65e5\u520a\u767b\u5728iMeta\u4e0a\u7684Microbial community roles and chemical mechanisms in the parasitic development of Orobanche cumana- iMeta | \n# \u897f\u519c\u6797\u96c1\u51b0\/ James M. Tiedje\u7b49\u63ed\u793a\u83cc\u7fa4\u5bf9\u5bc4\u751f\u690d\u7269\u5217\u5f53\u7684\u8c03\u63a7\u4f5c\u7528\uff0c\u9009\u62e9\u6587\u7ae0\u7684Figure 2B\u8fdb\u884c\u590d\u73b0\uff0c\n# \u57fa\u4e8e\u987e\u7956\u5149\u535a\u58eb\u5f00\u53d1\u7684circlize\u5305\uff0c\u8bb2\u89e3\u548c\u63a2\u8ba8\u73af\u5f62\u70ed\u56fe\u7684\u7ed8\u5236\u65b9\u6cd5\uff0c\u5148\u4e0a\u539f\u56fe\uff1a<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"1108\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-712\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># \u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u901a\u8fc7\u8be6\u5c3d\u7684\u4ee3\u7801\u9010\u6b65\u62c6\u89e3\u539f\u56fe\uff0c\u6700\u7ec8\u5b9e\u73b0\u5bf9\u539f\u56fe\u7684\u590d\u73b0\u3002\n# R\u5305\u68c0\u6d4b\u548c\u5b89\u88c5\n# 1. \u5b89\u88c5\u6838\u5fc3R\u5305circlize\u4ee5\u53ca\u4e00\u4e9b\u529f\u80fd\u8f85\u52a9\u6027R\u5305\uff0c\u5e76\u8f7d\u5165\u6240\u6709R\u5305\u3002\n# \u68c0\u67e5\u5f00\u53d1\u8005\u5de5\u5177devtools\uff0c\u5982\u6ca1\u6709\u5219\u5b89\u88c5\nif (!require(\"devtools\"))\n  install.packages(\"devtools\")\n# \u52a0\u8f7d\u5f00\u53d1\u8005\u5de5\u5177devtools\nlibrary(devtools)\n# \u68c0\u67e5circlize\u5305\uff0c\u6ca1\u6709\u5219\u901a\u8fc7github\u5b89\u88c5\u6700\u65b0\u7248\nif (!require(\"circlize\"))\n  install_github(\"jokergoo\/circlize\")\nif (!require(\"tidyverse\"))\n  install.packages('tidyverse') \nif (!require(\"ComplexHeatmap\"))\n  install.packages('ComplexHeatmap') \nif (!require(\"tidyverse\"))\n  install.packages('tidyverse') \n# \u52a0\u8f7d\u5305\nlibrary(circlize)\nlibrary(tidyverse)\nlibrary(ComplexHeatmap)\nlibrary(gridBase)\n# \u751f\u6210\u6d4b\u8bd5\u6570\u636e\n# 2.\u7531\u4e8e\u6ca1\u6709\u5728\u8865\u5145\u6587\u4ef6\u91cc\u627e\u5230\u539f\u6587\u76f8\u5173\u6570\u636e\uff0c\u5728\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7\u751f\u6210\u968f\u673a\u6570\u636e\u6765\u66ff\u4ee3\u3002\n#\u751f\u6210KEGG\u6570\u636e\u77e9\u9635\uff08\u77e9\u96351\uff09\ndata1&lt;-matrix(rnorm(670,mean=0.5),nrow=67)\nrownames(data1)&lt;-c(\"K01446\",\"K01971\",\"K01142\",\"K01151\",\"K01246\",\"K00784\",\"K02031\",\"K01644\",\"K02037\",\"K02065\",\"K01448\",\n                   \"K01890\",\"K00266\",\"K01725\",\"K00806\",\"K00231\",\"K01737\",\"K00858\",\"K00019\",\"K01715\",\"K01692\",\"K00249\",\n                   \"K00023\",\"K00626\",\"K00101\",\"K00803\",\"K01710\",\"K01791\",\"K01176\",\"K00799\",\"K00800\",\"K01667\",\"K01668\",\n                   \"K01712\",\"K00053\",\"K01696\",\"K01697\",\"K00108\",\"K00639\",\"K01489\",\"K00226\",\"K01488\",\"K02339\",\"K01428\",\n                   \"K01438\",\"K02124\",\"K02275\",\"K01796\",\"K00632\",\"K00648\",\"K00849\",\"K01805\",\"K01685\",\"K00065\",\"K00090\",\n                   \"K01619\",\"K01834\",\"K00121\",\"K02182\",\"K02082\",\"K02005\",\"K01266\",\"K01990\",\"K01463\",\"K02217\",\"K01174\",\"K02003\")\ncolnames(data1)&lt;-c(paste('H',seq(1:5),sep = \"\"),paste(\"PS\",seq(1:5),sep = \"\"))\n#\u751f\u6210EC\u6570\u636e\u77e9\u9635\uff08\u77e9\u96352\uff09\ndata2&lt;-matrix(rnorm(130,mean=1),nrow = 13)\nrownames(data2)&lt;-c(\"2.1.1.165\",\"1.1.5.-\",\"4.2.99.20\",\"1.1.1.86\",\"1.1.99.1\",\"1.1.2.3\",\"4.2.1.28\",\"4.2.1.82\",\"5.4.1.3\",\"1.13.12.16\",\"5.1.99.4\",\"1.17.4.1\",\"1.8.4.-\")\ncolnames(data2)&lt;-c(paste('H',seq(1:5),sep = \"\"),paste(\"PS\",seq(1:5),sep = \"\"))\n#\u751f\u6210\u7ec6\u83cc\u6570\u636e\u77e9\u9635\uff08\u77e9\u96353\uff09\ndata3&lt;-matrix(rnorm(20,mean=1),nrow = 10)\nsupdata&lt;-matrix(0,nrow = 10,ncol = 8)\n#\u7531\u4e8e\u8be5\u77e9\u9635\u4e3a10\u00d72\u77e9\u9635\uff0c\u9700\u8865\u514510\u00d78\u5168\u4e3a0\u7684\u77e9\u9635\uff0c\u4f7f\u5f97\u77e9\u9635123\u5747\u4e3am\u00d710\u7684\u77e9\u9635\ndata3&lt;-cbind(data3,supdata)\nrownames(data3)&lt;-c(\"Proteobacteria\",\"Actinobacteria\",\"Acidobacteria\",\"Bacteroidetes\",\"Gemmatimonadetes\",\"Chloroflexi\",\"Planctomycetes\",\"Firmicutes\",\"Verrucomicrobia\",\"unidentified_Acidobacteria\")\n#\u5c06\u4e09\u4e2a\u77e9\u9635\u6309\u884c\u5408\u5e76\nmat_data&lt;-rbind(data1,data2,data3)\n#\u6309\u884c\u5c06\u77e9\u9635\u53cd\u8f6c\uff0c\u8fd9\u6837\u77e9\u96353\u7684\u975e\u96f6\u6570\u636e\u4f1a\u51fa\u73b0\u5728\u5185\u5708\nmat_dataR&lt;-mat_data%&gt;% as.data.frame() %&gt;% rowwise() %&gt;% rev() %&gt;% as.matrix() \nrownames(mat_dataR)&lt;-rownames(mat_data)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image2-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"233\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image2-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-713\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># \u73af\u5f62\u70ed\u56fe\u9884\u89c8\n# 3.\u5f00\u59cb\u4f5c\u56fe\uff0c\u9996\u5148\u753b\u4e00\u4e2a\u6700\u57fa\u672c\u7684\u73af\u5f62\u70ed\u56fe\uff1a\npdf(\"plot1.pdf\",width = 8, height = 6)\n#\u8bbe\u7f6e\u70ed\u56fe\u989c\u8272\u8303\u56f4\uff1a\ncolpattern = colorRamp2(c(-1, 0, 1), c(\"#2574AA\", \"white\", \"#ED7B79\"))\n#\u8bbe\u7f6e\u6247\u533a\uff0c\u8fd9\u91cc\u5212\u5206\u4e86\u4e09\u4e2a\u6247\u533a\uff0cKEGG,EC\u548c\u7ec6\u83cc\u79cd\u7c7b\u3002\nlevel_test&lt;-c(rep(\"KEGG\",67),rep(\"EC\",13),rep(\"SP\",10)) %>% factor()\n\n#\u753b\u56fe\ncircos.heatmap(mat_dataR, col = colpattern, rownames.side = \"outside\", cluster = TRUE)\ncircos.clear()\n\ndev.off()\n#> png \n#>   2\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image3-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"630\" height=\"658\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image3-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-714\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#4. \u6dfb\u52a0\u6247\u533a\u5206\u5316\uff0c\u5355\u5143\u683c\u8fb9\u6846\uff0c\u8f68\u9053\u9ad8\u5ea6\uff0c\u6247\u533a\u95f4\u95f4\u9694\uff1a\npdf(\"plot2.pdf\",width = 8, height = 6)\ncircos.par(gap.after = c(10, 10, 12))\ncircos.heatmap(mat_dataR, split = level_test, \n               col = colpattern, rownames.side = \"outside\", \n               cluster = TRUE,cell.lwd=0.8,\n               cell.border=\"white\",track.height = 0.2)\ncircos.clear()\n\ndev.off()\n#&gt; png \n#&gt;   2\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image4-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1016\" height=\"858\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image4-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-715\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># 5.\u6dfb\u52a0\u77e9\u9635\u7684\u5217\u540d\u3002circos.heatmap()\u4e0d\u76f4\u63a5\u652f\u6301\u77e9\u9635\u7684\u5217\u540d\uff0c\u53ef\u4ee5\u901a\u8fc7\u81ea\u5b9a\u4e49panel.fun\u51fd\u6570\u8f7b\u677e\u6dfb\u52a0\uff1a\npdf(\"plot3.pdf\",width = 8, height = 6)\ncircos.par(gap.after = c(10, 10, 12))\ncircos.heatmap(mat_dataR, split = level_test, \n               col = colpattern, rownames.side = \"outside\", \n               cluster = TRUE,cell.lwd=0.8,\n               cell.border=\"white\",track.height = 0.2) \ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 1) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\n\ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 3) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\ncircos.clear()\n\ndev.off()\n#&gt; png \n#&gt;   2\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image5-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1076\" height=\"854\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image5-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-716\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#6.\u63a5\u4e0b\u6765\u6dfb\u52a0\u8fde\u63a5\u7ebf\uff0c\u8fde\u63a5\u7ebf\u8868\u793a\u4f4d\u7f6e\u548c\u4f4d\u7f6e\u7684\u5bf9\u5e94\u5173\u7cfb\u3002\u9996\u5148\u751f\u6210\u6570\u636e\uff1a\n#\u7070\u8272\u8fde\u63a5\u7ebf\u6570\u636e\ndf_link = data.frame(\n  from_index = sample(nrow(mat_dataR), 30),\n  to_index = sample(nrow(mat_dataR), 30)\n)\n#\u7ea2\u8272\u8fde\u63a5\u7ebf\u6570\u636e\nred_df_link&lt;-data.frame(from_index = c(86,87,82),\n                        to_index = c(2,15,36))\n#\u84dd\u8272\u8fde\u63a5\u7ebf\u6570\u636e\nblue_df_link&lt;-data.frame(from_index = c(84,86,90),\n                         to_index = c(72,76,69))<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image6-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"223\" height=\"217\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image6-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-717\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#7.\u63a5\u4e0b\u6765\u5f00\u59cb\u6dfb\u52a0link\uff1a\npdf(\"plot4.pdf\",width = 8, height = 6)\ncircos.par(gap.after = c(10, 10, 12))\ncircos.heatmap(mat_dataR, split = level_test, \n               col = colpattern, rownames.side = \"outside\", \n               cluster = TRUE,cell.lwd=0.8,\n               cell.border=\"white\",track.height = 0.2) \ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 1) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\n\ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 3) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\nfor(i in seq_len(nrow(df_link))) {\n  circos.heatmap.link(df_link$from_index&#91;i],\n                      df_link$to_index&#91;i],\n                      col = \"grey\")\n}\n\nfor(i in seq_len(nrow(red_df_link))) {\n  circos.heatmap.link(red_df_link$from_index&#91;i],\n                      red_df_link$to_index&#91;i],\n                      col = \"red\")\n}\n\nfor(i in seq_len(nrow(blue_df_link))) {\n  circos.heatmap.link(blue_df_link$from_index&#91;i],\n                      blue_df_link$to_index&#91;i],\n                      col = \"blue\")\n}\ncircos.clear()\n\n\ndev.off()\n#&gt; png \n#&gt;   2\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image7-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1019\" height=\"835\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image7-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-718\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#8.\u6dfb\u52a0\u56fe\u4f8b\uff0ccircos.heatmap()\u672c\u8eab\u662f\u4e0d\u652f\u6301\u6dfb\u52a0\u56fe\u4f8b\u7684\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u5229\u7528gridBase\u548cComplexHeatmap\u5305\u6dfb\u52a0\u56fe\u4f8b\uff1a\npdf(\"plot5.pdf\",width = 8, height = 6)\nplot.new()\ncircle_size = unit(1, \"snpc\") # snpc unit gives you a square region\n\npushViewport(viewport(x = 0, y = 0.5, width = circle_size, height = circle_size,\n                      just = c(\"left\", \"center\")))\npar(omi = gridOMI(), new = TRUE)\ncircos.par(gap.after = c(10, 10, 12))\ncircos.heatmap(mat_dataR, split = level_test, \n               col = colpattern, rownames.side = \"outside\", \n               cluster = TRUE,cell.lwd=0.8,\n               cell.border=\"white\",track.height = 0.2) \ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 1) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\n\ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 3) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\nfor(i in seq_len(nrow(df_link))) {\n  circos.heatmap.link(df_link$from_index&#91;i],\n                      df_link$to_index&#91;i],\n                      col = \"grey\")\n}\n\nfor(i in seq_len(nrow(red_df_link))) {\n  circos.heatmap.link(red_df_link$from_index&#91;i],\n                      red_df_link$to_index&#91;i],\n                      col = \"red\")\n}\n\nfor(i in seq_len(nrow(blue_df_link))) {\n  circos.heatmap.link(blue_df_link$from_index&#91;i],\n                      blue_df_link$to_index&#91;i],\n                      col = \"blue\")\n}\ncircos.clear()\nupViewport()\n\nh = dev.size()&#91;2]\nlgd = Legend(title = \"\", col_fun = colpattern)\ndraw(lgd, x = circle_size, just = \"left\")\n\ndev.off()\n#&gt; png \n#&gt;   2\n\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image8-1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1217\" height=\"848\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image8-1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-719\"\/><\/div><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">#\u6700\u540e\u7528AI\u8fdb\u884c\u4fee\u56fe\uff0c\u5904\u7406\u6389\u4e0d\u5408\u7406\u7684\u90e8\u5206\u3002\u6210\u54c1\u56fe\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image9-7.jpg'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"2480\" height=\"2201\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/image9-7.jpg\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-722\"  sizes=\"auto, (max-width: 2480px) 100vw, 2480px\" \/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u9644.\u5b8c\u6574\u4ee3\u7801\n# \u68c0\u67e5\u5f00\u53d1\u8005\u5de5\u5177devtools\uff0c\u5982\u6ca1\u6709\u5219\u5b89\u88c5\nif (!require(\"devtools\"))\n  install.packages(\"devtools\")\n# \u52a0\u8f7d\u5f00\u53d1\u8005\u5de5\u5177devtools\nlibrary(devtools)\n# \u68c0\u67e5circlize\u5305\uff0c\u6ca1\u6709\u5219\u901a\u8fc7github\u5b89\u88c5\u6700\u65b0\u7248\nif (!require(\"circlize\"))\n  install_github(\"jokergoo\/circlize\")\nif (!require(\"tidyverse\"))\n  install.packages('tidyverse') \nif (!require(\"ComplexHeatmap\"))\n  install.packages('ComplexHeatmap') \nif (!require(\"tidyverse\"))\n  install.packages('tidyverse') \n# \u52a0\u8f7d\u5305\nlibrary(circlize)\nlibrary(tidyverse)\nlibrary(ComplexHeatmap)\nlibrary(gridBase)\n\n#part1 \u751f\u6210\u6570\u636e\nset.seed(123)\n#\u751f\u6210KEGG\u6570\u636e\u77e9\u9635\uff08\u77e9\u96351\uff09\ndata1&lt;-matrix(rnorm(670,mean=0.5),nrow=67)\nrownames(data1)&lt;-c(\"K01446\",\"K01971\",\"K01142\",\"K01151\",\"K01246\",\"K00784\",\"K02031\",\"K01644\",\"K02037\",\"K02065\",\"K01448\",\n  \"K01890\",\"K00266\",\"K01725\",\"K00806\",\"K00231\",\"K01737\",\"K00858\",\"K00019\",\"K01715\",\"K01692\",\"K00249\",\n  \"K00023\",\"K00626\",\"K00101\",\"K00803\",\"K01710\",\"K01791\",\"K01176\",\"K00799\",\"K00800\",\"K01667\",\"K01668\",\n  \"K01712\",\"K00053\",\"K01696\",\"K01697\",\"K00108\",\"K00639\",\"K01489\",\"K00226\",\"K01488\",\"K02339\",\"K01428\",\n  \"K01438\",\"K02124\",\"K02275\",\"K01796\",\"K00632\",\"K00648\",\"K00849\",\"K01805\",\"K01685\",\"K00065\",\"K00090\",\n  \"K01619\",\"K01834\",\"K00121\",\"K02182\",\"K02082\",\"K02005\",\"K01266\",\"K01990\",\"K01463\",\"K02217\",\"K01174\",\"K02003\")\ncolnames(data1)&lt;-c(paste('H',seq(1:5),sep = \"\"),paste(\"PS\",seq(1:5),sep = \"\"))\n#\u751f\u6210EC\u6570\u636e\u77e9\u9635\uff08\u77e9\u96352\uff09\ndata2&lt;-matrix(rnorm(130,mean=1),nrow = 13)\nrownames(data2)&lt;-c(\"2.1.1.165\",\"1.1.5.-\",\"4.2.99.20\",\"1.1.1.86\",\"1.1.99.1\",\"1.1.2.3\",\"4.2.1.28\",\"4.2.1.82\",\"5.4.1.3\",\"1.13.12.16\",\"5.1.99.4\",\"1.17.4.1\",\"1.8.4.-\")\ncolnames(data2)&lt;-c(paste('H',seq(1:5),sep = \"\"),paste(\"PS\",seq(1:5),sep = \"\"))\n#\u751f\u6210\u7ec6\u83cc\u6570\u636e\u77e9\u9635\uff08\u77e9\u96353\uff09\ndata3&lt;-matrix(rnorm(20,mean=1),nrow = 10)\nsupdata&lt;-matrix(0,nrow = 10,ncol = 8)\n#\u7531\u4e8e\u8be5\u77e9\u9635\u4e3a10\u00d72\u77e9\u9635\uff0c\u9700\u8865\u514510\u00d78\u5168\u4e3a0\u7684\u77e9\u9635\uff0c\u4f7f\u5f97\u77e9\u9635123\u5747\u4e3am\u00d710\u7684\u77e9\u9635\ndata3&lt;-cbind(data3,supdata)\nrownames(data3)&lt;-c(\"Proteobacteria\",\"Actinobacteria\",\"Acidobacteria\",\"Bacteroidetes\",\"Gemmatimonadetes\",\"Chloroflexi\",\"Planctomycetes\",\"Firmicutes\",\"Verrucomicrobia\",\"unidentified_Acidobacteria\")\n#\u5c06\u4e09\u4e2a\u77e9\u9635\u6309\u884c\u5408\u5e76\nmat_data&lt;-rbind(data1,data2,data3)\n#\u6309\u884c\u5c06\u77e9\u9635\u53cd\u8f6c\uff0c\u8fd9\u6837\u77e9\u96353\u7684\u975e\u96f6\u6570\u636e\u4f1a\u51fa\u73b0\u5728\u5185\u5708\nmat_dataR&lt;-mat_data%&gt;% as.data.frame() %&gt;% rowwise() %&gt;% rev() %&gt;% as.matrix() \nrownames(mat_dataR)&lt;-rownames(mat_data)\n#\u8bbe\u7f6e\u70ed\u56fe\u989c\u8272\u8303\u56f4\ncolpattern = colorRamp2(c(-1, 0, 1), c(\"#2574AA\", \"white\", \"#ED7B79\"))\n#\u8bbe\u7f6e\u6247\u533a\uff0c\u8fd9\u91cc\u5212\u5206\u4e86\u4e09\u4e2a\u6247\u533a\uff0cKEGG,EC\u548c\u7ec6\u83cc\u79cd\u7c7b\nlevel_test&lt;-c(rep(\"KEGG\",67),rep(\"EC\",13),rep(\"SP\",10)) %&gt;% factor()\n#level_test&lt;-row.names(mat_dataR) %&gt;% str_match(\"&#91;k]+\") %&gt;% replace_na(\"EC\") %&gt;% factor()\n#\u751f\u6210\u8fde\u63a5\u7ebf\u6570\u636e\ndf_link = data.frame(\n  from_index = sample(nrow(mat_dataR), 30),\n  to_index = sample(nrow(mat_dataR), 30)\n)\nred_df_link&lt;-data.frame(from_index = c(86,87,82),\n                        to_index = c(2,15,36))\n\nblue_df_link&lt;-data.frame(from_index = c(84,86,90),\n                         to_index = c(72,76,69))\n\n#\u5f00\u59cb\u753b\u56fe\npdf(\"Figure 2B.pdf\",width = 8, height = 6)\nplot.new()\ncircle_size = unit(1, \"snpc\") # snpc unit gives you a square region\n\npushViewport(viewport(x = 0, y = 0.5, width = circle_size, height = circle_size,\n                      just = c(\"left\", \"center\")))\npar(omi = gridOMI(), new = TRUE)\ncircos.par(gap.after = c(10, 10, 12))\ncircos.heatmap(mat_dataR, split = level_test, \n               col = colpattern, rownames.side = \"outside\", \n               cluster = TRUE,cell.lwd=0.8,\n               cell.border=\"white\",track.height = 0.2) \ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 1) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\n\ncircos.track(track.index = get.current.track.index(), panel.fun = function(x, y) {\n  if(CELL_META$sector.numeric.index == 3) { # the last sector\n    cn = colnames(mat_dataR)\n    n = length(cn)\n    circos.text(rep(CELL_META$cell.xlim&#91;2], n) + convert_x(1, \"mm\"), \n                1:n - 0.5, cn, \n                cex = 0.3, adj = c(0, 0.5), facing = \"inside\")\n  }\n}, bg.border = NA)\n\nfor(i in seq_len(nrow(df_link))) {\n  circos.heatmap.link(df_link$from_index&#91;i],\n                      df_link$to_index&#91;i],\n                      col = \"grey\")\n}\n\n\nfor(i in seq_len(nrow(red_df_link))) {\n  circos.heatmap.link(red_df_link$from_index&#91;i],\n                      red_df_link$to_index&#91;i],\n                      col = \"red\")\n}\n\nfor(i in seq_len(nrow(blue_df_link))) {\n  circos.heatmap.link(blue_df_link$from_index&#91;i],\n                      blue_df_link$to_index&#91;i],\n                      col = \"blue\")\n}\ncircos.clear()\nupViewport()\n\nh = dev.size()&#91;2]\nlgd = Legend(title = \"\", col_fun = colpattern)\ndraw(lgd, x = circle_size, just = \"left\")\n\ndev.off()\n#&gt; png \n#&gt;   2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#\u6700\u540e\u7528AI\u8fdb\u884c\u4fee\u56fe\uff0c\u5904\u7406\u6389\u4e0d\u5408\u7406\u7684\u90e8\u5206\u3002\u6210\u54c1\u56fe\u5982\u4e0b\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-711","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/711","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=711"}],"version-history":[{"count":4,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/711\/revisions"}],"predecessor-version":[{"id":726,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/711\/revisions\/726"}],"wp:attachment":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=711"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=711"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=711"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}