commit 9fdbfada63d5b0b97ebf7b779fa045cca8173efa
Author: Florent Chuffart <florent.chuffart@ens-lyon.fr>
Date:   Mon Mar 17 16:52:45 2014 +0100

    Define and emproove get_intra_strain_fuzzy and get_unrs functions

diff --git a/build/nucleominer_2.3.33.tar.gz b/build/nucleominer_2.3.33.tar.gz
new file mode 100644
index 0000000..bf5d363
Binary files /dev/null and b/build/nucleominer_2.3.33.tar.gz differ
diff --git a/doc/sphinx_doc/build/latex/NucleoMiner2.pdf b/doc/sphinx_doc/build/latex/NucleoMiner2.pdf
index dd4d17d..b1b0867 100644
Binary files a/doc/sphinx_doc/build/latex/NucleoMiner2.pdf and b/doc/sphinx_doc/build/latex/NucleoMiner2.pdf differ
diff --git a/doc/sphinx_doc/conf.py b/doc/sphinx_doc/conf.py
index 8ae12b9..730462b 100644
--- a/doc/sphinx_doc/conf.py
+++ b/doc/sphinx_doc/conf.py
@@ -50,9 +50,9 @@ copyright = u'2012, Florent CHUFFART, Jean-Baptiste VEYRIERAS, Gael YVERT'
 # built documents.
 #
 # The short X.Y version.
-version = '2.3.32'
+version = '2.3.33'
 # The full version, including alpha/beta/rc tags.
-release = '2.3.32'
+release = '2.3.33'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/doc/sphinx_doc/rref.rst b/doc/sphinx_doc/rref.rst
index 048d67e..df5111c 100644
--- a/doc/sphinx_doc/rref.rst
+++ b/doc/sphinx_doc/rref.rst
@@ -986,6 +986,48 @@ Author(s)
 
 Florent Chuffart
 
+R: Compute the fuzzy list for a given strain.
+
+Compute the fuzzy list for a given strain.
+------------------------------------------
+
+Description
+~~~~~~~~~~~
+
+This function grabs the nucleosomes detxted by template\_filter that
+have been rejected bt aggregate\_intra\_strain\_nucs as well positions.
+
+Usage
+~~~~~
+
+::
+
+    get_intra_strain_fuzzy(wp_maps, roi, strain, config = NULL)
+
+Arguments
+~~~~~~~~~
+
+``wp_maps``
+
+Well positionned nucleosomes map.
+
+``roi``
+
+The region of interest.
+
+``strain``
+
+The strain we want to extracvt the fuzzy map.
+
+``config``
+
+GLOBAL config variable.
+
+Author(s)
+~~~~~~~~~
+
+Florent Chuffart
+
 R: Compute the list of SNEPs for a given set of marker, strain...
 
 Compute the list of SNEPs for a given set of marker, strain combination and nuc form.
@@ -1042,6 +1084,63 @@ Examples
     # foo = get_sneps(marker, combi, form)
     # foo = get_sneps("H4K12ac", c("BY", "RM"), "wp")
 
+R: Compute the unaligned nucleosomal regions (UNRs).
+
+Compute the unaligned nucleosomal regions (UNRs).
+-------------------------------------------------
+
+Description
+~~~~~~~~~~~
+
+This function aggregate non common wp nucs for each strain and substract
+common wp nucs. It does not take care about the size of the resulting
+UNR. It will be take into account in the count read part og the
+pipeline.
+
+Usage
+~~~~~
+
+::
+
+    get_unrs(combi, roi, roi_index, wp_maps, fuzzy_maps, common_nuc_results, 
+        config = NULL)
+
+Arguments
+~~~~~~~~~
+
+``combi``
+
+The strain combination to consider.
+
+``roi``
+
+The region of interest.
+
+``roi_index``
+
+The region of interest index.
+
+``wp_maps``
+
+Well positionned nucleosomes maps.
+
+``fuzzy_maps``
+
+Fuzzy nucleosomes maps.
+
+``common_nuc_results``
+
+Common wp nuc maps
+
+``config``
+
+GLOBAL config variable
+
+Author(s)
+~~~~~~~~~
+
+Florent Chuffart
+
 R: Returns the intersection of 2 list on regions.
 
 Returns the intersection of 2 list on regions.
