Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding grid lines to pathway heatmap (OA-348) #237

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions OlinkAnalyze/R/olink_Pathway_Heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
#'@importFrom magrittr %>%
#'@export

olink_pathway_heatmap<- function(enrich_results, test_results, method = "GSEA", keyword = NULL, number_of_terms = 20) {
olink_pathway_heatmap<- function(enrich_results, test_results, method = "GSEA", keyword = NULL, number_of_terms = 20,
grid = FALSE) {
if (!(method %in% c("ORA", "GSEA"))) {
stop("Method must be \"GSEA\" or \"ORA\".")
}
Expand Down Expand Up @@ -81,12 +82,35 @@ olink_pathway_heatmap<- function(enrich_results, test_results, method = "GSEA",
p <- ggplot2::ggplot(data = long_list1, ggplot2::aes(factor(x = Assay, levels = orderprot),
stringr::str_trunc(string = Pathway, width = 50, side = "center"))) +
ggplot2::geom_tile(ggplot2::aes(fill = estimate)) +
OlinkAnalyze::olink_fill_gradient(coloroption = c('teal', 'red'), name = "estimate") +
OlinkAnalyze::olink_fill_gradient(coloroption = c("teal", "red"), name = "estimate") +
OlinkAnalyze::set_plot_theme() +
ggplot2::theme(panel.grid.major = ggplot2::element_blank(),
axis.text.x = ggplot2::element_text(angle = 60, hjust = 1)) +
ggplot2::xlab("Protein Symbol") +
ggplot2::ylab("Pathway")

if(grid == TRUE){
n1 <- length(unique(long_list1$Assay))
n2 <- length(unique(long_list1$Pathway))

n3 <- length(unique(long_list1$Pathway))
n4 <- length(unique(long_list1$Assay))

p <- ggplot2::ggplot(data = long_list1, ggplot2::aes(factor(x = Assay, levels = orderprot),
stringr::str_trunc(string = Pathway, width = 50, side = "center"))) +
ggplot2::geom_tile(ggplot2::aes(fill = estimate)) +
OlinkAnalyze::olink_fill_gradient(coloroption = c("teal", "red"), name = "estimate") +
OlinkAnalyze::set_plot_theme() +
ggplot2::theme(panel.grid.major = ggplot2::element_blank(),
axis.ticks.length = unit(3,"mm"),
axis.text.x = ggplot2::element_text(angle = 90, hjust = 1)) +
ggplot2::xlab("Protein Symbol") +
ggplot2::ylab("Pathway") +
ggplot2::geom_line(data = data.frame(y = c(0, n2) + 0.5, x = rep(2:n1, each = 2) - 0.5),
aes(x = x, y = y, group = x)) + # Vertical lines
ggplot2::geom_line(data = data.frame(x = c(0, n4) + 0.5, y = rep(2:n3, each = 2) - 0.5),
aes(x = x, y = y, group = y)) # Horizontal lines
}

return(p)
}
3 changes: 2 additions & 1 deletion OlinkAnalyze/man/olink_pathway_heatmap.Rd

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