HenrikBengtsson / TopDom

R package: TopDom - An efficient and Deterministic Method for identifying Topological Domains in Genomes
https://cran.r-project.org/package=TopDom
20 stars 5 forks source link

BUG: Error in if (x[cp$cp[i]] >= x[cp$cp[i] - 1] && x[cp$cp[i]] >= x[cp$cp[i] + : missing value where TRUE/FALSE needed #4

Closed HenrikBengtsson closed 6 years ago

HenrikBengtsson commented 6 years ago

This happened with real data:

> x <- double(4L)
> TopDom:::Detect.Local.Extreme(x) on entry 
 num [1:4] 0 0 0 0
Error in if (x[cp$cp[i]] >= x[cp$cp[i] - 1] && x[cp$cp[i]] >= x[cp$cp[i] +  : 
  missing value where TRUE/FALSE needed

Debugging TopDom() reveals that:

Process Region #25 from 2565 to 2568
debug: local.ext[start:end] <- Detect.Local.Extreme(x = mean.cf[start:end])
Browse[2]> mean.cf[start:end]
[1] 0 0 0 0
Browse[2]> start:end
[1] 2565 2566 2567 2568
HenrikBengtsson commented 6 years ago

This bug occurred with TopDom 0.0.1:

> x <- double(4L)
> TopDom::legacy("0.0.1")$Detect.Local.Extreme(x)
Error in if (x[cp$cp[i]] >= x[cp$cp[i] - 1] && x[cp$cp[i]] >= x[cp$cp[i] +  : 
  missing value where TRUE/FALSE needed

but was fixed in TopDom 0.0.2:

> TopDom::legacy("0.0.2")$Detect.Local.Extreme(x)
[1] 0 0 0 0

The fix was:

> diffobj::diffDeparse(TopDom::legacy("0.0.2")$Detect.Local.Extreme, TopDom::legacy("0.0.1")$Detect.Local.Extreme)
< TopDom::legacy("0.0.2")$Detect.Local.Extreme                 
> TopDom::legacy("0.0.1")$Detect.Local.Extreme                 
@@ 14,6 / 14,4 @@                                              
      if (length(cp$cp) <= 2)                                  
          return(ret)                                          
<     if (length(cp$cp) == n_bins)                             
<         return(ret)                                          
      for (i in 2:(length(cp$cp) - 1)) {                       
          if (x[cp$cp[i]] >= x[cp$cp[i] - 1] && x[cp$cp[i]] >= 

This is now also fixed in the TopDom package:

> TopDom:::Detect.Local.Extreme(x)
[1] 0 0 0 0

(There was a thinko in the TopDom package causing it to implement the TopDom 0.0.1 version rather than the TopDom 0.0.2 version)