其他
跟着Nature学绘图(1) 热图|散点图
欢迎关注R语言数据分析指南
❝经常看到许多大佬的号推送论文图表复现,正好近期也不知道写些什么,索性也来尝试论文图复现,下面从一个小例子开始
❞
Pan-cancer characterization of immune-related lncRNAs identifies potential oncogenic biomarkers
安装并加载R包
package.list=c("tidyverse","ggsci","corrplot","RColorBrewer")
for (package in package.list) {
if (!require(package,character.only=T, quietly=T)) {
install.packages(package)
library(package, character.only=T)
}
}
加载数据
df <- read_tsv("data.xls") %>% column_to_rownames(var="gene") %>% t() %>%
as.matrix()
Figure-1
corrplot(df,method="pie",is.corr=FALSE, tl.col = "black",mar = c(0,0,1.5,0),
cl.pos = 'b',tl.cex=0.7,cl.ratio=0.4,cl.length=6,cl.cex=0.7,
col= rev(RColorBrewer::brewer.pal(6,"RdBu")))
Figure-2
read_tsv("data2.txt") %>% select(cell:`High 95% CI`) %>%
mutate(col=case_when(p_value > 0.05 ~ "N",
p_value < 0.05 ~ "Y")) %>%
ggplot(aes(cancer,`Odds Ratio`,ymin=`Low 95% CI`,ymax=`High 95% CI`))+
# geom_pointrange(color="black",shape=20)+
geom_errorbar(aes(ymin=`Low 95% CI`,ymax=`High 95% CI`), width = 0.5)+
geom_point(aes(color=col,fill=col),pch=21,size=3)+
geom_hline(yintercept =1,linetype ="dashed") +
coord_flip()+
facet_grid(~cell,scales = "free_x")+
scale_fill_jco()+
scale_color_jco()+
theme_test()+
theme(panel.spacing.x = unit(0.2,"cm"),
panel.spacing.y = unit(0.1, "cm"),
axis.title = element_blank(),
axis.line = element_line(color = "#999999",size = 0.2),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(size = 0.2,color = "#e5e5e5"),
strip.text.x = element_text(size=11,color="black"),
strip.background = element_blank(),
axis.text = element_text(color="black",size=9),
legend.position = "non",
plot.margin=unit(c(0.3,0.3,0.3,0.3),units=,"cm"))
数据获取
❝本节的内容到此结束,后续还会继续进行复现,喜欢的小伙伴欢迎转发此文档附上一句话到朋友圈「30分钟后台截图给我」,即可获取对应的数据及代码,如未及时回复可添加我的微信
❞
欢迎大家扫描下方二位码加入「QQ交流群」,与全国各地上千位小伙伴交流
「关注下方公众号下回更新不迷路」,如需要加入微信交流群可添加小编微信,请备注单位+方向+姓名
往期推荐