Workflow to prepare SNP data for genotypes dataframe

26 views
Skip to first unread message

Joe Welklin

unread,
Jun 14, 2023, 7:39:20 PM6/14/23
to R-hiphop
Hi Martijn, 

Have you found a good workflow, preferably in R, to go from a genotype file with SNP data, such as a vcf file, to the genotype dataframe needed for hiphop? I can figure it out if not but thought I'd check first. 

Thanks! 

Joe

Andrew Cockburn

unread,
Jun 14, 2023, 8:06:12 PM6/14/23
to Joe Welklin, R-hiphop

Hi Joe

 

The following package was designed to do things using the Dart format and converting that format to other structures, including the standard representation where the value of the SNP is the number of copies of the reference (common) allele, so 1 is a heterozygote instead of the 2 value which we get from Diversity Arrays.

 

https://cran.r-project.org/web/packages/dartR/index.html

 

Cheers, Andrew

--
You received this message because you are subscribed to the Google Groups "R-hiphop" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-hiphop+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/r-hiphop/bd33a620-2fdf-47b1-b74a-ab90a55814c4n%40googlegroups.com.

Joe Welklin

unread,
Jun 16, 2023, 7:29:43 PM6/16/23
to R-hiphop
Thanks, Andrew! 

I could not get DartR to load in R because another package it depends on (SNPRelate) does not appear to be on CRAN anymore. But reading the Dart tutorial was very helpful and led to another way to get my SNP data into the required format. I'll leave my code here in case anyone else runs into this problem in the future. Thank you for your help. 

library(vcfR)
library(adegenet)

##Load data
snp.vcf = read.vcfR("SNPdata.vcf")

##Convert to genlight format (used by DartR)
#adegenet can also do this if you have a genind object
snp.gl = vcfR2genlight(snp.vcf)

##Get genlight as SNP matrix
snp.m = as.matrix(snp.gl)

This appears to be the correct format for hiphop but I haven't tried running any analyses yet. If a future reader is starting with something other than a vcf file, note that adegenet has a variety of functions to convert between file types.

Joe
Reply all
Reply to author
Forward
0 new messages