Skip to content

Commit

Permalink
Update gsea plot functions to allow more arguments for gseaplot2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene233 committed Jan 12, 2024
1 parent 8ea0762 commit c9f9cee
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
matrix:
config:
# - { os: ubuntu-latest, r: 'devel', bioc: '3.19', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: ubuntu-latest, r: '4.3.2', bioc: '3.19', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: ubuntu-latest, r: 'devel', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: ubuntu-latest, r: '4.3.2', bioc: '3.19', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
- { os: ubuntu-latest, r: 'devel', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: ubuntu-latest, r: '4.3.2', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
# - { os: macOS-latest, r: '4.3.2', bioc: '3.18'}
# - { os: windows-latest, r: '4.3.2', bioc: '3.18'}
Expand Down
2 changes: 1 addition & 1 deletion R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ setGeneric(
#' @param digits num, specify the number of significant digits of pvalue table
#' @param rank_stat character, specify which metric used to rank for GSEA,
#' default "logFC"
#' @param ... params for function [get_de_table()]
#' @param ... params for function [get_de_table()] and function [enrichplot::gseaplot2()]
#'
#' @return patchwork object for all comparisons
#'
Expand Down
20 changes: 14 additions & 6 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -615,18 +615,26 @@ gsea_analysis <- function(tDEG, gsets, gene_id = "SYMBOL",
return(gse)
}
## gseaplot
gsea_plot_init <- function(gse, pvalue_table = FALSE) {
gsea_plot_init <- function(gse, pvalue_table = FALSE, ...) {
## check params
pars_def <- formals(enrichplot::gseaplot2)
pars <- modifyList(
pars_def, ## default params for gseaplot2 function
list(...) ## new params list
)
pars <- pars[names(pars) %in% names(pars_def)]

p <- lapply(names(gse), function(n) {
if (is.null(gse[[n]])) {
ms <- paste("No term was found enriched in", n, ".")
message(ms)
p <- ggpubr::as_ggplot(grid::textGrob(ms))
} else {
p <- enrichplot::gseaplot2(gse[[n]],
geneSetID = seq_len(nrow(gse[[n]])),
pvalue_table = pvalue_table,
title = n
)
pars_new <- modifyList(pars, list(x = gse[[n]],
geneSetID = seq_len(nrow(gse[[n]])),
pvalue_table = pvalue_table,
title = n))
p <- do.call(enrichplot::gseaplot2, pars_new)
p <- patchwork::wrap_elements(patchwork::wrap_plots(p, ncol = 1))
# ## add pvalue_table
# p <- p - patchwork::inset_element(gridExtra::tableGrob(
Expand Down
4 changes: 2 additions & 2 deletions R/sig_gseaplot-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ setMethod(
)

if (method == "gseaplot") {
p <- gsea_plot_init(gse, pvalue_table = pvalue_table)
p <- gsea_plot_init(gse, pvalue_table = pvalue_table, ...)
} else {
p <- gsea_dotplot_init(gse, col = col, size = size)
}
Expand Down Expand Up @@ -103,7 +103,7 @@ setMethod(
)

if (method == "gseaplot") {
p <- gsea_plot_init(gse, pvalue_table = pvalue_table)
p <- gsea_plot_init(gse, pvalue_table = pvalue_table, ...)
} else {
p <- gsea_dotplot_init(gse, col = col, size = size)
}
Expand Down
2 changes: 1 addition & 1 deletion man/sig_gseaplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c9f9cee

Please sign in to comment.