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

fix: Improved parameter estimation for (H)PHMM #371

Merged
merged 24 commits into from
Jun 12, 2023
Merged

Conversation

tedil
Copy link
Contributor

@tedil tedil commented May 11, 2023

Description

This PR updates the (H)PHMM parameter estimation routine:

  • counts transitions a little differently then before:
    1. conceptually expand cigar strings (i.e. 3M2D1I2M1M1M1M1D1D1I1M1M)
    2. iterate consecutive pairs e.g. (1M, 1M) and look at rseq and qseq at the corresponding positions
    3. classify that into any of the 82 transitions, e.g. (1M, 1M) together with ((T, T), (G, G)) corresponds to a match T → match G transition
  • this will only look at N records from the SAM/BAM/CRAM, where N is a number calculated as a multinomial sample size estimation as described in https://www.jstor.org/stable/2683352
    When the number of alignments in the file is known (which is the case for indexed BAM files but not for indexed SAM/CRAM), can use a finite population correction version of the estimate instead.
  • currently, iterates through the whole file with a fixed step size. However, this isn't any faster than simply looking at every record, so do any combination of the following instead:
    1. only use the first N records (possibly biased subsample, but definitely quicker)
    2. for CRAM, set lowlevel htslib reading options to skip fields that aren't used for estimation purposes (potentially quicker, but only for CRAM?)
    3. look at samtools subsample or simply use that as a preprocessing step
    4. make better use of indices for random access

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation at https://github.com/varlociraptor/varlociraptor.github.io is updated in a separate PR to reflect the changes or this is not necessary (e.g. if the change does neither modify the calling grammar nor the behavior or functionalities of Varlociraptor).

@tedil
Copy link
Contributor Author

tedil commented May 11, 2023

bam_utils.rs can be replaced if rust-bio/rust-htslib#387 is integrated

@tedil
Copy link
Contributor Author

tedil commented May 15, 2023

This now simply uses the first N records, where N is an estimation of alignments needed to perform the HPHMM param estimation.
If --num-records is specified on the CLI, this overrides the estimation and issues a warning.

@tedil tedil marked this pull request as ready for review May 15, 2023 07:27
@johanneskoester johanneskoester merged commit 508333e into master Jun 12, 2023
5 checks passed
@johanneskoester johanneskoester deleted the hphmm-est branch June 12, 2023 14:28
johanneskoester pushed a commit that referenced this pull request Jun 12, 2023
🤖 I have created a release \*beep\* \*boop\*
---
##
[8.2.0](https://www.github.com/varlociraptor/varlociraptor/compare/v8.1.1...v8.2.0)
(2023-06-12)


### Features

* warn on missing ANN records in mutational burden estimation
([#376](https://www.github.com/varlociraptor/varlociraptor/issues/376))
([32006fb](https://www.github.com/varlociraptor/varlociraptor/commit/32006fb62450ad0b1f9786dca9c20759588792a2))


### Bug Fixes

* Improved parameter estimation for (H)PHMM
([#371](https://www.github.com/varlociraptor/varlociraptor/issues/371))
([508333e](https://www.github.com/varlociraptor/varlociraptor/commit/508333e4471550ad7c14cb0b66ceeea8ff29996d))
---


This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

None yet

2 participants