I have a vcf file with individual level genetic data, that I read using the R package vcfR
gen <- read.vcfR('test.vcf')
Scanning file to determine attributes.
File attributes:
meta lines: 9
header_line: 10
variant count: 152
column count: 3798
Meta line 9 read in.
All meta lines processed.
gt matrix initialized.
Character matrix gt created.
Character matrix gt rows: 152
Character matrix gt cols: 3798
skip: 0
nrows: 153
row_num: 0
Processed variant: 153
All variants processed
How do I convert this file to a data frame that I can use for a GWAS or Mendelian Randomization study?
I was told that this should be a data frame where each column is a genetic variant and it take values 0, 1, or 2, depending on the number of "mutations".
I never worked with genetic data before and do not know much about genetics.
as(gen, "data.frame")
? $\endgroup$extract.gt
, then transform the matrix. Entries in this matrix are "0/0", "0/1", "1/0", and "1/1". I now have to recode these to 0, 1, 1, 2. $\endgroup$