Entering edit mode
2.0 years ago
LGMgeo
▴
110
Here is my VCF multisamples:
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample1 sample2
chr1 801950 . T <DEL> 2235 PASS SVTYPE=DEL;END=838297 GT:GQ:FT 0/0:.:. 0/0:.:.
By using cyvcf2, how can I get GT(sample1) or GT(sample2)?
I tried something like that:
from cyvcf2 import VCF
vcf = VCF(vcfFile)
for variant in vcf:
vcf.sample
variant.gt_types
Thank you for your help
vcf.samples
? (I have not tried it myself, therefore I leave this as a comment).it's useful to get a list of all sample names ;o)
Get all the genotypes with
variant.genotypes
. It will return a list containing the allele and phasing information for each sample. Access the sample-specific data with the respective index.Ref: https://brentp.github.io/cyvcf2/docstrings.html#cyvcf2.cyvcf2.Variant.genotypes