Skip to content

Add X chr functionality - #66

Merged
XingerTang merged 5 commits into
AlphaGenes:develfrom
AprilYUZhang:X_chr
Aug 24, 2026
Merged

XingerTang merged 5 commits into
AlphaGenes:develfrom
AprilYUZhang:X_chr

Conversation

@AprilYUZhang

@AprilYUZhang AprilYUZhang commented May 9, 2026 •

Copy link
Copy Markdown

Issue #47

pointEstimates[1, i] *= e
pointEstimates[2, i] *= 1 - e
pointEstimates[3, i] *= 1 - e
elif isXChrom:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am struggling since I am doing this on the fly and can’t check. @XingerTang can you have a look too?

Also, we don’t need the isXChrom block for the second haplotype below?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

"ind.haplotypes[0][i] != 9" means this individual is female. If this individual is female, the segregation probability must be pointEstimates[0, i] *= e; pointEstimates[1, i] *= e; pointEstimates[2, i] *= 1 - e; pointEstimates[3, i] *= 1 - e. Don't need to change if sirehap0 != 9 and sirehap1 != 9 and sirehap0 != sirehap1: because it is not possible for isXChrom. If you think if isXChrom: is easy to understand, I can change elif to if.

Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved

@gregorgorjanc gregorgorjanc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@AprilYUZhang great that you are pushing this functionality! I reviewed on the go without access to computer to look into the code, so I wasn’t sure in some places if the code is correct or not or it’s just my lack of deep understanding. @XingerTang your review would be also appreciated.

@gregorgorjanc gregorgorjanc changed the title update X chr Add X chr functionality May 10, 2026
@gregorgorjanc

Copy link
Copy Markdown
Member

@AprilYUZhang I left some more comments at de2b6c8#r184944694 on your latest commit

@gregorgorjanc

Copy link
Copy Markdown
Member

Github is behaving odd lately - you might need to toggle file by clicking the > symbol to hide and the unhide file contents to see the comments

@XingerTang XingerTang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Pre-commit not passed
  • pytest failed on my end:
(phase) xtang3@S37-50MAQ05D AlphaImpute2 % pytest tests/functional_tests 
======================================== test session starts =========================================
platform darwin -- Python 3.11.11, pytest-9.0.1, pluggy-1.6.0
benchmark: 5.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/xtang3/AlphaImpute2
configfile: pyproject.toml
plugins: benchmark-5.2.3
collected 2 items                                                                                    

tests/functional_tests/run_func_test.py F.                                                     [100%]

============================================== FAILURES ==============================================
_______________________________________________ test_1 _______________________________________________

    def test_1():
        """basic functionality test with pedigree only mode"""
        os.system(
            "AlphaImpute2 -genotypes tests/functional_tests/test_1/genotypes.txt -pedigree tests/functional_tests/test_1/pedigree.txt -ped_only -phase_output -seg_output -out tests/functional_tests/outputs/test_1"
        )
        assert os.path.exists("tests/functional_tests/outputs/test_1.genotypes")
        assert os.path.exists("tests/functional_tests/outputs/test_1.haplotypes")
        assert os.path.exists("tests/functional_tests/outputs/test_1.segregation")
    
        genotypes = read_file("tests/functional_tests/outputs/test_1.genotypes")
        expected_genotypes = read_file("tests/functional_tests/test_1/true_genotypes.txt")
>       assert genotypes == expected_genotypes
E       AssertionError: assert [['1', 1.0, 2....0, 0.0, 0.0]] == [['1', 1.0, 2....0, 0.0, 0.0]]
E         
E         At index 2 diff: ['3', 1.0, 2.0, 0.0, 0.0, 1.0] != ['3', 0.0, 2.0, 0.0, 0.0, 1.0]
E         Use -v to get more diff

tests/functional_tests/run_func_test.py:53: AssertionError
---------------------------------------- Captured stdout call ----------------------------------------
------------------------------------------
               AlphaImpute2               
------------------------------------------
Version: 0.0.3
Email:   alphagenes.dev@gmail.com
Website: https://github.com/AlphaGenes
------------------------------------------
Reading in AlphaGenes format: tests/functional_tests/test_1/genotypes.txt
Read in: 0.01 seconds

         Pedigree Imputation Only         
------------------------------------------
Number of peeling cycles: 4
Final cutoff: 0.1

Imputation cycle 1
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 4.86 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 4.89 seconds

Imputation cycle 2
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds

Imputation cycle 3
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds

Imputation cycle 4
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds
Core peeling cycles: 9.75 seconds
Heuristic Peeling: 11.28 seconds

           Writing Out Results            
------------------------------------------
Write out: 0.00 seconds
Full Program Run: 11.52 seconds

Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved
Comment thread src/alphaimpute2/alphaimpute2.py Resolved
@XingerTang
XingerTang marked this pull request as draft May 12, 2026 09:04
@XingerTang

Copy link
Copy Markdown
Contributor

No tests are written for this code. Convert this PR to a draft.

@XingerTang XingerTang linked an issue May 12, 2026 that may be closed by this pull request
@XingerTang

Copy link
Copy Markdown
Contributor

@AprilYUZhang, please rebase the change in #68 for correct geno prob updates after cycle 2

@AprilYUZhang

AprilYUZhang commented May 12, 2026 •

Copy link
Copy Markdown
Author

Hi @gregorgorjanc, rough modification for X chr, now it works on the simple X chr sample. However, pytest still doesn't work. I will be back after @XingerTang updates the pytest. @XingerTang, please let me know once you finish all basic and general modifications.

@AprilYUZhang

Copy link
Copy Markdown
Author
  • Pre-commit not passed
  • pytest failed on my end:
(phase) xtang3@S37-50MAQ05D AlphaImpute2 % pytest tests/functional_tests 
======================================== test session starts =========================================
platform darwin -- Python 3.11.11, pytest-9.0.1, pluggy-1.6.0
benchmark: 5.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/xtang3/AlphaImpute2
configfile: pyproject.toml
plugins: benchmark-5.2.3
collected 2 items                                                                                    

tests/functional_tests/run_func_test.py F.                                                     [100%]

============================================== FAILURES ==============================================
_______________________________________________ test_1 _______________________________________________

    def test_1():
        """basic functionality test with pedigree only mode"""
        os.system(
            "AlphaImpute2 -genotypes tests/functional_tests/test_1/genotypes.txt -pedigree tests/functional_tests/test_1/pedigree.txt -ped_only -phase_output -seg_output -out tests/functional_tests/outputs/test_1"
        )
        assert os.path.exists("tests/functional_tests/outputs/test_1.genotypes")
        assert os.path.exists("tests/functional_tests/outputs/test_1.haplotypes")
        assert os.path.exists("tests/functional_tests/outputs/test_1.segregation")
    
        genotypes = read_file("tests/functional_tests/outputs/test_1.genotypes")
        expected_genotypes = read_file("tests/functional_tests/test_1/true_genotypes.txt")
>       assert genotypes == expected_genotypes
E       AssertionError: assert [['1', 1.0, 2....0, 0.0, 0.0]] == [['1', 1.0, 2....0, 0.0, 0.0]]
E         
E         At index 2 diff: ['3', 1.0, 2.0, 0.0, 0.0, 1.0] != ['3', 0.0, 2.0, 0.0, 0.0, 1.0]
E         Use -v to get more diff

tests/functional_tests/run_func_test.py:53: AssertionError
---------------------------------------- Captured stdout call ----------------------------------------
------------------------------------------
               AlphaImpute2               
------------------------------------------
Version: 0.0.3
Email:   alphagenes.dev@gmail.com
Website: https://github.com/AlphaGenes
------------------------------------------
Reading in AlphaGenes format: tests/functional_tests/test_1/genotypes.txt
Read in: 0.01 seconds

         Pedigree Imputation Only         
------------------------------------------
Number of peeling cycles: 4
Final cutoff: 0.1

Imputation cycle 1
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 4.86 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 4.89 seconds

Imputation cycle 2
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds

Imputation cycle 3
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds

