8.7 Tidying VCF

We’ll first work with just the first SNP in the dataset, using the vcfR2tidy function to isolate the SNP of interest and extract its genotypes.

# extract first SNP, convert to tidy df, and get genotypes
test_snp_gt <- vcfR2tidy(vcf[1, ])$gt
## Extracting gt element GT
head(test_snp_gt)
## # A tibble: 6 × 5
##   ChromKey    POS Indiv gt_GT gt_GT_alleles
##      <int>  <int> <chr> <chr> <chr>        
## 1        1 558185 1001  0/0   A/A          
## 2        1 558185 1002  0/0   A/A          
## 3        1 558185 1003  0/0   A/A          
## 4        1 558185 1004  0/1   A/G          
## 5        1 558185 1005  0/0   A/A          
## 6        1 558185 1006  0/1   A/G

Every row in the test_snp_gt dataframe is a different individual in the VCF.