Commit 813b9f82 authored by domingue's avatar domingue
Browse files

Bug fix: hard-coded species

- detects species from gene names for gene name conversion.
Species is still needed as an input to retrieve the sets from GSEA

Fixes #94
parent 24f966e8
......@@ -95,11 +95,11 @@ dir.create("figure", showWarnings = FALSE)
# Libraries and custom functions
# =========================================================================
devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/v1.45/R/core_commons.R")
devtools::source_url("https://git.mpi-cbg.de/bioinfo/ngs_tools/raw/v11/common/cp_utils.R")
library("clusterProfiler")
library("msigdbr")
library("fgsea")
library("data.table")
library("org.Mm.eg.db")
set.seed(42)
## not present in my version of the package
......@@ -152,6 +152,7 @@ resultsBase <- if (!is.na(out)) {
#' - genes are ranked by their adjusted values and logFC signal, that is, genes with the lowest p-value are put at the beginning or the end of the list if they down- or up-regulated respectively
#' - ensemble gene IDs have to be converted to ENTREZ gene IDs
#' - the step above might generate duplicate entries which are removed
gene_df <- read_tsv(de_file) %>%
transmute(
ensembl_gene_id,
......@@ -162,7 +163,9 @@ gene_df <- read_tsv(de_file) %>%
) %>%
mutate(rank_score = ifelse(logfc < 0, rank_score * -1, rank_score))
eg <- bitr(gene_df$ensembl_gene_id, fromType = "ENSEMBL", toType = "ENTREZID", OrgDb = "org.Mm.eg.db") %>%
species_db <- guess_anno_db(gene_df$ensembl_gene_id)
eg <- bitr(gene_df$ensembl_gene_id, fromType = "ENSEMBL", toType = "ENTREZID", OrgDb = species_db) %>%
distinct_all(ENTREZID) %>%
distinct_all(ENSEMBL)
......@@ -313,13 +316,13 @@ grid.draw(p_table)
## save table
setDT(fgseaRes)
fgseaRes[, leadingEdgeGeneSymbol := mapIdsList(
x = org.Mm.eg.db,
x = eval(parse(text = species_db)),
keys = leadingEdge,
keytype = "ENTREZID",
column = "SYMBOL"
)]
fgseaRes[, leadingEdgeEnsemblID := mapIdsList(
x = org.Mm.eg.db,
x = eval(parse(text = species_db)),
keys = leadingEdge,
keytype = "ENTREZID",
column = "ENSEMBL"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment