Browse code

Check for features overlap

Marek Gierlinski authored on 18/08/2022 13:01:14
Showing 1 changed files

... ...
@@ -135,9 +135,14 @@ prepare_for_enrichment <- function(terms, mapping, all_features = NULL, feature_
135 135
 functional_enrichment <- function(feat_all, feat_sel, term_data, feat2name = NULL,
136 136
                                   min_count = 2, fdr_limit = 0.05) {
137 137
 
138
+  # Check term_data class
138 139
   if (!(class(term_data) == "fterms"))
139 140
     stop("'term_data' should be an object of class 'fterms'.")
140 141
 
142
+  # If no overlap between selection and all, return NULL
143
+  if(!any(feat_sel %in% feat_all))
144
+    return(NULL)
145
+
141 146
   # all terms present in the selection
142 147
   our_terms <- feat_sel |>
143 148
     purrr::map(\(x) term_data$feature2term[[x]]) |>