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

Have updog return phred-scaled genotype likelihoods #23

Open
YannDussert opened this issue Aug 2, 2022 · 3 comments
Open

Have updog return phred-scaled genotype likelihoods #23

YannDussert opened this issue Aug 2, 2022 · 3 comments

Comments

@YannDussert
Copy link

Hi,

First, thanks for developing updog!

I'd like to use the results from updog with another software, Entropy (https://bitbucket.org/buerklelab/mixedploidy-entropy/), which needs phred-scaled genotype likelihoods (PL), as computed by GATK. Do you have any suggestions on how to do that? Should I just multiply the genotype log-likelihood values from updog by -10?

Best regards,
Yann

@dcgerard
Copy link
Owner

dcgerard commented Aug 2, 2022

Hey @YannDussert,

Thanks for trying out {updog}!

The log genotype likelihoods from {updog} are actually using the natural log, so you also need to change the base if you want to get to the phred-scale.

Let’s demonstrate how to convert between log (base e) and phred-scaled data.

Generate some points between 0 and 1 for demonstration

p <- ppoints(5)

Calculate their phred-scaled values

phred_p <- -10 * log10(p)

Calculate their log (base e) values

log_p <- log(p)

Function to convert from log (base e) to phred

ln_to_phred <- function(x) {
  x * -10 / log(10)
}

Function to convert from phred to log (base e)

phred_to_ln <- function(x) {
  x / (-10 * log10(exp(1)))
}

Show that the ln_to_phred() is correct:

ln_to_phred(log_p)
## [1] 9.2428 5.0931 3.0103 1.6085 0.5505
phred_p
## [1] 9.2428 5.0931 3.0103 1.6085 0.5505

Show that phred_to_ln() is correct:

phred_to_ln(phred_p)
## [1] -2.1282 -1.1727 -0.6931 -0.3704 -0.1268
log_p
## [1] -2.1282 -1.1727 -0.6931 -0.3704 -0.1268

Let me know if you have any more questions.

Best,
David

@dcgerard dcgerard changed the title Obtain phred-scaled genotype likelihoods Have updog return phred-scaled genotype likelihoods Aug 2, 2022
@dcgerard
Copy link
Owner

dcgerard commented Aug 2, 2022

If would be great if {updog} could return the phred-scaled values as an option.

@YannDussert
Copy link
Author

Thanks for your quick and clear reply! I should probably have realized on my own that they in natural logs, if I had looked closely at the values of the posterior probabilities.

Best regards,
Yann

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

2 participants