@@ -1153,7 +1252,7 @@ Details
 +---------------+---------------------------------------------------+
 | Author:       | Florent Chuffart                                  |
 +---------------+---------------------------------------------------+
-| Version:      | 2.3.32                                            |
+| Version:      | 2.3.33                                            |
 +---------------+---------------------------------------------------+
 | License:      | CeCILL                                            |
 +---------------+---------------------------------------------------+
@@ -1485,9 +1584,9 @@ Usage
         plot_arrow_raw_reads = TRUE, plot_arrow_nuc_reads = TRUE, 
         plot_squared_reads = TRUE, plot_coverage = FALSE, plot_gaussian_reads = TRUE, 
         plot_gaussian_unified_reads = TRUE, plot_ellipse_nucs = TRUE, 
-        change_col = TRUE, plot_wp_nucs = TRUE, plot_wp_nuc_model = TRUE, 
-        plot_common_nucs = TRUE, plot_wp_nucs_4_nonmnase = FALSE, 
-        plot_chain = FALSE, aggregated_intra_strain_nucs = NULL, 
+        change_col = TRUE, plot_wp_nucs = TRUE, plot_fuzzy_nucs = TRUE, 
+        plot_wp_nuc_model = TRUE, plot_common_nucs = FALSE, plot_common_unrs = FALSE, 
+        plot_wp_nucs_4_nonmnase = FALSE, plot_chain = FALSE, aggregated_intra_strain_nucs = NULL, 
         aligned_inter_strain_nucs = NULL, height = 10, config = NULL)
 
 Arguments
@@ -1541,6 +1640,10 @@ Change the color of each nucleosome.
 
 Plot (or not) cluster of nucs
 
+``plot_fuzzy_nucs``
+
+Plot (or not) cluster of fuzzy
+
 ``plot_wp_nuc_model``
 
 Plot (or not) gaussian model for a cluster of nucs
@@ -1549,6 +1652,10 @@ Plot (or not) gaussian model for a cluster of nucs
 
 Plot (or not) aligned reads.
 
+``plot_common_unrs``
+
+Plot (or not) unaligned nucleosomal refgions (UNRs).
+
 ``plot_wp_nucs_4_nonmnase``
 
 Plot (or not) clusters for non inputs samples.
diff --git a/src/DESCRIPTION b/src/DESCRIPTION
index 25cdb4a..bfb95c7 100644
--- a/src/DESCRIPTION
+++ b/src/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: nucleominer
 Maintainer: Florent Chuffart <florent.chuffart@ens-lyon.fr>
 Author: Florent Chuffart
-Version: 2.3.32
+Version: 2.3.33
 License: CeCILL 
 Title: nm
 Depends: seqinr, plotrix, DESeq, cachecache
