This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = GXM | |
filename = paste0(data.dir,"tempo/gcta-run/gxm.grm") | |
ids = rnadata$sidno | |
write_GRMgz = function(X,filename,ids) | |
{ | |
#X[upper.tri(X,diag=TRUE)] | |
rmat = row(X) | |
cmat = col(X) | |
omat = cbind(cmat[upper.tri(cmat,diag=TRUE)],rmat[upper.tri(rmat,diag=TRUE)],ncol(rnamat),X[upper.tri(X,diag=TRUE)]) | |
write_tsv(data.frame(omat),path=filename,col_names = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Relatively fast linear regression | |
fastlm = function(xx,yy) | |
{ | |
## compute betahat (regression coef) and pvalue with Ftest | |
## for now it does not take covariates | |
df1 = 2 | |
df0 = 1 | |
ind = !is.na(xx) & !is.na(yy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# calculate ptrs function | |
calc_ptrs <- function(expr, weights) | |
{ | |
fast_generate_trait(expr, weights) %>% as.data.frame() %>% rownames_to_column(var = "IID") %>% tibble() | |
} | |
fast_generate_trait <- function(expr, weights){ | |
# convert the predicted df into a matrix | |
if(!is.matrix(expr)) test <- expr %>% column_to_rownames(var = "IID") %>% | |
as.matrix() else test <- expr |
OlderNewer