-
Notifications
You must be signed in to change notification settings - Fork 17
/
STAARpipeline_Null_Model_GENESIS.r
39 lines (34 loc) · 1.54 KB
/
STAARpipeline_Null_Model_GENESIS.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
###########################################################
# fit STAAR null model for single-trait analysis
# (using GENESIS package)
# Xihao Li, Zilin Li
# Initiate date: 11/04/2021
# Current date: 06/13/2024
###########################################################
rm(list=ls())
gc()
library(GENESIS)
library(STAAR)
library(STAARpipeline)
###########################################################
# User Input
###########################################################
## Phenotype file
phenotype <- read.csv("/path_to_the_file/pheno.csv")
## (sparse) GRM file
sgrm <- get(load("/path_to_the_file/sGRM.Rdata"))
## file directory for the output file
output_path <- "/path_to_the_output_file/"
## output file name
output_name <- "obj_nullmodel_GENESIS.Rdata"
###########################################################
# Main Function
###########################################################
## fit null model using GENESIS
data_GENESIS <- as(phenotype,"AnnotatedDataFrame") # Make AnnotatedDataFrame (specifically required by GENESIS)
obj_nullmodel_GENESIS <- fitNullModel(data_GENESIS,outcome="LDLadj.norm",
covars=c("age","age2","sex","PC1","PC2","PC3","PC4","PC5","PC6","PC7","PC8","PC9","PC10","study_ethnicity"),
cov.mat=sgrm,group.var="study_ethnicity",AIREML.tol=1e-4,verbose=TRUE)
## convert GENESIS null model to STAAR null model
obj_nullmodel <- genesis2staar_nullmodel(obj_nullmodel_GENESIS)
save(obj_nullmodel,file=paste0(output_path,output_name))