[Bioc-devel] Strange "internal logical NA value has been modified" error

Hervé Pagès hp@ge@@on@g|thub @end|ng |rom gm@||@com
Thu Oct 14 04:53:58 CEST 2021


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 using gmail.com



More information about the Bioc-devel mailing list