stephenslab / susieR

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

Can susie remember variable names when fitting? #116

Closed garyzhubc closed 3 years ago

garyzhubc commented 3 years ago

Can susie remember variable names when fitting? I put in a matrix with column names but the result was using column index to represent columns.

gaow commented 3 years ago

@garyzhubc I'll take a look at this -- somehow I thought we fixed this issue a while ago?

pcarbo commented 3 years ago

@gaow Some outputs have the names, but some do not:

library(susieR)
set.seed(1)
n <- 200
p <- 1000
beta <- rep(0,p)
beta[1:4] <- 1
X <- matrix(rnorm(n*p),nrow = n,ncol = p)
rownames(X) <- paste0("s",1:200)
colnames(X) <- paste0("p",1:1000)
X <- scale(X,center = TRUE,scale = TRUE)
y <- drop(X %*% beta + rnorm(n))
out <- susie(X,y,L = 10)
print(out$mu[1:4,1:4])
print(head(out$pip))
print(head(out$fitted))
#               p1           p2          p3            p4
# [1,]  1.02306649 -0.016982085  0.07386642  0.0744977502
# [2,]  0.06892560 -0.020335022  0.95542887 -0.0288463178
# [3,]  0.06518522 -0.000825135 -0.02704855  0.8963012719
# [4,] -0.01497910  0.903556894 -0.01921886 -0.0008332564
# [1] 1 1 1 1 0 0
# [1]  0.5129161  4.7965839  0.5514453  1.7148172 -2.0064900  0.2176768

It would be nice if both the row and column names of X were preserved in the susie outputs.

gaow commented 3 years ago

This was done in current master

garyzhubc commented 1 year ago

I suppose input label is better than matrix colnames because I'm using bigsnpr_object$genotypes[1:100,100:200], or does this make a difference?