我试图生成昼夜节律基因表达数据的热图,并在其上方显示测量的行为。
注意 2 个红点应在 CT13 和 CT37 上方(分别)...
这是我尝试使用的代码,但它会生成 2 个单独的图表:
library(pheatmap)
library(RColorBrewer)
library(ggplot2)
# prepare data for Heat map:
my_heatmap <- read.csv("circ_genes.csv", header = TRUE)
mymat <- my_heatmap[,c(2:13)]
rownames(mymat) <- paste("Gene", my_heatmap[,1], sep="_")
mydf <- data.frame(row.names = paste("Gene", my_heatmap[,1], sep="_"),
category = my_heatmap[,14])
my_palette <- colorRampPalette(c("blue", "white", "red"))(n = 1000)
# prepare data for line graph
behavior_LD <- read.csv("behavior.csv", header = TRUE)
CT <- behavior_LD$CT
CT <- as.character(CT)
behavior_LD$CT <- factor(behavior_LD$CT, levels = CT )
mycolours <- c("H1" = "red", "H0" = "black")
behavePlot <- ggplot(data=behavior_LD, aes(x=CT, y=Average, group=1)) +
geom_line()+
geom_point(aes(colour = factor(highlight)), size = 3) +
geom_errorbar(aes(ymin=Average-SE, ymax=Average+SE), width=.1)+
scale_color_manual(values = mycolours) + theme(legend.position="none") +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(plot.margin=unit(c(5,2,5,2),"cm"))
# plot 2 graphs
par(mfrow=c(2,1))
behavePlot
pheatmap(mymat, color = my_palette, legend_labels = "Clusters", cluster_cols
= F, cluster_rows = F, annotation_row = mydf, gaps_row = c(43, 60, 88, 124),
annotation_names_row = FALSE, show_rownames = FALSE )
我使用的文件可以在这里找到: https ://www.dropbox.com/sh/n3mplr0fdz7oh6f/AACU_CdVjT6OmJLzrKmAtxj2a?dl=0
感谢您的帮助!