Skip to content

Commit 60854b5

Browse files
committed
changed: load library factoextra to top chunck
1 parent c5ac17b commit 60854b5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

introduction_to_animal_breeding/notebooks/8.gwas_basic_models.Rmd

+8-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ library("sommer")
1818
library("rrBLUP")
1919
library("ggplot2")
2020
library("tidyverse")
21+
library("factoextra")
2122
library("data.table")
2223
2324
knitr::opts_chunk$set(echo = FALSE)
@@ -93,7 +94,7 @@ print(g)
9394
### ANOVA table
9495

9596
```{r echo=TRUE}
96-
kable(anova(fit))
97+
anova(fit)
9798
```
9899

99100
### Add population structure
@@ -118,11 +119,11 @@ Xscaled = scale(X, center = TRUE, scale = TRUE)
118119
119120
## uncomment if you want to recalculate PCs from SNP data
120121
## (this may take a while)
121-
# res <- prcomp(X, rank. = 3)
122+
res <- prcomp(X, rank. = 3)
122123
123124
## we can load precomputed PCs from the RData object in /data
124-
load("../data/pca.RData")
125-
names(res)
125+
# load("../data/pca.RData")
126+
# names(res)
126127
127128
npcs = length(res$sdev)
128129
print(paste("QUESTION: The total number of PCs is", npcs, ": can you guess why?"))
@@ -144,14 +145,15 @@ sum(variance[c(1:3)])
144145
```
145146

146147
```{r echo=TRUE}
147-
library("factoextra")
148+
#library("factoextra")
148149
fviz_eig(res, ncp = 25)
149150
```
150151

151152
#### Use principal components to model population structure
152153

153154
```{r}
154-
head(res$x[,c(1,2,3,123,124,125)])
155+
head(res$x[,c(1,2,3)])
156+
155157
## we use the first 3 PCs
156158
df <- cbind.data.frame(df,res$x[,c(1:3)])
157159
```
@@ -255,7 +257,6 @@ model1_x <- rrBLUP::GWAS(
255257
)
256258
```
257259

258-
259260
```{r}
260261
# model1_x <- sommer::GWAS(
261262
# fixed = phenotype~1,

0 commit comments

Comments
 (0)