Skip to content

Commit 8f4afce

Browse files
committed
downstream functional enrichment analysis updated with an error for unmatched list names between universe_list and res_list & indentation changed
1 parent a62c342 commit 8f4afce

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

workflows/rnaseq/downstream/functional-enrichment.Rmd

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,26 @@ if(!'degpatterns_list' %in% names(obj)){
7272
ontology_list <- lcdbwf:::get_ontology_list(config)
7373
7474
# Define background gene pool for overrepresentation analysis
75-
# This option will limit genes to the following criteria:
76-
# - option 1 ("exclude_zero_in_all"): genes with non-zero raw counts in one or more samples
77-
# - option 2 ("no_filter"): all available genes in each annotation database (e.g. GO, KEGG)
7875
univ_option <- config$functional_enrichment$limit_background_genes
7976
80-
# Print the current universe option
77+
# Set `universe_list` based on configuration or custom background
8178
if (univ_option == "exclude_zero_in_all") {
82-
# Retrieve all genes detected in one or more samples per contrast
83-
universe_list <- lapply(names(dds_list), function(name) nonzero_genes(dds_list[[name]]))
84-
names(universe_list) <- names(dds_list)
79+
# Retrieve all genes detected in one or more samples per contrast
80+
universe_list <- lapply(names(dds_list), function(name) nonzero_genes(dds_list[[name]]))
81+
names(universe_list) <- names(dds_list)
8582
} else if (univ_option == "no_filter") {
86-
# Set universe to NULL
87-
universe_list <- NULL
83+
########################################################################################
84+
# Here, a user can manually set the `universe_list` to a named list of vectors for #
85+
# custom background genes. Ensure to have names matched between `universe_list` and #
86+
# `res_list`. #
87+
########################################################################################
88+
universe_list <- NULL
89+
# Raise an error if names are unmatched
90+
if (!identical(names(universe_list), names(res_list)) & !is.null(universe_list)) {
91+
stop("universe_list has different names from res_list.")
92+
}
8893
} else {
89-
stop("Correct your background option in the config.yaml file.")
94+
stop("Correct your background option in the config.yaml file.")
9095
}
9196
```
9297

0 commit comments

Comments
 (0)