[Bioc-sig-seq] IRanges runmean Arithmetic Precision

Martin Morgan mtmorgan at fhcrc.org
Mon Feb 14 14:24:41 CET 2011


On 02/13/2011 07:00 PM, Dario Strbenac wrote:
> Hi,
> 
> We've noticed that using runmean on Rles with all elements being a mix of positive or zero numbers sometimes results in some very small negative numbers. Is it possible for it to be exactly zero ?
> 
>> cvg
> 'numeric' Rle of length 199432144 with 1495580 runs
>   Lengths:             35100                35 ...                18
>   Values :                 0 0.750447078847223 ... 0.750447078847223
>> negs <- which(cvg < 0)
>> negs
> integer(0)
>> smCvg <- IRanges::runmean(cvg, 1001, endrule = "constant")
>> negs <- which(smCvg < 0)
>> smCvg[head(negs)]
> 'numeric' Rle of length 6 with 1 run
>   Lengths:                     6
>   Values : -1.56163238628593e-16

Not that there couldn't be improvements in numerical precision of
runmean, but this is a realization of R FAQ 7.31

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

See also ?signif.

Martin

> 
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: x86_64-unknown-linux-gnu (64-bit)
> 
> locale:
>  [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
>  [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
>  [5] LC_MONETARY=C              LC_MESSAGES=en_AU.UTF-8   
>  [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
> [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       
> 
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
> 
> other attached packages:
>  [1] aroma.affymetrix_1.7.0             aroma.apd_0.1.7                   
>  [3] affxparser_1.22.0                  R.huge_0.2.0                      
>  [5] aroma.core_1.7.0                   aroma.light_1.18.0                
>  [7] matrixStats_0.2.2                  R.rsp_0.4.0                       
>  [9] R.cache_0.3.0                      R.filesets_0.9.0                  
> [11] digest_0.4.2                       R.utils_1.5.3                     
> [13] R.oo_1.7.4                         R.methodsS3_1.2.1                 
> [15] BSgenome.Hsapiens.UCSC.hg18_1.3.16 BSgenome_1.18.3                   
> [17] Biostrings_2.18.2                  GenomicRanges_1.2.3               
> [19] IRanges_1.8.9                     
> 
> loaded via a namespace (and not attached):
> [1] Biobase_2.10.0 tools_2.12.0  
> 
> 
> 
> --------------------------------------
> Dario Strbenac
> Research Assistant
> Cancer Epigenetics
> Garvan Institute of Medical Research
> Darlinghurst NSW 2010
> Australia
> 
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioc-sig-sequencing mailing list