ac <- read.csv("D:/High-throughput sequencing/!!!!GSE167940/RNA-seq/組蛋白修飾酶/ac.csv",header = T,row.names = 1)
me3 <- read.csv("D:/High-throughput sequencing/!!!!GSE167940/RNA-seq/組蛋白修飾酶/組蛋白修飾酶.csv",header = T,row.names = 1)
library(ggplot2)
library(tidyr)
library(dplyr)
#按行歸一化;
hd_ac = t(scale(t(ac)))
hd_me3 = t(scale(t(me3)))
#預(yù)覽數(shù)據(jù);
head(hd_ac)
#轉(zhuǎn)成數(shù)據(jù)框;
gene_ac <- row.names(hd_ac)
hf_ac <- data.frame(gene_ac,hd_ac)
gene_me3 <- row.names(hd_me3)
hf_me3 <- data.frame(gene_me3,hd_me3)
#轉(zhuǎn)成長(zhǎng)形數(shù)據(jù);
dt_ac <- hf_ac %>% pivot_longer(
cols = !gene_ac,
values_drop_na = FALSE,
names_to = "groups",
values_to = "expressions")
dt_me3 <- hf_me3 %>% pivot_longer(
cols = !gene_me3,
values_drop_na = FALSE,
names_to = "groups",
values_to = "expressions")
#預(yù)覽作圖數(shù)據(jù);
head(dt_ac)
轉(zhuǎn)成因子,避免ggplot2自動(dòng)排序;
#為了確保繪圖順序從上到下,可以顛倒level的順序;
dt_ac$gene_ac <- factor(dt_ac$gene_ac,
levels = rev(unique(dt_ac$gene_ac)),
ordered = T)
dt_me3$groups <- factor(dt_me3$groups,
levels = unique(dt_me3$groups),
ordered = T)
#繪制熱圖,linewidth調(diào)整格子線粗細(xì),color調(diào)整格子線顏色;
p_ac <- ggplot(dt_ac, aes(groups, gene_ac)) +
geom_tile(aes(fill = expressions),linewidth=0.4,
height=1,width=1,
colour = "black")+
scale_fill_gradient2(low = "#3FA9F5",
mid = "white",
high = "#FF931E",
midpoint = 0.5,
na.value = "grey92",
name="Exp")+
scale_x_discrete(position = "bottom")+
scale_y_discrete(position = "right")+
xlab('')+ylab('')+
theme(axis.text.x.bottom= element_text(angle = 45,face = "bold",
size=8,
hjust=0.3,vjust =0.5),
axis.text.y.right = element_text(angle = 0,face = "bold",
size=8,
hjust=1,vjust = 0.5),
panel.background = element_blank(),
legend.title = element_text(size = 6),
legend.position="left")+
guides(fill = guide_colourbar(direction = "vertical",
title.hjust=0,
title.position ="top",
ticks.colour="white",
frame.colour="purple",
barheight=5,
barwidth=0.7))+
coord_fixed(ratio = 1,expand=T)+
ggtitle("H3K27ac")
p_ac
p_me3 <- ggplot(dt_me3, aes(groups, gene_me3)) +
geom_tile(aes(fill = expressions),linewidth=0.4,
height=1,width=1,
colour = "black")+
scale_fill_gradient2(low = "#3FA9F5",
mid = "white",
high = "#FF931E",
midpoint = 0.5,
na.value = "grey92",
name="Exp")+
scale_x_discrete(position = "bottom")+
scale_y_discrete(position = "right")+
xlab('')+ylab('')+
theme(axis.text.x.bottom= element_text(angle = 45,face = "bold",
size=8,
hjust=0.3,vjust =0.5),
axis.text.y.right = element_text(angle = 0,face = "bold",
size=8,
hjust=1,vjust = 0.5),
panel.background = element_blank(),
legend.title = element_text(size = 6),
legend.position="left")+
guides(fill = guide_colourbar(direction = "vertical",
title.hjust=0,
title.position ="top",
ticks.colour="white",
frame.colour="purple",
barheight=5,
barwidth=0.7))+
coord_fixed(ratio = 1,expand=T)+
ggtitle("H3K4me3")
p_me3
【傻瓜美圖】ggplot2熱圖
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- ggplot2是一款強(qiáng)大的繪圖R包,今天的筆記內(nèi)容是學(xué)習(xí)使用ggplot2來繪制一幅熱圖,并進(jìn)行美化調(diào)整。需要加載...
- 熱圖系列快接近尾聲了,這節(jié)我們講下ggplot做的熱圖。實(shí)際上,之前heatmap已經(jīng)足夠了,但是ggplot2畫...
- 很久之前我們出過熱圖系列,一共有6篇文章,反響還是可以,但是最近發(fā)現(xiàn)很多新關(guān)注的小伙伴沒有翻看的習(xí)慣,居然不知道,...
- 論文 Single-cell profiling of vascular endothelial cells re...
- 論文是 De novo assembly, annotation, and comparative analysi...