---
title: "Lab8"
author: "Zhou"
date: "3/9/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## GWAS by GLM

```{r}
# load GAPIT
setwd("/Users/ZhouTang/Documents/WSU_courses/2021_spring/545/2021/Lab/Lab8")
library(compiler)
source("./emma.txt")
source("./gapit_functions.txt")
source("./G2P.R")
```


```{r}
# GWAS by GLM
myGD=read.table(file="./mdp_numeric.txt",head=T)
myGM=read.table(file="./mdp_SNP_information.txt",head=T)

X=myGD[,-1]
index1to5=myGM[,2]<6
X1to5 = X[,index1to5]

set.seed(99164)
mySim=G2P(X=X1to5,h2=.75,alpha=1,NQTN=10,distribution="normal")
myY=cbind(as.data.frame(myGD[,1]), mySim$y)
myGAPIT=GAPIT(
Y=myY,
GD=myGD,
GM=myGM,
QTN.position=mySim$QTN.position,
PCA.total=3,
group.from=1,
group.to=1,
group.by=10,
memo="GLM",
file.output=TRUE)

```

## GWAS by MLM

```{r}
myGAPIT=GAPIT(
Y=myY,
GD=myGD,
GM=myGM,
QTN.position=mySim$QTN.position,
PCA.total=3,
group.from=10000,
group.to=10000,
group.by=10,
memo= "MLM",
file.output=TRUE)
```


