Answers.Body: <p>Currently you have <strong>phred-scaled genotype likelihoods</strong> or <strong>PL</strong> values. Genotype likelihoods give the likelihood of observing the read data (i.e. the number of reads which map to either the ref or alt allele), given a particular underlying genotype (0/0, 0/1, 1/1 at a bi-allelic locus); <span class="math-container">$GL = p(G|D)$</span>. Phred scaling simply scales it like <span class="math-container">$PL = -10 * log(GL)$</span>. These are usually given by a genotype caller.</p>
  <p><strong>Genotype probabilities</strong> are slightly different in that they are posterior probabilities that the genotype is correct, given either other genotypes from a population or trio and a prior distribution for the allele frequencies. Therefore, you can't trivially go from likelihoods to probabilities without accounting for this external information and the prior. As suggested by JRodrigoF, you should use something like <a href="https://gatk.broadinstitute.org/hc/en-us/articles/360036730531-CalculateGenotypePosteriors" rel="nofollow noreferrer">CalculateGenotypePosteriors</a> to do this, maybe including 1000 genomes allele counts.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-24T19:31:36.613Z
Answers.LastActivityDate: 2022-09-24T19:31:36.613Z
Answers.UserDisplayName: user438383
Body: <p>I have a vcf info formatted in GT:PL.</p>
  <p><code>chr22  49994037    .   G   A   345.64  PASS    AC=1;AF=0.500;AN=2;BaseQRankSum=-3.605;DP=35;ExcessHet=3.0103;FS=1.377;MLEAC=1;MLEAF=0.500;MQ=60.00;MQRankSum=0.000;QD=10.17;ReadPosRankSum=-0.035;SOR=0.392    GT:AD:DP:GQ:PL  0/1:20,14:34:99:353,0,588</code></p>
  <p>I want to convert it into GT:GP. But I have to write a script for that. Is there any way to do it fast and simple?</p>
  <p>Note:</p>
  <p>GT:Genotype</p>
  <p>PL: Phred-scaled Genotype Likelihoods</p>
  <p>GP: Genotype Probabilities</p>
  <p>check the link below for all the info tags</p>
  <p><a href="https://samtools.github.io/hts-specs/VCFv4.2.pdf" rel="nofollow noreferrer">https://samtools.github.io/hts-specs/VCFv4.2.pdf</a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T14:18:30.177Z
Comments.Text: Seems like you may be confusing genotype probability and genotype likelihood? That's how you convert GL to PL, not GP to PL.
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:08:15.103Z
Comments.Text: I think I am right. GP limits to 0 to 1 probability. GL is genotype likelihoods comprised of comma-separated floating point log10-scaled likelihoods and PL is a Phred-scaled likelihood. So, the conversion formulae should be like this. Can u clarify what I have done wrong?
Comments.UserDisplayName: Shafayet Rahat
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:11:07.577Z
Comments.Text: It says ``PL : the phred-scaled genotype likelihoods``, not genotype probabilities. You said you want genotype probabilities, not genotype likelihoods. Why are you trying to convert PL to GP anyway? Genotype probabilities are usually posterior probabilities from imputation and genotype/phred-scaled likelihoods are what you get from variant callers.
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:11:50.370Z
Comments.Text: to compare my imputation accuracy with true genotype.
Comments.UserDisplayName: Shafayet Rahat
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:14:06.427Z
Comments.Text: So the line you shared is presumably the true genotype, since it doesn't look like it's been imputed? Either way, you want to use dosages for that, not genotype probabilities. Why do you want genotype probabilities?
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:15:40.620Z
Comments.Text: If u want to use IQS https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0009697#pone-0009697-t002 then u will need all the genotype probabilities. the r squared relation has some disadvantage in lower minor allele frequency
Comments.UserDisplayName: Shafayet Rahat
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-22T16:20:46.340Z
Comments.Text: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/139381/discussion-between-user438383-and-shafayet-rahat).
Comments.UserDisplayName: user438383
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-23T11:20:14.923Z
Comments.Text: Use this tool from GATK to obtain the posterior probabilities and then use bcftools to keep the only the FORMAT fields you want (e.g. GT:GP, ... )
  
   https://gatk.broadinstitute.org/hc/en-us/articles/360036730531-CalculateGenotypePosteriors
