Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

best way to convert SNP genotype to numeric matrix #9

Closed
qgao2 opened this issue Nov 7, 2017 · 4 comments
Closed

best way to convert SNP genotype to numeric matrix #9

qgao2 opened this issue Nov 7, 2017 · 4 comments

Comments

@qgao2
Copy link

qgao2 commented Nov 7, 2017

Hi Xiaolei,
thanks a lot for writing this nice package.
I would like to use MVP for my project, but I am not sure the best way to convert unphased SNP genotype (vcf format, around 60k SNPs) to numeric matrix (0,1,2). Do you which tool I should use to do the conversion.

@XiaoleiLiuBio
Copy link
Collaborator

I have written some codes for converting vcf to numeric, I will update the function in MVP soon.

@qgao2
Copy link
Author

qgao2 commented Nov 11, 2017 via email

@hyacz
Copy link
Collaborator

hyacz commented Feb 25, 2019

The code for converting vcf to numeric has been added to MVP some time ago. You can use the following code to get a 012-encoded genotype matrix in big.matrix format.

MVP.Data.VCF2MVP(fileVCF="my.vcf", out="my.mvp", threads=1)
geno <- attach.big.matrix("my.mvp.geno.desc")
  1. big.matrix is mostly similar to base::matrix , if you want a real base::matrix you can use the following code:
geno <- geno[]
  1. If you really need a 012-encoded genotype matrix text file, you can look at the write.big.matrix in the bigmemory package, which accepts a big.matrix
MVP.Data.VCF2MVP(fileVCF="my.vcf", out="my.mvp", threads=1)
geno <- attach.big.matrix("my.mvp.geno.desc")
write.big.matrix(geno, "my.numeric", sep=" ")

@hyacz
Copy link
Collaborator

hyacz commented Mar 6, 2019

This issue is closed because it is no longer active.

@hyacz hyacz closed this as completed Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants