論文
The flying spider-monkey tree fern genome provides insights into fern evolution and arborescence
https://www.nature.com/articles/s41477-022-01146-6#Sec44
數(shù)據(jù)下載鏈接
https://doi.org/10.6084/m9.figshare.19125641
今天的推文重復(fù)一下論文中的Extended Data Fig. 3 c
他這個(gè)圖的數(shù)據(jù)是怎么算出來的我還有點(diǎn)搞不明白,它的圖注的內(nèi)容也沒有看明白
Gene pairs plotted according to log2 fold change (L2F) as calculated for gene 1 (x-axis) and gene 2 (y-axis)
in DESeq2. Each point represents one gene pair with pairs colored according to the difference in L2F values (diffL2F = |L2F_1 - L2F_2|) to visualize the
arbitrary cutoffs of diffL2F = 2 and diffL2F = 4.
部分示例數(shù)據(jù)如下
作圖數(shù)據(jù)是 L2F_1 和 L2F_2 兩列辫红,根據(jù)L2F_diff的值需要增加一列映射顏色
首先是讀取數(shù)據(jù)
library(readxl)
dat01<-read_excel("data/20220529/20220529.xlsx")
head(dat01)
增加一列映射顏色
library(tidyverse)
dat01 %>%
mutate(diffL2F=case_when(
L2F_diff < 2 ~ "<2",
L2F_diff >=2 & L2F_diff<=4 ~ ">2",
TRUE ~ ">4"
)) -> dat01.1
作圖代碼
library(ggplot2)
ggplot(data=dat01.1,aes(x=L2F_1,y=L2F_2))+
geom_point(aes(color=diffL2F))+
scale_color_manual(values = c("<2"="#7f7f7f",
">2"="#fe0904",
">4"='#f9b54f'))+
geom_abline(intercept = 0,slope = 1,
lty="dashed",size=1,
color="blue")
論文中有六組數(shù)據(jù)怕轿,批量讀入,批量作圖
批量讀取excel
library(tidyverse)
library(readxl)
list.files("data/20220529/",
pattern = "*.xlsx",
full.names = TRUE) %>%
map(.,read_excel) -> dat.list
批量作圖
library(ggplot2)
plot.list = list()
text.label<-c("StGa","SoGa","LeGa","StSo","SoLe","LeSt")
for (i in 1:6){
dat.list[[i]] %>%
mutate(diffL2F=case_when(
L2F_diff < 2 ~ "<2",
L2F_diff >=2 & L2F_diff<=4 ~ ">2",
TRUE ~ ">4"
)) %>%
ggplot(aes(x=L2F_1,y=L2F_2))+
geom_point(aes(color=diffL2F))+
scale_color_manual(values = c("<2"="#7f7f7f",
">2"="#fe0904",
">4"='#f9b54f'))+
geom_abline(intercept = 0,slope = 1,
lty="dashed",size=1,
color="blue")+
geom_text(aes(x=-Inf,y=Inf),
hjust=-0.5,vjust=2,
label=text.label[i])+
labs(x=NULL,y=NULL) -> plot.list[[i]]
}
將六個(gè)圖拼接到一起
wrap_plots(plot.list,ncol=3,nrow=2,byrow = TRUE)+
plot_layout(guides = "collect") -> p1
p1
修改整體的邊界空白
p1 +
plot_annotation(theme =
theme(plot.margin = unit(c(0.2,0.2,1.2,1.2),'cm')))
添加坐標(biāo)軸標(biāo)題
grid::grid.draw(grid::textGrob("Log2(fold change)\ngene1", x = 0.04, rot = 90))
grid::grid.draw(grid::textGrob("Log2(fold change)\ngene2", y = 0.04))
示例數(shù)據(jù)可以到論文中去下載脱吱,代碼可以直接在推文中復(fù)制,如果需要我整理好的示例數(shù)據(jù)和代碼艳悔,可以給推文打賞1元獲取
歡迎大家關(guān)注我的公眾號(hào)
小明的數(shù)據(jù)分析筆記本
小明的數(shù)據(jù)分析筆記本 公眾號(hào) 主要分享:1急凰、R語言和python做數(shù)據(jù)分析和數(shù)據(jù)可視化的簡單小例子;2猜年、園藝植物相關(guān)轉(zhuǎn)錄組學(xué)抡锈、基因組學(xué)、群體遺傳學(xué)文獻(xiàn)閱讀筆記乔外;3床三、生物信息學(xué)入門學(xué)習(xí)資料及自己的學(xué)習(xí)筆記!