chr1swallace/coloc

Bug in code to set up sample size argument to pass to susie_rss

Opened this issue · 1 comments

It looks like the code you introduced to add the sample size to the susie arguments has a bug i.e. this code in susie.R:

while(!converged) {
   message("running max iterations: ",maxit)
   ## at 0.12.6 susieR introduced need for n = sample size
   susie_args=c(list(n=d$N), susie_args)
   res=do.call(susie_rss,
               c(list(z=z, R=LD, max_iter=maxit), susie_args))
   converged=res$converged; #s_init=res; maxit=maxit*2
   message("\tconverged: ",converged)
   if(!converged && repeat_until_convergence==FALSE)
     stop("susie_rss() did not converge in ",maxit," iterations. Try running with run_until_convergence=TRUE")
   if(!converged)
     maxit=maxit * 100 # no point in half measures!
 }

The line

susie_args=c(list(n=d$N), susie_args)

needs to be outside the while loop otherwise if susie_rss does not converge the first time then next time round the loop another n gets appended to the susie_args and susie bombs out with this error:

Error in (function (z, R, n, bhat, shat, var_y, z_ld_weight = 0, estimate_residual_variance = FALSE,  : 
  formal argument "n" matched by multiple actual arguments

So any dataset that doesn't converge on the first set of iterations fails.

I wondered why I was getting so few results back.

@chr1swallace This issue was already fixed (in commit 7646f8c) so this issue can be closed.