{"id":488,"date":"2023-06-28T12:18:22","date_gmt":"2023-06-28T12:18:22","guid":{"rendered":"https:\/\/yunshangtulv.com.cn\/?p=488"},"modified":"2023-06-28T12:18:22","modified_gmt":"2023-06-28T12:18:22","slug":"sci%e5%9b%be%e7%89%87%e5%a4%8d%e7%8e%b0%ef%bc%9ago%e6%9f%b1%e7%8a%b6%e5%9b%be-%e4%b8%8d%e5%90%8c%e8%89%b2%e5%bd%a9%e5%88%86%e7%bb%84","status":"publish","type":"post","link":"https:\/\/yunshangtulv.com.cn\/?p=488","title":{"rendered":"SCI\u56fe\u7247\u590d\u73b0\uff1aGO\u67f1\u72b6\u56fe-\u4e0d\u540c\u8272\u5f69\u5206\u7ec4"},"content":{"rendered":"<p>\u6211\u4eec\u9700\u8981\u4e00\u4e2aCSV\u6587\u4ef6\uff0c\u5176\u4e2d\u81f3\u5c11\u5305\u542b\u4e09\u5217\u6570\u636e\uff1a'Description'\uff0c'Count' \u548c 'Cluster'\u3002'Description' \u662f\u5bf9\u9879\u76ee\u7684\u63cf\u8ff0\uff0c'Count' \u662f\u76f8\u5e94\u7684\u8ba1\u6570\uff0c'Cluster' \u662f\u7528\u6765\u6307\u5b9a\u5206\u7ec4\u6216\u989c\u8272\u7684\u5217\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u6ee1\u8db3\u8fd9\u4e9b\u9700\u6c42\u7684\u6a21\u62df\u6570\u636e\u6846\uff0c\u5e76\u6253\u5370\u51fa\u524d\u51e0\u884c\uff0c\u7136\u540e\u5c55\u793a\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"corepress-code-pre\"><code># \u786e\u4fdd\u52a0\u8f7d\u5fc5\u8981\u7684\u5305\r\nlibrary(ggplot2)\r\nlibrary(forcats)\r\n\r\n# \u8bbe\u7f6e\u968f\u673a\u79cd\u5b50\uff0c\u786e\u4fdd\u7ed3\u679c\u53ef\u590d\u73b0\r\nset.seed(123)\r\n\r\n# \u751f\u6210\u968f\u673a\u7684Description, Count\u548cCluster\r\nDescription &lt;- paste0(\"Desc_\", sample(1:100, 38))\r\nCount &lt;- sample(1:100, 38)\r\nCluster &lt;- sample(c('Cluster1', 'Cluster2', 'Cluster3'), 38, replace = TRUE)\r\n\r\n# \u521b\u5efa\u6570\u636e\u6846\r\nA &lt;- data.frame(Description, Count, Cluster)\r\n\r\n# \u6253\u5370\u51fa\u524d\u51e0\u884c\u6570\u636e\r\nhead(A)\r\n\r\n# \u6309\u7167\u63cf\u8ff0\u7684\u987a\u5e8f\u5c06\u63cf\u8ff0\u8f6c\u5316\u4e3a\u56e0\u5b50\r\nA$Description &lt;- fct_inorder(A$Description)\r\n\r\n# \u521b\u5efa\u989c\u8272\u6620\u5c04\u4ee5\u5339\u914d\u7c07\u6807\u7b7e\r\ncolor_map &lt;- c('Cluster1' = '#852f88', 'Cluster2' = '#eb990c', 'Cluster3' = '#0f8096')\r\n\r\n# \u521b\u5efa\u65b0\u7684\u989c\u8272\u5217\r\nA$Color &lt;- color_map[A$Cluster]\r\n\r\n# \u4f7f\u7528\u8fd9\u4e9b\u989c\u8272\u521b\u5efa\u57fa\u4e8e\u7c07\u7684\u67f1\u72b6\u56fe\uff0c\u5e76\u5c06\u8ba1\u6570\u6807\u7b7e\u6dfb\u52a0\u5230\u67f1\u72b6\u56fe\u4e0a\r\np &lt;- ggplot(A, aes(Description, Count)) +\r\n  geom_bar(aes(fill = Cluster), stat = \"identity\") +\r\n  geom_text(aes(label = Count, y = Count + 5), size = 3) +\r\n  coord_flip() +\r\n  labs(x = '', y = 'Gene count', title = 'GO enrichment of cluster') +\r\n  scale_fill_manual(values = color_map) +\r\n  theme_bw() +\r\n  theme(panel.grid = element_blank(),\r\n        legend.position = 'none',\r\n        axis.ticks.y = element_blank(),\r\n        plot.title = element_text(hjust = 0.5, size = 10),\r\n        axis.text.y = element_text(size = rel(0.85), colour = A$Color),\r\n        plot.margin = unit(c(0.2, 0.2, 0.2, 0.2), units = \"inches\"))\r\n\r\n# \u6253\u5370\u51fa\u56fe\u50cf\r\nprint(p)\r\n\r\n# \u5c06\u7ed3\u679c\u4fdd\u5b58\u4e3aPDF\u548cCSV\u6587\u4ef6\r\nggsave(\"GO_enrichment.pdf\", p, width = 10, height = 7)\r\nwrite.csv(A, \"GO.csv\", row.names = FALSE)\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe.png\" alt=\"\" width=\"672\" height=\"672\" class=\"alignnone size-full wp-image-489\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe.png 672w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe-300x300.png 300w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe-100x100.png 100w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe-600x600.png 600w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe-150x150.png 150w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/p>\n<p>\u8fdb\u4e00\u6b65\u4f18\u5316\uff0c\u4f7f\u5f97\u540c\u989c\u8272\u5728\u4e00\u8d77<\/p>\n<pre class=\"corepress-code-pre\"><code># \u786e\u4fdd\u52a0\u8f7d\u5fc5\u8981\u7684\u5305\r\nlibrary(ggplot2)\r\nlibrary(forcats)\r\nlibrary(dplyr)\r\n\r\n# \u8bbe\u7f6e\u968f\u673a\u79cd\u5b50\uff0c\u786e\u4fdd\u7ed3\u679c\u53ef\u590d\u73b0\r\nset.seed(123)\r\n\r\n# \u751f\u6210\u968f\u673a\u7684Description, Count\u548cCluster\r\nDescription &lt;- paste0(\"Desc_\", sample(1:100, 38))\r\nCount &lt;- sample(1:100, 38)\r\nCluster &lt;- sample(c('Cluster1', 'Cluster2', 'Cluster3'), 38, replace = TRUE)\r\n\r\n# \u521b\u5efa\u6570\u636e\u6846\u5e76\u6309Cluster\u6392\u5e8f\r\nA &lt;- data.frame(Description, Count, Cluster) %&gt;%\r\n  arrange(Cluster)\r\n\r\n# \u6253\u5370\u51fa\u524d\u51e0\u884c\u6570\u636e\r\nhead(A)\r\n\r\n# \u6309\u7167\u63cf\u8ff0\u7684\u987a\u5e8f\u5c06\u63cf\u8ff0\u8f6c\u5316\u4e3a\u56e0\u5b50\r\nA$Description &lt;- fct_inorder(A$Description)\r\n\r\n# \u521b\u5efa\u989c\u8272\u6620\u5c04\u4ee5\u5339\u914d\u7c07\u6807\u7b7e\r\ncolor_map &lt;- c('Cluster1' = '#852f88', 'Cluster2' = '#eb990c', 'Cluster3' = '#0f8096')\r\n\r\n# \u521b\u5efa\u65b0\u7684\u989c\u8272\u5217\r\nA$Color &lt;- color_map[A$Cluster]\r\n\r\n# \u4f7f\u7528\u8fd9\u4e9b\u989c\u8272\u521b\u5efa\u57fa\u4e8e\u7c07\u7684\u67f1\u72b6\u56fe\uff0c\u5e76\u5c06\u8ba1\u6570\u6807\u7b7e\u6dfb\u52a0\u5230\u67f1\u72b6\u56fe\u4e0a\r\np &lt;- ggplot(A, aes(Description, Count)) +\r\n  geom_bar(aes(fill = Cluster), stat = \"identity\") +\r\n  geom_text(aes(label = Count, y = Count + 5), size = 3) +\r\n  coord_flip() +\r\n  labs(x = '', y = 'Gene count', title = 'GO enrichment of cluster') +\r\n  scale_fill_manual(values = color_map) +\r\n  theme_bw() +\r\n  theme(panel.grid = element_blank(),\r\n        legend.position = 'none',\r\n        axis.ticks.y = element_blank(),\r\n        plot.title = element_text(hjust = 0.5, size = 10),\r\n        axis.text.y = element_text(size = rel(0.85), colour = A$Color),\r\n        plot.margin = unit(c(0.2, 0.2, 0.2, 0.2), units = \"inches\"))\r\n\r\n# \u6253\u5370\u51fa\u56fe\u50cf\r\nprint(p)\r\n\r\n# \u5c06\u7ed3\u679c\u4fdd\u5b58\u4e3aPDF\u548cCSV\u6587\u4ef6\r\nggsave(\"GO_enrichment.pdf\", p, width = 10, height = 7)\r\nwrite.csv(A, \"GO.csv\", row.names = FALSE)\r\n<\/code><\/pre>\n<p><span>\u5728\u8fd9\u4e2a\u4fee\u6539\u540e\u7684\u7248\u672c\u4e2d\uff0c\u6211\u4eec\u6dfb\u52a0\u4e86\u4e00\u4e2a\u65b0\u7684\u6b65\u9aa4\uff0c\u7528<\/span><code>dplyr<\/code><span>\u7684<\/span><code>arrange()<\/code><span>\u51fd\u6570\u5c06\u6570\u636e\u6846<\/span><code>A<\/code><span>\u6309\u7167<\/span><code>Cluster<\/code><span>\u8fdb\u884c\u6392\u5e8f\u3002\u73b0\u5728\uff0c\u76f8\u540c\u989c\u8272\u7684\u6761\u5f62\u5c06\u88ab\u653e\u5728\u4e00\u8d77\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1.png\" alt=\"\" width=\"672\" height=\"672\" class=\"alignnone size-full wp-image-490\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1.png 672w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1-300x300.png 300w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1-100x100.png 100w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1-600x600.png 600w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe1-150x150.png 150w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/p>\n<p>\u7ee7\u7eed\u4f18\u5316\uff0c\u4f7f\u540c\u989c\u8272\u5206\u7ec4\u5728\u4e00\u8d77\u540c\u65f6\u6309\u67f1\u957f\u77ed\u6392\u5e03<\/p>\n<pre class=\"corepress-code-pre\"><code># \u786e\u4fdd\u52a0\u8f7d\u5fc5\u8981\u7684\u5305\r\nlibrary(ggplot2)\r\nlibrary(forcats)\r\nlibrary(dplyr)\r\n\r\n# \u8bbe\u7f6e\u968f\u673a\u79cd\u5b50\uff0c\u786e\u4fdd\u7ed3\u679c\u53ef\u590d\u73b0\r\nset.seed(123)\r\n\r\n# \u751f\u6210\u968f\u673a\u7684Description, Count\u548cCluster\r\nDescription &lt;- paste0(\"Desc_\", sample(1:100, 38))\r\nCount &lt;- sample(1:100, 38)\r\nCluster &lt;- sample(c('Cluster1', 'Cluster2', 'Cluster3'), 38, replace = TRUE)\r\n\r\n# \u521b\u5efa\u6570\u636e\u6846\u5e76\u6309Cluster\u6392\u5e8f\uff0c\u7136\u540e\u5728\u6bcf\u4e2aCluster\u4e2d\u6309Count\u6392\u5e8f\r\nA &lt;- data.frame(Description, Count, Cluster) %&gt;%\r\n  arrange(Cluster, Count)\r\n\r\n# \u6253\u5370\u51fa\u524d\u51e0\u884c\u6570\u636e\r\nhead(A)\r\n\r\n# \u6309\u7167\u63cf\u8ff0\u7684\u987a\u5e8f\u5c06\u63cf\u8ff0\u8f6c\u5316\u4e3a\u56e0\u5b50\r\nA$Description &lt;- fct_inorder(A$Description)\r\n\r\n# \u521b\u5efa\u989c\u8272\u6620\u5c04\u4ee5\u5339\u914d\u7c07\u6807\u7b7e\r\ncolor_map &lt;- c('Cluster1' = '#852f88', 'Cluster2' = '#eb990c', 'Cluster3' = '#0f8096')\r\n\r\n# \u521b\u5efa\u65b0\u7684\u989c\u8272\u5217\r\nA$Color &lt;- color_map[A$Cluster]\r\n\r\n# \u4f7f\u7528\u8fd9\u4e9b\u989c\u8272\u521b\u5efa\u57fa\u4e8e\u7c07\u7684\u67f1\u72b6\u56fe\uff0c\u5e76\u5c06\u8ba1\u6570\u6807\u7b7e\u6dfb\u52a0\u5230\u67f1\u72b6\u56fe\u4e0a\r\np &lt;- ggplot(A, aes(Description, Count)) +\r\n  geom_bar(aes(fill = Cluster), stat = \"identity\") +\r\n  geom_text(aes(label = Count, y = Count + 5), size = 3) +\r\n  coord_flip() +\r\n  labs(x = '', y = 'Gene count', title = 'GO enrichment of cluster') +\r\n  scale_fill_manual(values = color_map) +\r\n  theme_bw() +\r\n  theme(panel.grid = element_blank(),\r\n        legend.position = 'none',\r\n        axis.ticks.y = element_blank(),\r\n        plot.title = element_text(hjust = 0.5, size = 10),\r\n        axis.text.y = element_text(size = rel(0.85), colour = A$Color),\r\n        plot.margin = unit(c(0.2, 0.2, 0.2, 0.2), units = \"inches\"))\r\n\r\n# \u6253\u5370\u51fa\u56fe\u50cf\r\nprint(p)\r\n\r\n# \u5c06\u7ed3\u679c\u4fdd\u5b58\u4e3aPDF\u548cCSV\u6587\u4ef6\r\nggsave(\"GO_enrichment.pdf\", p, width = 10, height = 7)\r\nwrite.csv(A, \"GO.csv\", row.names = FALSE)\r\n<\/code><\/pre>\n<p><span>\u5728\u8fd9\u4e2a\u4fee\u6539\u540e\u7684\u7248\u672c\u4e2d\uff0c\u6211\u4eec\u5728<\/span><code>arrange()<\/code><span>\u51fd\u6570\u4e2d\u540c\u65f6\u6307\u5b9a\u4e86\"Cluster\"\u548c\"Count\"\uff0c\u8fd9\u6837\u6570\u636e\u5c31\u4f1a\u5148\u6309\u7167\"Cluster\"\u8fdb\u884c\u5206\u7ec4\uff0c\u7136\u540e\u5728\u6bcf\u4e2a\u5206\u7ec4\u4e2d\u6309\u7167\"Count\"\u7684\u5927\u5c0f\u8fdb\u884c\u6392\u5e8f\u3002\u8fd9\u6837\uff0c\u76f8\u540c\u989c\u8272\u7684\u6761\u5f62\u5c06\u88ab\u653e\u5728\u4e00\u8d77\uff0c\u5e76\u4e14\u5728\u6bcf\u4e2a\u989c\u8272\u7ec4\u4e2d\uff0c\u6761\u5f62\u5c06\u6309\u7167\u5927\u5c0f\u8fdb\u884c\u6392\u5e8f\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2.png\" alt=\"\" width=\"672\" height=\"672\" class=\"alignnone size-full wp-image-491\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2.png 672w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2-300x300.png 300w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2-100x100.png 100w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2-600x600.png 600w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u67f1\u72b6\u56fe2-150x150.png 150w\" sizes=\"auto, (max-width: 672px) 100vw, 672px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u9700\u8981\u4e00\u4e2aCSV\u6587\u4ef6\uff0c\u5176\u4e2d\u81f3\u5c11\u5305\u542b\u4e09\u5217\u6570\u636e\uff1a'Description'\uff0c'Count' \u548c 'Cluster [&hellip;]<\/p>\n","protected":false},"author":111,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-488","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=488"}],"version-history":[{"count":0,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/488\/revisions"}],"wp:attachment":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}