#' @param messages if TRUE, returns messages for the GWAS function
#' @param print if TRUE, results are saved in a CSV
#' @param trait character value for trait name
#' @param rapid this option skips all side options and returns just GWAS results
#' @return Manhatten plot, QQ plot plus p-values, type-1 error and power for every SNP and results in a CSV
GWASapply<- function(pheno=NULL, geno=NULL, Cov=NULL, GM=NULL, PCA.M=3, QTN.position=NULL, cutoff=NULL,plots=FALSE,messages=FALSE,print=FALSE,trait="unknown",rapid=FALSE){
if(rapid==TRUE){
apply_start <- proc.time()
GD=geno
n=nrow(GD)
m=ncol(GD)
CV=Cov[,-1]
y=pheno
PCA=prcomp(GD)
P=apply(GD,2, function(x)
# CHECK FOR GENOTYPE DISTRIBUTION
if(max(x)==min(x)){p=1
P=p[length(p)]
# IF MAX NOT EQUAL TO MIN
}else{
# CHECK FOR DEPENDENCE
# IF NO CV INPUT
if (is.null(CV)){X=cbind(1, PCA$x[,1:PCA.M],x)
# IF THERE IS CV INPUT
}else{fD <- fix_Dep(PCA$x[,1:PCA.M], as.matrix(CV))
# WITH CV INPUT, CONDITION 1: NO DEPENDENCE
if (is.null(fD)){X=cbind(1, PCA$x[,1:PCA.M],as.matrix(CV), x)
# WITH CV INPUT, CONDITION 2: WITH DEPENDENCE
}else {X=cbind(1, PCA$x[,1:PCA.M],x)}
}# END FOR DEPENDECE
# SOLVE THE LINEAR REGRESSION MATRIX:
#  X=as.matrix(X)
LHS=t(X)%*%X
C=solve(LHS)
RHS=t(X)%*%y
b=C%*%RHS
yb=X%*%b
e=y-yb
n=length(y)
ve=sum(e^2)/(n-1)
vt=C*ve
t=b/sqrt(diag(vt))
p=2*(1-pt(abs(t),n-2))
P=p[length(p)]
}# END FOR MAX NOT EQUAL TO MIN
# COLLECT P-VALUES
) #end of appply function for markers
P=t(matrix(P))
P.value=P
order.SNP=order(P.value)
#If cutoff is default, uses Bonferroni
cutoff.final=(ifelse(
is.null(cutoff),
0.05/m,
cutoff
))
sig.SNP <- order.SNP[sort(P.value)<=cutoff.final]
lsnp=length(sig.SNP)
###
zeros=P==0
P[zeros]=1e-20
P=data.frame(P)
GWAS.Results=list(P.value.res=P.value, cutoff.final.res=cutoff.final, sig.SNP.res=sig.SNP, sig.SNP.P.res=P.value[sig.SNP], order.SNP.res=order.SNP)
apply_end <- proc.time()
apply_elapsed <- apply_end[3] - apply_start[3]
if(messages==TRUE){print(paste0("GWASapply ran successfully and took ",as.character(round(apply_elapsed[[1]],2))," seconds"))}
return(GWAS.Results)
}else{
#If messages is true display gwas starting
if(messages==TRUE){print("GWASapply Starting")}
apply_start <- proc.time()
###check and copy input data
GD=geno
n=nrow(GD)
m=ncol(GD)
CV=Cov[,-1]
y=pheno
PCA=prcomp(GD)
if(messages==TRUE){print("Principal Components have been calculated Successfully")}
PCA_results <- summary(PCA)
if(plots==TRUE){print(kable(round(PCA_results$importance[,1:10], 2)))
#Variance Explained
var_exp_plot_data <- data.frame(t(PCA_results$importance)) # I transposed the data to be in long form and coerce to a data.frame for ggplot
names(var_exp_plot_data) <- c("sdev", "var_exp", "cum_var_exp") # rename the columns (because the original rownames has spaces)
var_exp_plot_data$pca_index <- 1:nrow(var_exp_plot_data) # Add a new column that is the integer index of the component
var_exp_plot <- ggplot(data = var_exp_plot_data, aes(x = pca_index, y = var_exp)) +
geom_line() +
geom_point() +
labs(x = "PCA component index", y = "Variance explained", title = "Variance Explained")
#Cumulative Variance Explained
cum_var_exp_plot <- ggplot(data = var_exp_plot_data, aes(x = pca_index, y = cum_var_exp)) +
geom_line() +
geom_point() +
labs(x = "PCA component index", y = "Cumulative Variance explained", title = "Cumulative Variance Explained")
grid.arrange(var_exp_plot, cum_var_exp_plot, nrow = 1, ncol = 2, top = "Variance of Principal Components")
#normal_print(pcav)
# Plotting the first three components
PCA_plot_data <- data.frame(PCA$x)
pca_comp_plot_12 <-
ggplot(data = PCA_plot_data, aes(x = PC1, y = PC2)) +
geom_point()
pca_comp_plot_13 <-
ggplot(data = PCA_plot_data, aes(x = PC1, y = PC3)) +
geom_point()
pca_comp_plot_23 <-
ggplot(data = PCA_plot_data, aes(x = PC2, y = PC3)) +
geom_point()
grid.arrange(pca_comp_plot_12, pca_comp_plot_13, pca_comp_plot_23, nrow = 2, ncol = 2, top = "Principal Components")
if(messages==TRUE){print("Principal Components plots have been printed Successfully")}}
P=apply(GD,2, function(x)
# CHECK FOR GENOTYPE DISTRIBUTION
if(max(x)==min(x)){p=1
P=p[length(p)]
# IF MAX NOT EQUAL TO MIN
}else{
# CHECK FOR DEPENDENCE
# IF NO CV INPUT
if (is.null(CV)){X=cbind(1, PCA$x[,1:PCA.M],x)
# IF THERE IS CV INPUT
}else{fD <- fix_Dep(PCA$x[,1:PCA.M], as.matrix(CV))
# WITH CV INPUT, CONDITION 1: NO DEPENDENCE
if (is.null(fD)){X=cbind(1, PCA$x[,1:PCA.M],CV, x)
# WITH CV INPUT, CONDITION 2: WITH DEPENDENCE
}else {X=cbind(1, PCA$x[,1:PCA.M],x)}
}# END FOR DEPENDECE
# SOLVE THE LINEAR REGRESSION MATRIX:
#  X=as.matrix(X)
LHS=t(X)%*%X
C=solve(LHS)
RHS=t(X)%*%y
b=C%*%RHS
yb=X%*%b
e=y-yb
n=length(y)
ve=sum(e^2)/(n-1)
vt=C*ve
t=b/sqrt(diag(vt))
p=2*(1-pt(abs(t),n-2))
P=p[length(p)]
}# END FOR MAX NOT EQUAL TO MIN
# COLLECT P-VALUES
) #end of appply function for markers
P=t(matrix(P))
P.value=P
order.SNP=order(P.value)
#If cutoff is default, uses Bonferroni; else uses -log(value)
cutoff.final=(ifelse(
is.null(cutoff),
0.05/m,
cutoff
))
if(messages==TRUE){print(paste0("The final cuttoff for a significant p-value is ",as.character(cutoff.final)))}
sig.SNP <- order.SNP[sort(P.value)<=cutoff.final]
lsnp=length(sig.SNP)
minor_allele_freq <- apply(GD, 2, function(x) #Minor allele frequency calculation using Matt McGowan's code
{
allele_freq1 <- (sum(x == 0)*2 + sum(x == 1)) / (sum(!is.na(x)) * 2)
allele_freq2 <- (sum(x == 2)*2 + sum(x == 1)) / (sum(!is.na(x)) * 2)
return(min(allele_freq1, allele_freq2))
})
sig.MAF<-minor_allele_freq[sig.SNP]
if(messages==TRUE){print(paste0(as.character(lsnp), " Significant SNPs were found"))}
###
zeros=P==0
P[zeros]=1e-20
P=data.frame(P)
###Generate Manhattan plot
if (is.null(QTN.position)){
if(plots==TRUE){mp=manhattan_plot(GM,P,cutoff.final,trait=as.character(trait))
knit_print(mp)
if(messages==TRUE){print("Manhattan Plot Printed without QTN")}}
# WITH CV INPUT, CONDITION 2: WITH DEPENDENCE
}else {
###power.fdr.type1error calculation
power.fdr.type1error=NULL
if (!is.null(QTN.position)){
power.fdr.type1error=power.fdr(P.value, QTN.position,cutoff.final)
}
detected=intersect(sig.SNP,QTN.position)
if(length(detected)==0){detected=NULL}
falsePositive=setdiff(sig.SNP, QTN.position)
if(messages==TRUE){print(paste0("QTN's detected with ",as.character(length(detected))," True Positives and ",as.character(length(falsePositive))," False Positives."))}
if(plots==TRUE){ mp=manhattan_plot(GM,P,cutoff.final,QTN.position,falsePositive,detected,trait=as.character(trait))
knit_print(mp)
if(messages==TRUE){print("Manhattan Plot Printed with QTNs and False and True Positives")}}
}
###Generate QQ plot
if(plots==TRUE){qq=qq_plot(GM,P,trait=as.character(trait))
knit_print(qq)
if(messages==TRUE){print("QQ-Plot Printed")}}
#Generate Results and Return
##Create a table of P-values
P.value_df=data.frame(t(P.value))
#Create a table of results
SNP.MAF=data.frame(minor_allele_freq)
sig.table=data.frame(sig.SNP,P.value[sig.SNP],sig.MAF)
sig.table=data.frame(rownames(sig.table),sig.table)
rownames(sig.table) <- c()
colnames(sig.table)=c("SNP ID","SNP Position","P-value","MAF")
#Create out put for all markers and output to CSV
if(print==TRUE){GLM.results = data.frame(GM,P.value_df,rank(P.value_df),SNP.MAF)
colnames(GLM.results)=c("SNP ","Chromosome ","Position ","P value","Order","MAF")
fwrite(GLM.results,file="GLM.results.csv",row.names=FALSE)}
if(messages==TRUE){print("GWASapply results have printed")}
#Returns Values that include false and true positives if QTN are provided
if (!is.null(QTN.position)){
GWAS.Results=list(True.Positive=detected,False.Positive=falsePositive,P.value.res=P.value, cutoff.final.res=cutoff.final, sig.SNP.res=sig.SNP, sig.SNP.P.res=P.value[sig.SNP], sig.SNP.MAF.res=sig.MAF,order.SNP.res=order.SNP, power.fdr.type1error.res=power.fdr.type1error,sig.table=sig.table)
}else{
GWAS.Results=list(P.value.res=P.value, cutoff.final.res=cutoff.final, sig.SNP.res=sig.SNP, sig.SNP.P.res=P.value[sig.SNP],sig.SNP.MAF.res=sig.MAF, order.SNP.res=order.SNP,sig.table=sig.table)
}
apply_end <- proc.time()
apply_elapsed <- apply_end[3] - apply_start[3]
if(messages==TRUE){print(paste0("GWASapply ran successfully and took ",as.character(round(apply_elapsed[[1]],2))," seconds"))}
return(GWAS.Results)
}}
#' Rapid GWAS with PCA
#'
#' @param pheno file with numeric phenotypic values
#' @param geno data.frame with genotype calls coded as 0,1,2.
#' @param Cov numeric data.frame with covariates values
#' @param PCA.M number of principal components to use default is 3
#' @param cutoff  If cutoff is default, uses Bonferroni; 0.05/number of SNPs
#' @return GWAS P-values
GWASapply_rapid<- function(pheno=NULL, geno=NULL, Cov=NULL, PCA.M=3,cutoff=NULL){
GD=geno
n=nrow(GD)
m=ncol(GD)
CV=Cov[,-1]
y=pheno
PCA=prcomp(GD)
P=apply(GD,2, function(x)
# CHECK FOR GENOTYPE DISTRIBUTION
if(max(x)==min(x)){p=1
P=p[length(p)]
# IF MAX NOT EQUAL TO MIN
}else{
# CHECK FOR DEPENDENCE
# IF NO CV INPUT
if (is.null(CV)){X=cbind(1, PCA$x[,1:PCA.M],x)
# IF THERE IS CV INPUT
}else{fD <- fix_Dep(PCA$x[,1:PCA.M], as.matrix(CV))
# WITH CV INPUT, CONDITION 1: NO DEPENDENCE
if (is.null(fD)){X=cbind(1, PCA$x[,1:PCA.M],as.matrix(CV), x)
# WITH CV INPUT, CONDITION 2: WITH DEPENDENCE
}else {X=cbind(1, PCA$x[,1:PCA.M],x)}
}# END FOR DEPENDECE
# SOLVE THE LINEAR REGRESSION MATRIX:
LHS=t(X)%*%X
C=solve(LHS)
RHS=t(X)%*%y
b=C%*%RHS
yb=X%*%b
e=y-yb
n=length(y)
ve=sum(e^2)/(n-1)
vt=C*ve
t=b/sqrt(diag(vt))
p=2*(1-pt(abs(t),n-2))
P=p[length(p)]
}# END FOR MAX NOT EQUAL TO MIN
# COLLECT P-VALUES
) #end of appply function for markers
P=t(matrix(P))
P.value=P
GWAS.Results=list(P.value.res=P.value)
return(GWAS.Results)
}
gt_scan1 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric1.txt", header = T, stringsAsFactors = F, sep = "\t", nrows = 1))
classes1 <- sapply(gt_scan1, class)
genotypes1 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric1.txt", header = T, row.names = 1, colClasses = classes, stringsAsFactors = F, sep = "\t"))
#import genetic map, phenotypes, and covariates
GM1 <- read.table("GAPIT_Tutorial_Data/mdp_SNP_information1.txt", header = T, stringsAsFactors = F, sep = "\t")
#run replicate
garapid1=replicate(30,{
mySim=G2P(genotypes1, h2, alpha, NQTN, distribution)
#start time for function
loop_start <- proc.time()
p6_rep=GWASapply_rapid(mySim$y,genotypes1,CV,GM1,PCA.M = 3)
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#power calculations
p6_power=power.fdr(p6_rep$P.value.res,mySim$QTN.position)
p6_pwr=mean(p6_power$power)
p6_fdr=mean(p6_power$fdr)
FalP=length(p6_power$FP.fdr.power)
TruP=length(p6_power$TP.fdr.power)
pwr.fdr=c(p6_pwr,p6_fdr,loop_elapsed,FalP,TruP)
#timet=c(loop_elapsed[[1]])
})
means1=rowMeans(garapid1)
out8 <- rbind(means1[1],means1[2],means1[3],means1[4],means1[5])
out8 <- as.data.frame(out8)
colnames(out8) <- c("GWASapply Average")
rownames(out8) <-c("Power","FDR","Seconds","False Positive","True Postive")
#write map and numeric genotype files compatible with BLINK
myGM1=GM1
colnames(myGM1)=c("rs","chr","pos")
write.table(t(genotypes1),file="myData1.dat",quote=F,sep="\t",col.name=F,row.name=F)
write.table(myGM1,file="myData1.map",quote=F,sep="\t",col.name=T,row.name=F)
colnames(CV)=c("taxa","CV1","CV2")
write.table(CV,file="myData1.cov",quote=F,sep="\t",col.name=T,row.name=F)
#run replicate
blinkrep1=replicate(30,{
mySim=G2P(genotypes1, h2, alpha, NQTN, distribution)
myY=cbind(rownames(mySim$y),mySim$y)
colnames(myY)=c("taxa","Sim")
write.table(myY,file="myData1.txt",quote=F,sep="\t",col.name=T,row.name=F)
#start time for function
loop_start <- proc.time()
system("blink --file myData1 --numeric --gwas")
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#read in results
blink.p <- read.table("Sim_GWAS_result.txt", header = T, stringsAsFactors = F, sep = "\t")
p=t(blink.p$p_value)
#power calculations
p6_blink=power.fdr(p, QTN.position=mySim$QTN.position,cutoff=NULL)
p6_pwr_blink=mean(p6_blink$power)
p6_fdr_blink=mean(p6_blink$fdr)
FalP=length(p6_blink$FP.fdr.power)
TruP=length(p6_blink$TP.fdr.power)
pwr.fdr=c(p6_pwr_blink,p6_fdr_blink,loop_elapsed,FalP,TruP)
})
means1=rowMeans(blinkrep1)
out9 <- rbind(means1[1],means1[2],means1[3],means1[4],means1[5])
out9 <- as.data.frame(out9)
colnames(out9) <- c("Blink Average")
rownames(out9) <-c("Power","FDR","Seconds","False Positive","True Postive")
kable(out9)
out2=data.frame(out8,out9)
#output results
kable(out2)
#run replicate
garapid2=replicate(30,{
mySim=G2P(genotypes2, h2, alpha, NQTN, distribution)
#start time for function
loop_start <- proc.time()
p6_rep=GWASapply_rapid(mySim$y,genotypes2,CV,PCA.M = 3)
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#power calculations
p6_power=power.fdr(p6_rep$P.value.res,mySim$QTN.position)
p6_pwr=mean(p6_power$power)
p6_fdr=mean(p6_power$fdr)
FalP=length(p6_power$FP.fdr.power)
TruP=length(p6_power$TP.fdr.power)
pwr.fdr=c(p6_pwr,p6_fdr,loop_elapsed,FalP,TruP)
#timet=c(loop_elapsed[[1]])
})
gt_scan2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, stringsAsFactors = F, sep = "\t", nrows = 1))
classes2 <- sapply(gt_scan2, class)
genotypes2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, row.names = 1, colClasses = classes, stringsAsFactors = F, sep = "\t"))
#import genetic map, phenotypes, and covariates
GM2 <- read.table("GAPIT_Tutorial_Data/mdp_SNP_information2.txt", header = T, stringsAsFactors = F, sep = "\t")
#run replicate
garapid2=replicate(30,{
mySim=G2P(genotypes2, h2, alpha, NQTN, distribution)
#start time for function
loop_start <- proc.time()
p6_rep=GWASapply_rapid(mySim$y,genotypes2,CV,PCA.M = 3)
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#power calculations
p6_power=power.fdr(p6_rep$P.value.res,mySim$QTN.position)
p6_pwr=mean(p6_power$power)
p6_fdr=mean(p6_power$fdr)
FalP=length(p6_power$FP.fdr.power)
TruP=length(p6_power$TP.fdr.power)
pwr.fdr=c(p6_pwr,p6_fdr,loop_elapsed,FalP,TruP)
#timet=c(loop_elapsed[[1]])
})
means2=rowMeans(garapid2)
out10 <- rbind(means2[1],means2[2],means2[3],means2[4],means2[5])
out10 <- as.data.frame(out10)
colnames(out10) <- c("GWASapply Average")
rownames(out10) <-c("Power","FDR","Seconds","False Positive","True Postive")
#write map and numeric genotype files compatible with BLINK
myGM2=GM2
colnames(myGM2)=c("rs","chr","pos")
write.table(t(genotypes2),file="myData2.dat",quote=F,sep="\t",col.name=F,row.name=F)
write.table(myGM2,file="myData2.map",quote=F,sep="\t",col.name=T,row.name=F)
colnames(CV)=c("taxa","CV1","CV2")
write.table(CV,file="myData2.cov",quote=F,sep="\t",col.name=T,row.name=F)
#run replicate
blinkrep2=replicate(30,{
mySim=G2P(genotypes2, h2, alpha, NQTN, distribution)
myY=cbind(rownames(mySim$y),mySim$y)
colnames(myY)=c("taxa","Sim")
write.table(myY,file="myData2.txt",quote=F,sep="\t",col.name=T,row.name=F)
#start time for function
loop_start <- proc.time()
system("blink --file myData2 --numeric --gwas")
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#read in results
blink.p <- read.table("Sim_GWAS_result.txt", header = T, stringsAsFactors = F, sep = "\t")
p=t(blink.p$p_value)
#power calculations
p6_blink=power.fdr(p, QTN.position=mySim$QTN.position,cutoff=NULL)
p6_pwr_blink=mean(p6_blink$power)
p6_fdr_blink=mean(p6_blink$fdr)
FalP=length(p6_blink$FP.fdr.power)
TruP=length(p6_blink$TP.fdr.power)
pwr.fdr=c(p6_pwr_blink,p6_fdr_blink,loop_elapsed,FalP,TruP)
})
means2=rowMeans(blinkrep2)
out11 <- rbind(means2[1],means2[2],means2[3],means2[4],means2[5])
out11 <- as.data.frame(out11)
colnames(out11) <- c("Blink Average")
rownames(out11) <-c("Power","FDR","Seconds","False Positive","True Postive")
out3=data.frame(out10,out11)
#output results
kable(out3)
#t-test for time
t.test(garapid2[3,],blinkrep2[3,], paired = T,  na.rm=T)
#write map and numeric genotype files compatible with BLINK
myGM=GM
colnames(myGM)=c("rs","chr","pos")
write.table(t(genotypes),file="myData.dat",quote=F,sep="\t",col.name=F,row.name=F)
write.table(myGM,file="myData.map",quote=F,sep="\t",col.name=T,row.name=F)
colnames(CV)=c("taxa","CV1","CV2")
write.table(CV,file="myData.cov",quote=F,sep="\t",col.name=T,row.name=F)
#run replicate
blinkrep=replicate(30,{
mySim=G2P(genotypes, h2, alpha, NQTN, distribution)
myY=cbind(rownames(mySim$y),mySim$y)
colnames(myY)=c("taxa","Sim")
write.table(myY,file="myData.txt",quote=F,sep="\t",col.name=T,row.name=F)
#start time for function
loop_start <- proc.time()
system("blink --file myData --numeric --gwas --glm")
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#read in results
blink.p <- read.table("Sim_GWAS_result.txt", header = T, stringsAsFactors = F, sep = "\t")
p=t(blink.p$p_value)
#power calculations
p6_blink=power.fdr(p, QTN.position=mySim$QTN.position,cutoff=NULL)
p6_pwr_blink=mean(p6_blink$power)
p6_fdr_blink=mean(p6_blink$fdr)
FalP=length(p6_blink$FP.fdr.power)
TruP=length(p6_blink$TP.fdr.power)
pwr.fdr=c(p6_pwr_blink,p6_fdr_blink,loop_elapsed,FalP,TruP)
})
means=rowMeans(blinkrep)
out7 <- rbind(means[1],means[2],means[3],means[4],means[5])
out7 <- as.data.frame(out7)
colnames(out7) <- c("Blink Average")
rownames(out7) <-c("Power","FDR","Seconds","False Positive","True Postive")
out1=data.frame(out6,out7)
#output results
kable(out1)
#write map and numeric genotype files compatible with BLINK
myGM=GM
colnames(myGM)=c("rs","chr","pos")
write.table(t(genotypes),file="myData.dat",quote=F,sep="\t",col.name=F,row.name=F)
write.table(myGM,file="myData.map",quote=F,sep="\t",col.name=T,row.name=F)
colnames(CV)=c("taxa","CV1","CV2")
write.table(CV,file="myData.cov",quote=F,sep="\t",col.name=T,row.name=F)
#run replicate
blinkrep=replicate(30,{
mySim=G2P(genotypes, h2, alpha, NQTN, distribution)
myY=cbind(rownames(mySim$y),mySim$y)
colnames(myY)=c("taxa","Sim")
write.table(myY,file="myData.txt",quote=F,sep="\t",col.name=T,row.name=F)
#start time for function
loop_start <- proc.time()
system("blink --file myData --numeric --gwas")
loop_end <- proc.time()
#end time for function
loop_elapsed <- loop_end[3] - loop_start[3]
#read in results
blink.p <- read.table("Sim_GWAS_result.txt", header = T, stringsAsFactors = F, sep = "\t")
p=t(blink.p$p_value)
#power calculations
p6_blink=power.fdr(p, QTN.position=mySim$QTN.position,cutoff=NULL)
p6_pwr_blink=mean(p6_blink$power)
p6_fdr_blink=mean(p6_blink$fdr)
FalP=length(p6_blink$FP.fdr.power)
TruP=length(p6_blink$TP.fdr.power)
pwr.fdr=c(p6_pwr_blink,p6_fdr_blink,loop_elapsed,FalP,TruP)
})
means=rowMeans(blinkrep)
out7 <- rbind(means[1],means[2],means[3],means[4],means[5])
out7 <- as.data.frame(out7)
colnames(out7) <- c("Blink Average")
rownames(out7) <-c("Power","FDR","Seconds","False Positive","True Postive")
out1=data.frame(out6,out7)
#output results
kable(out1)
use warnings()
warnings()
warnings()
warnings()
gt_scan2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, stringsAsFactors = F, sep = "\t", nrows = 1))
classes2 <- sapply(gt_scan2, class)
genotypes2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, row.names = 1, colClasses = classes2, stringsAsFactors = F, sep = "\t"))
#import genetic map, phenotypes, and covariates
GM2 <- read.table("GAPIT_Tutorial_Data/mdp_SNP_information2.txt", header = T, stringsAsFactors = F, sep = "\t")
gt_scan2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, stringsAsFactors = F, sep = "\t", nrows = 1))
classes2 <- sapply(gt_scan2, class)
genotypes2 <- data.frame(read.table("GAPIT_Tutorial_Data/mdp_numeric2.txt", header = T, row.names = 1, colClasses = classes2, stringsAsFactors = F, sep = "\t"))
#import genetic map, phenotypes, and covariates
GM2 <- read.table("GAPIT_Tutorial_Data/mdp_SNP_information2.txt", header = T, stringsAsFactors = F, sep = "\t")
gt_scan2
class
