Commit 6e905134 authored by Leon-Charles Tranchevent's avatar Leon-Charles Tranchevent
Browse files

Small correction for Fisher's test as to have the correct background.

parent 87e61139
...@@ -447,6 +447,7 @@ background_map <- bitr(background, ...@@ -447,6 +447,7 @@ background_map <- bitr(background,
fromType = "SYMBOL", fromType = "SYMBOL",
toType = c("ENTREZID"), toType = c("ENTREZID"),
OrgDb = org.Hs.eg.db) #nolint OrgDb = org.Hs.eg.db) #nolint
rm(background)
# We perform the enrichment on all rankings files. # We perform the enrichment on all rankings files.
ranking_files <- list.files(path = output_data_dir, pattern = "*rankings.tsv") ranking_files <- list.files(path = output_data_dir, pattern = "*rankings.tsv")
...@@ -518,6 +519,7 @@ for (ranking_file in ranking_files) { ...@@ -518,6 +519,7 @@ for (ranking_file in ranking_files) {
# the adjusted P values. # the adjusted P values.
selection_sy <- ranking_final %>% filter(adj_P_value < 0.05) selection_sy <- ranking_final %>% filter(adj_P_value < 0.05)
selection_eg <- selection_sy %>% filter(!is.na(EGene)) selection_eg <- selection_sy %>% filter(!is.na(EGene))
rm(ranking_final, ranking_final_eg)
# We loop over the functional sources. # We loop over the functional sources.
for (k in seq_len(length(config$functional_sources))) { for (k in seq_len(length(config$functional_sources))) {
...@@ -529,21 +531,24 @@ for (ranking_file in ranking_files) { ...@@ -529,21 +531,24 @@ for (ranking_file in ranking_files) {
} }
# We define the reference genes (depending on the source). # We define the reference genes (depending on the source).
ranking <- NULL ranking <- NULL
logFC <- NULL logFC <- NULL
selection <- NULL selection <- NULL
background <- NULL
if (func_source$cp_gene_id_type == "entrezgene") { if (func_source$cp_gene_id_type == "entrezgene") {
ranking <- ranking_eg ranking <- ranking_eg
logFC <- logFC_eg logFC <- logFC_eg
selection <- selection_eg selection <- selection_eg$EGene
background <- background_map$ENTREZID
} else if (func_source$cp_gene_id_type == "symbol") { } else if (func_source$cp_gene_id_type == "symbol") {
ranking <- ranking_sy ranking <- ranking_sy
logFC <- logFC_sy logFC <- logFC_sy
selection <- selection_sy selection <- selection_sy$Gene
background <- background_map$SYMBOL
} }
# We run the Fisher analysis. # We run the Fisher analysis.
fisher_adjP <- perform_enrichment(selection$Gene, fisher_adjP <- perform_enrichment(selection,
background, background,
type = func_source$cp_name, type = func_source$cp_name,
file_dir = output_data_dir, file_dir = output_data_dir,
...@@ -574,11 +579,12 @@ for (ranking_file in ranking_files) { ...@@ -574,11 +579,12 @@ for (ranking_file in ranking_files) {
file_tag = ofile_prefix) file_tag = ofile_prefix)
message(paste0("[", Sys.time(), "][", analysis_prefix, "] CP GSEA enrichment (", message(paste0("[", Sys.time(), "][", analysis_prefix, "] CP GSEA enrichment (",
func_source$cp_name, ") done.")) func_source$cp_name, ") done."))
rm(func_source, gsea_pi, logFC, ranking) rm(func_source, gsea_pi, fisher_adjP, logFC, ranking, selection, background)
} # End for each functional source. } # End for each functional source.
rm(k, ranking_eg, ranking_sy, logFC_eg, logFC_sy, analysis_prefix, ofile_prefix) rm(k, ranking_eg, ranking_sy, logFC_eg, logFC_sy, selection_sy, selection_eg)
rm(analysis_prefix, ofile_prefix)
} # End for each integration. } # End for each integration.
rm(ranking_file, ranking_files) rm(ranking_file, ranking_files, background_map)
# We log the session details for reproducibility. # We log the session details for reproducibility.
rm(config, input_data_dir, output_data_dir, msigdb) rm(config, input_data_dir, output_data_dir, msigdb)
......
Supports Markdown
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