GOHeat - x 轴标签(基因名称)不显示在图上

GOHeat - x axis labels (gene names) don't show on the plot

我正在尝试使用 GOplot 包绘制我的 Gene Ontology 数据,特别是 GOHeat() 函数。不幸的是,基因名称的显示存在问题 - 图上的 x 轴标签。这是问题的可视化:

从小插图中绘制它应该是这样的:

下面是我绘制它时的样子:

我决定仔细研究一下 GOHeat() 函数,它非常简单,整个函数是 here 但是我尝试修改 ggplot():

  g <- ggplot() + 
    geom_tile(data = df_o, aes(x = x, y = y, fill = z))+
    scale_x_discrete(breaks = 1:length(unique(df_o$x)), labels = unique(df_o$lab)) +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5), axis.title.x=element_blank(), axis.title.y=element_blank(),
          axis.text.y = element_text(size = 14), panel.background=element_blank(), panel.grid.major=element_blank(),
          panel.grid.minor=element_blank())

我认为axis.text.x = element_text(...)中的边缘,但我的努力根本没有改变情节,甚至出现了一些错误。

为了让事情更简单,我展示了数据的样子:

> head(unique(df_o$x))
[1] 1 2 3 4 5 6
> head(unique(df_o$lab))
[1] TGFBR3  NRP2    GNA13   SLC22A5 APOE    LEPR   
37 Levels: ACVRL1 AMOT APOE ATP6V0A1 CAV1 CDH2 CDH5 CERKL CXCR4 ECSCR     EFNB2 FGF2 ... VANGL2

如果能提供有关如何 'turn on' x 轴标签的线索,我将不胜感激。

这里是固定函数:

GOHeat_fix <- function (data, nlfc, fill.col) 
{
  x <- y <- z <- NULL
  if (missing(nlfc)) 
    nlfc <- 0
  else nlfc <- nlfc
  if (missing(fill.col)) 
    fill.col <- c("firebrick", "white", "dodgerblue")
  else fill.col <- fill.col
  distance <- dist(data)
  cluster <- hclust(distance)
  M <- dim(data)[2]
  nterm <- M - nlfc
  if (nlfc == 0) {
    s <- rowSums(data[, 1:nterm])
    tmp <- NULL
    for (r in 1:nrow(data)) {
      tmp <- c(tmp, as.numeric(gsub(1, s[r], data[r, 1:nterm])))
    }
  }
  else {
    tmp <- NULL
    for (r in 1:nrow(data)) {
      tmp <- c(tmp, as.numeric(gsub(1, data[r, (nterm + 
                                                  1)], data[r, 1:nterm])))
    }
  }
  df <- data.frame(x = factor(rep(cluster$order, each = nterm)), y = rep(colnames(data[, 
                                                                               1:nterm]), length(rownames(data))), z = tmp, lab = rep(rownames(data), 
                                                                                                                                      each = nterm))
  df_o <- df[order(df$x), ]
  g <- ggplot() +
    geom_tile(data = df_o, aes(x = x, y = y, fill = z)) +
    scale_x_discrete(breaks = 1:length(unique(df_o$x)), labels = unique(df_o$lab)) +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1),
          axis.title.x = element_blank(),
          axis.title.y = element_blank(), 
          axis.text.y = element_text(size = 14),
          panel.background = element_blank(), 
          panel.grid.major = element_blank(),
          panel.grid.minor = element_blank()) +
    coord_fixed()
  if (nlfc == 0) {
    g + scale_fill_gradient2("Count", space = "Lab", low = fill.col[2], 
                             mid = fill.col[3], high = fill.col[1])
  }
  else {
    g + scale_fill_gradient2("logFC", space = "Lab", low = fill.col[3], 
                             mid = fill.col[2], high = fill.col[1])
  }
}

示例:

library(GOplot)
data(EC)
circ <- circle_dat(EC$david, EC$genelist)
chord <- chord_dat(data = circ, genes = EC$genes, process = EC$process)
GOHeat_fix(chord[,-8], nlfc = 0)

我解决了标签问题并添加了 coord_fixed() 因为热图通常是这样制作的。