Skip to content

Commit

Permalink
fix the bug of irGSEA.heatmap and irGSEA.bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
chuiqin committed Mar 29, 2024
1 parent d2fe91d commit c206f93
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: irGSEA
Type: Package
Title: The integration of single cell rank-based gene set enrichment analysis
Version: 3.2.4
Version: 3.2.5
Author: Chuiqin Fan
Author@R: person("Chuiqin", "Fan", role = c('aut', 'cre'), email = '[email protected]')
Maintainer: Chuiqin Fan <[email protected]>
Expand Down
4 changes: 4 additions & 0 deletions R/irGSEA.bubble.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ irGSEA.bubble <- function(object = NULL, method = "RRA",
pvalue < 0.05 ~ "< 0.05",
pvalue >= 0.05 ~ ">= 0.05",
TRUE ~ NA_character_)) %>%
dplyr::mutate(Name = factor(Name, levels = unique(Name))) %>%
tidyr::spread(cell, pvalue, fill = ">= 0.05") %>%
tibble::column_to_rownames(var = "Name")

Expand All @@ -108,6 +109,8 @@ irGSEA.bubble <- function(object = NULL, method = "RRA",
sig.genesets.bubble <- sig.genesets.bubble %>% dplyr::slice_head(n = top)
}else{
sig.genesets.bubble <- sig.genesets.bubble[rownames(sig.genesets.bubble) %in% show.geneset, ]
sig.genesets.bubble <- sig.genesets.bubble[intersect(show.geneset, rownames(sig.genesets.bubble)), ]

if (purrr::is_null(sig.genesets.bubble)) {
stop("All genesets of `show.geneset` are not in the `method`.")
}
Expand Down Expand Up @@ -191,6 +194,7 @@ irGSEA.bubble <- function(object = NULL, method = "RRA",
# bulid ggtree matrix
sig.genesets.bubble.matrix <- sig.genesets.bubble %>%
dplyr::select(c(Name, cell, value)) %>%
dplyr::mutate(Name = factor(Name, levels = unique(Name))) %>%
tidyr::spread(cell, value) %>%
tibble::column_to_rownames(var = "Name")

Expand Down
6 changes: 6 additions & 0 deletions R/irGSEA.heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ irGSEA.heatmap <- function(object = NULL, method = "RRA",
dplyr::mutate(cell = stringr::str_c(cluster, direction, sep = "_")) %>%
dplyr::select(c("Name", "pvalue", "cell")) %>%
dplyr::mutate(pvalue = dplyr::if_else(pvalue < 0.05, "significant","no significant")) %>%
dplyr::mutate(Name = factor(Name, levels = unique(Name))) %>%
tidyr::spread(cell, pvalue, fill = "no significant") %>%
tibble::column_to_rownames(var = "Name")

Expand All @@ -110,6 +111,7 @@ irGSEA.heatmap <- function(object = NULL, method = "RRA",
pvalue < 0.05 ~ "*",
pvalue >= 0.05 ~ " ",
TRUE ~ NA_character_)) %>%
dplyr::mutate(Name = factor(Name, levels = unique(Name))) %>%
tidyr::spread(cell, pvalue, fill = " ") %>%
tibble::column_to_rownames(var = "Name")

Expand Down Expand Up @@ -144,6 +146,9 @@ irGSEA.heatmap <- function(object = NULL, method = "RRA",
}else{
sig.genesets.heatmap <- sig.genesets.heatmap[rownames(sig.genesets.heatmap) %in% show.geneset, ]
sig.genesets.heatmap.text <- sig.genesets.heatmap.text[rownames(sig.genesets.heatmap.text) %in% show.geneset, ]
sig.genesets.heatmap <- sig.genesets.heatmap[intersect(show.geneset, rownames(sig.genesets.heatmap)), ]
sig.genesets.heatmap.text <- sig.genesets.heatmap.text[intersect(show.geneset, rownames(sig.genesets.heatmap.text)), ]

if (purrr::is_null(sig.genesets.heatmap)) {
stop("All genesets of `show.geneset` are not in the `method`.")
}
Expand Down Expand Up @@ -180,6 +185,7 @@ irGSEA.heatmap <- function(object = NULL, method = "RRA",

sig.genesets.heatmap <- sig.genesets.heatmap %>%
tibble::rownames_to_column(var = "Name") %>%
dplyr::mutate(Name = factor(Name, levels = unique(Name))) %>%
tidyr::gather(cell, value, -Name) %>%
dplyr::mutate(value = dplyr::if_else(value=="no significant", 0, 1)) %>%
tidyr::spread(cell, value) %>%
Expand Down

0 comments on commit c206f93

Please sign in to comment.