Imputation cycle 4
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
Peel down: 0.00 seconds
False -1
[[2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]
 [2.8239352e-01 3.0398920e-01 3.3998200e-01 3.9997000e-01 4.9994999e-01]
 [2.1760647e-01 1.9601080e-01 1.6001801e-01 1.0003000e-01 4.9999999e-05]]
False 1
[[0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]
 [0.25 0.25 0.25 0.25 0.25]]
Peel up: 0.00 seconds
Core peeling cycles: 9.75 seconds
Heuristic Peeling: 11.28 seconds

           Writing Out Results            
------------------------------------------
Write out: 0.00 seconds
Full Program Run: 11.52 seconds

pytest doesn't work on my end, too. I have no idea why pytest isn't working, since I didn't make any modifications that might affect the function test. But the tinyhouse version is different. I used the latest main branch because it includes the updates about sex chromosomes. This is the commit that I stay:f6cd2bc45f3e81d5a2b34e093be0f14b20f4218d. I suggest prioritizing tinyhouse update on your end, and then we can figure out where the problems are together. Finally, merge your branch to this request.

@gregorgorjanc

Copy link
Copy Markdown
Member

It must be due to code changes you have done for the autosomal case. I have spotted some odd cases and highlighted those via comments but could have missed some, I reckon. Happy bug hunting;)

@gregorgorjanc

Copy link
Copy Markdown
Member

Just to add that you should attempt to fix this @AprilYUZhang if at all possible. @XingerTang input is of course welcome and valuable.

@AprilYUZhang

Copy link
Copy Markdown
Author

Here are the test results with new simulation data, with simple file name replacements and variable changes. It does not give very credible results:

===========================================================  Accuracy ============================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abs_diff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The metric abs_diff is the sum of absolute difference divided by the norm of the number of loci being counted. 
The lower the value, the better the accuracy.
----------------------------------------------------------- genotypes ------------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.057 | ###############################################............................................ |
ped_only             0.095 | ########################################################################################### |
combined             0.019 | #####...................................................................................... |
pop_only_x_chr       0.032 | ####################....................................................................... |
ped_only_x_chr       0.070 | ##############################################################............................. |
combined_x_chr       0.014 | ........................................................................................... |
----------------------------------------------------------- haplotypes -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.304 | ####....................................................................................... |
ped_only             0.158 | #.......................................................................................... |
combined             0.070 | ........................................................................................... |
pop_only_x_chr       4.817 | ########################################################################################### |
ped_only_x_chr       4.762 | #########################################################################################.. |
combined_x_chr       4.700 | ########################################################################################... |
---------------------------------------------------------- segregation -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
ped_only             1.502 | ######################################################################################..... |
combined             1.502 | ########################################################################################### |
ped_only_x_chr       1.493 | ........................................................................................... |
combined_x_chr       1.493 | ........................................................................................... |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ correct_rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summing up the probabilities of the true state from the output data divided by the number of loci being counted.
---------------------------------------------------------- segregation -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
ped_only             0.249 | ####....................................................................................... |
combined             0.249 | ........................................................................................... |
ped_only_x_chr       0.253 | ##########################################################################################. |
combined_x_chr       0.253 | ########################################################################################### |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ind_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at individuals, ranged from 0 to 1.
----------------------------------------------------------- genotypes ------------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.956 | ############################################################............................... |
ped_only             0.901 | ######..................................................................................... |
combined             0.986 | ########################################################################################### |
pop_only_x_chr       0.959 | ###############################################################............................ |
ped_only_x_chr       0.895 | ........................................................................................... |
combined_x_chr       0.982 | #######################################################################################.... |
----------------------------------------------------------- haplotypes -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.676 | ........................................................................................... |
ped_only             0.852 | ###########################################################................................ |
combined             0.926 | ####################################################################################....... |
pop_only_x_chr       0.775 | #################################.......................................................... |
ped_only_x_chr       0.867 | ################################################################........................... |
combined_x_chr       0.944 | ########################################################################################### |
---------------------------------------------------------- segregation -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
ped_only             0.001 | ########................................................................................... |
combined             -0.001 | ........................................................................................... |
ped_only_x_chr       0.020 | ########################################################################################### |
combined_x_chr       0.020 | ########################################################################################### |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ marker_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at markers, ranged from 0 to 1.
----------------------------------------------------------- genotypes ------------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.874 | ####################################################....................................... |
ped_only             0.747 | ........................................................................................... |
combined             0.956 | ######################################################################################..... |
pop_only_x_chr       0.928 | ##########################################################################................. |
ped_only_x_chr       0.807 | ########################................................................................... |
combined_x_chr       0.968 | ########################################################################################### |
----------------------------------------------------------- haplotypes -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
pop_only             0.414 | ########################################################................................... |
ped_only             0.662 | ###########################################################################................ |
combined             0.863 | ########################################################################################### |
pop_only_x_chr       -0.320 | ........................................................................................... |
ped_only_x_chr       -0.305 | #.......................................................................................... |
combined_x_chr       -0.300 | #.......................................................................................... |
---------------------------------------------------------- segregation -----------------------------------------------------------
Method               Value     
----------------------------------------------------------------------------------------------------------------------------------
ped_only             -0.001 | ###############............................................................................ |
combined             -0.002 | ........................................................................................... |
ped_only_x_chr       0.004 | ########################################################################################### |
combined_x_chr       0.004 | ########################################################################################### |

