@@ -72,21 +72,26 @@ if(!'degpatterns_list' %in% names(obj)){
72
72
ontology_list <- lcdbwf:::get_ontology_list(config)
73
73
74
74
# 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)
78
75
univ_option <- config$functional_enrichment$limit_background_genes
79
76
80
- # Print the current universe option
77
+ # Set `universe_list` based on configuration or custom background
81
78
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)
85
82
} 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
+ }
88
93
} else {
89
- stop("Correct your background option in the config.yaml file.")
94
+ stop("Correct your background option in the config.yaml file.")
90
95
}
91
96
```
92
97
0 commit comments