Skip to content

Commit

Permalink
fix: add library(data.table) and data.table() conversion in fgsea::co…
Browse files Browse the repository at this point in the history
…llapsePathways() to avoid ctlab/fgsea#98
  • Loading branch information
dlaehnemann committed Jan 29, 2024
1 parent 2aceae9 commit 3aec0e1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion workflow/scripts/fgsea.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sink(log, type="message")

library("fgsea")
library(snakemake@params[["bioc_species_pkg"]], character.only = TRUE)
# avoid this error: https://github.com/ctlab/fgsea/issues/98
library("data.table")

# provides library("tidyverse") and functions load_bioconductor_package() and
# get_prefix_col(), the latter requires snakemake@output[["samples"]] and
Expand Down Expand Up @@ -128,7 +130,7 @@ tg <- plotGseaTable(
)
ggsave(filename = snakemake@output[["plot"]], plot = tg, width = 15, height = height, limitsize=FALSE)

collapsed_pathways <- collapsePathways(fgsea_res %>% arrange(pval) %>% filter(padj <= snakemake@params[["gene_set_fdr"]]), gene_sets, ranked_genes)
collapsed_pathways <- collapsePathways(fgsea_res %>% arrange(pval) %>% filter(padj <= snakemake@params[["gene_set_fdr"]]) %>% data.table(), gene_sets, ranked_genes)
main_pathways <- fgsea_res %>% filter(pathway %in% collapsed_pathways$mainPathways) %>% arrange(-NES) %>% pull(pathway)
selected_gene_sets <- gene_sets[main_pathways]
height = .7 * (length(selected_gene_sets) + 2)
Expand Down

0 comments on commit 3aec0e1

Please sign in to comment.