I noticed that the first haplotype for the male X chromosome is not set to 9 in the new simulation data. That may be the cause of some of the issues, but there might be more. I don't have time to correct everything now. Since the original simulation data already gives better accuracy in predicting seg prob after the recent fixes, and figuring out why it doesn't was the initial motive for setting up this new simulation data, now that our main concern is resolved, I propose we leave this new simulation data adoption for the future.

I agree with you. I haven't check true value of simulation. If the problem has solved, the new simulation can be ignored.

@AprilYUZhang

Copy link
Copy Markdown
Author

I noticed that the first haplotype for the male X chromosome is not set to 9 in the new simulation data. That may be the cause of some of the issues, but there might be more. I don't have time to correct everything now.
Since the original simulation data already gives better accuracy in predicting seg prob after the recent fixes, and figuring out why it doesn't was the initial motive for setting up this new simulation data, now that our main concern is resolved, I propose we leave this new simulation data adoption for the future.

@AprilYUZhang can you share what's the difference between the old and the new simulation?

Regarding founder genome, back to a single runMacs call producing 2 chromosomes, then pullSegSiteHaplo for each, then importHaplo to glue on the SD locus onto the "XY" group only (chromosome "A" is untouched autosome, "XY" = X markers + SD). Everything downstream is duplicated per chromosome type.
Regarding error functions: both generateGenoErr_auto and generateGenoErr_X.

@XingerTang

Copy link
Copy Markdown
Contributor

After the commit 8e77d4d, with the exact same settings as before, the runtime lasts 1962.219222598 seconds on Eddie, which is in my expected range for the autosomal chromosome runtime. The GitHub runner also shows that the autosomal runtime is somewhat restored to the state before the XChr is added. Therefore, I would say we have completed the runtime optimisation.

@gregorgorjanc

Copy link
Copy Markdown
Member

Excellent push @XingerTang - so runtime "mystery" has now been resolved. I got lost in the process regarding the accuracies - how do they look like for A vs. X chr? Thanks!

@XingerTang

XingerTang commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Excellent push @XingerTang - so runtime "mystery" has now been resolved. I got lost in the process regarding the accuracies - how do they look like for A vs. X chr? Thanks!

Currently, X chr is better than autosomal chr in all metrics and all files:

=============================================================================== test session starts ===============================================================================
platform darwin -- Python 3.11.11, pytest-9.0.1, pluggy-1.6.0
benchmark: 5.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/xtang3/AlphaImpute2
configfile: pyproject.toml
plugins: benchmark-5.2.3, memray-1.9.0
collected 12 items                                                                                                                                                                

tests/accuracy_tests/run_accu_test.py ...                                                                                                                                   [ 25%]
tests/accuracy_tests/run_sex_accu_test.py ...                                                                                                                               [ 50%]
tests/functional_tests/run_func_test.py ......                                                                                                                              [100%]

