how to convert SNP genotype data to genlight object?

854 views
Skip to first unread message

venkata ramireddy

unread,
Aug 15, 2018, 10:24:30 AM8/15/18
to poppr
Hi to all
I have example SNP genotype data of 485 individuals genotyped with 100 snps in text format here


Now i want to convert this data into genlight object because i have very big original data with 30000 snps genotyped on 2000 individuals. Now i tried to convert this data into hapmap format and used function hapmap2df.r but i got this error Error in x[[gt.col]] : subscript out of bounds and  more columns than column names. yesterday i converted this data to genind object and i tried to convert this genind object to genlight but not successfull in my attempt. can any help me to solve this errors and final converting genotype data to Genlight object. My current example is not in hapmap format it is just genotype file only.
Thanks in advance
Regards

Zhian Kamvar

unread,
Aug 15, 2018, 10:45:03 AM8/15/18
to venkata ramireddy, poppr
Hello,

I'm assuming you used the hapmap2df function that I wrote five years ago: https://gist.github.com/zkamvar/7015503. Personally, I wouldn't trust five year old scripts unless they are continuously tested (like poppr is).

You mention that you tried converting your data to hapmap so that you can use the above function. What did you convert your data from? If your data were originally in a VCF file, I would recommend using the vcfR package, which has the vcfR2genlight() function.

Hope that helps,
Zhian

--
You received this message because you are subscribed to the Google Groups "poppr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to poppr+un...@googlegroups.com.
To post to this group, send email to po...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/poppr/c846e79c-5675-498a-81be-a6ff310b6934%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

venkata ramireddy

unread,
Aug 22, 2018, 7:27:53 AM8/22/18
to poppr
Dear Zhian Kamvar
Good evening
Thank you very much for your kind reply to my request. yes i used your function only. is there any way to get rid of this error
but i got this error Error in x[[gt.col]] : subscript out of bounds and  more columns than column names. while converting to genlight? actually my data is not in perfect vcf format and i am facing problem to convert it to genlight object. If you have free time please have look this error.
Thanks in advance
Regards,

Zhian Kamvar

unread,
Aug 22, 2018, 9:04:16 AM8/22/18
to venkata ramireddy, poppr
Hi Venkata,

As I mentioned before, don't use that code. It hasn't been tested and it appears that your version of a hapmap file is different than the one expected by the code I wrote five years ago.

I will attempt to help you out with the example file you've provided, but it may take a bit of time. In the meantime, I would encourage you to try and solve the problem yourself by reading the documentation for the genlight object in adegenet's "genomics" tutorial: https://github.com/thibautjombart/adegenet/wiki/Tutorials. In essence, you want to create a data frame/matrix with only 0s, 1s, and 2s indicating the number of minor alleles for a given individual per SNP.

Zhian

--
You received this message because you are subscribed to the Google Groups "poppr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to poppr+un...@googlegroups.com.
To post to this group, send email to po...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages