BUG: median(IRanges::Rle(NA), na.rm=TRUE)) should return NA
1
0
Entering edit mode
Malcolm Cook ★ 1.6k
@malcolm-cook-6293
Last seen 1 day ago
United States
A little further sleuthing suggests that perhaps the more general issues is that > Rle()[FALSE] Error in Rle()[FALSE] : subscript out of bounds # but > vector()[FALSE][NA] [1] NA >-----Original Message----- >From: Cook, Malcolm >Sent: Wednesday, September 04, 2013 9:28 AM >To: 'bioconductor at r-project.org'; 'Hervé Pagès'; 'lawrence.michael at gene.com' >Cc: Chen, Guangbo; Johnston, Jeffrey >Subject: BUG: median(IRanges::Rle(NA),na.rm=TRUE)) should return NA > >Hi, > >I think the Rle functions should preserve semantics from stats. > >Here is at least one case where they do not: > >> median(Rle(NA),na.rm=TRUE) >Error in x[FALSE] : subscript out of bounds > ># but: > >> median(c(NA),na.rm=TRUE) >[1] NA > ># some other border cases: > >> median(c()) >NULL ># arguably correct, if you read the docs and appreciate that as(NA,class(c())) is NULL > >> median(Rle()) >Error in x[FALSE] : subscript out of bounds ># should probably be NULL > > >Agreed? > >Can be fixed? > >Thanks! > >~ Malcolm Cook >Computational Biology / Shilatifard Lab - Stowers Institute for Medical Research - Kansas City >
• 701 views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 1 day ago
Seattle, WA, United States
Hi Malcolm, Thanks for reporting this. A fix is on its way (in IRanges 1.19.30, will be in devel). With this version: > Rle()[FALSE] logical-Rle of length 0 with 0 runs Lengths: Values : More generally, most Vector derivatives now support subsetting by a logical vector longer than 'x' as long as all the out of bounds subscript elements are FALSE: > IRanges(1:2, 4)[c(FALSE, TRUE, FALSE)] IRanges of length 1 start end width [1] 2 4 3 With this change: > median(Rle(NA), na.rm=TRUE) [1] NA and: > median(Rle(integer(0))) [1] NA # NA_integer_ > median(Rle(logical(0))) [1] NA # logical NA > median(Rle()) [1] NA # logical NA The reason the last one returns a logical NA is because the 'Rle()' call is equivalent to 'Rle(logical(0))'. Cheers, H. On 09/04/2013 07:53 AM, Cook, Malcolm wrote: > A little further sleuthing suggests that perhaps the more general issues is that > >> Rle()[FALSE] > Error in Rle()[FALSE] : subscript out of bounds > # but >> vector()[FALSE][NA] > [1] NA > > > > >-----Original Message----- > >From: Cook, Malcolm > >Sent: Wednesday, September 04, 2013 9:28 AM > >To: 'bioconductor at r-project.org'; 'Hervé Pagès'; 'lawrence.michael at gene.com' > >Cc: Chen, Guangbo; Johnston, Jeffrey > >Subject: BUG: median(IRanges::Rle(NA),na.rm=TRUE)) should return NA > > > >Hi, > > > >I think the Rle functions should preserve semantics from stats. > > > >Here is at least one case where they do not: > > > >> median(Rle(NA),na.rm=TRUE) > >Error in x[FALSE] : subscript out of bounds > > > ># but: > > > >> median(c(NA),na.rm=TRUE) > >[1] NA > > > ># some other border cases: > > > >> median(c()) > >NULL > ># arguably correct, if you read the docs and appreciate that as(NA,class(c())) is NULL > > > >> median(Rle()) > >Error in x[FALSE] : subscript out of bounds > ># should probably be NULL > > > > > >Agreed? > > > >Can be fixed? > > > >Thanks! > > > >~ Malcolm Cook > >Computational Biology / Shilatifard Lab - Stowers Institute for Medical Research - Kansas City > > > -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpages at fhcrc.org Phone: (206) 667-5791 Fax: (206) 667-1319
ADD COMMENT

Login before adding your answer.

Traffic: 663 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6