Graph pangenome captures missing heritability and empowers tomato breeding
https://www.nature.com/articles/s41586-022-04808-9#MOESM8
没有找到论文里的作图的代码,但是找到了部分组图数据,我们可以用论文中提供的原始数据模仿出论文中的图
今天的推文重复一下论文中的Figure2a

如何在山脊图上添加辅助线
另外一个知识点是如何把图例放到整个图的左下角

library(readxl)
dat.fig2a<-read_excel("data/20220711/41586_2022_4808_MOESM6_ESM.xlsx",
sheet = "Fig2a",
skip = 1)
library(tidyverse)
library(stringr)
reshape2::melt(dat.fig2a) %>%
select(variable,value) %>%
mutate(new_col01 = str_split_fixed(variable,'_',2)[,1],
new_col02 = str_split_fixed(variable,'_',2)[,2]) -> new.df
这里还有一个知识点是 指定分隔符拆分字符串函数 str_split_fixed()可以指定拆分成多少个
new.df$new_col02<-factor(new.df$new_col02,
levels = c("snps","indels","svs",
"snps_indels","snps_indels_svs"))
ggplot(data=new.df,aes(x=value,y=new_col02))+
geom_density_ridges(aes(fill=new_col01,color=new_col01),
alpha=0.4,
bandwidth=0.04,
quantile_lines=TRUE,
quantile_fun=function(x,...)mean(x),
#linetype="dashed",
scale=1,
vline_linetype="dashed")+
scale_fill_manual(values = c("graph"="#ca612d",
"linear"="#2772a7"))+
scale_color_manual(values = c("graph"="#ca612d",
"linear"="#2772a7"))+
theme_classic() +
guides(fill="none",color="none") -> p1
p1

这里有一个问题是辅助线的位置是在平均值,这里通过一个求平均值的函数实现,如果是任意数值应该怎么做暂时想不到方法
new.df %>%
group_by(new_col01,new_col02) %>%
summarise(mean_value=mean(value)) %>%
ungroup() %>%
mutate(new_col02 = fct_relevel(new_col02,
c("snps","indels","svs",
"snps_indels","snps_indels_svs"))) %>%
mutate(new_col03=as.numeric(new_col02)) -> new.df01
p1+
scale_y_discrete(labels=c("SNP","Indel","SV","SNP + Indel","SNP + Indel + SV"))
geom_text(data=new.df01 %>% filter(new_col01=="graph"),
aes(y=new_col03+0.1,x=mean_value,
label=round(mean_value,2)),
hjust=-0.5,color="#ca612d")+
geom_text(data=new.df01 %>% filter(new_col01=="linear"),
aes(y=new_col03+0.1,x=mean_value,
label=round(mean_value,2)),
hjust=1.5,color="#2772a7")
ggplot(data=new.df,aes(x=value,y=new_col02))+
geom_density_ridges(aes(fill=new_col01,color=new_col01),
alpha=0.4)+
scale_fill_manual(values = c("graph"="#ca612d",
"linear"="#2772a7"),
name="",
label=c("TGG1.1-332","SL5.0-332"))+
guides(color="none")-> p2
library(ggpubr)
as_ggplot(get_legend(p2)) -> p3
library(latex2exp)
pdf(file = "Rplot13.pdf",
width=9.4,height = 4)
p1+
scale_y_discrete(labels=c("SNP","Indel","SV","SNP + Indel",
"SNP + Indel + SV"))+
geom_text(data=new.df01 %>% filter(new_col01=="graph"),
aes(y=new_col03+0.1,x=mean_value,
label=round(mean_value,2)),
hjust=-0.5,color="#ca612d")+
geom_text(data=new.df01 %>% filter(new_col01=="linear"),
aes(y=new_col03+0.1,x=mean_value,
label=round(mean_value,2)),
hjust=1.5,color="#2772a7")+
labs(x=TeX(r"(\textit{h}$^2$)"),y="")+
annotation_custom(grob=ggplotGrob(p3),
xmin=-0.35,xmax = -0.35,ymin = 1,ymax = 1)+
coord_cartesian(clip="on")+
theme(plot.margin = unit(c(0.1,0.1,0.1,1),'cm'))+
annotate(geom = "text",
x=0.8,y=1.5,
label=TeX(r"(\textit{P} = 1.70 \times 10$^{-217}$)"),
vjust=-0.5)
dev.off()

