{"id":26244,"date":"2024-01-25T12:12:48","date_gmt":"2024-01-25T04:12:48","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=26244"},"modified":"2024-01-25T12:12:50","modified_gmt":"2024-01-25T04:12:50","slug":"%e5%8f%aa%e9%9c%80%e4%b8%89%e5%88%86%e9%92%9f%ef%bc%81%e5%b0%8f%e6%9e%9c%e6%95%99%e4%bd%a0%e5%9c%a8%e7%bb%98%e5%88%b6%e7%9a%84%e7%83%ad%e5%9b%be%e6%b7%bb%e5%8a%a0%e6%b3%a8%e9%87%8a%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=26244","title":{"rendered":"\u53ea\u9700\u4e09\u5206\u949f\uff01\u5c0f\u679c\u6559\u4f60\u5728\u7ed8\u5236\u7684\u70ed\u56fe\u6dfb\u52a0\u6ce8\u91ca\u4fe1\u606f\uff01\uff01"},"content":{"rendered":"\n<p>\u6709\u4e0d\u5c11\u5c0f\u4f19\u4f34\u5728\u7ed8\u5236\u70ed\u56fe\u65f6\u5019\uff0c\u7ed8\u5236\u7684\u56fe\u4fe1\u606f\u5f88\u5c11\uff0c\u53ea\u6709\u540d\u79f0\u548c\u76f8\u5173\u6027\u503c\uff0c\u6709\u65f6\u770b\u8d77\u6765\u67af\u71e5\u4e4f\u5473\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u6559\u5927\u5bb6\u4e00\u4e2a\u65b0\u7684\u65b9\u5f0f\u7ed8\u5236\u70ed\u56fe\uff0c\u53ef\u4ee5\u8ba9\u5c0f\u4f19\u4f34\u5728\u7ed8\u5236\u70ed\u56fe\u7684\u65f6\u5019\u6dfb\u52a0\u81ea\u5df1\u60f3\u8981\u7684\u6ce8\u91ca\u4fe1\u606f\uff0c\u8fd9\u6837\u4e00\u6765\u5c0f\u4f19\u4f34\u7ed8\u5236\u7684\u56fe\u7247\u5c31\u4f1a\u8ba9\u8bfb\u8005\u770b\u6765\u4e86\u6e05\u6670\u660e\u4e86\u3002\u5feb\u8ddf\u7740\u5c0f\u679c\u53d6\u5b66\u4e60\u5427\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5e73\u65f6\u53d6\u7ed8\u5236\u70ed\u56fe\u7684\u65f6\u5019\u4e00\u822c\u662f\u4f7f\u7528pheatmap\u4e13\u95e8\u7ed8\u5236\u70ed\u56fe\u7684\uff0c\u8fd9\u4e2a\u5305\u53ef\u4ee5\u5feb\u901f\u51fa\u571f\uff0c\u4f46\u662f\u5374\u4e0d\u80fd\u4fee\u6539\u4e00\u4e9b\u56fe\u7247\u4e2d\u7684\u7ec6\u8282\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u8001\u670b\u53cbggplot2\u5305\u53d6\u5b9e\u73b0\u66f4\u591a\u7684\u81ea\u5b9a\u4e49\u8bbe\u7f6e\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u4f7f\u7528\u81ea\u5e26\u7684mtcars\u5305\u4e2d\u7684\u6570\u636e\uff0c\u5e26\u9886\u5927\u5bb6\u7ed8\u5236\u70ed\u56fe\uff0c\u53d6\u6dfb\u52a0\u4e00\u4e9b\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5c31\u662f\u5728Y\u8f74\u7684\u6807\u7b7e\u5728\u6700\u5916\u9762\u3002<\/p>\n\n\n\n<p>\u5176\u5b9e\u6807\u7b7e\u663e\u793a\u5728\u6700\u5916\u9762\u539f\u7406\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5982\u56fe\u4e0d\u663e\u793aaxis.text.y\uff0c\u800c\u662f\u6dfb\u52a0\u7684\u6ce8\u91ca\u90a3\u4e2a\u6761\u6dfb\u52a0\u4e0aaxis.text.y\u3002\u5982\u679c\u6709\u591a\u4e2a\uff0c\u53ea\u6709\u5916\u9762\u7684\u663e\u793aaxis.tsxt,y<\/p>\n\n\n\n<p>\u4e0b\u9762\u8ddf\u7740\u5c0f\u679c\u53d6\u5b66\u4e60\u5427\uff1a<\/p>\n\n\n\n<p>library(ggplot2)<\/p>\n\n\n\n<p>library(aplot)<\/p>\n\n\n\n<p>library(tidyr)<\/p>\n\n\n\n<p>library(dplyr)<\/p>\n\n\n\n<p>#\u6211\u4eec\u5148\u8c03\u7528\u8fd9\u51e0\u4e2a\u5305\uff0c\u5c0f\u4f19\u4f34\u6ca1\u6709\u7684\u81ea\u884c\u53bb\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<p>p &lt;- scale(mtcars) %&gt;% data.frame()<\/p>\n\n\n\n<p>p$mtxars &lt;- rownames(p)#\u8fd9\u91cc\u9700\u8981\u628a\u6570\u636e\u8c03\u6574\u4e00\u4e0b<\/p>\n\n\n\n<p>#\u8fd9\u91cc\u4f7f\u7528mtcars\u81ea\u5e26\u7684\u6570\u636e\u5c0f\u4f19\u4f34\u6839\u636e\u6570\u636e\u5f62\u5f0f\u81ea\u884c\u53bb\u8bbe\u7f6e<\/p>\n\n\n\n<p>#\u8fd9\u91cc\u5c0f\u4f19\u4f34\u6ce8\u610f\u4e00\u4e0b\uff0c\u6309\u7167\u5b9e\u9645\u987a\u5e8f\u6392\u5217\uff0c\u4e0d\u8fdb\u884c\u8fd9\u4e00\u6b65ggplot\u9ed8\u8ba4\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\uff0c\u56fe\u4f1a\u4e71\u6389<\/p>\n\n\n\n<p>p$mtxars &lt;- factor(p$mtxars,level = p$mtxars)<\/p>\n\n\n\n<p>#\u5bbd\u8868\u8f6c\u957f\u8868<\/p>\n\n\n\n<p>p1 &lt;- gather(p, 1:11, key=&#8221;condition&#8221;, value=&#8217;expr&#8217;)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"288\" height=\"366\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?resize=288%2C366\" alt=\"\" class=\"wp-image-26245\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?w=288 288w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?resize=236%2C300 236w\" sizes=\"(max-width: 288px) 100vw, 288px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u4e0a\u8ff0\u6211\u4eec\u628a\u6570\u636e\u5df2\u7ecf\u6574\u7406\u5b8c\u6210\u4e86\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u53bb\u7ed8\u5236\u70ed\u56fe\uff1a<\/p>\n\n\n\n<p>#\u7ed8\u5236\u70ed\u56fe<\/p>\n\n\n\n<p>pp1 &lt;- ggplot(p1,aes(condition,mtxars)) +<\/p>\n\n\n\n<p>geom_tile(aes(fill=expr),colour = &#8220;white&#8221;)+<\/p>\n\n\n\n<p>scale_fill_gradientn(values = seq(0,1,0.2),colours = c(&#8216;#6699CC&#8217;,&#8217;#FFFF99&#8242;,&#8217;#CC3333&#8242;))+<\/p>\n\n\n\n<p>theme_minimal()+<\/p>\n\n\n\n<p>scale_y_discrete(position=&#8221;right&#8221;)+<\/p>\n\n\n\n<p>xlab(NULL) + ylab(NULL)+<\/p>\n\n\n\n<p>theme(axis.text.y = element_blank())<\/p>\n\n\n\n<p>#\u8fd9\u91cc\u628a\u53c2\u6570\u8c03\u7528\u51fa\u6765\uff0c\u4e0a\u8ff0\u989c\u8272\u53ef\u4ee5\u4e86\u81ea\u884c\u8c03\u6574\uff0c<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"479\" height=\"252\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?resize=479%2C252\" alt=\"\" class=\"wp-image-26246\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?w=479 479w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?resize=300%2C158 300w\" sizes=\"(max-width: 479px) 100vw, 479px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>pp2 &lt;- ggplot(p1,aes(condition,mtxars)) +<\/p>\n\n\n\n<p>scale_color_gradientn(values = seq(0,1,0.2),colours = c(&#8216;#6699CC&#8217;,&#8217;#FFFF99&#8242;,&#8217;#CC3333&#8242;))+<\/p>\n\n\n\n<p>theme_bw()+<\/p>\n\n\n\n<p>geom_point(aes(size=expr,color=expr))+<\/p>\n\n\n\n<p>theme(panel.grid = element_blank(),axis.text.x =element_text(angle =90,hjust =0.5,vjust = 0.5))+<\/p>\n\n\n\n<p>xlab(NULL) + ylab(NULL)+<\/p>\n\n\n\n<p>theme(panel.border = element_rect(fill=NA,color=&#8221;black&#8221;, size=1, linetype=&#8221;solid&#8221;),<\/p>\n\n\n\n<p>axis.text.y = element_blank())#<\/p>\n\n\n\n<p>Type_A &lt;- rownames(p) %&gt;% as.data.frame() %&gt;%<\/p>\n\n\n\n<p>mutate(group=rep(c(&#8220;A&#8221;,&#8221;B&#8221;,&#8221;C&#8221;),<\/p>\n\n\n\n<p>times=c(10,10,12))) %&gt;%<\/p>\n\n\n\n<p>mutate(p=&#8221;&#8221;)%&gt;%<\/p>\n\n\n\n<p>ggplot(aes(p,.,fill=group))+<\/p>\n\n\n\n<p>geom_tile() +<\/p>\n\n\n\n<p>scale_y_discrete(position=&#8221;right&#8221;) +<\/p>\n\n\n\n<p>theme_minimal()+xlab(NULL) + ylab(NULL) +<\/p>\n\n\n\n<p>theme(axis.text.y = element_blank())+<\/p>\n\n\n\n<p>labs(fill = &#8220;Type_A&#8221;)<\/p>\n\n\n\n<p>Type_B &lt;- rownames(p) %&gt;% as.data.frame() %&gt;%<\/p>\n\n\n\n<p>mutate(group=rep(c(&#8220;D&#8221;,&#8221;E&#8221;,&#8221;F&#8221;),<\/p>\n\n\n\n<p>times=c(6,12,14))) %&gt;%<\/p>\n\n\n\n<p>mutate(p=&#8221;&#8221;)%&gt;%<\/p>\n\n\n\n<p>ggplot(aes(p,.,fill=group))+<\/p>\n\n\n\n<p>geom_tile() +<\/p>\n\n\n\n<p>scale_y_discrete(position=&#8221;right&#8221;) +<\/p>\n\n\n\n<p>theme_minimal()+xlab(NULL) + ylab(NULL)+<\/p>\n\n\n\n<p>labs(fill = &#8220;Type_B&#8221;)<\/p>\n\n\n\n<p>#\u4e0a\u8ff0\u5bf9\u6570\u636e\u96c6\u7684\u53c2\u6570\u8fdb\u884c\u8c03\u6574\uff0c\u8bbe\u7f6e\u6211\u4eec\u8981\u7ed8\u5236\u7684\u7ec4\uff0c\u5c0f\u4f19\u4f34\u8981\u770b\u6e05\u695a\uff0c\u628a\u81ea\u5df1\u7684\u6570\u636e\u5957\u7528\u8fdb\u53bb\uff0c\u4e0b\u9762\u6211\u4eec\u628a\u7ed3\u679c\u8c03\u6574\u597d\u7684\u7ed3\u679c\u53ef\u89c6\u5316\uff1a<\/p>\n\n\n\n<p>pp1 %&gt;%<\/p>\n\n\n\n<p>insert_left(Type_A, width = .05)%&gt;%<\/p>\n\n\n\n<p>insert_left(Type_B,width=.05) #\u6709\u4e9b\u5c0f\u4f19\u4f34%&gt;%\u8fd9\u91cc\u7ecf\u5e38\u4f1a\u62a5\u9519\uff0c\u662f\u56e0\u4e3aR\u5305dplyr\u6ca1\u8c03\u7528\u597d\uff0c\u4f7f\u7ed8\u5236\u56fe\u7247\u7684\u65f6\u5019\u627e\u4e0d\u5230\u8981\u7ed8\u5236\u7684\u7ec4\uff0c\u8c03\u7528\u4e0d\u4e86\u51fd\u6570\u3002\u91cd\u65b0\u8c03\u7528\u4e00\u4e0b\u5c31\u53ef\u4ee5\uff0c\u6216\u8005\u9700\u8981\u66f4\u65b0\u4e00\u4e0bR\u5305\uff0c\u4e0d\u8981\u5fd8\u8bb0\u91cd\u65b0\u6253\u5f00R\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"652\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=640%2C652\" alt=\"\" class=\"wp-image-26247\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?w=650 650w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=295%2C300 295w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=600%2C611 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u4e0a\u8ff0\u5c31\u662f\u5bf9\u56fe\u7247\u7684\u7ed8\u5236\uff0c\u70ed\u56fe\u7684\u5de6\u4fa7\u662f\u4e00\u4e9b\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5c0f\u4f19\u4f34\u6709\u6ca1\u6709\u5fc3\u52a8\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5566\u8c03\u6574\u4e00\u4e0b\u70ed\u56fe\u4e2d\u7684\u5f62\u72b6\uff0c\uff1a<\/p>\n\n\n\n<p>\u4e0b\u9762\u4f7f\u7528PP2\u7ec4\u7684\u6570\u636e<br>pp2 %&gt;%<\/p>\n\n\n\n<p>insert_left(Type_A, width = .05)%&gt;%<\/p>\n\n\n\n<p>insert_left(Type_B,width=.05)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"645\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=640%2C645\" alt=\"\" class=\"wp-image-26248\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?w=650 650w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=298%2C300 298w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=150%2C150 150w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=600%2C605 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=100%2C100 100w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e0b\u5c31\u5927\u529f\u544a\u6210\u4e86\uff0c\u4e0a\u8ff0\u56fe\u7247\u4e2d\u6709\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5982\u679c\u6709\u5c0f\u4f19\u4f34\u5176\u4ed6\u7684\u5982\u679c\u6709\u5176\u5b83\u987a\u5e8f\uff0c\u6392\u5e8f\u4e4b\u540e\u91cd\u65b0\u8bbe\u7f6efactor\u3002<\/p>\n\n\n\n<p>\u5c31\u662f\u8fd9\u4e00\u6b65\uff1a<\/p>\n\n\n\n<p>#\u6309\u7167\u5b9e\u9645\u987a\u5e8f\u6392\u5217\uff0c\u4e0d\u8fdb\u884c\u8fd9\u4e00\u6b65ggplot\u9ed8\u8ba4\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\uff0c\u56fe\u4f1a\u4e71\u6389<br>p$mtxars &lt;- factor(p$mtxars,level = p$mtxars)<\/p>\n\n\n\n<p>\u5c0f\u4f19\u4f34\u6709\u6ca1\u6709\u5fc3\u52a8\u5462\uff0c\u5feb\u53bb\u8bd5\u8bd5\u81ea\u5df1\u7684\u6570\u636e\u5427\u3002\u5176\u5b9e\uff0cggplot2\u662f\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u7684\u5305\uff0c\u5b83\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5f88\u591a\u56fe\u7247\u4e2d\u7684\u7ec6\u8282\uff0c\u5c0f\u4f19\u4f34\u8981\u591a\u591a\u5b66\u4e60\uff0c\u7406\u89e3\u4ee3\u7801\u4e2d\u7684\u542b\u4e49\uff0c\u624d\u80fd\u7ed8\u5236\u51fa\u81ea\u5df1\u60f3\u8981\u7684\u56fe\u3002<\/p>\n\n\n<p><strong>\u53ea\u9700\u4e09\u5206\u949f\uff01\u5c0f\u679c\u6559\u4f60\u5728\u7ed8\u5236\u7684\u70ed\u56fe\u6dfb\u52a0\u6ce8\u91ca\u4fe1\u606f\uff01\uff01<\/strong><\/p>\n<p>\u6709\u4e0d\u5c11\u5c0f\u4f19\u4f34\u5728\u7ed8\u5236\u70ed\u56fe\u65f6\u5019\uff0c\u7ed8\u5236\u7684\u56fe\u4fe1\u606f\u5f88\u5c11\uff0c\u53ea\u6709\u540d\u79f0\u548c\u76f8\u5173\u6027\u503c\uff0c\u6709\u65f6\u770b\u8d77\u6765\u67af\u71e5\u4e4f\u5473\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u6559\u5927\u5bb6\u4e00\u4e2a\u65b0\u7684\u65b9\u5f0f\u7ed8\u5236\u70ed\u56fe\uff0c\u53ef\u4ee5\u8ba9\u5c0f\u4f19\u4f34\u5728\u7ed8\u5236\u70ed\u56fe\u7684\u65f6\u5019\u6dfb\u52a0\u81ea\u5df1\u60f3\u8981\u7684\u6ce8\u91ca\u4fe1\u606f\uff0c\u8fd9\u6837\u4e00\u6765\u5c0f\u4f19\u4f34\u7ed8\u5236\u7684\u56fe\u7247\u5c31\u4f1a\u8ba9\u8bfb\u8005\u770b\u6765\u4e86\u6e05\u6670\u660e\u4e86\u3002\u5feb\u8ddf\u7740\u5c0f\u679c\u53d6\u5b66\u4e60\u5427\u3002<\/p>\n<p>\u6211\u4eec\u5e73\u65f6\u53d6\u7ed8\u5236\u70ed\u56fe\u7684\u65f6\u5019\u4e00\u822c\u662f\u4f7f\u7528pheatmap\u4e13\u95e8\u7ed8\u5236\u70ed\u56fe\u7684\uff0c\u8fd9\u4e2a\u5305\u53ef\u4ee5\u5feb\u901f\u51fa\u571f\uff0c\u4f46\u662f\u5374\u4e0d\u80fd\u4fee\u6539\u4e00\u4e9b\u56fe\u7247\u4e2d\u7684\u7ec6\u8282\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u8001\u670b\u53cbggplot2\u5305\u53d6\u5b9e\u73b0\u66f4\u591a\u7684\u81ea\u5b9a\u4e49\u8bbe\u7f6e\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u4f7f\u7528\u81ea\u5e26\u7684mtcars\u5305\u4e2d\u7684\u6570\u636e\uff0c\u5e26\u9886\u5927\u5bb6\u7ed8\u5236\u70ed\u56fe\uff0c\u53d6\u6dfb\u52a0\u4e00\u4e9b\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5c31\u662f\u5728Y\u8f74\u7684\u6807\u7b7e\u5728\u6700\u5916\u9762\u3002<\/p>\n<p>\u5176\u5b9e\u6807\u7b7e\u663e\u793a\u5728\u6700\u5916\u9762\u539f\u7406\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5982\u56fe\u4e0d\u663e\u793aaxis.text.y\uff0c\u800c\u662f\u6dfb\u52a0\u7684\u6ce8\u91ca\u90a3\u4e2a\u6761\u6dfb\u52a0\u4e0aaxis.text.y\u3002\u5982\u679c\u6709\u591a\u4e2a\uff0c\u53ea\u6709\u5916\u9762\u7684\u663e\u793aaxis.tsxt,y<\/p>\n<p>\u4e0b\u9762\u8ddf\u7740\u5c0f\u679c\u53d6\u5b66\u4e60\u5427\uff1a<\/p>\n<p>library(ggplot2)<\/p>\n<p>library(aplot)<\/p>\n<p>library(tidyr)<\/p>\n<p>library(dplyr)<\/p>\n<p>#\u6211\u4eec\u5148\u8c03\u7528\u8fd9\u51e0\u4e2a\u5305\uff0c\u5c0f\u4f19\u4f34\u6ca1\u6709\u7684\u81ea\u884c\u53bb\u4e0b\u8f7d\u3002<\/p>\n<p>p &lt;- scale(mtcars) %&gt;% data.frame()<\/p>\n<p>p$mtxars &lt;- rownames(p)#\u8fd9\u91cc\u9700\u8981\u628a\u6570\u636e\u8c03\u6574\u4e00\u4e0b<\/p>\n<p>#\u8fd9\u91cc\u4f7f\u7528mtcars\u81ea\u5e26\u7684\u6570\u636e\u5c0f\u4f19\u4f34\u6839\u636e\u6570\u636e\u5f62\u5f0f\u81ea\u884c\u53bb\u8bbe\u7f6e<\/p>\n<p>#\u8fd9\u91cc\u5c0f\u4f19\u4f34\u6ce8\u610f\u4e00\u4e0b\uff0c\u6309\u7167\u5b9e\u9645\u987a\u5e8f\u6392\u5217\uff0c\u4e0d\u8fdb\u884c\u8fd9\u4e00\u6b65ggplot\u9ed8\u8ba4\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\uff0c\u56fe\u4f1a\u4e71\u6389<\/p>\n<p>p$mtxars &lt;- factor(p$mtxars,level = p$mtxars)<\/p>\n<p>#\u5bbd\u8868\u8f6c\u957f\u8868<\/p>\n<p>p1 &lt;- gather(p, 1:11, key=&#8221;condition&#8221;, value=&#8217;expr&#8217;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"288\" height=\"366\" class=\"wp-image-26245\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?resize=288%2C366\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?w=288 288w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-1.png?resize=236%2C300 236w\" sizes=\"(max-width: 288px) 100vw, 288px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0a\u8ff0\u6211\u4eec\u628a\u6570\u636e\u5df2\u7ecf\u6574\u7406\u5b8c\u6210\u4e86\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u53bb\u7ed8\u5236\u70ed\u56fe\uff1a<\/p>\n<p>#\u7ed8\u5236\u70ed\u56fe<\/p>\n<p>pp1 &lt;- ggplot(p1,aes(condition,mtxars)) +<\/p>\n<p>geom_tile(aes(fill=expr),colour = &#8220;white&#8221;)+<\/p>\n<p>scale_fill_gradientn(values = seq(0,1,0.2),colours = c(&#8216;#6699CC&#8217;,&#8217;#FFFF99&#8242;,&#8217;#CC3333&#8242;))+<\/p>\n<p>theme_minimal()+<\/p>\n<p>scale_y_discrete(position=&#8221;right&#8221;)+<\/p>\n<p>xlab(NULL) + ylab(NULL)+<\/p>\n<p>theme(axis.text.y = element_blank())<\/p>\n<p>#\u8fd9\u91cc\u628a\u53c2\u6570\u8c03\u7528\u51fa\u6765\uff0c\u4e0a\u8ff0\u989c\u8272\u53ef\u4ee5\u4e86\u81ea\u884c\u8c03\u6574\uff0c<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"479\" height=\"252\" class=\"wp-image-26246\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?resize=479%2C252\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?w=479 479w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-2.png?resize=300%2C158 300w\" sizes=\"(max-width: 479px) 100vw, 479px\" data-recalc-dims=\"1\" \/><\/p>\n<p>pp2 &lt;- ggplot(p1,aes(condition,mtxars)) +<\/p>\n<p>scale_color_gradientn(values = seq(0,1,0.2),colours = c(&#8216;#6699CC&#8217;,&#8217;#FFFF99&#8242;,&#8217;#CC3333&#8242;))+<\/p>\n<p>theme_bw()+<\/p>\n<p>geom_point(aes(size=expr,color=expr))+<\/p>\n<p>theme(panel.grid = element_blank(),axis.text.x =element_text(angle =90,hjust =0.5,vjust = 0.5))+<\/p>\n<p>xlab(NULL) + ylab(NULL)+<\/p>\n<p>theme(panel.border = element_rect(fill=NA,color=&#8221;black&#8221;, size=1, linetype=&#8221;solid&#8221;),<\/p>\n<p>axis.text.y = element_blank())#<\/p>\n<p>Type_A &lt;- rownames(p) %&gt;% as.data.frame() %&gt;%<\/p>\n<p>mutate(group=rep(c(&#8220;A&#8221;,&#8221;B&#8221;,&#8221;C&#8221;),<\/p>\n<p>times=c(10,10,12))) %&gt;%<\/p>\n<p>mutate(p=&#8221;&#8221;)%&gt;%<\/p>\n<p>ggplot(aes(p,.,fill=group))+<\/p>\n<p>geom_tile() +<\/p>\n<p>scale_y_discrete(position=&#8221;right&#8221;) +<\/p>\n<p>theme_minimal()+xlab(NULL) + ylab(NULL) +<\/p>\n<p>theme(axis.text.y = element_blank())+<\/p>\n<p>labs(fill = &#8220;Type_A&#8221;)<\/p>\n<p>Type_B &lt;- rownames(p) %&gt;% as.data.frame() %&gt;%<\/p>\n<p>mutate(group=rep(c(&#8220;D&#8221;,&#8221;E&#8221;,&#8221;F&#8221;),<\/p>\n<p>times=c(6,12,14))) %&gt;%<\/p>\n<p>mutate(p=&#8221;&#8221;)%&gt;%<\/p>\n<p>ggplot(aes(p,.,fill=group))+<\/p>\n<p>geom_tile() +<\/p>\n<p>scale_y_discrete(position=&#8221;right&#8221;) +<\/p>\n<p>theme_minimal()+xlab(NULL) + ylab(NULL)+<\/p>\n<p>labs(fill = &#8220;Type_B&#8221;)<\/p>\n<p>#\u4e0a\u8ff0\u5bf9\u6570\u636e\u96c6\u7684\u53c2\u6570\u8fdb\u884c\u8c03\u6574\uff0c\u8bbe\u7f6e\u6211\u4eec\u8981\u7ed8\u5236\u7684\u7ec4\uff0c\u5c0f\u4f19\u4f34\u8981\u770b\u6e05\u695a\uff0c\u628a\u81ea\u5df1\u7684\u6570\u636e\u5957\u7528\u8fdb\u53bb\uff0c\u4e0b\u9762\u6211\u4eec\u628a\u7ed3\u679c\u8c03\u6574\u597d\u7684\u7ed3\u679c\u53ef\u89c6\u5316\uff1a<\/p>\n<p>pp1 %&gt;%<\/p>\n<p>insert_left(Type_A, width = .05)%&gt;%<\/p>\n<p>insert_left(Type_B,width=.05) #\u6709\u4e9b\u5c0f\u4f19\u4f34%&gt;%\u8fd9\u91cc\u7ecf\u5e38\u4f1a\u62a5\u9519\uff0c\u662f\u56e0\u4e3aR\u5305dplyr\u6ca1\u8c03\u7528\u597d\uff0c\u4f7f\u7ed8\u5236\u56fe\u7247\u7684\u65f6\u5019\u627e\u4e0d\u5230\u8981\u7ed8\u5236\u7684\u7ec4\uff0c\u8c03\u7528\u4e0d\u4e86\u51fd\u6570\u3002\u91cd\u65b0\u8c03\u7528\u4e00\u4e0b\u5c31\u53ef\u4ee5\uff0c\u6216\u8005\u9700\u8981\u66f4\u65b0\u4e00\u4e0bR\u5305\uff0c\u4e0d\u8981\u5fd8\u8bb0\u91cd\u65b0\u6253\u5f00R\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"652\" class=\"wp-image-26247\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=640%2C652\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?w=650 650w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=295%2C300 295w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-3.png?resize=600%2C611 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0a\u8ff0\u5c31\u662f\u5bf9\u56fe\u7247\u7684\u7ed8\u5236\uff0c\u70ed\u56fe\u7684\u5de6\u4fa7\u662f\u4e00\u4e9b\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5c0f\u4f19\u4f34\u6709\u6ca1\u6709\u5fc3\u52a8\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5566\u8c03\u6574\u4e00\u4e0b\u70ed\u56fe\u4e2d\u7684\u5f62\u72b6\uff0c\uff1a<\/p>\n<p>\u4e0b\u9762\u4f7f\u7528PP2\u7ec4\u7684\u6570\u636e <br \/>pp2 %&gt;%<\/p>\n<p>insert_left(Type_A, width = .05)%&gt;%<\/p>\n<p>insert_left(Type_B,width=.05)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"645\" class=\"wp-image-26248\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=640%2C645\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?w=650 650w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=298%2C300 298w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=150%2C150 150w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=600%2C605 600w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26244-4.png?resize=100%2C100 100w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u8fd9\u4e0b\u5c31\u5927\u529f\u544a\u6210\u4e86\uff0c\u4e0a\u8ff0\u56fe\u7247\u4e2d\u6709\u6ce8\u91ca\u7684\u4fe1\u606f\uff0c\u5982\u679c\u6709\u5c0f\u4f19\u4f34\u5176\u4ed6\u7684\u5982\u679c\u6709\u5176\u5b83\u987a\u5e8f\uff0c\u6392\u5e8f\u4e4b\u540e\u91cd\u65b0\u8bbe\u7f6efactor\u3002<\/p>\n<p>\u5c31\u662f\u8fd9\u4e00\u6b65\uff1a<\/p>\n<p>#\u6309\u7167\u5b9e\u9645\u987a\u5e8f\u6392\u5217\uff0c\u4e0d\u8fdb\u884c\u8fd9\u4e00\u6b65ggplot\u9ed8\u8ba4\u5b57\u6bcd\u987a\u5e8f\u6392\u5217\uff0c\u56fe\u4f1a\u4e71\u6389 <br \/>p$mtxars &lt;- factor(p$mtxars,level = p$mtxars)<\/p>\n<p>\u5c0f\u4f19\u4f34\u6709\u6ca1\u6709\u5fc3\u52a8\u5462\uff0c\u5feb\u53bb\u8bd5\u8bd5\u81ea\u5df1\u7684\u6570\u636e\u5427\u3002\u5176\u5b9e\uff0cggplot2\u662f\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u7684\u5305\uff0c\u5b83\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5f88\u591a\u56fe\u7247\u4e2d\u7684\u7ec6\u8282\uff0c\u5c0f\u4f19\u4f34\u8981\u591a\u591a\u5b66\u4e60\uff0c\u7406\u89e3\u4ee3\u7801\u4e2d\u7684\u542b\u4e49\uff0c\u624d\u80fd\u7ed8\u5236\u51fa\u81ea\u5df1\u60f3\u8981\u7684\u56fe\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e0d\u5c11\u5c0f\u4f19\u4f34\u5728\u7ed8\u5236\u70ed\u56fe\u65f6\u5019\uff0c\u7ed8\u5236\u7684\u56fe\u4fe1\u606f\u5f88\u5c11\uff0c\u53ea\u6709\u540d\u79f0\u548c\u76f8\u5173\u6027\u503c\uff0c\u6709\u65f6\u770b\u8d77\u6765\u67af\u71e5\u4e4f\u5473\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u6559\u5927\u5bb6\u4e00\u4e2a\u65b0\u7684 [&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\/26244"}],"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=26244"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/26244\/revisions"}],"predecessor-version":[{"id":26253,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/26244\/revisions\/26253"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}