{"id":727,"date":"2024-06-26T11:00:27","date_gmt":"2024-06-26T03:00:27","guid":{"rendered":"https:\/\/linguopeng.top\/?p=727"},"modified":"2024-06-26T11:00:27","modified_gmt":"2024-06-26T03:00:27","slug":"%e8%b7%9f%e7%9d%80imeta%e5%ad%a6%e5%81%9a%e5%9b%be%ef%bd%9c%e7%94%a8%e4%b8%89%e5%85%83%e5%9b%be%e5%b1%95%e7%a4%ba%e5%be%ae%e7%94%9f%e7%89%a9%e7%a7%8d%e7%be%a4%e7%9b%b8%e5%af%b9%e4%b8%b0%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/linguopeng.top\/?p=727","title":{"rendered":"\u8ddf\u7740iMeta\u5b66\u505a\u56fe\uff5c\u7528\u4e09\u5143\u56fe\u5c55\u793a\u5fae\u751f\u7269\u79cd\u7fa4\u76f8\u5bf9\u4e30\u5ea6"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># \u519c\u5fc3\u751f\u4fe1\u5de5\u4f5c\u5ba4\n# 2023-01-27\n# \u672c\u6587\u4ee3\u7801\u5df2\u7ecf\u4e0a\u4f20\u81f3https:\/\/github.com\/iMetaScience\/iMetaPlot230125ternary \u5982\u679c\u4f60\u4f7f\u7528\u672c\u4ee3\u7801\uff0c\u8bf7\u5f15\u7528\uff1aChenyuan Dang. 2022. Microorganisms as bio\u2010filters to mitigate greenhouse gas emissions from high\u2010altitude permafrost revealed by nanopore\u2010based metagenomics. iMeta 1: e24 https:\/\/onlinelibrary.wiley.com\/doi\/10.1002\/imt2.24\n# \u4ee3\u7801\u7f16\u5199\u53ca\u6ce8\u91ca\uff1a\u519c\u5fc3\u751f\u4fe1\u5de5\u4f5c\u5ba4\n# \u4e09\u5143\u76f8\u56fe (Ternary plot) \u53ef\u4ee5\u5c55\u793a\u4e09\u4e2a\u53d8\u91cf\u7684\u5173\u7cfb\uff0c\u65e2\u7f8e\u89c2\u4e14\u4fe1\u606f\u66f4\u52a0\u4e30\u5bcc\uff0c\u5728\u5fae\u751f\u7269\u9886\u57df\u5e38\u7528\u4e8e\u6bd4\u8f83\u591a\u4e2a\u6837\u54c1\u7684\u4e30\u5ea6\u4fe1\u606f\u3002\u672c\u671f\u6211\u4eec\u6311\u9009\u520a\u767b\u5728iMeta\u4e0a\u7684Microorganisms as bio\u2010filters to mitigate greenhouse gas emissions from high\u2010altitude permafrost revealed by nanopore\u2010based metagenomics.\u8bba\u6587\u7684Figure 2A\u8fdb\u884c\u590d\u73b0\uff0c\u57fa\u4e8eggtern\u7ed8\u5236\u4e09\u5143\u56fe\uff0c\u5148\u4e0a\u539f\u56fe\uff1a\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\/Fig2A.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"699\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/Fig2A.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-728\"\/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># R\u5305\u68c0\u6d4b\u548c\u5b89\u88c5\n# 1.\u5b89\u88c5\u6838\u5fc3R\u5305ggtern\u4ee5\u53ca\u4e00\u4e9b\u529f\u80fd\u8f85\u52a9\u6027R\u5305\uff0c\u5e76\u8f7d\u5165\u6240\u6709R\u5305\noptions(repos = list(CRAN=\"https:\/\/mirrors.tuna.tsinghua.edu.cn\/CRAN\/\"))\nif (!require(\"devtools\"))\n  install.packages('devtools') \nif (!require(\"ggtern\"))\n  install.packages('ggtern')\ninstall.packages(\"devtools\")\ndevtools::install_github(\"microbiota\/amplicon\")\n# \u52a0\u8f7d\u5305\nlibrary(amplicon)\nlibrary(ggtern)\n# \u8bfb\u53d6\u6570\u636e\u53ca\u6570\u636e\u5904\u7406\n# 2.\u4f7f\u7528R\u5305amplicon\u4e2d\u7684\u793a\u4f8b\u6570\u636etax_phylum\u5e76\u8ba1\u7b97\u76f8\u5bf9\u4e30\u5ea6\ndim(tax_phylum) # \u67e5\u770b\u6570\u636e\u7ef4\u5ea6\uff0c\u51713\u4e2a\u6837\u54c1\u54046\u4e2a\u91cd\u590d\u517118\u5217\u6570\u636e\n#> &#91;1] 18 19\nrela_tax &lt;- apply(tax_phylum, 2, function(x) x\/sum(x)) # \u7edd\u5bf9\u4e30\u5ea6\/\u5bf9\u6bcf\u4e00\u5217\u7684\u4e30\u5ea6\u603b\u548c\u5f97\u5230\u6bcf\u4e2a\u7269\u79cd\u7684\u76f8\u5bf9\u4e30\u5ea6\nrela_group_tax &lt;- t(apply(rela_tax, 1, function(x) c(mean(x&#91;1:6]), mean(x&#91;7:12]), mean(x&#91;13:18])))) # \u5bf9\u6bcf\u4e2a\u6837\u54c1\u76846\u4e2a\u91cd\u590d\u8ba1\u7b97\u76f8\u5bf9\u4e30\u5ea6\u5747\u503c\ncolnames(rela_group_tax) &lt;- c('KO', \"OE\", \"WT\") # \u5bf9\u5217\u91cd\u547d\u540d\n#3.\u4fdd\u7559\u76f8\u5bf9\u4e30\u5ea6\u8f83\u9ad8\u768410\u4e2a\u95e8\uff0c\u5408\u5e76\u5176\u4f59\u95e8\u7684\u76f8\u5bf9\u4e30\u5ea6\ndf &lt;- as.data.frame(rela_group_tax)\ndf$total &lt;- rowSums(df) # \u5bf9\u6bcf\u4e2a\u95e8\u989d\u5916\u8ba1\u7b97\u4e00\u5217\u603b\u76f8\u5bf9\u4e30\u5ea6\u7528\u4e8e\u9009\u51fa\u9ad8\u4e30\u5ea6\u7684\u95e8\nsort_df &lt;- df&#91;order(df$total, decreasing = T),] # \u5f97\u5230\u6392\u5e8f\u540e\u7684\u6570\u636e\u6846\nothers &lt;- colSums(sort_df&#91;11:nrow(df),]) # \u8ba1\u7b97\u5176\u4ed6\u4f4e\u4e30\u5ea6\u95e8\u7684\u4e30\u5ea6\u603b\u548c\ndf2 &lt;- rbind(sort_df&#91;1:10, ], others) # \u5408\u5e76\u8868\u683c\n# \u8ba1\u7b97\u4e30\u5ea6\u5e76\u6dfb\u52a0\u5206\u7ec4\uff0c\u5206\u522b\u4ee3\u8868\u4e09\u5143\u56fe\u4e2d\u70b9\u7684\u5927\u5c0f\u548c\u989c\u8272\ndf2$Abundance &lt;- rowMeans(df2) \ngp &lt;- c(rownames(df2)&#91;1:10],\"Others\")\ndf2$Phylum &lt;- factor(gp, level=gp)\n# \u7ed8\u56fe\u9884\u89c8\n# 4.\u4f7f\u7528ggtern\u5305\u7ed8\u5236\u7fa4\u843d\u4e30\u5ea6\u4e09\u5143\u56fe\uff1a\np &lt;- ggtern(data=df2, aes(KO, OE, WT)) + geom_point(aes(color=Phylum, size=Abundance)) +  theme_bw() +  theme_arrowdefault()\nggsave('ternay.png', p, width = 10, height = 8)\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\/ternay.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"3000\" height=\"2400\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/ternay.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-729\"  sizes=\"auto, (max-width: 3000px) 100vw, 3000px\" \/><\/div><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9644.\u5b8c\u6574\u4ee3\u7801\noptions(repos = list(CRAN=\"https:\/\/mirrors.tuna.tsinghua.edu.cn\/CRAN\/\"))\nif (!require(\"devtools\"))\n  install.packages('devtools') \nif (!require(\"ggtern\"))\n  install.packages('ggtern')\ninstall.packages(\"devtools\")\ndevtools::install_github(\"microbiota\/amplicon\")\n# \u52a0\u8f7d\u5305\nlibrary(amplicon)\nlibrary(ggtern)\ndim(tax_phylum) # \u67e5\u770b\u6570\u636e\u7ef4\u5ea6\uff0c\u51713\u4e2a\u6837\u54c1\u54046\u4e2a\u91cd\u590d\u517118\u5217\u6570\u636e\n#> &#91;1] 18 19\nrela_tax &lt;- apply(tax_phylum, 2, function(x) x\/sum(x)) # \u7edd\u5bf9\u4e30\u5ea6\/\u5bf9\u6bcf\u4e00\u5217\u7684\u4e30\u5ea6\u603b\u548c\u5f97\u5230\u6bcf\u4e2a\u7269\u79cd\u7684\u76f8\u5bf9\u4e30\u5ea6\nrela_group_tax &lt;- t(apply(rela_tax, 1, function(x) c(mean(x&#91;1:6]), mean(x&#91;7:12]), mean(x&#91;13:18])))) # \u5bf9\u6bcf\u4e2a\u6837\u54c1\u76846\u4e2a\u91cd\u590d\u8ba1\u7b97\u76f8\u5bf9\u4e30\u5ea6\u5747\u503c\ncolnames(rela_group_tax) &lt;- c('KO', \"OE\", \"WT\") # \u5bf9\u5217\u91cd\u547d\u540d\ndf &lt;- as.data.frame(rela_group_tax)\ndf$total &lt;- rowSums(df) # \u5bf9\u6bcf\u4e2a\u95e8\u989d\u5916\u8ba1\u7b97\u4e00\u5217\u603b\u76f8\u5bf9\u4e30\u5ea6\u7528\u4e8e\u9009\u51fa\u9ad8\u4e30\u5ea6\u7684\u95e8\nsort_df &lt;- df&#91;order(df$total, decreasing = T),] # \u5f97\u5230\u6392\u5e8f\u540e\u7684\u6570\u636e\u6846\nothers &lt;- colSums(sort_df&#91;11:nrow(df),]) # \u8ba1\u7b97\u5176\u4ed6\u4f4e\u4e30\u5ea6\u95e8\u7684\u4e30\u5ea6\u603b\u548c\ndf2 &lt;- rbind(sort_df&#91;1:10, ], others) # \u5408\u5e76\u8868\u683c\n# \u8ba1\u7b97\u4e30\u5ea6\u5e76\u6dfb\u52a0\u5206\u7ec4\uff0c\u5206\u522b\u4ee3\u8868\u4e09\u5143\u56fe\u4e2d\u70b9\u7684\u5927\u5c0f\u548c\u989c\u8272\ndf2$Abundance &lt;- rowMeans(df2) \ngp &lt;- c(rownames(df2)&#91;1:10],\"Others\")\ndf2$Phylum &lt;- factor(gp, level=gp)\np &lt;- ggtern(data=df2, aes(KO, OE, WT)) + geom_point(aes(color=Phylum, size=Abundance)) +  theme_bw() +  theme_arrowdefault()\nggsave('ternay.png', p, width = 10, height = 8)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","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-727","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/727","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=727"}],"version-history":[{"count":1,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":730,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/727\/revisions\/730"}],"wp:attachment":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}