-
Notifications
You must be signed in to change notification settings - Fork 13
/
export_genind_genclone.Rmd
55 lines (32 loc) · 1.33 KB
/
export_genind_genclone.Rmd
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "Export to genind and genclone"
---
The R packages **adegenet** and **poppr** are popular tools for population genetic analysis.
Here we describe how to convert a vcfR object to a genind and genclone object.
## Data import
We will use the example dataset provided by vcfR.
```{r}
library(vcfR)
data(vcfR_example)
```
## Creating genind objects
The packages **adegenet** and **poppr** use objects of class **genind**.
We can create genind objects with the function **vcfR2genind()**.
```{r genind, eval=TRUE}
my_genind <- vcfR2genind(vcf)
class(my_genind)
my_genind
```
The function `vcfR2genind()` calls `extract.gt()` to create a matrix of genotypes.
This matrix is converted into a genind object with the adegenet function `df2genind()`.
Currently, this function does not scale well to large quantities of data.
This appears to be due a call to the function adegenet::df2genind (this function was produced prior to high throughput sequencing).
The genlight object is designed to perform better for larger datasets.
## Creating genclone objects
The package **poppr** uses objects of class genclone as well as genind.
Once a genind object has been created, it is fairly straight forward to create a genclone object.
```{r genclone, eval=TRUE}
my_genclone <- poppr::as.genclone(my_genind)
class(my_genclone)
my_genclone
```