I have the dataset below:
我有以下数据集:
gene_symbol<-c("DADA","SDAASD","SADDSD","SDADD","ASDAD","XCVXCVX","EQWESDA","DASDADS","SDASDASD","DADADASD","sdaadfd","DFSD","SADADDAD","SADDADADA","DADSADSASDWQ","SDADASDAD","ASD","DSADD")
panel<-c("growth","growth","growth","growth","big","big","big","small","small","small","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDA<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDb<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf1<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf2<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf3<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf4<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf5<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDA1<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDb1<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf1<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf11<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf21<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf31<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf41<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
ASDDAf51<-c("normal","over","low","over","normal","over","low","over","normal","over","DF","DF","DF","DF","DF","DF","DF","DF")
Gene_states22<-data.frame(gene_symbol,panel,ASDDA,ASDDb,ASDDAf,ASDDAf1,ASDDAf2,ASDDAf3,ASDDAf4,ASDDAf5,ASDDA1,ASDDb1,ASDDAf1,ASDDAf11,ASDDAf21,ASDDAf31,ASDDAf41,ASDDAf51)
Then I create 4 heatmaps based on the number of diffrenet panel
types. As you can see I want the y-axis text to be displayed only for the 1st one and this is why I create it separatedly from the others.
然后我根据diffrenet面板类型的数量创建4个热图。正如您所看到的,我希望仅为第一个显示y轴文本,这就是我将其与其他文本分开创建的原因。
library(plotly)
library(ggplot2); library(reshape2)
HG3<-split(Gene_states22[,1:15], Gene_states22$panel)
HG4 <- melt(HG3, id.vars= c("gene_symbol","panel"))
HG4<-HG4[,-5]
HG5<-split(HG4, HG4$panel)
p<-list()
p[[1]]<-ggplotly(
ggplot(HG5[[1]], aes(gene_symbol,variable)) + geom_tile(aes(fill = value),
colour = "grey50") + scale_fill_manual(values=c("white", "red", "blue","black","yellow","green","brown"))+
labs(title = "Heatmap",x = "gene_symbol",y="sample",fill="value")+
theme(title = element_text(family = "sans serif",
size = 14,
face = "bold"),
axis.title = element_text(family = "sans serif",
size = 16,
face = "bold",
color = "black"),
axis.text.x = element_text(family = "sans serif",
size = 11),
axis.text.y= element_text(family = "sans serif",
size = 11),
axis.title.y = element_text(vjust = 10,hjust = 10),
panel.background = element_rect(fill = NA),
panel.grid.major = element_line(colour = "grey50"),
panel.spacing = unit(0, "lines"),
strip.placement = "outside")
)%>%
layout( autosize = F,hoverlabel = list(bgcolor = "white",
font = list(family = "sans serif",
size = 9,
color = "black")))
Then I create the rest of them
然后我创建其余的
for(i in 2:length(HG5)){
p[[i]]<-ggplotly(
ggplot(HG5[[i]], aes(gene_symbol,variable)) + geom_tile(aes(fill = value),
colour = "grey50") + scale_fill_manual(values=c("white", "red", "blue","black","yellow","green","brown"))+
labs(title = "Heatmap",x = "gene_symbol",y="sample",fill="value")+
theme(title = element_text(family = "sans serif",
size = 14,
face = "bold"),
axis.title = element_text(family = "sans serif",
size = 16,
face = "bold",
color = "black"),
axis.text.x = element_text(family = "sans serif",
size = 11),
axis.title.y = element_blank(),
axis.text.y=element_blank(),
panel.background = element_rect(fill = NA),
panel.grid.major = element_line(colour = "grey50"),
panel.spacing = unit(0, "lines"),
strip.placement = "outside")
)%>%
layout( autosize = F,hoverlabel = list(bgcolor = "white",
font = list(family = "sans serif",
size = 9,
color = "black")))
}
And finally I combine them with subplot
最后我将它们与子图组合在一起
subplot(p)
The problem is that I cannot see the y-axis test as you can see in the picture.
问题是我看不到你在图片中看到的y轴测试。