Browse code

bug fix: bug fix: allowMissingTFs in filterGRNAndConnectGenes filtered unnecessarily with filterLoops

Christian Arnold authored on 24/08/2022 15:19:40
Showing1 changed files

  • R/core.R index 674129a..3e28eb1 100755
... ...
@@ -3105,7 +3105,12 @@ filterGRNAndConnectGenes <- function(GRN,
3105 3105
     if (filterLoops) {
3106 3106
       futile.logger::flog.info(paste0(" Filter TF-TF self-loops"))
3107 3107
       futile.logger::flog.info(paste0("  Number of rows before filtering genes: ", nrow(grn.filt)))
3108
-      grn.filt = dplyr::filter(grn.filt, as.character(.data$gene.ENSEMBL) != as.character(.data$TF.ENSEMBL))
3108
+      
3109
+      # Be aware of NA values here in the selection, depending on allowMissingTFs
3110
+      grn.filt = dplyr::filter(grn.filt, 
3111
+                               is.na(.data$TF.ENSEMBL) | 
3112
+                               (!is.na(.data$TF.ENSEMBL) & (as.character(.data$gene.ENSEMBL) != as.character(.data$TF.ENSEMBL))))
3113
+      
3109 3114
       futile.logger::flog.info(paste0("  Number of rows after filtering genes: ", nrow(grn.filt)))
3110 3115
     }
3111 3116