{"id":26254,"date":"2024-01-25T12:14:11","date_gmt":"2024-01-25T04:14:11","guid":{"rendered":"http:\/\/www.biocloudservice.com\/wordpress\/?p=26254"},"modified":"2024-01-25T12:14:13","modified_gmt":"2024-01-25T04:14:13","slug":"%e6%95%b2%e9%bb%91%e6%9d%bf%ef%bc%81%ef%bc%81%e5%b0%8f%e6%9e%9c%e6%95%99%e4%bd%a0%e5%ad%a6%e4%b9%a0r%e5%8c%85-ggalluvial%ef%bc%8c%e7%bb%98%e5%88%b6%e7%82%ab%e9%85%b7%e7%9a%84%e6%a1%91%e5%9f%ba","status":"publish","type":"post","link":"http:\/\/www.biocloudservice.com\/wordpress\/?p=26254","title":{"rendered":"\u6572\u9ed1\u677f\uff01\uff01\u5c0f\u679c\u6559\u4f60\u5b66\u4e60R\u5305-ggalluvial\uff0c\u7ed8\u5236\u70ab\u9177\u7684\u6851\u57fa\u56fe\uff08Sankey\uff09\uff01\uff01"},"content":{"rendered":"<p>\u5c0f\u4f19\u4f34\u5e73\u65f6\u9762\u5bf9\u591a\u4e2a\u6570\u636e\u5173\u7cfb\u4e0d\u77e5\u9053\u5982\u4f55\u7ed8\u5236\u56fe\uff0c\u4e00\u822c\u6765\u8bf4\u4f7f\u7528\u5e38\u89c1\u7684\u8868\u683c\u5df2\u7ecf\u6ee1\u8db3\u4e0d\u4e86\u5c0f\u4f19\u4f34\uff0c\u5e76\u4e14\u4e5f\u4e0d\u597d\u770b\u3002\u800c\u4eca\u5929\u5c0f\u679c\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u7684\u6851\u57fa\u56fe\u53ef\u4ee5\u5448\u73b0\u6570\u636e\u7684\u6d41\u52a8\u548c\u5206\u5e03\u3002\u800c\u6851\u57fa\u56fe\uff08Sankey\uff09\u4f5c\u4e3a\u76f8\u5bf9\u590d\u6742\u7684\u56fe\u8868\u79cd\u7c7b\uff0c\u5e73\u65f6\u5f88\u5c11\u7528\u5230\uff0c\u4e3b\u8981\u662f\u5b83\u4f7f\u7528\u7684\u800c\u73af\u5883\u4e0d\u591a\uff0c\u5e76\u4e14\u5236\u4f5c\u96be\u5ea6\u5f88\u5927\uff0c\u4f46\u662f\u6851\u57fa\u56fe\u53ef\u4ee5\u5f88\u597d\u7684\u5c55\u793a\u6211\u4eec\u6570\u636e\u7684\u5206\u5e03\u3002<\/p>\n<p>\u6211\u4eec\u5c31\u5e26\u5c0f\u4f19\u4f34\u53bb\u5b66\u4e60\u6851\u57fa\u56fe\u7684\u7ed8\u5236\uff0c\u5c0f\u679c\u5e26\u5c0f\u4f19\u4f34\u7ed8\u5236\u7684\u6851\u57fa\u56fe\u662f\u4e00\u79cd\u7279\u5b9a\u7c7b\u578b\u7684\u6d41\u7a0b\u56fe\uff0c\u5176\u4e2d\u56fe\u4e2d\u5ef6\u4f38\u5206\u652f\u7684\u5bbd\u5ea6\u5bf9\u5e94\u6570\u636e\u6d41\u91cf\u7684\u5927\u5c0f\uff0c\u901a\u5e38\u5e94\u7528\u6211\u4eec\u6570\u636e\u7684\u53ef\u89c6\u5316\u5206\u6790\u3002<\/p>\n<p>\u63a5\u4e0b\u91cc\u5c0f\u679c\u5c31\u5927\u5bb6\u53bb\u5b66\u4e60\u5427!<\/p>\n<p>\u9996\u5148\u6211\u4eec\u5148\u8f7d\u5165R\u5305\uff0c\u4e3b\u8981\u7528\u5230\u4e3b\u8981\u7684\u7528\u5230\u8fd8\u662fggalluvial\u8fd9\u4e13\u95e8\u7ed8\u5236\u6851\u57fa\u56fe\u7684\u5305<\/p>\n<p>library(ggalluvial)<\/p>\n<p>library(ggplot2)<\/p>\n<p>library(dplyr)<\/p>\n<p>#\u8fd9\u91cc\u5c0f\u679c\u4f7f\u7528\u7684\u5b9e\u4f8b\u6570\u636e\u5e26\u9886\u5927\u5bb6\u53bb\u5b66\u4e60\uff0c\u4e3b\u8981\u7528\u7684\u4f7f\u7528TCGA\u6570\u636e\u96c6\u4e2d\u7684LIHC\u7684\u4e34\u5e8a\u6570\u636e\u8fdb\u884c\u5c55\u793a\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u6570\u636e\u683c\u5f0f\u5904\u7406\u81ea\u5df1\u7684\u4e34\u5e8a\u6570\u636e\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"581\" height=\"385\" class=\"wp-image-26255\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-1.png?resize=581%2C385\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-1.png?w=581 581w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-1.png?resize=300%2C199 300w\" sizes=\"(max-width: 581px) 100vw, 581px\" data-recalc-dims=\"1\" \/><\/p>\n<p>#\u8bfb\u5165LIHC\u4e34\u5e8a\u6570\u636e<\/p>\n<p>LIHC &lt;- read.csv(&#8220;data.csv&#8221;,header=TRUE)<\/p>\n<p>#\u5728\u8fd9\u91cc\u5c55\u793a\u6570\u636e\u60c5\u51b5<\/p>\n<p>head(LIHC)<\/p>\n<p>summary(LIHC)<\/p>\n<p>\u5c0f\u4f19\u4f34\u6ce8\u610f\u4e0b\uff1a\u6851\u57fa\u56fe\u7684\u6570\u636e\u7ed3\u6784\u9700\u8981\u8282\u70b9\uff0c\u6743\u91cd\u7b49\u4fe1\u606f\uff0c\u800cggalluvial\u7684\u8f93\u5165\u6570\u636e\u53ef\u4ee5\u662f\u957f\u6570\u636e\u4ea6\u53ef\u4ee5\u662f\u5bbd\u6570\u636e<\/p>\n<p>\u6211\u4eec\u5148\u5bf9\u4e34\u5e8a\u6570\u636e\u8fdb\u884c\u7b80\u5355\u7684\u5904\u7406\u5f97\u5230\u56db\u4e2a\u53d8\u91cf\u7684\u9891\u6570\uff0c\u6574\u7406\u6210\u5bbd\u6570\u636e\u3002\uff1a<\/p>\n<p>#\u5206\u7ec4\u8ba1\u7b97\u9891\u6570<\/p>\n<p>LIHCData &lt;- group_by(LIHC,AGE,SEX,AJCC_PATHOLOGIC_TUMOR_STAGE,OS_STATUS) %&gt;% summarise(., count = n())<\/p>\n<p>#\u67e5\u770b\u5bbd\u6570\u636e\u683c\u5f0f<\/p>\n<p>head(LIHCData)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"625\" height=\"240\" class=\"wp-image-26256\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-2.png?resize=625%2C240\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-2.png?w=625 625w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-2.png?resize=300%2C115 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-2.png?resize=600%2C230 600w\" sizes=\"(max-width: 625px) 100vw, 625px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0a\u8ff0\u6570\u636e\u5904\u7406\u5b8c\u6210\uff0c\u6211\u4eec\u5f00\u59cb\u53bb\u7ed8\u5236\u6851\u57fa\u56fe\uff1a<\/p>\n<p>ggplot(as.data.frame(LIHCData),<\/p>\n<p>aes(axis1 = AJCC_PATHOLOGIC_TUMOR_STAGE, axis2 = SEX, axis3 = AGE,<\/p>\n<p>y= count)) +<\/p>\n<p>scale_x_discrete(limits = c(&#8220;AJCC_STAGE&#8221;, &#8220;SEX&#8221;, &#8220;AGE&#8221;), expand = c(.1, .05)) +<\/p>\n<p>geom_alluvium(aes(fill = OS_STATUS)) +<\/p>\n<p>geom_stratum() + geom_text(stat = &#8220;stratum&#8221;, label.strata = TRUE) +<\/p>\n<p>theme_minimal() +<\/p>\n<p>ggtitle(&#8220;Patients in the TCGA-LIHC cohort&#8221;,<\/p>\n<p>&#8220;stratified by demographics and survival&#8221;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"399\" class=\"wp-image-26257\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?resize=640%2C399\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?w=1061 1061w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?resize=300%2C187 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?resize=1024%2C638 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?resize=768%2C478 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-3.png?resize=600%2C374 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0caxis\u53c2\u6570\u8bbe\u7f6e\u5f85\u5c55\u793a\u7684\u8282\u70b9\u4fe1\u606f\uff08\u5c31\u662f\u67f1\u5b50\uff09<\/p>\n<p>\u8fd8\u6709geom_alluvium\u53c2\u6570\u8bbe\u7f6e\u7684\u662f\u7ec4\u95f4\u9762\u79ef\u8fde\u63a5\uff0c\u8fd9\u4e2a\u5730\u65b9\u5c0f\u679c\u8fd9\u91cc\u6309\u7167\u751f\u5b58\u72b6\u6001\u5206\u7ec4\uff1b\u5c0f\u4f19\u4f34\u53ef\u4ee5\u6309\u7167\u53c2\u6570\u8bbe\u7f6e\u81ea\u884c\u5b89\u6392\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5bf9\u957f\u6570\u636e\u793a\u4f8b\u7684\u5c55\u793a\uff1a<\/p>\n<p>ggplot2\u901a\u5e38\u5904\u7406\u7684\u662f\u957f\u8868\u683c\u7684\u6a21\u5f0f\uff0c\u90a3\u6211\u4eec\u5c31\u4f7f\u7528to_lodes_form\u51fd\u6570\u5373\u53ef\u8f6c\u6362<\/p>\n<p>#to_lodes_form\u751f\u6210alluvium\u548cstratum\u5217\uff0c\u4e3b\u5206\u7ec4\u4f4d\u4e8ekey\u5217\u4e2d<\/p>\n<p>LIHC_long &lt;- to_lodes_form(data.frame(LIHCData),<\/p>\n<p>key = &#8220;Demographic&#8221;,<\/p>\n<p>axes = 1:3)<\/p>\n<p>head(LIHC_long)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"476\" height=\"218\" class=\"wp-image-26258\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-4.png?resize=476%2C218\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-4.png?w=476 476w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-4.png?resize=300%2C137 300w\" sizes=\"(max-width: 476px) 100vw, 476px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u7136\u540e\u63a5\u4e0b\u6765\u7ed8\u5236\u6851\u57fa\u56fe\uff1a<\/p>\n<p># \u7ed8\u5236\u6851\u57fa\u56fe<\/p>\n<p>ggplot(data = LIHC_long,<\/p>\n<p>aes(x = Demographic, stratum = stratum, alluvium = alluvium,<\/p>\n<p>y = count, label = stratum)) +<\/p>\n<p>geom_alluvium(aes(fill = OS_STATUS)) +<\/p>\n<p>geom_stratum() + geom_text(stat = &#8220;stratum&#8221;) +<\/p>\n<p>theme_minimal() +<\/p>\n<p>ggtitle(&#8220;Patients in the TCGA-LIHC cohort&#8221;,<\/p>\n<p>&#8220;stratified by demographics and survival&#8221;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"413\" class=\"wp-image-26259\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?resize=640%2C413\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?w=1297 1297w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?resize=300%2C194 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?resize=1024%2C661 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?resize=768%2C496 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-5.png?resize=600%2C387 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u8fd8\u4ee5\u5229\u7528\u6851\u57fa\u56fe\u53bb\u5c55\u793a\u72b6\u6001\u53d8\u5316\u7684\u8d8b\u52bf<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u4f7f\u7528R\u5305\u4e2d\u5185\u7f6e\u6570\u636e\u96c6 vaccinations \u8fd9\u4e2a\u53ef\u4ee5\u5c55\u793a\u540c\u4e00\u4e2a\u9879\u76ee\u4e0b\u4e0d\u540c\u751f\u5b58\u72b6\u6001\u7684\u60c5\u51b5<\/p>\n<p>\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u6309\u7167\u4e00\u4e0b\u6570\u636e\u5f62\u5f0f\u53bb\u8bbe\u7f6e\u81ea\u5df1\u7684\u6570\u636e\u96c6\uff1a<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"509\" height=\"394\" class=\"wp-image-26260\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-6.png?resize=509%2C394\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-6.png?w=509 509w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-6.png?resize=300%2C232 300w\" sizes=\"(max-width: 509px) 100vw, 509px\" data-recalc-dims=\"1\" \/><\/p>\n<p>data(vaccinations)<\/p>\n<p>levels(vaccinations$response) &lt;- rev(levels(vaccinations$response))#\u5c0f\u679c\u5728\u8fd9\u91cc\u4f5c\u4e3a\u6f14\u793a<\/p>\n<p>\u63a5\u4e0b\u6765\u7ed8\u5236\u6851\u57fa\u56fe\uff1a<\/p>\n<p>ggplot(vaccinations,<\/p>\n<p>aes(x = survey, stratum = response, alluvium = subject,<\/p>\n<p>y = freq,<\/p>\n<p>fill = response, label = response)) +<\/p>\n<p>scale_x_discrete(expand = c(.1, .1)) +<\/p>\n<p>geom_flow() +<\/p>\n<p>geom_stratum(alpha = .5) +<\/p>\n<p>geom_text(stat = &#8220;stratum&#8221;, size = 3) +<\/p>\n<p>theme(legend.position = &#8220;none&#8221;) +<\/p>\n<p>ggtitle(&#8220;vaccination survey responses at three points in time&#8221;)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"640\" height=\"412\" class=\"wp-image-26261\" src=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?resize=640%2C412\" srcset=\"https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?w=1302 1302w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?resize=300%2C193 300w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?resize=1024%2C659 1024w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?resize=768%2C494 768w, https:\/\/i0.wp.com\/www.biocloudservice.com\/wordpress\/wp-content\/uploads\/2024\/01\/word-image-26254-7.png?resize=600%2C386 600w\" sizes=\"(max-width: 640px) 100vw, 640px\" data-recalc-dims=\"1\" \/><\/p>\n<p>\u8fd9\u6837\u4e00\u6765\u72b6\u6001\u53d8\u5316\u7684\u8d8b\u52bf\u5c31\u5c55\u793a\u51fa\u6765\u4e86\u3002<\/p>\n<p>\u4e0a\u8ff0\u5c31\u662f\u5982\u4f55\u4f7f\u7528R\u5305-ggalluvial\u7ed8\u5236\u6851\u57fa\u56fe\uff01\uff0c\u5c0f\u4f19\u4f34\u6709\u6ca1\u6709\u5fc3\u52a8\u5462\uff0c\u5feb\u53bb\u8bbe\u7f6e\u81ea\u5df1\u7684\u6570\u636e\u96c6\u53bb\u5b8c\u6210\u6851\u57fa\u56fe\u3002\u5c0f\u679c\u5728\u8fd9\u91cc\u63d0\u9192\u5927\u5bb6\u4e00\u4e0b\uff0c\u8981\u6ce8\u610f\u591a\u591a\u7406\u89e3\u4ee3\u7801\u4e2d\u53c2\u6570\u7684\u542b\u4e49\uff0c\u8fd9\u6837\u80fd\u628a\u81ea\u5df1\u53ef\u89c6\u5316\u7684\u7ed3\u679c\u5c55\u793a\u6210\u81ea\u5df1\u7684\u56fe\u7247\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u4f19\u4f34\u5e73\u65f6\u9762\u5bf9\u591a\u4e2a\u6570\u636e\u5173\u7cfb\u4e0d\u77e5\u9053\u5982\u4f55\u7ed8\u5236\u56fe\uff0c\u4e00\u822c\u6765\u8bf4\u4f7f\u7528\u5e38\u89c1\u7684\u8868\u683c\u5df2\u7ecf\u6ee1\u8db3\u4e0d\u4e86\u5c0f\u4f19\u4f34\uff0c\u5e76\u4e14\u4e5f\u4e0d\u597d\u770b\u3002\u800c\u4eca\u5929\u5c0f\u679c [&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\/26254"}],"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=26254"}],"version-history":[{"count":1,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/26254\/revisions"}],"predecessor-version":[{"id":26262,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/26254\/revisions\/26262"}],"wp:attachment":[{"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26254"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.biocloudservice.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}