forked from duty-machine/duty-machine
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
跟着Nature Communications学作图:R语言ggplot2箱线图/抖动散点图展示多物种基因组大小和TE含量
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
docs/2023-09/跟着Nature_Communications学作图_R语言ggplot2箱线图_抖动散点图展示多物种基因组大小和TE含量.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "跟着Nature Communications学作图:R语言ggplot2箱线图/抖动散点图展示多物种基因组大小和TE含量" | ||
date: 2023-09-09T15:31:24Z | ||
draft: ["false"] | ||
tags: [ | ||
"fetched", | ||
"小明的数据分析笔记本" | ||
] | ||
categories: ["Acdemic"] | ||
--- | ||
跟着Nature Communications学作图:R语言ggplot2箱线图/抖动散点图展示多物种基因组大小和TE含量 by 小明的数据分析笔记本 | ||
------ | ||
<div><section data-tool="mdnice编辑器" data-website="https://www.mdnice.com" data-mpa-powered-by="yiban.io"><h2 data-tool="mdnice编辑器"><span></span><span>论文</span><span></span><span> </span></h2><blockquote data-tool="mdnice编辑器"><p>Large-scale genome sequencing of mycorrhizal fungi provides insights into the early evolution of symbiotic traits</p></blockquote><p data-tool="mdnice编辑器">https://www.nature.com/articles/s41467-020-18795-w</p><p data-tool="mdnice编辑器"><code>s41467-020-18795-w.pdf</code></p><p data-tool="mdnice编辑器">这个是是有读者在公众号后台留言问到</p><p data-tool="mdnice编辑器"><img data-ratio="0.43665436654366546" data-src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIpVibxf9FJZ99ejWos6zndoD8l83BDkrXiakyGvdIAeiaVq8U6jN54PmMg/640?wx_fmt=png" data-type="png" data-w="813" src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIpVibxf9FJZ99ejWos6zndoD8l83BDkrXiakyGvdIAeiaVq8U6jN54PmMg/640?wx_fmt=png">我把论文找来看了一下,论文对应的图大部分都有数据,我们可以试着复现其中的图,先从最简单的的开始,论文中的Figure2是箱线图加抖动散点图,论文的配色也很好看,可以保留作为自己配色备选</p><h2 data-tool="mdnice编辑器"><span></span><span>部分示例数据截图</span><span></span><span> </span></h2><figure data-tool="mdnice编辑器"><img data-ratio="0.1699810606060606" data-src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIBibicrXpuickGXyhSUsib2z87icN7Nibibe5znOTOUiaa1ItUibXG2LE7eSUPYQ/640?wx_fmt=png" data-type="png" data-w="2112" src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIBibicrXpuickGXyhSUsib2z87icN7Nibibe5znOTOUiaa1ItUibXG2LE7eSUPYQ/640?wx_fmt=png"><figcaption>image.png</figcaption></figure><p data-tool="mdnice编辑器">首先是读取数据</p><pre data-tool="mdnice编辑器"><span></span><code>library(tidyverse)<br><br>dat<-read_delim(<span>"data/20230909/Source Data/Source_Data_figure_1a.csv"</span>,<br> delim = <span>","</span>)<br><br>colnames(dat)<br><br><br>dat %>% <br> pull(Ecology) %>% <br> table()<br></code></pre><p data-tool="mdnice编辑器">左侧的图展示基因组大小,代码如下</p><pre data-tool="mdnice编辑器"><span></span><code>ggplot(data=dat %>% <br> filter(Ecology!=<span>"Yeast"</span>&Ecology!=<span>"Parasite"</span>) %>% <br> mutate(Ecology=factor(Ecology,levels = c(<span>"Wood decayer"</span>,<br> <span>"Endophyte"</span>,<br> <span>"Arbuscular mycorrhizae"</span>,<br> <span>"Orchid mycorrhizae"</span>,<br> <span>"Ericoid mycorrhizae"</span>,<br> <span>"Pathogen"</span>,<br> <span>"Saprotroph"</span>,<br> <span>"Ectomycorrhizae"</span>))),<br> aes(x=Genome.size,y=Ecology))+<br> geom_boxplot(color=<span>"gray"</span>)+<br> geom_jitter(aes(color=Ecology),<br> size=5,<br> show.legend = FALSE,<br> alpha=0.5)+<br> scale_color_manual(values = c(<span>"#f1a2c9"</span>,<span>"#b6b3b3"</span>,<span>"#a8e3ea"</span>,<br> <span>"#fde05f"</span>,<span>"#f49b40"</span>,<br> <span>"#7ac84e"</span>,<span>"#73a1cb"</span>,<span>"#e15e53"</span>))+<br> scale_x_continuous(limits = c(0,150000000),<br> labels = <span>function</span>(x){x/1000000})+<br> theme_bw()+<br> theme(panel.border = element_blank(),<br> axis.ticks = element_blank())+<br> labs(x=NULL,y=NULL,title = <span>"Genomes (Mbp)"</span>)<br></code></pre><figure data-tool="mdnice编辑器"><img data-ratio="0.6509695290858726" data-src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIrHh3z3Xj6AEuNXgbjstao1bngEPWTzOfwCCiauw9haI94RlVMFfMQhw/640?wx_fmt=png" data-type="png" data-w="722" src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIrHh3z3Xj6AEuNXgbjstao1bngEPWTzOfwCCiauw9haI94RlVMFfMQhw/640?wx_fmt=png"><figcaption>image.png</figcaption></figure><p data-tool="mdnice编辑器">右侧的图代码基本一样</p><pre data-tool="mdnice编辑器"><span></span><code>ggplot(data=dat %>% <br> filter(Ecology!=<span>"Yeast"</span>&Ecology!=<span>"Parasite"</span>) %>% <br> mutate(Ecology=factor(Ecology,levels = c(<span>"Wood decayer"</span>,<br> <span>"Endophyte"</span>,<br> <span>"Arbuscular mycorrhizae"</span>,<br> <span>"Orchid mycorrhizae"</span>,<br> <span>"Ericoid mycorrhizae"</span>,<br> <span>"Pathogen"</span>,<br> <span>"Saprotroph"</span>,<br> <span>"Ectomycorrhizae"</span>))),<br> aes(x=TE.CoverageTotal,y=Ecology))+<br> geom_boxplot(color=<span>"gray"</span>)+<br> geom_jitter(aes(color=Ecology),<br> size=5,<br> show.legend = FALSE,<br> alpha=0.5)+<br> scale_color_manual(values = c(<span>"#f1a2c9"</span>,<span>"#b6b3b3"</span>,<span>"#a8e3ea"</span>,<br> <span>"#fde05f"</span>,<span>"#f49b40"</span>,<br> <span>"#7ac84e"</span>,<span>"#73a1cb"</span>,<span>"#e15e53"</span>))+<br> scale_x_continuous(limits = c(0,100))+<br> theme_bw()+<br> theme(panel.border = element_blank(),<br> axis.ticks = element_blank(),<br> axis.text.y = element_blank())+<br> labs(x=NULL,y=NULL,title = <span>"Repeat element coverage (%)"</span>)<br></code></pre><figure data-tool="mdnice编辑器"><img data-ratio="0.6675938803894298" data-src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIahKeXCJV12zcUY0KDVFhEXjpLoFtxYHiaLdrfibn107MZSABQuUlBDAg/640?wx_fmt=png" data-type="png" data-w="719" src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIahKeXCJV12zcUY0KDVFhEXjpLoFtxYHiaLdrfibn107MZSABQuUlBDAg/640?wx_fmt=png"><figcaption>image.png</figcaption></figure><p data-tool="mdnice编辑器">最后是拼图</p><pre data-tool="mdnice编辑器"><span></span><code>library(patchwork)<br><br>p1+p2<br></code></pre><figure data-tool="mdnice编辑器"><img data-ratio="0.4225" data-src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIsvGKWhCWj6g5b166ibyvzDbAOzlMmFV4QibCn8QKjuJuHibfxKXAK5JNg/640?wx_fmt=png" data-type="png" data-w="2000" src="https://mmbiz.qpic.cn/sz_mmbiz_png/t1wZDoUyFk5WrSg9QGmRgwyickib5hxGbIsvGKWhCWj6g5b166ibyvzDbAOzlMmFV4QibCn8QKjuJuHibfxKXAK5JNg/640?wx_fmt=png"><figcaption>image.png</figcaption></figure><blockquote data-tool="mdnice编辑器"><p>示例数据可以到论文中下载,代码可以在推文中复制,或者给推文打赏一元获取我整理好的数据和代码</p></blockquote><p data-tool="mdnice编辑器">欢迎大家关注我的公众号</p><p data-tool="mdnice编辑器"><strong>小明的数据分析笔记本</strong></p><section><mp-common-profile data-pluginname="mpprofile" data-id="MzI3NzQ3MTcxMg==" data-headimg="http://mmbiz.qpic.cn/mmbiz_png/t1wZDoUyFk5t1sOnM0iabvBhnfIj5YpyqrMib0E1MGCd9ibcYxaOPZd0GWhQBDvK2BPEwsicQxd6y5MHLfphnwHnow/0?wx_fmt=png" data-nickname="小明的数据分析笔记本" data-alias="" data-signature="分享R语言和python在生物信息领域做数据分析和数据可视化的简单小例子;偶尔会分享一些组学数据处理相关的内容" data-from="0" data-is_biz_ban="0"></mp-common-profile></section><p data-tool="mdnice编辑器"></p><blockquote data-tool="mdnice编辑器"><p>小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!</p></blockquote></section><p><br></p><p><mp-style-type data-value="3"></mp-style-type></p></div> | ||
<hr> | ||
<a href="https://mp.weixin.qq.com/s/8kk04B3ptyhDLRhcdIIf0g",target="_blank" rel="noopener noreferrer">原文链接</a> |