{"id":29212,"date":"2024-02-21T17:43:57","date_gmt":"2024-02-21T09:43:57","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=29212"},"modified":"2024-02-21T17:43:59","modified_gmt":"2024-02-21T09:43:59","slug":"%e4%b8%80%e6%96%87%e5%ad%a6%e4%bc%9a%ef%bc%8canova%e5%8f%8c%e5%9b%a0%e7%b4%a0%e6%96%b9%e5%b7%ae%e5%88%86%e6%9e%90","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=29212","title":{"rendered":"\u4e00\u6587\u5b66\u4f1a\uff0cANOVA\u53cc\u56e0\u7d20\u65b9\u5dee\u5206\u6790"},"content":{"rendered":"<p>\u4eca\u5929\u5c0f\u679c\u901a\u8fc7\u8fd9\u4e00\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u5b66\u4f1a\u548c\u4e86\u89e3\u53cc\u56e0\u7d20\u65b9\u5dee\u5206\u6790(ANOVA),\u8bdd\u4e0d\u591a\u8bf4\uff0c\u8bf7\u770b\u4e0b\u9762\u4ee3\u7801\uff1a<\/p>\n<ol>\n<li>\u5b89\u88c5\u9700\u8981\u7684R\u5305<\/li>\n<\/ol>\n<p>install.packages(\u201cggplot2\u201d)<\/p>\n<p>install.packages(\u201ctidyverse\u201d)<\/p>\n<p>install.packages(&#8220;multcompView&#8221;)<\/p>\n<p>install.packages(\u201cggsci\u201d)<\/p>\n<ol>\n<li>\u8f7d\u5165\u9700\u8981\u7684R\u5305<\/li>\n<\/ol>\n<p>library(ggplot2)<\/p>\n<p>library(tidyverse)<\/p>\n<p>library(multcompView)<\/p>\n<p>library(ggsci)<\/p>\n<ol>\n<li>\u4ee3\u7801\u5c55\u793a<\/li>\n<\/ol>\n<p>soil &lt;- read.table(file=&#8221;soil.txt&#8221;, sep = &#8216;\\t&#8217;, header = TRUE)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"215\" class=\"wp-image-29213\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154627.jpeg?resize=640%2C215\" alt=\"Dingtalk_20230302154627\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154627.jpeg?w=947 947w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154627.jpeg?resize=300%2C101 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154627.jpeg?resize=768%2C258 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154627.jpeg?resize=600%2C201 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>group &lt;- read.table(file=&#8221;group.txt&#8221;, sep = &#8216;\\t&#8217;, header = TRUE)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"204\" class=\"wp-image-29214\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154741.jpeg?resize=640%2C204\" alt=\"Dingtalk_20230302154741\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154741.jpeg?w=984 984w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154741.jpeg?resize=300%2C95 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154741.jpeg?resize=768%2C244 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302154741.jpeg?resize=600%2C191 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>#\u5de6\u8fde\u63a5\u5408\u5e76\u4e24\u4e2a\u6587\u4ef6<\/p>\n<p>soil &lt;- left_join(soil, group, by = &#8216;sample&#8217;)<\/p>\n<p>#\u7b5b\u9009\u9700\u8981\u7684\u5217<\/p>\n<p>chao1 &lt;- select(soil ,c(&#8216;sample&#8217;, &#8216;treat&#8217;, &#8216;times&#8217;, &#8216;chao1&#8217;))<\/p>\n<p>#\u5c06\u8fd9\u4e24\u4e2a\u56e0\u7d20\u7c7b\u578b(trate\u548ctimes)\u6539\u4e3a\u56e0\u5b50<\/p>\n<p>chao1$treat &lt;- factor(chao1$treat)<\/p>\n<p>chao1$times &lt;- factor(chao1$times)<\/p>\n<p>#\u53cc\u56e0\u7d20\u65b9\u5dee\u5206\u6790<\/p>\n<p>anova&lt;- aov(chao1~treat*times, data = chao1)<\/p>\n<p>#\u8ba1\u7b97mean\u548csd(\u5206\u7ec4\u7edf\u8ba1mean\u548ctimes\uff09<\/p>\n<p>dt &lt;- chao1 %&gt;% group_by(treat,times) %&gt;%<\/p>\n<p>summarise(w=mean(chao1), sd = sd(chao1)) %&gt;%<\/p>\n<p>arrange(desc(w)) %&gt;%<\/p>\n<p>ungroup()<\/p>\n<p>#\u591a\u91cd\u914d\u5bf9\u6bd4\u8f83<\/p>\n<p>cld &lt;- TukeyHSD(anova) %&gt;% multcompLetters4(anova,.)<\/p>\n<p>le &lt;- as.data.frame.list(cld$`treat:times`)<\/p>\n<p>#\u83b7\u53d6\u5b57\u6bcd\u6807\u8bb0<\/p>\n<p>dt$Tukey &lt;- le$Letters<\/p>\n<p>#\u5f00\u59cb\u7ed8\u5236\u5e26\u6709\u663e\u8457\u6027\u5b57\u6bcd\u6807\u8bb0\u7684\u67f1\u72b6\u56fe<\/p>\n<p>ggplot(dt, aes(times, w)) +<\/p>\n<p>geom_bar(stat = &#8220;identity&#8221;,aes(fill=times),show.legend = FALSE,width=0.5) +<\/p>\n<p>geom_errorbar(aes(ymin = w-sd, ymax=w+sd), width = 0.1) +<\/p>\n<p>geom_text(aes(label = Tukey, y = w + sd), vjust = -0.5)+<\/p>\n<p>facet_wrap(~treat)+<\/p>\n<p>scale_fill_npg()+<\/p>\n<p>labs(x=&#8221;&#8221;,y=&#8221;&#8221;)+<\/p>\n<p>theme_test()+<\/p>\n<p>theme(panel.background = element_blank(),<\/p>\n<p>axis.line = element_line(color = &#8220;black&#8221;),<\/p>\n<p>axis.text = element_text(size = 10,color = &#8220;black&#8221;),<\/p>\n<p>axis.text.y = element_text(size = 10),<\/p>\n<p>axis.ticks.x = element_blank())<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"588\" height=\"529\" class=\"wp-image-29215\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302155410.jpeg?resize=588%2C529\" alt=\"Dingtalk_20230302155410\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302155410.jpeg?w=588 588w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/02\/dingtalk_20230302155410.jpeg?resize=300%2C270 300w\" sizes=\"(max-width: 588px) 100vw, 588px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u6700\u7ec8\u901a\u8fc7\u4e00\u4e2a\u793a\u4f8b\u6570\u636e\u8fdb\u884c\u4e86\u53cc\u56e0\u7d20\u65b9\u5dee\u5206\u6790\uff0c\u4eca\u5929\u5c0f\u679c\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\u5965\uff0c\u4e0b\u671f\u518d\u89c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u5c0f\u679c\u901a\u8fc7\u8fd9\u4e00\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u5b66\u4f1a\u548c\u4e86\u89e3\u53cc\u56e0\u7d20\u65b9\u5dee\u5206\u6790(ANOVA),\u8bdd\u4e0d\u591a\u8bf4\uff0c\u8bf7\u770b\u4e0b\u9762\u4ee3\u7801\uff1a \u5b89\u88c5\u9700\u8981\u7684R\u5305  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[1],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/29212"}],"collection":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=29212"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/29212\/revisions"}],"predecessor-version":[{"id":29216,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/29212\/revisions\/29216"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=29212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=29212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=29212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}