====================================================================================  Accuracy ====================================================================================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abs_diff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The metric abs_diff is the sum of absolute difference divided by the norm of the number of loci being counted. 
The lower the value, the better the accuracy.
------------------------------------------------------------------------------------ genotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.023 | ########################..................................................................................................... |
ped_only             0.096 | ############################################################################################################################. |
combined             0.009 | ####......................................................................................................................... |
pop_only_x_chr       0.009 | ####......................................................................................................................... |
ped_only_x_chr       0.067 | #####################################################################################........................................ |
combined_x_chr       0.005 | ............................................................................................................................. |
----------------------------------------------------------------------------------- haplotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.303 | ############################################################################################################################# |
ped_only             0.161 | ###########################################################.................................................................. |
combined             0.068 | ################............................................................................................................. |
pop_only_x_chr       0.144 | ###################################################.......................................................................... |
ped_only_x_chr       0.096 | #############################................................................................................................ |
combined_x_chr       0.032 | ............................................................................................................................. |
----------------------------------------------------------------------------------- segregation -----------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.094 | ############################################################################################################################# |
combined             0.094 | ###########################################################################################################################.. |
ped_only_x_chr       0.046 | ............................................................................................................................. |
combined_x_chr       0.045 | ............................................................................................................................. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ correct_rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summing up the probabilities of the true state from the output data divided by the number of loci being counted.
----------------------------------------------------------------------------------- segregation -----------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.953 | ............................................................................................................................. |
combined             0.953 | #............................................................................................................................ |
ped_only_x_chr       0.977 | ############################################################################################################################. |
combined_x_chr       0.977 | ############################################################################################################################# |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ind_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at individuals, ranged from 0 to 1.
------------------------------------------------------------------------------------ genotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.981 | ############################################################################################################................. |
ped_only             0.897 | ............................................................................................................................. |
combined             0.993 | ###########################################################################################################################.. |
pop_only_x_chr       0.989 | ######################################################################################################################....... |
ped_only_x_chr       0.902 | ######....................................................................................................................... |
combined_x_chr       0.994 | ############################################################################################################################# |
----------------------------------------------------------------------------------- haplotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.668 | ............................................................................................................................. |
ped_only             0.847 | ##############################################################################............................................... |
combined             0.926 | #################################################################################################################............ |
pop_only_x_chr       0.790 | #####################################################........................................................................ |
ped_only_x_chr       0.875 | ##########################################################################################................................... |
combined_x_chr       0.953 | ############################################################################################################################# |
----------------------------------------------------------------------------------- segregation -----------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.930 | ............................................................................................................................. |
combined             0.931 | #################............................................................................................................ |
ped_only_x_chr       0.936 | ###########################################################################################################.................. |
combined_x_chr       0.937 | ############################################################################################################################# |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ marker_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at markers, ranged from 0 to 1.
------------------------------------------------------------------------------------ genotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.953 | ###########################################################################################################.................. |
ped_only             0.770 | ............................................................................................................................. |
combined             0.980 | ###########################################################################################################################.. |
pop_only_x_chr       0.974 | #######################################################################################################################...... |
ped_only_x_chr       0.803 | ###################.......................................................................................................... |
combined_x_chr       0.983 | ############################################################################################################################# |
----------------------------------------------------------------------------------- haplotypes ------------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.473 | ............................................................................................................................. |
ped_only             0.686 | ##################################################........................................................................... |
combined             0.881 | ################################################################################################............................. |
pop_only_x_chr       0.997 | ############################################################################################################################. |
ped_only_x_chr       0.998 | ############################################################################################################################. |
combined_x_chr       0.999 | ############################################################################################################################# |
----------------------------------------------------------------------------------- segregation -----------------------------------------------------------------------------------
Method               Value     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.968 | ............................................................................................................................. |
combined             0.969 | #######...................................................................................................................... |
ped_only_x_chr       0.985 | ############################################################################################################################# |
combined_x_chr       0.985 | ############################################################################################################################# |

The accuracy improvement is happened at: #66 (comment)

@gregorgorjanc gregorgorjanc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome that you find solution to reduced the increased runtime - it bulks up the code, but this is the price we have to pay.

