在 R 中向 gprofiler2 gosttable 添加标题

Add a title to gprofiler2 gosttable in R

您好,我是一名新的生物信息学家,请多多包涵! 我正在使用 emacs/ess 在 R 中使用 gprofiler2 到 运行 GO/KEGG 分析,我想为它提供的 table 添加一个标题:

publish_gosttable(gostres, highlight_terms = gostres$result[c(1:2,10,120),],
                        use_colors = TRUE, 
                        show_columns = c("source", "term_name", "term_size", "intersection_size"),
                        filename = NULL)

我尝试了title()tab_header()功能,但我似乎无法添加标题。我的问题是是否有一些其他功能或包可以让我添加它而不必手动添加。

到目前为止的代码

GOresult <- gost(
geneid1up$gene,
organism = "hsapiens",
ordered_query = FALSE, 
multi_query = FALSE,
significant = TRUE, 
exclude_iea = FALSE,
measure_underrepresentation = FALSE,
evcodes = FALSE,
user_threshold = 0.05,
correction_method =  "gSCS",
domain_scope = "annotated",
custom_bg = NULL,
numeric_ns = "",
sources = c("GO:BP","GO:MF","GO:CC","KEGG"),
as_short_link = FALSE)

GOresult1 <- as.data.frame(GOresult$result)
GOresult1$minuslog10pval <- -log10(GOresult1$p_value)
names(GOresult1)[15] <- "-log10(pval)"
GOresult2 <- GOresult1[order(GOresult1$p_value, decreasing=F),]

plot1 <- publish_gosttable(GOresult2, highlight_terms = GOresult2[c(1:20),],
                        use_colors = FALSE, 
                        show_columns = c("source", "term_name", "term_size", "intersection_size","-log10(pval)"),
                        filename = NULL)

这行吗?

    library(gprofiler2)
library(ggplot2)
gostres <- gost(query = c("X:1000:1000000", "rs17396340", "GO:0005005", "ENSG00000156103", "NLRP1"), 
                organism = "hsapiens", ordered_query = FALSE, 
                multi_query = FALSE, significant = TRUE, exclude_iea = FALSE, 
                measure_underrepresentation = FALSE, evcodes = FALSE, 
                user_threshold = 0.05, correction_method = "g_SCS", 
                domain_scope = "annotated", custom_bg = NULL, 
                numeric_ns = "", sources = NULL, as_short_link = FALSE)

publish_gosttable(gostres, highlight_terms = gostres$result[c(1:2,10,120),],
                  use_colors = TRUE, 
                  show_columns = c("source", "term_name", "term_size", "intersection_size"),
                  filename = NULL)+
  ggtitle('Your Title')

结果:

诀窍在于情节是一个 ggplot objet。因此,您可以在情节代码后使用 +ggtitle('Your Title') 添加标题(如我的示例)