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

Add support for multi-allelic variants #976

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

jdidion
Copy link
Contributor

@jdidion jdidion commented Apr 3, 2024

No description provided.

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Attention: Patch coverage is 97.14286% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.63%. Comparing base (9a2d510) to head (0232972).

Files Patch % Lines
.../scala/com/fulcrumgenomics/vcf/DownsampleVcf.scala 97.14% 1 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           tb-add-downsample-vcf     #976      +/-   ##
=========================================================
- Coverage                  95.64%   95.63%   -0.01%     
=========================================================
  Files                        127      127              
  Lines                       7457     7473      +16     
  Branches                     521      501      -20     
=========================================================
+ Hits                        7132     7147      +15     
- Misses                       325      326       +1     
Flag Coverage Δ
unittests 95.63% <97.14%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@TedBrookings TedBrookings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me. A couple very minor issues, but I think the functional organization is actually improved and easier to understand even with the more complex likelihood model.

Comment on lines +146 to +159
val logProbs: Array[Double] = Array(
math.log10(epsilon),
math.log10((1 - epsilon) / 2),
math.log10(1 - epsilon)
)
// compute genotype log-likelihoods
(0 until numAlleles).flatMap(b =>
(0 to b).map(a =>
(0 until numAlleles).map(allele =>
logProbs(Array(a, b).count(_ == allele)) * alleleDepths(allele)
).sum
)
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that this passes the equivalency test with the biallelic case, but I found it very difficult to understand. It might help to have a bit more commentary here. I'd suggest at least something like:

// compute genotype log-likelihoods in a flat array pairing each allele with all alleles earlier or equal to it
// e.g. lp_AA, lp_BA, lp_BB, lp_CA, lp_CB, lp_CC, ...

Likelihoods.logToPhredLikelihoods(genotypeLikelihoods)
}

def mostLikelyGenotype: Option[(Int, Int)] = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def mostLikelyGenotype: Option[(Int, Int)] = {
private def mostLikelyGenotype: Option[(Int, Int)] = {

@@ -13,6 +13,7 @@ import com.fulcrumgenomics.vcf.DownsampleVcf.{downsampleAndRegenotype, winnowVar

import scala.math.log10
import scala.util.Random
import scala.tools.nsc.doc.html.HtmlTags

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

@jdidion jdidion merged commit 75de344 into tb-add-downsample-vcf Apr 15, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants