meyer-lab / tHMM

A general Python framework for using hidden Markov models on binary trees or cell lineage trees.
https://asmlab.org
MIT License
9 stars 1 forks source link

Cross validation with equal transitions #957

Closed Farnazmdi closed 1 year ago

Farnazmdi commented 2 years ago
  1. To have equal transitions between the states (and not estimating the T), in BaumWelch.py, during the M step, the transition probabilities are set manually according to the number of states. (only one line is added, and line 89 is commented to prevent the T estimation). Other changes are some clean ups.
  2. The function that is used for performing the cross-validation and finding the likelihood of masked observations (output_LL) is moved to the crossval.py
  3. figure 19 is the figure where we perform cross validation on synthetic data.
  4. figure 21 is the figure we perform cross validation on experimental data.
codecov[bot] commented 2 years ago

Codecov Report

Merging #957 (9dd5c0a) into master (ba1e50d) will decrease coverage by 0.41%. The diff coverage is 62.06%.

:exclamation: Current head 9dd5c0a differs from pull request most recent head 335a2cb. Consider uploading reports for the commit 335a2cb to get more accurate results

@@            Coverage Diff             @@
##           master     #957      +/-   ##
==========================================
- Coverage   75.46%   75.05%   -0.41%     
==========================================
  Files          26       26              
  Lines        2164     2169       +5     
==========================================
- Hits         1633     1628       -5     
- Misses        531      541      +10     
Flag Coverage Δ
unittests 75.05% <62.06%> (-0.41%) :arrow_down:

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

Impacted Files Coverage Δ
lineage/BaumWelch.py 89.24% <ø> (ø)
lineage/plotTree.py 0.00% <0.00%> (ø)
lineage/crossval.py 82.50% <68.18%> (-17.50%) :arrow_down:
lineage/states/stateCommon.py 100.00% <100.00%> (ø)
lineage/tests/test_CrossVal.py 100.00% <100.00%> (ø)
lineage/Analyze.py 92.78% <0.00%> (-1.04%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

aarmey commented 1 year ago

@Farnazmdi is this something that should eventually be merged or deleted?

Farnazmdi commented 1 year ago

There is an underflow error here in calculating the gamma likelihood when building figure 21 (cross validation for experimental data of lapatinib and gemcittabine): outt -= np.sum(gammas[i][jidx] * np.log(gamP)) FloatingPointError: underflow encountered in multiply in gamma_LL line 65.

@aarmey Do you have an idea about how to address this? It is already in log format..

aarmey commented 1 year ago

I made a small adjustment that I think will fix the issue. Let me know if it still errors.

Farnazmdi commented 1 year ago

Thank you, it is fixed.

Farnazmdi commented 1 year ago

This should be ready to merge.

aarmey commented 1 year ago

Great. Merging.