{"id":482,"date":"2023-06-24T07:11:48","date_gmt":"2023-06-24T07:11:48","guid":{"rendered":"https:\/\/yunshangtulv.com.cn\/?p=482"},"modified":"2023-06-24T07:11:48","modified_gmt":"2023-06-24T07:11:48","slug":"sci%e5%9b%be%e7%89%87%e5%a4%8d%e7%8e%b0%ef%bc%9a%e6%89%b9%e9%87%8f%e6%95%a3%e7%82%b9%e6%9f%b1%e7%8a%b6%e5%9b%be","status":"publish","type":"post","link":"https:\/\/yunshangtulv.com.cn\/?p=482","title":{"rendered":"SCI\u56fe\u7247\u590d\u73b0\uff1a\u6279\u91cf\u6563\u70b9\u67f1\u72b6\u56fe"},"content":{"rendered":"<p><span>\u4ee3\u7801\u662f\u505a\u4e00\u7cfb\u5217\u7684\u57fa\u56e0\u8868\u8fbe\u91cf\u7684\u7bb1\u7ebf\u56fe\u5e76\u8fdb\u884c\u4e86\u5206\u7ec4\u7684t\u68c0\u9a8c\u3002\u9700\u8981\u4e24\u4e2aCSV\u6587\u4ef6\uff0c\u4e00\u4e2a\u662f \"Exp.csv\"\uff0c\u5b83\u5e94\u8be5\u5305\u542b\u8868\u8fbe\u91cf\u6570\u636e\uff0c\u53e6\u4e00\u4e2a\u662f \"info.csv\"\uff0c\u5b83\u5e94\u8be5\u5305\u542b\u6837\u672c\u4fe1\u606f\u3002<\/span><\/p>\n<h3>1. \u751f\u6210\u6a21\u62df\u6570\u636e<\/h3>\n<pre class=\"corepress-code-pre\"><code># \u8bbe\u7f6e\u5de5\u4f5c\u76ee\u5f55\r\nsetwd(\"\")\r\n\r\n# \u8bbe\u5b9a\u968f\u673a\u6570\u79cd\u5b50\u4ee5\u786e\u4fdd\u53ef\u91cd\u590d\u6027\r\nset.seed(123)\r\n\r\n# \u751f\u6210\u6a21\u62df\u6570\u636e\r\nExp &lt;- matrix(runif(200), nrow=20)\r\ncolnames(Exp) &lt;- c(\"CD28\",\"CD3D\",\"CD8A\",\"LCK\",\"GATA3\",\"EOMES\",\"IL23A\",\"CXCL8\",\"IL1R2\",\"IL1R1\")\r\nrownames(Exp) &lt;- paste0(\"Sample_\", 1:20)\r\n\r\n# \u751f\u6210\u6837\u672c\u4fe1\u606f\r\ninfo &lt;- data.frame(Sample = rownames(Exp), \r\n                   Type = sample(c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\"), 20, replace = TRUE))\r\n\r\n# \u4fdd\u5b58\u6570\u636e\r\nwrite.csv(Exp, \"Exp.csv\", row.names = TRUE)\r\nwrite.csv(info, \"info.csv\", row.names = FALSE)\r\n\r\n# \u68c0\u67e5\u751f\u6210\u7684\u6570\u636e\r\nhead(Exp)\r\nhead(info)\r\n<\/code><\/pre>\n<h3>2. \u4fee\u6539\u4ee3\u7801\u4ee5\u9002\u5e94\u751f\u6210\u7684\u6570\u636e<\/h3>\n<p><span>\u56e0\u4e3a\u6a21\u62df\u6570\u636e\u5df2\u7ecf\u662f\u6b63\u6001\u5206\u5e03\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u6267\u884c\u5bf9\u6570\u8f6c\u6362\u3002<\/span><\/p>\n<pre class=\"corepress-code-pre\"><code># \u8bfb\u53d6\u6a21\u62df\u6570\u636e\r\nExp &lt;- read.csv(\"Exp.csv\",header=T,row.names=1)\r\ninfo &lt;- read.csv(\"info.csv\",header=T)\r\n\r\n# \u9700\u8981\u4f5c\u56fe\u7684\u57fa\u56e0\r\ngene &lt;- c(\"CD28\",\"CD3D\",\"CD8A\",\"LCK\",\"GATA3\",\"EOMES\",\"IL23A\",\"CXCL8\",\"IL1R2\",\"IL1R1\")\r\ngene &lt;- as.vector(gene)\r\nExp_plot &lt;- Exp[,gene]\r\n\r\n# \u8c03\u6574\u6837\u672c\u4fe1\u606f\u7684\u987a\u5e8f\u4ee5\u5339\u914d\u8868\u8fbe\u6570\u636e\u7684\u987a\u5e8f\r\ninfo$Sample &lt;- factor(info$Sample, levels = rownames(Exp_plot))\r\ninfo &lt;- info[order(info$Sample),]\r\n\r\n# \u6839\u636e\u6837\u672c\u4fe1\u606f\u8c03\u6574\u8868\u8fbe\u6570\u636e\u7684\u987a\u5e8f\r\nExp_plot &lt;- Exp_plot[info$Sample,]\r\nExp_plot$sam &lt;- info$Type\r\nExp_plot$sam &lt;- factor(Exp_plot$sam,levels=c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\"))\r\n\r\n# \u7136\u540e\u8ddf\u968f\u4f60\u7684\u4ee3\u7801\u8fdb\u884c\u56fe\u5f62\u751f\u6210\u548c\u53ef\u89c6\u5316...\r\n<\/code><\/pre>\n<h3>3. \u4ee3\u7801\u4f18\u5316\u53ca\u6ce8\u91ca<\/h3>\n<pre class=\"corepress-code-pre\"><code># \u5b9a\u4e49\u989c\u8272\r\ncol &lt;-c(\"#5CB85C\",\"#337AB7\",\"#F0AD4E\",\"#D9534F\")\r\n\r\n# \u5b9a\u4e49\u6240\u6709\u6bd4\u8f83\u7ec4\r\ngroups &lt;- c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\")\r\ncomparisons &lt;- combn(groups, 2, simplify = FALSE)\r\n\r\n# \u521d\u59cb\u5316\u5217\u8868\u6765\u4fdd\u5b58\u56fe\u5f62\r\nplist2 &lt;- list()\r\n\r\n# \u9488\u5bf9\u6bcf\u4e2a\u57fa\u56e0\u751f\u6210\u7bb1\u7ebf\u56fe\u5e76\u8fdb\u884ct\u68c0\u9a8c\r\nfor (i in 1:length(gene)) {\r\n  # \u63d0\u53d6\u57fa\u56e0\u8868\u8fbe\u4fe1\u606f\r\n  bar_tmp &lt;- Exp_plot[,c(gene[i],\"sam\")]\r\n  colnames(bar_tmp) &lt;- c(\"Expression\",\"sam\")\r\n\r\n  # \u751f\u6210\u5e76\u4fee\u6539\u7bb1\u7ebf\u56fe\r\n  pb1 &lt;- ggboxplot(bar_tmp, x = \"sam\", y = \"Expression\", color = \"sam\", add = \"jitter\", \r\n                   bxp.errorbar.width = 0.6, width = 0.4, size = 0.01, \r\n                   font.label = list(size = 30), palette = col) +\r\n    theme(panel.background = element_blank(),\r\n          axis.line = element_line(colour = \"black\"),\r\n          axis.title.x = element_blank(),\r\n          axis.title.y = element_blank(),\r\n          axis.text.x = element_text(size = 15, angle = 45, vjust = 1, hjust = 1),\r\n          axis.text.y = element_text(size = 15),\r\n          plot.title = element_text(hjust = 0.5, size = 15, face = \"bold\"),\r\n          legend.position = \"none\") +\r\n    ggtitle(gene[i]) +\r\n    stat_compare_means(method = \"t.test\", hide.ns = F, comparisons = comparisons, label = \"p.signif\")\r\n\r\n  # \u4fdd\u5b58\u56fe\u5f62\r\n  plist2[[i]] &lt;- pb1\r\n}\r\n\r\n# \u5c06\u6240\u6709\u56fe\u5f62\u7ec4\u5408\u5230\u4e00\u4e2a\u56fe\u4e2d\r\npall &lt;- plot_grid(plotlist = plist2, ncol = 4)\r\npall\r\n<\/code><\/pre>\n<h3>4. \u4f18\u5316\u56fe\u7247\u7684\u7f8e\u89c2\u5ea6<\/h3>\n<pre class=\"corepress-code-pre\"><code># \u66f4\u65b0\u4e3b\u9898\u4ee5\u4f18\u5316\u56fe\u5f62\u7f8e\u89c2\u5ea6\r\npb1 &lt;- pb1 + theme_classic() +  # \u4f7f\u7528\u7ecf\u5178\u4e3b\u9898\r\n  theme( \r\n    axis.text.x = element_text(size = 15, angle = 45, vjust = 1, hjust = 1, color = \"black\"), \r\n    axis.text.y = element_text(size = 15, color = \"black\"),\r\n    axis.title = element_text(size = 16, face = \"bold\"),\r\n    plot.title = element_text(hjust = 0.5, size = 18, face = \"bold\", color = \"black\"),\r\n    legend.title = element_text(size = 14, face = \"bold\"),\r\n    legend.text = element_text(size = 12)\r\n  )\r\n<\/code><\/pre>\n<h3>5. \u4fdd\u5b58\u751f\u6210\u7684\u7ed3\u679c<\/h3>\n<pre class=\"corepress-code-pre\"><code># \u4fdd\u5b58\u56fe\u50cf\u4e3a PDF \u683c\u5f0f\r\nggsave(\"boxplots.pdf\", pall, width = 10, height = 10)\r\n\r\n# \u4fdd\u5b58\u6570\u636e\u4e3a CSV \u683c\u5f0f\r\nwrite.csv(Exp_plot, \"Exp_plot.csv\", row.names = TRUE)\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n<pre class=\"corepress-code-pre\"><code># \u52a0\u8f7d\u5fc5\u8981\u7684\u5305\r\nlibrary(RColorBrewer)\r\nlibrary(ggpubr)\r\nlibrary(ggplot2)\r\nlibrary(cowplot)\r\n\r\n\r\n# \u8bbe\u5b9a\u5de5\u4f5c\u76ee\u5f55\r\nsetwd(\"C:\/Users\/\u8d56\u9f99\/Desktop\")\r\n\r\n# \u8bbe\u5b9a\u968f\u673a\u6570\u79cd\u5b50\u4ee5\u786e\u4fdd\u53ef\u91cd\u590d\u6027\r\nset.seed(123)\r\n\r\n# \u751f\u6210\u6a21\u62df\u6570\u636e\r\n# \u751f\u6210\u6a21\u62df\u6570\u636e\r\nExp &lt;- matrix(runif(200), nrow=20, ncol=10) # \u6ce8\u610f\u8fd9\u91cc\u7684 ncol \u53c2\u6570\uff0c\u786e\u4fdd\u4f60\u670912\u5217\r\ncolnames(Exp) &lt;- c(\"CD28\",\"CD3D\",\"CD8A\",\"LCK\",\"GATA3\",\"EOMES\",\"IL23A\",\"CXCL8\",\"IL1R2\",\"IL1R1\")\r\nrownames(Exp) &lt;- paste0(\"Sample_\", 1:20)\r\n\r\n# \u751f\u6210\u6837\u672c\u4fe1\u606f\r\ninfo &lt;- data.frame(Sample = rownames(Exp), \r\n                   Type = sample(c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\"), 20, replace = TRUE))\r\n\r\n# \u4fdd\u5b58\u6a21\u62df\u6570\u636e\r\nwrite.csv(Exp, \"Exp.csv\", row.names = TRUE)\r\nwrite.csv(info, \"info.csv\", row.names = FALSE)\r\n\r\n# \u8bfb\u53d6\u6a21\u62df\u6570\u636e\r\nExp &lt;- read.csv(\"Exp.csv\",header=T,row.names=1)\r\ninfo &lt;- read.csv(\"info.csv\",header=T)\r\n\r\n# \u9700\u8981\u4f5c\u56fe\u7684\u57fa\u56e0\r\ngene &lt;- c(\"CD28\",\"CD3D\",\"CD8A\",\"LCK\",\"GATA3\",\"EOMES\",\"IL23A\",\"CXCL8\",\"IL1R2\",\"IL1R1\")\r\ngene &lt;- as.vector(gene)\r\nExp_plot &lt;- Exp[,gene]\r\n\r\n# \u8c03\u6574\u6837\u672c\u4fe1\u606f\u7684\u987a\u5e8f\u4ee5\u5339\u914d\u8868\u8fbe\u6570\u636e\u7684\u987a\u5e8f\r\ninfo$Sample &lt;- factor(info$Sample, levels = rownames(Exp_plot))\r\ninfo &lt;- info[order(info$Sample),]\r\n\r\n# \u6839\u636e\u6837\u672c\u4fe1\u606f\u8c03\u6574\u8868\u8fbe\u6570\u636e\u7684\u987a\u5e8f\r\nExp_plot &lt;- Exp_plot[info$Sample,]\r\nExp_plot$sam &lt;- info$Type\r\nExp_plot$sam &lt;- factor(Exp_plot$sam,levels=c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\"))\r\n\r\n# \u5b9a\u4e49\u989c\u8272\r\ncol &lt;-c(\"#5CB85C\",\"#337AB7\",\"#F0AD4E\",\"#D9534F\")\r\n\r\n# \u5b9a\u4e49\u6240\u6709\u6bd4\u8f83\u7ec4\r\ngroups &lt;- c(\"Asymptomatic\",\"Mild\",\"Severe\",\"Critical\")\r\ncomparisons &lt;- combn(groups, 2, simplify = FALSE)\r\n\r\n# \u521d\u59cb\u5316\u5217\u8868\u6765\u4fdd\u5b58\u56fe\u5f62\r\nplist2 &lt;- list()\r\n\r\n# \u9488\u5bf9\u6bcf\u4e2a\u57fa\u56e0\u751f\u6210\u7bb1\u7ebf\u56fe\u5e76\u8fdb\u884ct\u68c0\u9a8c\r\nfor (i in 1:length(gene)) {\r\n  # \u63d0\u53d6\u57fa\u56e0\u8868\u8fbe\u4fe1\u606f\r\n  bar_tmp &lt;- Exp_plot[,c(gene[i],\"sam\")]\r\n  colnames(bar_tmp) &lt;- c(\"Expression\",\"sam\")\r\n\r\n  # \u751f\u6210\u5e76\u4fee\u6539\u7bb1\u7ebf\u56fe\r\n  pb1 &lt;- ggboxplot(bar_tmp, x = \"sam\", y = \"Expression\", color = \"sam\", add = \"jitter\", \r\n                   bxp.errorbar.width = 0.6, width = 0.4, size = 0.01, \r\n                   font.label = list(size = 30), palette = col) +\r\n    theme(panel.background = element_blank(),\r\n          axis.line = element_line(colour = \"black\"),\r\n          axis.title.x = element_blank(),\r\n          axis.title.y = element_blank(),\r\n          axis.text.x = element_text(size = 15, angle = 45, vjust = 1, hjust = 1, color = \"black\"),\r\n          axis.text.y = element_text(size = 15, color = \"black\"),\r\n          plot.title = element_text(hjust = 0.5, size = 18, face = \"bold\", color = \"black\"),\r\n          legend.position = \"none\") +\r\n    ggtitle(gene[i]) +\r\n    stat_compare_means(method = \"t.test\", hide.ns = F, comparisons = comparisons, label = \"p.signif\")\r\n\r\n  # \u4fdd\u5b58\u56fe\u5f62\r\n  plist2[[i]] &lt;- pb1\r\n}\r\n\r\n# \u5c06\u6240\u6709\u56fe\u5f62\u7ec4\u5408\u5230\u4e00\u4e2a\u56fe\u4e2d\r\npall &lt;- plot_grid(plotlist = plist2, ncol = 4)\r\n\r\n# \u663e\u793a\u7ec4\u5408\u56fe\r\nprint(pall)\r\n\r\n# \u4fdd\u5b58\u56fe\u50cf\u4e3a PDF \u683c\u5f0f\r\nggsave(\"boxplots.pdf\", pall, width = 10, height = 10)\r\n\r\n# \u4fdd\u5b58\u6570\u636e\u4e3a CSV \u683c\u5f0f\r\nwrite.csv(Exp_plot, \"Exp_plot.csv\", row.names = TRUE)\r\n<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-1024x954.png\" alt=\"\" width=\"1024\" height=\"954\" class=\"alignnone size-large wp-image-483\" srcset=\"https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-1024x954.png 1024w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-600x559.png 600w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-300x280.png 300w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-768x716.png 768w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-1536x1431.png 1536w, https:\/\/yunshangtulv.com.cn\/wp-content\/uploads\/2023\/06\/\u622a\u56fe_20230624144346-2048x1908.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u662f\u505a\u4e00\u7cfb\u5217\u7684\u57fa\u56e0\u8868\u8fbe\u91cf\u7684\u7bb1\u7ebf\u56fe\u5e76\u8fdb\u884c\u4e86\u5206\u7ec4\u7684t\u68c0\u9a8c\u3002\u9700\u8981\u4e24\u4e2aCSV\u6587\u4ef6\uff0c\u4e00\u4e2a\u662f \"Exp.csv\"\uff0c\u5b83\u5e94\u8be5 [&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-482","post","type-post","status-publish","format-standard","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/482","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=482"}],"version-history":[{"count":0,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/482\/revisions"}],"wp:attachment":[{"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yunshangtulv.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}