[Bioc-devel] Strange "internal logical NA value has been modified" error
I guess it's a situation where the unit tests were missing to cover an
important situation ("important" as in "it's important that the returned
object be always sorted"). ;-)
Cheers,
H.
On 13/10/2021 17:46, Pariksheet Nanda wrote:
Hi Herv?, On 10/13/21 12:43 PM, Herv? Pag?s wrote:
On 12/10/2021 15:43, Pariksheet Nanda wrote:
The function in question is:
replace_unstranded <- function (gr) {
???? idx <- strand(gr) == "*"
???? if (length(idx) == 0L)
??????????? ^^^^^^^^^^^^^^^^^ Not related to the "internal logical NA value has been modified" error but shouldn't you be doing '!any(idx)' instead of 'length(idx) == 0L' here?
Indeed.? Although in a roundabout way the result somehow satisfied the unit tests, idx is a poor choice of name because it's really a mask, and your suggestion of OR-ing the mask FALSE values with any() is more intuitive.? The name is_unstranded might be less cryptic than mask. Applying your suggestion of the correct condition uncovered a bug where return(gr) was returning the unsorted value, which is inconsistent with the behavior of the final statement returns a sorted value.? So changed to return(sort(gr)) for a consistent contract. Fixed in f6892ea
Best, H.
???????? return(gr) ???? sort(c( ???????? gr[! idx], ???????? `strand<-`(gr[idx], value = "+"), ???????? `strand<-`(gr[idx], value = "-"))) }
Pariksheet
Herv? Pag?s Bioconductor Core Team hpages.on.github at gmail.com