@gregorgorjanc

Copy link
Copy Markdown
Member

Currently, X chr is better than autosomal chr in all metrics and all files:

Perfect - very pleasing to see these results - they do make sense now. I am curious what was the source of the error that was puzzling @AprilYUZhang!

@XingerTang is there anything else we need before we merge this in? Runtime is good (check), accuracy is good (check), documentation (done?), changelog (done?), anything else?

@XingerTang

Copy link
Copy Markdown
Contributor

Currently, X chr is better than autosomal chr in all metrics and all files:

Perfect - very pleasing to see these results - they do make sense now. I am curious what was the source of the error that was puzzling @AprilYUZhang!

@XingerTang is there anything else we need before we merge this in? Runtime is good (check), accuracy is good (check), documentation (done?), changelog (done?), anything else?

There were several different things involved, but the major issue is that the XChr flag is not passed into the anterior probability calculation function in several places where it is called.

I'm now trying to fix the GitHub Actions tests. Later after that, will move on to the documentation and changelog.

@XingerTang

Copy link
Copy Markdown
Contributor

The indexing error that kept causing access issues is fixed; here is a Codex summary of how that bug was introduced into the code:

The invalid indexing has two layers:

Latent unsafe pattern:
Introduced in 1163a77 on 2020-05-05 (Trying to get faster phasing done).

That commit added patterns like:

exclusion = (own_haplotypes[0, true_index], own_haplotypes[1, true_index])

and:

rec_state, selected_genotype = (-1, -1)

Those were unsafe in principle, but mostly latent because the original autosomal path usually had two haplotypes when has_own_haplotypes was true.

X-chr trigger:
Introduced in ce39e93 on 2026-06-03 (solve the Xchr run on only-pop and combined).

That commit changed X male reference-library construction to use only:

haplotypes = [ind.current_haplotypes[1]]

So male X exclusions became shape (1, n_loci). After that, the older assumption that own_haplotypes[1, true_index] exists became invalid.

Current duplicated/split location:
bc2024e on 2026-08-19 (Runtime optimisation) split/duplicated the sampler paths, so blame points there for the current autosome/X sampler bodies. But it mostly carried forward the unsafe assumptions; the X-specific crash condition was already created by ce39e93.

So the short version: the bad indexing pattern is old, but it became a real X-chr bug at ce39e93.

@gregorgorjanc

Copy link
Copy Markdown
Member

The indexing error that kept causing access issues is fixed; here is a Codex summary of how that bug was introduced into the code

Huh, interesting development of this bug! I wonder why it did not impact accuracy and interesting to see the difference between how different OS handle such a bug (Windows fail vs other somewhat tolerating it).

Well done Evie and Codex;)

@XingerTang
XingerTang marked this pull request as ready for review August 21, 2026 18:36
@XingerTang

Copy link
Copy Markdown
Contributor

At this point, all the changes for X chromosome imputation have been completed, with the imputation results accurate and efficient. The remaining part of this PR would be the last round of review and then squashing the commits if possible.

@gregorgorjanc gregorgorjanc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good! It pays off we spend quite a bit of time on docs for AlphaPeel;)

@gregorgorjanc

Copy link
Copy Markdown
Member

Do we have clear small example with X chr for AlphaImpute2? Could use one from AlphaPeel (assuming we have one). Such small examples are key for users to start using a tool.

@AprilYUZhang

AprilYUZhang commented Aug 24, 2026 •

Copy link
Copy Markdown
Author

Yes, the small example has been stored in AlphaImpute2/example/data/X_chr
I have synchronized Alphapeel and AlphaImpute2's function tests as follows:
Screenshot 2026-08-24 at 14 52 31

By the way, here I just set Y haplotype to 9 and reset the position of Sex-determined loci; the accuracy table looks fine. I think the previous 'weird ' accuracy resulted from the Sex-determined locus that was localized in the middle.
================================================================================= Accuracy ==================================================================================

