sipss / GCIMS

Other
3 stars 0 forks source link

find_regions_rip_saturated #21

Closed clarissefm closed 4 months ago

clarissefm commented 4 months ago

Using integratePeaks() (from R/utils-integration.R) , i got the following error : Error in find_regions_rip_saturated(intmat, rip_saturation_threshold = rip_saturation_threshold, : object 'saturation_list' not found.

This occurs in the IF branch, because saturation_list is not created before the if clause, and is used after the if-else.

if (length(rt_rip_saturated_indices) == 0L) {
    rt_saturated_regions <- matrix(nrow = 0L, ncol = 2L)
  } else {
    **saturation_list** <- split(rt_rip_saturated_indices, cumsum(c(1, diff(rt_rip_saturated_indices)) != 1))
    rt_saturated_regions <- matrix(0, nrow = length(**saturation_list**), ncol = 2)
    for (k in seq_along(saturation_list)) {
      rt_saturated_regions[k, 1L] <- min(**saturation_list**[[k]])
      rt_saturated_regions[k, 2L] <- max(**saturation_list**[[k]])
    }
 }
  colnames(rt_saturated_regions) <- c("begin", "end")
  if (!is.null(retention_time)) {
    rt_saturated_regions_s <- matrix(0.0, nrow = length(**saturation_list**), ncol = 2L)
    rt_saturated_regions_s[,1L] <- retention_time[rt_saturated_regions[,1L]]
    rt_saturated_regions_s[,2L] <- retention_time[rt_saturated_regions[,2L]]
    return(rt_saturated_regions_s)
  } else {
    return(rt_saturated_regions)
  }

The solution would be to define it before the if-else branch, could you take an eye on it ? I can do a pull request if necessited. Thank you

zeehio commented 4 months ago

Thanks for the bug report @clarissefm! Feel free to report more if you find them!