Comments.UserDisplayName: JRodrigoF
Tags: <vcf><format-conversion><conversion>
Title: convert GT:PL format to GT:GP format
ThreadText: # convert GT:PL format to GT:GP format
  
  (Asked by: username_0 on 2022-09-21)
  
  I have a vcf info formatted in GT:PL.
  
  `chr22 49994037 . G A 345.64 PASS AC=1;AF=0.500;AN=2;BaseQRankSum=-3.605;DP=35;ExcessHet=3.0103;FS=1.377;MLEAC=1;MLEAF=0.500;MQ=60.00;MQRankSum=0.000;QD=10.17;ReadPosRankSum=-0.035;SOR=0.392 GT:AD:DP:GQ:PL 0/1:20,14:34:99:353,0,588`
  
  I want to convert it into GT:GP. But I have to write a script for that. Is there any way to do it fast and simple?
  
  Note:
  
  GT:Genotype
  
  PL: Phred-scaled Genotype Likelihoods
  
  GP: Genotype Probabilities
  
  check the link below for all the info tags
  
  <https://samtools.github.io/hts-specs/VCFv4.2.pdf>
  
  **Tags:** vcf, format-conversion, conversion
  
  > **Comments:**
  > **username_1**: Seems like you may be confusing genotype probability and genotype likelihood? That's how you convert GL to PL, not GP to PL.  
  > **username_0**: I think I am right. GP limits to 0 to 1 probability. GL is genotype likelihoods comprised of comma-separated floating point log10-scaled likelihoods and PL is a Phred-scaled likelihood. So, the conversion formulae should be like this. Can u clarify what I have done wrong?  
  > **username_1**: It says ``PL : the phred-scaled genotype likelihoods``, not genotype probabilities. You said you want genotype probabilities, not genotype likelihoods. Why are you trying to convert PL to GP anyway? Genotype probabilities are usually posterior probabilities from imputation and genotype/phred-scaled likelihoods are what you get from variant callers.  
  > **username_0**: to compare my imputation accuracy with true genotype.  
  > **username_1**: So the line you shared is presumably the true genotype, since it doesn't look like it's been imputed? Either way, you want to use dosages for that, not genotype probabilities. Why do you want genotype probabilities?  
  > **username_0**: If u want to use IQS https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0009697#pone-0009697-t002 then u will need all the genotype probabilities. the r squared relation has some disadvantage in lower minor allele frequency  
  > **username_1**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/139381/discussion-between-username_1-and-username_0-username_0).  
  > **username_2**: Use this tool from GATK to obtain the posterior probabilities and then use bcftools to keep the only the FORMAT fields you want (e.g. GT:GP, ... )   https://gatk.broadinstitute.org/hc/en-us/articles/360036730531-CalculateGenotypePosteriors  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-09-24. Score: 1 | Accepted answer
  
  Currently you have **phred-scaled genotype likelihoods** or **PL** values. Genotype likelihoods give the likelihood of observing the read data (i.e. the number of reads which map to either the ref or alt allele), given a particular underlying genotype (0/0, 0/1, 1/1 at a bi-allelic locus); $GL = p(G|D)$. Phred scaling simply scales it like $PL = -10 \* log(GL)$. These are usually given by a genotype caller.
  
  **Genotype probabilities** are slightly different in that they are posterior probabilities that the genotype is correct, given either other genotypes from a population or trio and a prior distribution for the allele frequencies. Therefore, you can't trivially go from likelihoods to probabilities without accounting for this external information and the prior. As suggested by username_2, you should use something like [CalculateGenotypePosteriors](https://gatk.broadinstitute.org/hc/en-us/articles/360036730531-CalculateGenotypePosteriors) to do this, maybe including 1000 genomes allele counts.
  
  
  ---
  
  