Closed gaow closed 4 years ago
@pcarbo sorry but would you provide me a minimal working example you had for reproducing this issue?
@gaow Here is a minimal working example:
library(mvtnorm)
library(susieR)
ns <- 1000
n <- 1000
b <- c(0,1,1,0,0)
S <- rbind(c( 1, 0.99, 0.7, 0.7, 0.9),
c(0.99, 1, 0.7, 0.7, 0.9),
c( 0.7, 0.7, 1, 0.99, 0.8),
c( 0.7, 0.7, 0.99, 1, 0.8),
c( 0.9, 0.9, 0.8, 0.8, 1))
set.seed(1)
X <- rmvnorm(n,sigma = S)
y <- drop(X %*% b + 3*rnorm(n))
fit <- susie(X,y,L = 5,s_init = susie_init_coef(5:1,rep(1,5),5))
susie_get_cs(fit)
round(fit$alpha,digits = 2)
Using susieR 0.9.0.580, I got:
> susie_get_cs(fit)
$cs
$cs[[1]]
[1] 3 4
$cs[[2]]
[1] 1 2
$coverage
[1] 0.95
> round(fit$alpha,digits = 2)
[,1] [,2] [,3] [,4] [,5]
[1,] 0.20 0.20 0.20 0.20 0.2
[2,] 0.20 0.20 0.20 0.20 0.2
[3,] 0.00 0.00 0.78 0.22 0.0
[4,] 0.20 0.20 0.20 0.20 0.2
[5,] 0.22 0.78 0.00 0.00 0.0
But I don't see how I can use this output to map the CSs to the rows of fit$alpha
. Did I do the right thing?
@pcarbo I see. We typically dont do that additionally step with susie_get_cs
that does not factor in purity. eg below works:
> fit <- susie(X,y,L = 5,s_init = susie_init_coef(5:1,rep(1,5),5))
> fit$sets
$cs
$cs$L3
[1] 3 4
$cs$L5
[1] 1 2
$purity
min.abs.corr mean.abs.corr median.abs.corr
L3 0.9906903 0.9953452 0.9953452
L5 0.9897910 0.9948955 0.9948955
$cs_index
[1] 3 5
$coverage
[1] 0.95
I just pushed a patch though to fix the case when the function is called without purity filter:
> fit <- susie(X,y,L = 5,s_init = susie_init_coef(5:1,rep(1,5),5))
> susie_get_cs(fit)
$cs
$cs$L3
[1] 3 4
$cs$L5
[1] 1 2
$coverage
[1] 0.95
Adding rownames to alpha
requires changing the saved results of unit testing. I postpone it to #93 . Please close this ticket as you see fit.
@gaow It is looking good now. Thanks.
Adding rownames to alpha requires changing the saved results of unit testing.
Or you could ignore the row and column names in your unit tests.
Here is output of
susie_get_cs
on one example we have:but clearly
L2
should correspond to the 5th effect where variable 3 and 4 should be in the CS, as one can tell fromfit$alpha
. So it should read$cs$L5
not currentlycs$L2
.Also related to #93
fit$alpha
should also have row and column names when applicable.