0

当我使用 ggplot 函数时,我感到很困惑。

当我用 ggplot 输入以下代码时:我实际上得到了火山图并且没有收到错误

##--> Add the pval and the qval
average_data$Pval <- sig_limma_cont[match(row.names(average_data),
                                         row.names(sig_limma_cont)),6]
average_data$Qval <- sig_limma_cont[match(row.names(average_data),
                                         row.names(sig_limma_cont)),7]
ggplot(data = volcano_data, aes(y = -log10(Qval), x = Max_LFC)) +
  geom_point(aes(color = Change)) +
  geom_text_repel(data = subset(volcano_data, Change == "DOWN")[c(1:20),],
                  aes(label = Gene_Symbol),
                  segment.color = "black", size = 3,  force = 1, nudge_x = -0.25) +
  geom_text_repel(data = subset(volcano_data, Change == "UP")[c(1:20),],
                  aes(label = Gene_Symbol),
                  segment.color = "black", size = 3,  force = 1, nudge_x = 0.25) +
  geom_hline(yintercept = -log10(.005)) +
  geom_vline(xintercept = c(-0.48,0.48)) +
  scale_x_continuous(limits = c(-7, 7), name = "Max Abs Log2 FC") +
  scale_y_continuous(name = "-log10 Qval", limits = c(0,10)) +
  geom_point(data = volcano_data[which(volcano_data$Change == "STABLE"),],
             aes(y = -log10(Qval), x = Max_LFC), color = "grey50") +
  scale_color_manual(values=c("cyan", "black", "gold")) + ggtitle("LFC 1 DE Genes in relative to Naive all comparisons") +
  theme_classic() + theme(legend.position="none")

但是,在使用 ggplot 添加第二个代码后,我收到一条错误消息。这是代码和错误消息:

ggplot(data = volcano_data_CM, aes(y = -log10(Qval), x = Max_LFC_CM)) +
  geom_point(aes(color = Change)) +
  geom_text_repel(data = subset(volcano_data_CM, Change == "DOWN")[c(1:500),],
                  aes(label = Gene_Symbol),
                  segment.color = "black", size = 3,  force = 2, nudge_x = -0.35) +
  geom_text_repel(data = subset(volcano_data_CM, Change == "UP")[c(1:400),],
                  aes(label = Gene_Symbol),
                  segment.color = "black", size = 3,  force = 2, nudge_x = 0.35) +
  geom_hline(yintercept = -log10(.005)) +
  geom_vline(xintercept = c(-0.48,0.48)) +
  scale_x_continuous(limits = c(-7, 7), name = "Max Abs Log2 FC") +
  scale_y_continuous(name = "-log10 Qval", limits = c(0,10)) +
  geom_point(data = volcano_data_CM[which(volcano_data_CM$Change == "STABLE"),],
             aes(y = -log10(Qval), x = Max_LFC_CM), color = "grey50") +
  scale_color_manual(values=c("darkblue", "black", "gold")) + ggtitle("LFC 1 DE CM") +
  theme_classic() + theme(legend.position="none")

为了修复之前Qval not found的错误,我尝试了这段代码:

> geom_path(data = path, aes(x = x,y = y), inherit.aes = FALSE )

现在我得到:控制台的错误消息输出:

Error in FUN(X[[i]], ...) : object 'Gene_Symbol' not found

有谁知道如何解决这个问题?我很困惑为什么它在第一个 ggplot 函数中被识别,但在其他函数中却没有?

让我知道

4

0 回答 0