diff --git a/src/NAMESPACE b/src/NAMESPACE
index da5d5fe..e4f5188 100644
--- a/src/NAMESPACE
+++ b/src/NAMESPACE
@@ -1 +1 @@
-export(flat_aggregated_intra_strain_nucs, FDR, lod_score_vecs, dfadd, filter_tf_inputs, filter_tf_outputs, sign_from_strand, flat_reads, get_comp_strand, aggregate_intra_strain_nucs, align_inter_strain_nucs, translate_roi, fetch_mnase_replicates, substract_region, union_regions, collapse_regions, translate_regions, crop_fuzzy, get_all_reads, get_design, plot_dist_samples, analyse_design, get_sneps, watch_samples, compute_inter_all_strain_curs, switch_pairlist, build_replicates, ARAB2ROM, ROM2ARAB)
+export(flat_aggregated_intra_strain_nucs, FDR, lod_score_vecs, dfadd, filter_tf_inputs, filter_tf_outputs, sign_from_strand, flat_reads, get_comp_strand, aggregate_intra_strain_nucs, align_inter_strain_nucs, translate_roi, fetch_mnase_replicates, substract_region, union_regions, collapse_regions, translate_regions, crop_fuzzy, get_all_reads, get_design, plot_dist_samples, analyse_design, get_sneps, watch_samples, compute_inter_all_strain_curs, switch_pairlist, build_replicates, ARAB2ROM, ROM2ARAB, get_intra_strain_fuzzy, get_unrs)
diff --git a/src/R/nucleominer.R b/src/R/nucleominer.R
index fedfb05..f1fff4a 100644
--- a/src/R/nucleominer.R
+++ b/src/R/nucleominer.R
@@ -876,7 +876,6 @@ config=NULL, ##<< GLOBAL config variable
 roi ##<< The region of interest.
 ) {
   tr_regions = apply(t(1:length(regions[,1])), 2, function(i) {
-    print(i)
     tmp_regions_ref2 = list(name="foo", begin=regions[i,]$lower_bound, end=regions[i,]$upper_bound, chr=as.character(regions[i,]$chr), strain_ref = combi[2])
     big_roi =  roi
     trs_tmp_regions_ref2 = translate_roi(tmp_regions_ref2, combi[1], config = config, big_roi = big_roi)
@@ -1833,8 +1832,10 @@ plot_gaussian_unified_reads = TRUE,  ##<< Plot (or not) gaussian model of a nuc.
 plot_ellipse_nucs = TRUE,  ##<< Plot (or not) ellipse for a nuc.
 change_col = TRUE, ##<< Change the color of each nucleosome.
 plot_wp_nucs = TRUE,  ##<< Plot (or not) cluster of nucs
+plot_fuzzy_nucs = TRUE,  ##<< Plot (or not) cluster of fuzzy
 plot_wp_nuc_model = TRUE,  ##<< Plot (or not) gaussian model for a cluster of nucs
-plot_common_nucs = TRUE,  ##<< Plot (or not) aligned reads.
+plot_common_nucs = FALSE,  ##<< Plot (or not) aligned reads.
+plot_common_unrs = FALSE,  ##<< Plot (or not) unaligned nucleosomal refgions (UNRs).
 plot_wp_nucs_4_nonmnase = FALSE,  ##<< Plot (or not) clusters for non inputs samples.
 plot_chain = FALSE,  ##<< Plot (or not) clusterised nuceosomes between mnase samples.
 aggregated_intra_strain_nucs = NULL, ##<< list of aggregated intra strain nucs. If NULL, it will be computed.
@@ -1865,6 +1866,8 @@ config=NULL ##<< GLOBAL config variable
   axis(2, at=0:(nb_rank_glo*2) * delta_y_glo / (nb_rank_glo*2), labels=c(rep(c(height/2,0),nb_rank_glo),height/2))
   # Go
 	replicates_wp_nucs = list()
+  wp_maps = list()
+  fuzzy_maps = list()
   for (replicate_rank in 1:length(replicates)) {
 		# Computing replicate parameters
 		nb_rank = length(samples)
@@ -1976,7 +1979,7 @@ config=NULL ##<< GLOBAL config variable
 	  }
 
 	  # Plot wp nucs
-		if ((plot_wp_nucs_4_nonmnase | sample$marker == "Mnase_Seq") & (plot_wp_nucs | plot_common_nucs | plot_chain)) {
+		if ((plot_wp_nucs_4_nonmnase | sample$marker == "Mnase_Seq") & (plot_wp_nucs | plot_fuzzy_nucs | plot_common_nucs | plot_chain)) {
 			if (samples[[1]]$marker == "Mnase_Seq") {
 				if (is.null(aggregated_intra_strain_nucs)) {
 	  			wp_nucs = aggregate_intra_strain_nucs(samples)[[1]]
@@ -2028,21 +2031,29 @@ config=NULL ##<< GLOBAL config variable
         text(tmp_x_inter, tmp_y_inter, tmp_lod_inter, srt=90, cex=0.9, bg = "yellow")#, col=(tmp_lod_inter < 20) + 2)
       }
 
-      if (plot_wp_nucs | plot_common_nucs ) {
+      if (plot_wp_nucs | plot_fuzzy_nucs | plot_common_nucs ) {
     		replicates_wp_nucs[[replicate_rank]] = wp_nucs
-  			for (wp_nuc in wp_nucs) {
-  				if (wp_nuc$wp){
-  					rect(sign(x_min) * wp_nuc$lower_bound + shift, y_min, sign(x_min) * wp_nuc$upper_bound + shift, y_max, col=adjustcolor(2, alpha.f = 0.1), border=1)
-  					all_original_reads = c()
-  					for(initial_nuc in wp_nuc$nucs) {
-  						all_original_reads = c(all_original_reads, initial_nuc$original_reads)
-  					}
-  					delta_x = wp_nuc$lower_bound:wp_nuc$upper_bound
-  					if (FALSE) {
-  					  rect(sign(x_min) * wp_nuc$lower_bound + shift, y_min, sign(x_min) * wp_nuc$upper_bound + shift, y_max, col="#EEEEEE", border=1)
-  				  }
-  					if (plot_wp_nuc_model) {
-  					  lines(sign(x_min) * delta_x + shift, dnorm(delta_x, mean(all_original_reads), sd(all_original_reads)) * length(all_original_reads) * height/5 + y_min, col=1)
+        strain = samples[[1]]$strain
+        wp_maps[[strain]] = flat_aggregated_intra_strain_nucs(wp_nucs, "foo")
+        fuzzy_maps[[strain]] = get_intra_strain_fuzzy(wp_maps[[strain]], as.list(samples[[1]]$roi), samples[[1]]$strain, config=config)
+
+        if (plot_fuzzy_nucs) {
+          fuzzy_map = fuzzy_maps[[strain]]
+          rect(sign(x_min) * fuzzy_map$lower_bound + shift, y_min, sign(x_min) * fuzzy_map$upper_bound + shift, y_max, col=adjustcolor(3, alpha.f = 0.1), border=1)        
+        } 
+
+        if (plot_wp_nucs) {
+    			for (wp_nuc in wp_nucs) {
+    				if (wp_nuc$wp){
+    					rect(sign(x_min) * wp_nuc$lower_bound + shift, y_min, sign(x_min) * wp_nuc$upper_bound + shift, y_max, col=adjustcolor(2, alpha.f = 0.1), border=1)
+    					if (plot_wp_nuc_model) {
+      					all_original_reads = c()
+      					for(initial_nuc in wp_nuc$nucs) {
+      						all_original_reads = c(all_original_reads, initial_nuc$original_reads)
+      					}
+      					delta_x = wp_nuc$lower_bound:wp_nuc$upper_bound
+    					  lines(sign(x_min) * delta_x + shift, dnorm(delta_x, mean(all_original_reads), sd(all_original_reads)) * length(all_original_reads) * height/5 + y_min, col=1)
+    				  }
   				  }
   				}
   			}
@@ -2051,51 +2062,200 @@ config=NULL ##<< GLOBAL config variable
 	}
 
 	if (plot_common_nucs) {
-		if (is.null(aligned_inter_strain_nucs)) {
-			aligned_inter_strain_nucs = align_inter_strain_nucs(replicates, replicates_wp_nucs[[1]], replicates_wp_nucs[[2]], config=config)[[1]]
-		}
-		if (plot_common_nucs) {
-      #Plot common wp nucs
-      mid_y = shift = x_min = x_max = nb_rank = base = ylim = ymin = y_max = delta_y = list()
-            for (replicate_rank in 1:length(replicates)) {
-        nb_rank[[replicate_rank]] = length(samples)
-        base[[replicate_rank]] = (replicate_rank-1) * height * nb_rank[[replicate_rank]]
-        ylim[[replicate_rank]] = c(base[[replicate_rank]], base[[replicate_rank]] + height * nb_rank[[replicate_rank]])
-        y_min[[replicate_rank]] = min(ylim[[replicate_rank]])
-        y_max[[replicate_rank]] = max(ylim[[replicate_rank]])
-        delta_y[[replicate_rank]] = y_max[[replicate_rank]] - y_min[[replicate_rank]]
-        mid_y[[replicate_rank]] = (y_max[[replicate_rank]] + y_min[[replicate_rank]]) / 2
+    if (is.null(aligned_inter_strain_nucs)) {
+      aligned_inter_strain_nucs = align_inter_strain_nucs(replicates, replicates_wp_nucs[[1]], replicates_wp_nucs[[2]], config=config)[[1]]
+      aligned_inter_strain_nucs$roi_index = "foo" 
+    }
 
-        samples = replicates[[replicate_rank]]
-        for (sample_rank in 1:length(samples)) {
-          sample = samples[[sample_rank]]
-          y_lev = y_min[[replicate_rank]] + (sample_rank - 0.5) * delta_y[[replicate_rank]]/nb_rank[[replicate_rank]]
-          if (sample$roi[["begin"]] < sample$roi[["end"]]) {
-            x_min[[replicate_rank]] = sample$roi[["begin"]]
-            x_max[[replicate_rank]] = sample$roi[["end"]]
-          } else {
-            x_min[[replicate_rank]] = - sample$roi[["begin"]]
-            x_max[[replicate_rank]] = - sample$roi[["end"]]
-          }
-          shift[[replicate_rank]] = x_min[[1]] - x_min[[replicate_rank]]
+    #Plot common wp nucs
+    mid_y = shift = x_min = x_max = nb_rank = base = ylim = ymin = y_max = delta_y = list()
+    for (replicate_rank in 1:length(replicates)) {
+      nb_rank[[replicate_rank]] = length(samples)
+      base[[replicate_rank]] = (replicate_rank-1) * height * nb_rank[[replicate_rank]]
+      ylim[[replicate_rank]] = c(base[[replicate_rank]], base[[replicate_rank]] + height * nb_rank[[replicate_rank]])
+      y_min[[replicate_rank]] = min(ylim[[replicate_rank]])
+      y_max[[replicate_rank]] = max(ylim[[replicate_rank]])
+      delta_y[[replicate_rank]] = y_max[[replicate_rank]] - y_min[[replicate_rank]]
+      mid_y[[replicate_rank]] = (y_max[[replicate_rank]] + y_min[[replicate_rank]]) / 2
+
+      samples = replicates[[replicate_rank]]
+      for (sample_rank in 1:length(samples)) {
+        sample = samples[[sample_rank]]
+        y_lev = y_min[[replicate_rank]] + (sample_rank - 0.5) * delta_y[[replicate_rank]]/nb_rank[[replicate_rank]]
+        if (sample$roi[["begin"]] < sample$roi[["end"]]) {
+          x_min[[replicate_rank]] = sample$roi[["begin"]]
+          x_max[[replicate_rank]] = sample$roi[["end"]]
+        } else {
+          x_min[[replicate_rank]] = - sample$roi[["begin"]]
+          x_max[[replicate_rank]] = - sample$roi[["end"]]
         }
+        shift[[replicate_rank]] = x_min[[1]] - x_min[[replicate_rank]]
       }
-      for (inter_strain_nuc_index in 1:length(aligned_inter_strain_nucs[,1])) {
-        inter_strain_nuc = aligned_inter_strain_nucs[inter_strain_nuc_index,]
-        tmp_xs = tmp_ys = c()
-        for (replicate_rank in 1:length(replicates)) {
-          samples = replicates[[replicate_rank]]
-          strain = samples[[1]]$strain
-          tmp_xs = c(tmp_xs, sign(x_min[[replicate_rank]]) * (inter_strain_nuc[[paste("lower_bound_",strain,sep="")]] + inter_strain_nuc[[paste("upper_bound_",strain,sep="")]])/2 + shift[[replicate_rank]])
-          tmp_ys = c(tmp_ys, mid_y[[replicate_rank]])
-        }
-        lines(tmp_xs, tmp_ys, col=2, type="b", lwd=dev.size()[1]*100/(x_max[[1]]-x_min[[1]]), cex=dev.size()[1]*200/(x_max[[1]]-x_min[[1]]), pch=19)
+    }
+    for (inter_strain_nuc_index in 1:length(aligned_inter_strain_nucs[,1])) {
+      inter_strain_nuc = aligned_inter_strain_nucs[inter_strain_nuc_index,]
+      tmp_xs = tmp_ys = c()
+      for (replicate_rank in 1:length(replicates)) {
+        samples = replicates[[replicate_rank]]
+        strain = samples[[1]]$strain
+        tmp_xs = c(tmp_xs, sign(x_min[[replicate_rank]]) * (inter_strain_nuc[[paste("lower_bound_",strain,sep="")]] + inter_strain_nuc[[paste("upper_bound_",strain,sep="")]])/2 + shift[[replicate_rank]])
+        tmp_ys = c(tmp_ys, mid_y[[replicate_rank]])
       }
-		}
+      lines(tmp_xs, tmp_ys, col=2, type="b", lwd=dev.size()[1]*100/(x_max[[1]]-x_min[[1]]), cex=dev.size()[1]*200/(x_max[[1]]-x_min[[1]]), pch=19)
+    }
+    
+    if (plot_common_unrs) {
+      combi = c(replicates[[1]][[1]]$strain, replicates[[2]][[1]]$strain)
+      roi = as.list(samples[[1]]$roi)
+      roi_index = "foo"
+      common_nuc_results = list()
+      common_nuc_results[[paste(combi[1], combi[2], sep="_")]] = aligned_inter_strain_nucs
+      unrs = get_unrs(combi, roi, roi_index, wp_maps, fuzzy_maps, common_nuc_results, config = config) 
+      rect(sign(x_min[[1]]) * unrs$lower_bound + shift[[1]], y_min[[1]], sign(x_min[[1]]) * unrs$upper_bound + shift[[1]], y_max[[2]], col=adjustcolor(4, alpha.f = 0.3), border=1)        
+    }
+
 	}
   return(returned_list)
 }
 
 
 
+get_intra_strain_fuzzy = function(# Compute the fuzzy list for a given strain.
+### This function grabs the nucleosomes detxted by template_filter that have been rejected bt aggregate_intra_strain_nucs as well positions.
+wp_maps, ##<< Well positionned nucleosomes map.
+roi, ##<< The region of interest.
+strain, ##<< The strain we want to extracvt the fuzzy map.
+config=NULL ##<< GLOBAL config variable.
+) {
+  fuzzy_map = wp_map[wp_map$wp==0, ]
+  if (nrow(fuzzy_map) > 0) {
+    fuzzy_map = substract_region(fuzzy_map, wp_map[wp_map$wp==1,])
+    if (!is.null(fuzzy_map)) {
+      fuzzy_map = union_regions(fuzzy_map)
+      fuzzy_map = crop_fuzzy(fuzzy_map, roi, strain, config)
+    }
+  }
+  return(fuzzy_map)
+}
+
+
+
+
+
+get_unrs = function(# Compute the unaligned nucleosomal regions (UNRs).
+### This function aggregate non common wp nucs for each strain and substract common wp nucs. It does not take care about the size of the resulting UNR. It will be take into account in the count read part og the pipeline.
+combi, ##<< The strain combination to consider.
+roi, ##<< The region of interest.
+roi_index, ##<< The region of interest index.
+wp_maps, ##<< Well positionned nucleosomes maps.
+fuzzy_maps, ##<< Fuzzy nucleosomes maps.
+common_nuc_results, ##<< Common wp nuc maps
+config=NULL ##<< GLOBAL config variable
+) {
+  print(roi_index)
+
+  tmp_combi_key = paste(combi[1], combi[2], sep="_")
+  tmp_common_nucs = common_nuc_results[[tmp_combi_key]]
+  tmp_common_nucs = tmp_common_nucs[tmp_common_nucs$roi_index == roi_index, ]
+
+  print(paste("Dealing with unr from", combi[1]))
+  tmp_fuzzy = fuzzy_maps[[combi[1]]]
+  tmp_fuzzy = tmp_fuzzy[tmp_fuzzy$roi_index == roi_index, ]
+  tmp_wp = wp_maps[[combi[1]]]
+  tmp_wp = tmp_wp[tmp_wp$wp==1,]
+  tmp_wp = tmp_wp[tmp_wp$roi_index == roi_index, ]
+  # Let's go!
+  tmp_index = unlist(apply(t(tmp_wp$index_nuc), 2, function(index_nuc) {
+    if (index_nuc %in% tmp_common_nucs[[paste("index_nuc", combi[1], sep="_")]]) {
+      return(NULL)
+    } else {
+      return (index_nuc)
+    }
+  }))
+  tmp_unaligned_wp = tmp_wp[tmp_wp$index_nuc %in% tmp_index, ]
+  tmp_unr = rbind(tmp_fuzzy,tmp_unaligned_wp[,1:4])
+  if (length(tmp_unr) != 0) {
+    tmp_unr = union_regions(tmp_unr)
+  }
+  tmp_unr_nucs_1 = tmp_unr
+  if (length(tmp_unr_nucs_1[,1]) == 0) {return(NULL)}
+  agg_unr_1 = tmp_unr_nucs_1
+
+  print(paste("Dealing with unr from ", combi[2]))
+  tmp_fuzzy = fuzzy_maps[[combi[2]]]
+  tmp_fuzzy = tmp_fuzzy[tmp_fuzzy$roi_index == roi_index, ]
+  tmp_wp = wp_maps[[combi[2]]]
+  tmp_wp = tmp_wp[tmp_wp$wp==1,]
+  tmp_wp = tmp_wp[tmp_wp$roi_index == roi_index, ]
+  # Let's go!
+  tmp_index = unlist(apply(t(tmp_wp$index_nuc), 2, function(index_nuc) {
+    if (index_nuc %in% tmp_common_nucs[[paste("index_nuc", combi[2], sep="_")]]) {
+      return(NULL)
+    } else {
+      return (index_nuc)
+    }
+  }))
+  tmp_unaligned_wp = tmp_wp[tmp_wp$index_nuc %in% tmp_index, ]
+  tmp_unr = rbind(tmp_fuzzy,tmp_unaligned_wp[,1:4])
+  if (length(tmp_unr) != 0) {
+    tmp_unr = union_regions(tmp_unr)
+  }
+  tmp_unr_nucs_2 = tmp_unr
+  if (length(tmp_unr_nucs_2[,1]) == 0) {return(NULL)}
+  agg_unr_2 = crop_fuzzy(tmp_unr_nucs_2, roi, combi[2], config)
+  tr_agg_unr_2 = translate_regions(agg_unr_2, combi, roi_index, roi=roi, config=config)
+  tr_agg_unr_2 = union_regions(tr_agg_unr_2)
+
+  print("Dealing with unr from both...")
+  all_unr = union_regions(rbind(agg_unr_1, tr_agg_unr_2))
+
+  print(paste("Dealing with wp from", combi[1]))
+  tmp_wp = wp_maps[[combi[1]]]
+  tmp_wp = tmp_wp[tmp_wp$wp==1,]
+  tmp_wp = tmp_wp[tmp_wp$roi_index == roi_index, ]
+  # Let's go!
+  tmp_index = unlist(apply(t(tmp_wp$index_nuc), 2, function(index_nuc) {
+    if (index_nuc %in% tmp_common_nucs[[paste("index_nuc", combi[1], sep="_")]]) {
+      return (index_nuc)
+    } else {
+      return(NULL)
+    }
+  }))
+  wp_nucs_1 = tmp_wp[tmp_wp$index_nuc %in% tmp_index, ]
+  
+  print(paste("Dealing with wp from", combi[2]))
+  tmp_wp = wp_maps[[combi[2]]]
+  tmp_wp = tmp_wp[tmp_wp$wp==1,]
+  tmp_wp = tmp_wp[tmp_wp$roi_index == roi_index, ]
+  # Let's go!
+  tmp_index = unlist(apply(t(tmp_wp$index_nuc), 2, function(index_nuc) {
+    if (index_nuc %in% tmp_common_nucs[[paste("index_nuc", combi[2], sep="_")]]) {
+      return (index_nuc)
+    } else {
+      return(NULL)
+    }
+  }))
+  wp_nucs_2 = tmp_wp[tmp_wp$index_nuc %in% tmp_index, ]
+  wp_nucs_2 = crop_fuzzy(wp_nucs_2, roi, combi[2], config)
+  if (nrow(wp_nucs_2) == 0) {
+    tr_wp_nucs_2 = wp_nucs_2
+  } else {
+    tr_wp_nucs_2 = translate_regions(wp_nucs_2, combi, roi_index, roi=roi, config=config)      
+  }
+
+  print("Dealing with wp from both...")
+  all_wp = union_regions(rbind(wp_nucs_1[,1:4], tr_wp_nucs_2))
+
+  print("Dealing with unr and wp...")
+  non_inter_unr = substract_region(all_unr, all_wp)
+  non_inter_unr = crop_fuzzy(non_inter_unr, roi, combi[1], config)
+  if (is.null(non_inter_unr)) { return(NULL) }
+  non_inter_unr$len = non_inter_unr$upper_bound - non_inter_unr$lower_bound
+  # non_inter_fuzzy = non_inter_fuzzy[non_inter_fuzzy$len >= min_fuzz_width,]
+
+  non_inter_unr$index_nuc = 1:length(non_inter_unr[,1])
+  return (non_inter_unr)
+}
+
+
 
