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

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to