The metric abs_diff is the sum of absolute differences divided by the norm of the number of loci being counted. 
The lower the value, the better the accuracy.
--------------------------------------------------------------------------------- genotypes ----------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.006 | #####.................................................................................................................... |
ped_only             0.086 | ########################################################################################################################. |
combined             0.002 | ......................................................................................................................... |
pop_only_x_chr       0.003 | #........................................................................................................................ |
ped_only_x_chr       0.064 | ########################################################################################................................. |
combined_x_chr       0.002 | ......................................................................................................................... |
--------------------------------------------------------------------------------- haplotypes ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.278 | ######################################################################################################################### |
ped_only             0.147 | #########################################################................................................................ |
combined             0.059 | ###############.......................................................................................................... |
pop_only_x_chr       0.123 | ##############################################........................................................................... |
ped_only_x_chr       0.091 | ###############################.......................................................................................... |
combined_x_chr       0.026 | ......................................................................................................................... |
-------------------------------------------------------------------------------- segregation ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.067 | ######################################################################################################################### |
combined             0.067 | ########################################################################################################################. |
ped_only_x_chr       0.030 | ......................................................................................................................... |
combined_x_chr       0.030 | ......................................................................................................................... |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ correct_rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summing up the probabilities of the true state from the output data divided by the number of loci being counted.
-------------------------------------------------------------------------------- segregation ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.966 | ......................................................................................................................... |
combined             0.967 | ......................................................................................................................... |
ped_only_x_chr       0.985 | ######################################################################################################################### |
combined_x_chr       0.985 | ########################################################################################################################. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ind_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at individuals, ranged from 0 to 1.
--------------------------------------------------------------------------------- genotypes ----------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.995 | ####################################################################################################################..... |
ped_only             0.914 | ####..................................................................................................................... |
combined             0.998 | ######################################################################################################################### |
pop_only_x_chr       0.996 | ######################################################################################################################... |
ped_only_x_chr       0.911 | ......................................................................................................................... |
combined_x_chr       0.997 | #######################################################################################################################.. |
--------------------------------------------------------------------------------- haplotypes ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.702 | ......................................................................................................................... |
ped_only             0.865 | ############################################################################............................................. |
combined             0.936 | #############################################################################################################............ |
pop_only_x_chr       0.817 | #####################################################.................................................................... |
ped_only_x_chr       0.882 | ####################################################################################..................................... |
combined_x_chr       0.961 | ######################################################################################################################### |
-------------------------------------------------------------------------------- segregation ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.950 | ......................................................................................................................... |
combined             0.950 | ......................................................................................................................... |
ped_only_x_chr       0.966 | ######################################################################################################################### |
combined_x_chr       0.966 | ######################################################################################################################### |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ marker_corr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pearson correlation evaluated at markers, ranged from 0 to 1.
--------------------------------------------------------------------------------- genotypes ----------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.985 | #####################################################################################################################.... |
ped_only             0.775 | ......................................................................................................................... |
combined             0.992 | ######################################################################################################################### |
pop_only_x_chr       0.990 | #######################################################################################################################.. |
ped_only_x_chr       0.807 | #################........................................................................................................ |
combined_x_chr       0.990 | #######################################################################################################################.. |
--------------------------------------------------------------------------------- haplotypes ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pop_only             0.485 | ......................................................................................................................... |
ped_only             0.687 | ###############################################.......................................................................... |
combined             0.883 | #############################################################################################............................ |
pop_only_x_chr       0.998 | ########################################################################################################################. |
ped_only_x_chr       0.998 | ########################################################################################################################. |
combined_x_chr       1.000 | ######################################################################################################################### |
-------------------------------------------------------------------------------- segregation ---------------------------------------------------------------------------------
Method               Value     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ped_only             0.978 | ......................................................................................................................... |
combined             0.978 | ......................................................................................................................... |
ped_only_x_chr       0.990 | ######################################################################################################################### |
combined_x_chr       0.990 | ######################################################################################################################### |

