knausb / vcfR

Tools to work with variant call format files
240 stars 54 forks source link

Put gt back to vcf #171

Closed zoeluo15 closed 3 years ago

zoeluo15 commented 3 years ago

Hi,

I have a vcf where homozygotes were not phased, and I want to change "./." to ".|." for homozygotes in order to do downstream analysis. Here is what I have done so far:

s26<-read.vcfR("S26.phased.vcf") gt <- extract.gt(s26) gt<-ifelse(gt=="0/0","0|0",gt) gt<-ifelse(gt=="1/1","1|1",gt) s26@gt[,-1]<-gt

I was wondering if there is a better way to do this without losing other information (e.g. DP, AD, GQ, PL) in GT?

Many thanks for your help in advance.

knausb commented 3 years ago

Hi @zoeluo15 ,

I have a post on extracting genotypes, modifying them, and pasting them back into the VCF data. Sounds pretty similar to what you're trying to do. Please take a look and let me know if that gets you where you want.

Brian

zoeluo15 commented 3 years ago

Thank you, Brian! That's exactly what I wanted to do. Zoe On Saturday, September 5, 2020, 10:17:02 AM GMT+12, Brian Knaus notifications@github.com wrote:

Hi @zoeluo15 ,

I have a post on extracting genotypes, modifying them, and pasting them back into the VCF data. Sounds pretty similar to what you're trying to do. Please take a look and let me know if that gets you where you want.

Brian

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.