[Bioc-sig-seq] reduce error on RangedData with unused space names

Janet Young jayoung at fhcrc.org
Wed Feb 23 21:15:25 CET 2011


Hi again,

I noticed that "reduce" gives an error on RangedData objects if there are space names that contain no ranges:
	Error in endoapply(x[, by], FUN) : 'FUN' did not produce an endomorphism

I can work around it, but it'd great not to need to do that.  All the details are below.

thanks very much,

Janet

------------------------------------------------------------------- 

Dr. Janet Young (Trask lab)

Fred Hutchinson Cancer Research Center
1100 Fairview Avenue N., C3-168, 
P.O. Box 19024, Seattle, WA 98109-1024, USA.

tel: (206) 667 1471 fax: (206) 667 6524
email: jayoung  ...at...  fhcrc.org

http://www.fhcrc.org/labs/trask/

------------------------------------------------------------------- 



> library(IRanges,warn.conflicts=F)

> myregions_RD <- RangedData(IRanges(start=c(101L,201L,101L,101L),end=c(250L,300L,220L,501L)),space=c("chr1","chr1","chr1","chr2"),strand=c("+","+","+","+")   )

> #### this works
> reduce(myregions_RD)
RangedData with 2 rows and 1 value column across 2 spaces
        space     ranges |      strand
  <character>  <IRanges> | <character>
1        chr1 [101, 300] |           +
2        chr2 [101, 501] |           +

> ### drop regions that are bigger than 300bp (now there's nothing left on chr2)
> myregions_RD <- myregions_RD[which(width(myregions_RD)<=300),]

> ### this doesn't work - reduce doesn't like a space without any elements
> reduce(myregions_RD)
Error in endoapply(x[, by], FUN) : 'FUN' did not produce an endomorphism

> ### workaround - drop the unused space names
> myregions_RD <- RangedData(IRanges(start=start(myregions_RD),end=end(myregions_RD)),space=as.character(space(myregions_RD)),strand=myregions_RD$strand   )

> ### now it works
> reduce(myregions_RD)
RangedData with 1 row and 1 value column across 1 space
        space     ranges |      strand
  <character>  <IRanges> | <character>
1        chr1 [101, 300] |           +

> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] IRanges_1.8.9



More information about the Bioc-sig-sequencing mailing list