----------------------------------------------------------------------------------- benchmark: 6 tests -----------------------------------------------------------------------------------
Name (time in s)                Min                Max               Mean            StdDev             Median               IQR            Outliers     OPS            Rounds  Iterations
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_accu[ped_only]         14.5152 (1.0)      16.7561 (1.07)     15.1573 (1.0)      0.9112 (4.59)     14.8994 (1.0)      0.7774 (3.59)          1;1  0.0660 (1.0)           5           1
test_sex_accu[pop_only]     14.8731 (1.02)     20.6160 (1.32)     18.9280 (1.25)     2.3127 (11.64)    19.7156 (1.32)     1.9514 (9.01)          1;1  0.0528 (0.80)          5           1
test_sex_accu[ped_only]     15.0893 (1.04)     15.6374 (1.0)      15.3421 (1.01)     0.1987 (1.0)      15.3467 (1.03)     0.2167 (1.0)           2;0  0.0652 (0.99)          5           1
test_accu[pop_only]         15.8955 (1.10)     18.1373 (1.16)     16.7629 (1.11)     0.8363 (4.21)     16.5011 (1.11)     0.8153 (3.76)          2;0  0.0597 (0.90)          5           1
test_sex_accu[combined]     22.2092 (1.53)     30.6899 (1.96)     27.5407 (1.82)     3.6452 (18.35)    29.1342 (1.96)     5.8089 (26.81)         1;0  0.0363 (0.55)          5           1
test_accu[combined]         26.2440 (1.81)     27.3298 (1.75)     26.5613 (1.75)     0.4454 (2.24)     26.3764 (1.77)     0.4632 (2.14)          1;0  0.0376 (0.57)          5           1
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================= 12 passed in 924.52s (0:15:24) =======================================================================

@AprilYUZhang

Copy link
Copy Markdown
Author

@XingerTang Good job! Thank you for moving forward.

@XingerTang

Copy link
Copy Markdown
Contributor

I think the example mentioned by

Do we have clear small example with X chr for AlphaImpute2? Could use one from AlphaPeel (assuming we have one). Such small examples are key for users to start using a tool.

refers to the example in the documentation, and for that the answer is no, we don't have an X chromosome example in the documentation for AlphaPeel.

@AprilYUZhang

Copy link
Copy Markdown
Author

I think the example mentioned by

Do we have clear small example with X chr for AlphaImpute2? Could use one from AlphaPeel (assuming we have one). Such small examples are key for users to start using a tool.

refers to the example in the documentation, and for that the answer is no, we don't have an X chromosome example in the documentation for AlphaPeel.

Do you mean document usage.rst?
For this, we have an X chromosome pedigree and genotype

id1 and id3 are males, while id2 and id4 are females:

::

id1 0 1 9 0
id2 1 1 1 1
id3 1 0 1 0
id4 0 2 1 0

@XingerTang

Copy link
Copy Markdown
Contributor

I think the example mentioned by

Do we have clear small example with X chr for AlphaImpute2? Could use one from AlphaPeel (assuming we have one). Such small examples are key for users to start using a tool.

refers to the example in the documentation, and for that the answer is no, we don't have an X chromosome example in the documentation for AlphaPeel.

Do you mean document usage.rst? For this, we have an X chromosome pedigree and genotype

id1 and id3 are males, while id2 and id4 are females:

::

id1 0 1 9 0
id2 1 1 1 1
id3 1 0 1 0
id4 0 2 1 0

They are not the same; I added the pedigree file format X Chr example to the AlphaImpute2 documentation in my last commit. But here, the example probably refers to this: https://alphapeel.readthedocs.io/en/latest/get_started.html#an-example

AprilYUZhang and others added 5 commits August 24, 2026 17:02
refactor the code to follow the order as the autosomal

update PhasingObject for rec

Fix anterior prob calc and more

Clean up code
@XingerTang

Copy link
Copy Markdown
Contributor

I squashed the original 56 commits into 5 commits through git rebase for a cleaner commit log. This marks the end of this PR, and any new changes (such as using the new simulation data instead of the old simulation data) can be moved to a new PR.

@XingerTang
XingerTang merged commit 32acec6 into AlphaGenes:devel Aug 24, 2026
3 checks passed
@gregorgorjanc

Copy link
Copy Markdown
Member

Great job @AprilYUZhang @XingerTang!!

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.

Add x_chr functionality

4 participants