DIR="H:/Wenjian/SV-spacc/packages-new/v0.1/" # directory to store package install.packages(paste0(DIR,"SV2bc_0.1.tar.gz"), repos = NULL, type = "source") library(SV2bc) set.seed(1) nsub=1e7; # number of subjects ########### The below is to simulate dataset b0=1 b1=0 # effect size of genotype on secondary phenotype, 0 for null model. maf=0.3 OR.D.X <- 1; # OR value between D (disease status) and X (genotype). If data is simulated based on lin's method, the simulated data follow OR value; if data is simulated based on set-valued model, OR value is slightly biased. OR.D.Y <- 2; # OR value between D (disease status) and Y (secondary phenotype). simu.model="lin" # "lin" or "sv" for lin's method and set-valued model, respectively. sp.type="continuous" # "continuous" or "binary" prev=0.05; gamma.est <- para.est(OR.D.X,OR.D.Y,prev,b0,b1,maf,simu.model,sp.type) g0=gamma.est[1]; g1=gamma.est[2]; g2=gamma.est[3]; data.res <- data.simu(nsub,g0,g1,g2,b0,b1,maf,simu.model,sp.type) D <- data.res[,1]; # disease status for the population n.smp <- 1000; # sample size for either case group or control group. data <- data.res[c(sample(which(D==1),n.smp), sample(which(D==0),n.smp)),] ########### END of data simulation ########### Main function to compute p-value and other parameters SV2bc.test(data,prev,sp.type) # pval.sp should be 0.7117