{"id":642,"date":"2024-06-13T14:38:04","date_gmt":"2024-06-13T06:38:04","guid":{"rendered":"https:\/\/linguopeng.top\/?p=642"},"modified":"2024-06-13T14:38:49","modified_gmt":"2024-06-13T06:38:49","slug":"pcoa%e4%b8%a4%e4%b8%a4%e6%af%94%e8%be%83","status":"publish","type":"post","link":"https:\/\/linguopeng.top\/?p=642","title":{"rendered":"pcoa\u4e24\u4e24\u6bd4\u8f83"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code># dune\u662f\u4e00\u5957\u5305\u542b\u4e8620\u4e2a\u6837\u54c1\u548c30\u4e2a\u7269\u79cd\u4e30\u5ea6\u6570\u636e\u7684\u7edf\u8ba1\u8868\u3002\n# \u5176\u683c\u5f0f\u662f\u5e38\u89c1OTU\u8868\u8f6c\u7f6e\u540e\u7684\u683c\u5f0f\uff0c\n# \u6bcf\u4e00\u884c\u662f\u4e00\u4e2a\u6837\u54c1\uff0c\u6bcf\u4e00\u5217\u662f\u4e00\u4e2a\u7269\u79cd (\u68c0\u6d4b\u6307\u6807)\u3002\n# dune.env\u662f\u5143\u6570\u636e\u4fe1\u606f\uff0c\u5305\u542b\u6570\u636e\u7684\u5206\u5b50\u4fe1\u606f\u3001\u751f\u5b58\u73af\u5883\u4fe1\u606f\u7b49\uff0c\u8bb0\u5f55\u4e865\u4e2a\u56e0\u7d20 (\u540c\u65f6\u5305\u542b\u8fde\u7eed\u53d8\u91cf\u4fe1\u606f\u548c\u5206\u7ec4\u53d8\u91cf\u4fe1\u606f)\uff1a\n# A1: \u571f\u58e4\u539a\u5ea6\u4fe1\u606f a numeric vector of thickness of soil A1 horizon.\n# Moisture: \u6e7f\u5ea6\u7b49\u7ea7\u4fe1\u606f\uff0c\u52064\u4e2a\u7b49\u7ea7\uff0c1 &lt; 2 &lt; 4 &lt; 5.\n# Management: \u5206\u7ec4\u4fe1\u606f\uff0c\u4e0d\u540c\u7684\u7ba1\u7406\u65b9\u5f0f a factor with levels: BF (Biological farming), HF (Hobby farming), NM (Nature Conservation Management), and SF (Standard Farming).\n# Use: \u4e00\u4e2a\u5206\u7ec4\u4fe1\u606f an ordered factor of land-use with levels: Hayfield &lt; Haypastu &lt; Pasture.\n# Manure: \u4e00\u4e2a\u5206\u7ec4\u4fe1\u606f\uff0c0 &lt; 1 &lt; 2 &lt; 3 &lt; 4\nlibrary(vegan)\ndata(dune)\ndata(dune.env)\n## &#91;1] 20 30\nhead(dune)\nhead(dune.env)\n#\u7ed8\u5236\u4e00\u4e2aPcOA\u7684\u56fe\u770b\u4e00\u4e0b\n# \u8ba1\u7b97\u52a0\u6743bray-curtis\u8ddd\u79bb\ndune_dist &lt;- vegdist(dune, method=\"bray\", binary=F)\ndune_pcoa &lt;- cmdscale(dune_dist, k=3, eig=T)\ndune_pcoa_points &lt;- as.data.frame(dune_pcoa$points)\nsum_eig &lt;- sum(dune_pcoa$eig)\neig_percent &lt;- round(dune_pcoa$eig\/sum_eig*100,1)\ncolnames(dune_pcoa_points) &lt;- paste0(\"PCoA\", 1:3)\ndune_pcoa_result &lt;- cbind(dune_pcoa_points, dune.env)\nhead(dune_pcoa_result)\nlibrary(ggplot2)\nggplot(dune_pcoa_result, aes(x=PCoA1, y=PCoA2, color=Management)) +\n  labs(x=paste(\"PCoA 1 (\", eig_percent&#91;1], \"%)\", sep=\"\"),\n       y=paste(\"PCoA 2 (\", eig_percent&#91;2], \"%)\", sep=\"\")) +\n  geom_point(size=4\n  ) + stat_ellipse(level=0.6) +\n  theme_classic()\n#\u6837\u54c1\u4e2d\u91cd\u590d\u592a\u5c11\u4e86\uff0c\u505a\u4e0d\u51fa\u7f6e\u4fe1\u692d\u5706\u3002\u6362\u4e2a\u65b9\u5f0f\uff0c\u7528ggalt\u5305\u4e2d\u7684geom_encircle\u628a\u6837\u54c1\u5305\u8d77\u6765\u3002\ninstall.packages(\"ggalt\")\nlibrary(ggalt)\nggplot(dune_pcoa_result, aes(x=PCoA1, y=PCoA2, color=Management, group = Management)) +\n  labs(x=paste(\"PCoA 1 (\", eig_percent&#91;1], \"%)\", sep=\"\"),\n       y=paste(\"PCoA 2 (\", eig_percent&#91;2], \"%)\", sep=\"\")) +\n  geom_point(size=5) + \n  geom_encircle(aes(fill=Management), alpha = 0.1, show.legend = F) +\n  theme_classic() + coord_fixed(1)\n# \u57fa\u4e8ebray-curtis\u8ddd\u79bb\u8fdb\u884c\u8ba1\u7b97\nset.seed(1)\ndune.div &lt;- adonis2(dune ~ Management, data = dune.env, permutations = 999, method=\"bray\")\ndune.div\ndune_adonis &lt;- paste0(\"adonis R2: \",round(dune.div$R2,2), \"; P-value: \", dune.div$`Pr(>F)`)\nlibrary(ggalt)\np&lt;-ggplot(dune_pcoa_result, aes(x=PCoA1, y=PCoA2, color=Management, group = Management)) +\n  labs(x=paste(\"PCoA 1 (\", eig_percent&#91;1], \"%)\", sep=\"\"),\n       y=paste(\"PCoA 2 (\", eig_percent&#91;2], \"%)\", sep=\"\"),\n       title=dune_adonis) +\n  geom_point(size=5) + \n  geom_encircle(aes(fill=Management), alpha = 0.1, show.legend = F) +\n  theme_classic() + coord_fixed(1)\n#\u6574\u4f53\u6709\u5dee\u5f02\u4e86\uff0c\u540e\u9762\u5c31\u770b\u770b\u5177\u4f53\u90a3\u4e24\u7ec4\u4e4b\u95f4\u6709\u5dee\u5f02\uff0c\u54ea\u4e24\u7ec4\u4e4b\u95f4\u65e0\u5dee\u5f02~~~\n#\u8fd9\u65f6\u5c31\u9700\u8981pairwise.adonis\u6765\u8fdb\u884c\u914d\u5bf9\u68c0\u9a8c\u4e86\u3002\nhead(dune)\nhead(dune.env)\nlibrary(pairwiseAdonis)\ndune.pairwise.adonis &lt;- pairwise.adonis(x=dune, factors=dune.env$Management, sim.function = \"vegdist\",\n                                        sim.method = \"bray\",\n                                        p.adjust.m = \"BH\",\n                                        reduce = NULL,\n                                        perm = 999)\ndune.pairwise.adonis\nlibrary(ggpubr)\nlibrary(patchwork)\ntab2 &lt;- ggtexttable(dune.pairwise.adonis&#91;,c(\"pairs\",\"R2\",\"p.value\",\"p.adjusted\")], rows = NULL, \n                    theme = ttheme(\"blank\")) %>% \n  tab_add_hline(at.row = 1:2, row.side = \"top\", linewidth = 1)  %>% \n  tab_add_hline(at.row = nrow(dune.pairwise.adonis)+1, row.side = \"bottom\", linewidth = 1)  \n\np2 = p + tab2 \np2\n# \u8c03\u5e03\u5c40\np2 + plot_layout(design=c(area(1,1), area(2,1)))\n# p \/ tab2<\/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\/1.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"1181\" height=\"606\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/1.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-643\"\/><\/div><\/figure>\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\/2.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"836\" height=\"683\" data-original=\"https:\/\/linguopeng.top\/wp-content\/uploads\/2024\/06\/2.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-644\"\/><\/div><\/figure>\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-642","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/642","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=642"}],"version-history":[{"count":2,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions"}],"predecessor-version":[{"id":646,"href":"https:\/\/linguopeng.top\/index.php?rest_route=\/wp\/v2\/posts\/642\/revisions\/646"}],"wp:attachment":[{"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=642"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=642"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linguopeng.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=642"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}