示例数据和代码可以自己到论文中获取,或者给本篇推文点赞,点击在看,然后留言获取
欢迎大家关注我的公众号
小明的数据分析笔记本
小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!
当我使用Bundler时,是否需要在我的Gemfile中将其列为依赖项?毕竟,我的代码中有些地方需要它。例如,当我进行Bundler设置时:require"bundler/setup" 最佳答案 没有。您可以尝试,但首先您必须用鞋带将自己抬离地面。 关于ruby-我需要将Bundler本身添加到Gemfile中吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/4758609/
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我有一个ModularSinatra应用程序,我正在尝试将Bootstrap添加到应用程序中。get'/bootstrap/application.css'doless:"bootstrap/bootstrap"end我在views/bootstrap中有所有less文件,包括bootstrap.less。我收到这个错误:Less::ParseErrorat/bootstrap/application.css'reset.less'wasn'tfound.Bootstrap.less的第一行是://CSSReset@import"reset.less";我尝试了所有不同的路径格式,但它
我正在使用Sequel构建一个愿望list系统。我有一个wishlists和itemstable和一个items_wishlists连接表(该名称是续集选择的名称)。items_wishlists表还有一个用于facebookid的额外列(因此我可以存储opengraph操作),这是一个NOTNULL列。我还有Wishlist和Item具有续集many_to_many关联的模型已建立。Wishlist类也有:selectmany_to_many关联的选项设置为select:[:items.*,:items_wishlists__facebook_action_id].有没有一种方法可以
我在app/helpers/sessions_helper.rb中有一个帮助程序文件,其中包含一个方法my_preference,它返回当前登录用户的首选项。我想在集成测试中访问该方法。例如,这样我就可以在测试中使用getuser_path(my_preference)。在其他帖子中,我读到这可以通过在测试文件中包含requiresessions_helper来实现,但我仍然收到错误NameError:undefinedlocalvariableormethod'my_preference'.我做错了什么?require'test_helper'require'sessions_hel
几个月前,我读了一篇关于rubygem的博客文章,它可以通过阅读代码本身来确定编程语言。对于我的生活,我不记得博客或gem的名称。谷歌搜索“ruby编程语言猜测”及其变体也无济于事。有人碰巧知道相关gem的名称吗? 最佳答案 是这个吗:http://github.com/chrislo/sourceclassifier/tree/master 关于ruby-寻找通过阅读代码确定编程语言的rubygem?,我们在StackOverflow上找到一个类似的问题:
当谈到运行时自省(introspection)和动态代码生成时,我认为ruby没有任何竞争对手,可能除了一些lisp方言。前几天,我正在做一些代码练习来探索ruby的动态功能,我开始想知道如何向现有对象添加方法。以下是我能想到的3种方法:obj=Object.new#addamethoddirectlydefobj.new_method...end#addamethodindirectlywiththesingletonclassclass这只是冰山一角,因为我还没有探索instance_eval、module_eval和define_method的各种组合。是否有在线/离线资
我注意到类定义,如果我打开classMyClass,并在不覆盖的情况下添加一些东西我仍然得到了之前定义的原始方法。添加的新语句扩充了现有语句。但是对于方法定义,我仍然想要与类定义相同的行为,但是当我打开defmy_method时似乎,def中的现有语句和end被覆盖了,我需要重写一遍。那么有什么方法可以使方法定义的行为与定义相同,类似于super,但不一定是子类? 最佳答案 我想您正在寻找alias_method:classAalias_method:old_func,:funcdeffuncold_func#similartoca
我有带有Logo图像的公司模型has_attached_file:logo我用他们的Logo创建了许多公司。现在,我需要添加新样式has_attached_file:logo,:styles=>{:small=>"30x15>",:medium=>"155x85>"}我是否应该重新上传所有旧数据以重新生成新样式?我不这么认为……或者有什么rake任务可以重新生成样式吗? 最佳答案 参见Thumbnail-Generation.如果rake任务不适合你,你应该能够在控制台中使用一个片段来调用重新处理!关于相关公司
我正在尝试使用Curbgem执行以下POST以解析云curl-XPOST\-H"X-Parse-Application-Id:PARSE_APP_ID"\-H"X-Parse-REST-API-Key:PARSE_API_KEY"\-H"Content-Type:image/jpeg"\--data-binary'@myPicture.jpg'\https://api.parse.com/1/files/pic.jpg用这个:curl=Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")curl.multipart_form_