stephenslab / susieR

R package for "sum of single effects" regression.
https://stephenslab.github.io/susieR
Other
172 stars 43 forks source link

Error when following vignette for fine-mapping with sumstats #167

Closed dtaylo95 closed 2 years ago

dtaylo95 commented 2 years ago

Hi. I'm trying to follow this vignette and I'm running into issues when running susie_rss. When I run the code that appears in the vignette:

data(N3finemapping)
attach(N3finemapping)

n <- nrow(X)
sumstats <- univariate_regression(X, Y[,1])
z_scores <- sumstats$betahat / sumstats$sebetahat
R <- cor(X)

fitted_rss1 <- susie_rss(
    bhat=sumstats$betahat,
    shat=sumstats$sebetahat, 
    n=n, 
    R=R, 
    var_y = var(Y[,1]), 
    L=10, 
    estimate_residual_variance=TRUE
)

I get the following error:

Error in susie_rss(bhat = sumstats$betahat, shat = sumstats$sebetahat,  :
  argument "z" is missing, with no default
Execution halted

So, I can replace the bhat and shat arguments with z=s_scores, but then I get the following error:

Error in susie_suff_stat(XtX = R, Xty = z, n = 2, yty = 1, scaled_prior_variance = prior_variance,  :
  formal argument "n" matched by multiple actual arguments
Calls: susie_rss
Execution halted

If I remove the n argument, I get the same error with the estimated_residual_variance argument. If I remove that as well, susie_rss successfully runs, but I'm wondering if I should be concerned that I am not explicitly defining those arguments (especially as it looks like the n parameter passed to susie_suff_stat is n=2).

Thanks for any feedback you're able to offer!

gaow commented 2 years ago

@dtaylo95 i see a syntax error here:

    shat=sumstats$sebetahat=z_scores, 

perhaps that's what caused it?

dtaylo95 commented 2 years ago

@gaow Thanks for your prompt reply. I actually must have copied the code incorrectly here. I just edited the initial issue with the code that I actually ran, and it is indeed still not working.

pcarbo commented 2 years ago

@dtaylo95 Please make sure you using the latest version of susieR available from CRAN or GitHub.

dtaylo95 commented 2 years ago

That worked, I had thought I had the latest version. My mistake, and thank you so much!

bschilder commented 2 years ago

Just to summarise, it seems there was a bug in susieR v<12 that caused this error. It has since been fixed in susieRv>=12, so i think the general advice would be to avoid using earlier releases of susieR.

stephens999 commented 2 years ago

i'm not sure it was a bug. We made changes to the susie_rss interface and updated the example, and I think the issue is that the example is then incompatible with older versions of susie_rss that do not have the changes.