text: user1012: I have the genotyped data from impute2 output in .gen format (imputed to 1000G P3). The file has genotype posterior probabilities (GP:3 values per variant). I have converted .gen to .vcf using qctools and the .vcf file has GT:GP format. I need to convert the .vcf file with GT:GP format to GT:DS. Genotype dosages are recommended for use in qtltools/fastqtl analysis. However, I cannot find a tool that would keep the .vcf format and convert GP to DS. Any help much appreciated!
  
  user1183: Hm, I didn't know that the plugin existed so I wrote my own script to convert GP to minor allele dosage on github. Maybe someone else will find it useful :) https://github.com/7methylg/VCF-GP-to-DS
  
  user1017: You can do this in Hail.
  Here's the rough code to do it (0.1 versions).
  Setup:
  from hail import *
  hc = HailContext()
  
  Import the .gen file. VCF works too:
  dataset = hc.import_gen(
      'src/test/resources/example.gen', 
      'src/test/resources/example.sample')
  
  Remap the genotype schema and export to VCF:
  dataset.annotate_genotypes_expr('g = {GT: g.call(), DS: g.dosage()}')\
      .export_vcf('/tmp/out.vcf.bgz')
  
  Take a look at the getting started page if you want to try it out!
  I should note that you may be able to do QTL analyses in Hail, depending on the method you want to use. See blog post here.
  
original_text: 1012: <p>I have the genotyped data from impute2 output in .gen format (imputed to 1000G P3). The file has genotype posterior probabilities (GP:3 values per variant). I have converted .gen to .vcf using qctools and the .vcf file has GT:GP format. I need to convert the .vcf file with GT:GP format to GT:DS. Genotype dosages are recommended for use in qtltools/fastqtl analysis. However, I cannot find a tool that would keep the .vcf format and convert GP to DS. Any help much appreciated!</p>
   1183: <p>Hm, I didn't know that the plugin existed so I wrote my own script to convert GP to minor allele dosage on github. Maybe someone else will find it useful :) <a href="https://github.com/7methylg/VCF-GP-to-DS" rel="nofollow noreferrer">https://github.com/7methylg/VCF-GP-to-DS</a></p>
   1017: <p>You can do this in <a href="https://hail.is/" rel="nofollow noreferrer">Hail</a>.</p>
  
  <p>Here's the rough code to do it (0.1 versions).</p>
  
  <p>Setup:</p>
  
  <pre><code>from hail import *
  hc = HailContext()
  </code></pre>
  
  <p>Import the .gen file. VCF works too:</p>
  
  <pre><code>dataset = hc.import_gen(
      'src/test/resources/example.gen', 
      'src/test/resources/example.sample')
  </code></pre>
  
  <p>Remap the genotype schema and export to VCF:</p>
  
  <pre><code>dataset.annotate_genotypes_expr('g = {GT: g.call(), DS: g.dosage()}')\
      .export_vcf('/tmp/out.vcf.bgz')
  </code></pre>
  
  <p>Take a look at the <a href="https://hail.is/hail/getting_started.html" rel="nofollow noreferrer">getting started page</a> if you want to try it out!</p>
  
  <p>I should note that you may be able to do QTL analyses in Hail, depending on the method you want to use. See <a href="http://discuss.hail.is/t/fast-linear-regression-for-multiple-phenotypes-eqtls/190" rel="nofollow noreferrer">blog post here</a>.</p>
  