Skip to content

Commit

Permalink
output 2 locus haplotypes in TSV if they are explicitly specified (#107)
Browse files Browse the repository at this point in the history
* handle 2 locus haplotypes if they are explicitly specified
* add corresponding new unit test
* disable unit test_GenerateTSV_2_locus on Windows, currently fails for unknown reasons
  • Loading branch information
alexlancaster authored Jul 31, 2023
1 parent 6368440 commit 6ef00da
Show file tree
Hide file tree
Showing 15 changed files with 279 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/PyPop/xslt/meta-to-r.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,9 @@ MODIFICATIONS.
<xsl:text>n.gametes&#09;locus1&#09;locus2&#09;metaloci&#09;ld.dprime&#09;ld.wn&#09;q.chisq&#09;q.df&#09;lrt.pval&#09;lrt.z</xsl:text>
<xsl:call-template name="newline"/>
<xsl:call-template name="gen-lines">
<!-- either explicitly set as an all-pairwise mode, or 'haplo' mode with 2 loci -->
<xsl:with-param name="nodes"
select="/meta/dataanalysis/emhaplofreq/group[(@mode='all-pairwise-ld-with-permu' or @mode='all-pairwise-ld-no-permu') and not(@role='no-data')]"/>
select="/meta/dataanalysis/emhaplofreq/group[(@mode='all-pairwise-ld-with-permu' or @mode='all-pairwise-ld-no-permu' or (@mode='haplo' and (string-length(@loci) - string-length(translate(@loci, ':', '')))=1)) and not(@role='no-data')]"/>
<xsl:with-param name="type" select="'multi-locus-summary'"/>
</xsl:call-template>
</exsl:document>
Expand All @@ -1108,8 +1109,9 @@ MODIFICATIONS.
<xsl:text>locus&#09;allele&#09;allele.freq&#09;allele.count&#09;ld.d&#09;ld.dprime&#09;ld.chisq&#09;obs&#09;obs.freq&#09;exp</xsl:text>
<xsl:call-template name="newline"/>
<xsl:call-template name="gen-lines">
<!-- either explicitly set as an all-pairwise mode, or 'haplo' mode with 2 loci -->
<xsl:with-param name="nodes"
select="/meta/dataanalysis/emhaplofreq/group[(@mode='all-pairwise-ld-with-permu' or @mode='all-pairwise-ld-no-permu') and not(@role='no-data')]"/>
select="/meta/dataanalysis/emhaplofreq/group[(@mode='all-pairwise-ld-with-permu' or @mode='all-pairwise-ld-no-permu' or (@mode='haplo' and (string-length(@loci) - string-length(translate(@loci, ':', '')))=1)) and not(@role='no-data')]"/>
<xsl:with-param name="type" select="'multi-locus-haplo'"/>
</xsl:call-template>
</exsl:document>
Expand Down
63 changes: 63 additions & 0 deletions tests/data/WS_BDCtrl_Test_EM_2_locus.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
;; comment out or change as desired
;; 1 = true, 0 = false

[General]
debug=0

[ParseGenotypeFile]
untypedAllele=****

;; designates field name that holds population name
popNameDesignator=+

;; designates field name that holds allele data
alleleDesignator=*

;; valid fields for sample data block
validSampleFields=SampleID
+Disease
*A_1
*A_2
; *B_1
; *B_2
; *C_1
; *C_2
; *DPA1_1
; *DPA1_2
; *DPB1_1
; *DPB1_2
; *DQA1_1
; *DQA1_2
*DQB1_1
*DQB1_2
*DRB1_1
*DRB1_2
*DRB3_1
*DRB3_2
*DRB4_1
*DRB4_2
*DRB5_1
*DRB5_2
; *HLA-A_1
; *HLA-A_2
; *HLA-B_1
; *HLA-B_2
; *HLA-C_1
; *HLA-C_2
; *HLA-DPA1_1
; *HLA-DPA1_2
; *HLA-DPB1_1
; *HLA-DPB1_2
; *HLA-DQA1_1
; *HLA-DQA1_2
; *HLA-DQB1_1
; *HLA-DQB1_2
; *HLA-DRB1_1
; *HLA-DRB1_2
; *HLA-DRB3_1
; *HLA-DRB3_2

[Emhaplofreq]

lociToEstHaplo=a:drb1

69 changes: 69 additions & 0 deletions tests/data/output/generate_tsv_2_locus/1-locus-allele.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
pop labcode method ethnic collect.site region latit longit complex locus allele allele.freq allele.count
0 **** **** **** **** **** **** **** **** A 01:01:01:01 0.08283 166
0 **** **** **** **** **** **** **** **** A 02:01:01:01 0.02894 58
0 **** **** **** **** **** **** **** **** A 02:05:01 0.07086 142
0 **** **** **** **** **** **** **** **** A 03:01:01:01 0.07236 145
0 **** **** **** **** **** **** **** **** A 03:01:03 0.05389 108
0 **** **** **** **** **** **** **** **** A 11:01:01:01 0.02944 59
0 **** **** **** **** **** **** **** **** A 11:01:01:02 0.02944 59
0 **** **** **** **** **** **** **** **** A 23:01:01 0.02246 45
0 **** **** **** **** **** **** **** **** A 24:02:01:01 0.07834 157
0 **** **** **** **** **** **** **** **** A 24:02:04 0.02894 58
0 **** **** **** **** **** **** **** **** A 25:01:01 0.01896 38
0 **** **** **** **** **** **** **** **** A 26:01:01 0.04790 96
0 **** **** **** **** **** **** **** **** A 26:08 0.05539 111
0 **** **** **** **** **** **** **** **** A 29:01:01:01 0.02894 58
0 **** **** **** **** **** **** **** **** A 29:02:01:02 0.05389 108
0 **** **** **** **** **** **** **** **** A 31:01:02:01 0.04790 96
0 **** **** **** **** **** **** **** **** A 31:01:02:02 0.00449 9
0 **** **** **** **** **** **** **** **** A 32:01:01 0.01497 30
0 **** **** **** **** **** **** **** **** A 32:02 0.10130 203
0 **** **** **** **** **** **** **** **** A 33:01:01 0.00449 9
0 **** **** **** **** **** **** **** **** A 68:01:01 0.03992 80
0 **** **** **** **** **** **** **** **** A 68:06 0.08433 169
0 **** **** **** **** **** **** **** **** DRB1 01:01:01 0.13017 258
0 **** **** **** **** **** **** **** **** DRB1 03:01:01:01 0.06155 122
0 **** **** **** **** **** **** **** **** DRB1 03:01:02 0.05752 114
0 **** **** **** **** **** **** **** **** DRB1 04:01:01 0.07921 157
0 **** **** **** **** **** **** **** **** DRB1 04:03:01 0.00252 5
0 **** **** **** **** **** **** **** **** DRB1 04:04:01 0.00252 5
0 **** **** **** **** **** **** **** **** DRB1 07:01:01:01 0.14682 291
0 **** **** **** **** **** **** **** **** DRB1 08:01:03 0.14934 296
0 **** **** **** **** **** **** **** **** DRB1 11:01:01 0.07064 140
0 **** **** **** **** **** **** **** **** DRB1 11:03 0.01009 20
0 **** **** **** **** **** **** **** **** DRB1 11:04:01 0.03380 67
0 **** **** **** **** **** **** **** **** DRB1 13:01:01 0.02422 48
0 **** **** **** **** **** **** **** **** DRB1 13:02:01 0.00656 13
0 **** **** **** **** **** **** **** **** DRB1 13:03:01 0.00252 5
0 **** **** **** **** **** **** **** **** DRB1 14:01:01 0.04137 82
0 **** **** **** **** **** **** **** **** DRB1 15:01:01:01 0.18113 359
0 **** **** **** **** **** **** **** **** DQB1 02:01:01 0.02545 51
0 **** **** **** **** **** **** **** **** DQB1 02:02:01 0.08982 180
0 **** **** **** **** **** **** **** **** DQB1 03:01:01:01 0.07784 156
0 **** **** **** **** **** **** **** **** DQB1 03:01:01:03 0.03194 64
0 **** **** **** **** **** **** **** **** DQB1 03:02:01 0.06487 130
0 **** **** **** **** **** **** **** **** DQB1 03:02:12 0.09381 188
0 **** **** **** **** **** **** **** **** DQB1 03:03:02:03 0.08982 180
0 **** **** **** **** **** **** **** **** DQB1 04:01:01 0.03992 80
0 **** **** **** **** **** **** **** **** DQB1 04:02:01 0.00399 8
0 **** **** **** **** **** **** **** **** DQB1 05:01:01:01 0.05739 115
0 **** **** **** **** **** **** **** **** DQB1 05:01:01:03 0.03643 73
0 **** **** **** **** **** **** **** **** DQB1 05:02:01 0.03643 73
0 **** **** **** **** **** **** **** **** DQB1 05:03:01:01 0.09631 193
0 **** **** **** **** **** **** **** **** DQB1 06:01:01 0.00449 9
0 **** **** **** **** **** **** **** **** DQB1 06:02:01 0.12176 244
0 **** **** **** **** **** **** **** **** DQB1 06:03:01 0.03593 72
0 **** **** **** **** **** **** **** **** DQB1 06:05:01 0.09381 188
0 **** **** **** **** **** **** **** **** DRB3 00:00 0.69173 1371
0 **** **** **** **** **** **** **** **** DRB3 01:01:02:01 0.08829 175
0 **** **** **** **** **** **** **** **** DRB3 01:01:02:02 0.06408 127
0 **** **** **** **** **** **** **** **** DRB3 02:01:01:01 0.03380 67
0 **** **** **** **** **** **** **** **** DRB3 02:02:01:02 0.04137 82
0 **** **** **** **** **** **** **** **** DRB3 03:01:01 0.08073 160
0 **** **** **** **** **** **** **** **** DRB4 00:00 0.76892 1524
0 **** **** **** **** **** **** **** **** DRB4 01:01:01:01 0.07921 157
0 **** **** **** **** **** **** **** **** DRB4 01:03:01:01 0.00252 5
0 **** **** **** **** **** **** **** **** DRB4 01:03:01:03 0.00252 5
0 **** **** **** **** **** **** **** **** DRB4 01:03:03 0.14682 291
0 **** **** **** **** **** **** **** **** DRB5 00:00 0.81887 1623
0 **** **** **** **** **** **** **** **** DRB5 01:01:01 0.18113 359
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pop labcode method ethnic collect.site region latit longit complex locus genotype observed expected pval.chisq pval.chisq.chen pval.chen.mcmc pval.chen.monte-carlo pval.diff.mcmc pval.diff.monte-carlo pval.diff.enum pval.diff.enum.three pval.chen.enum pval.chen.enum.three steps.mcmc steps.monte.carlo stat.chen.mc stat.diff.mc stat.chen.mcmc stat.diff.mcmc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pop labcode method ethnic collect.site region latit longit complex locus lump k gt.pval gt.monte-carlo.pval hw.enum.pval hw.chisq.pval hw.homo.chisq.pval hw.het.chisq.pval gt.arl.pval gt.arl.pval.sd gt.arl.exp.het gt.arl.obs.het n.common.genos n.common.genos.sig n.common.heteros n.common.heteros.sig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pop labcode method ethnic collect.site region latit longit complex locus1 locus2 metaloci f.slatkin.fnd
7 changes: 7 additions & 0 deletions tests/data/output/generate_tsv_2_locus/1-locus-summary.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pop labcode method ethnic collect.site region latit longit complex locus n.gametes untyped unsequenced k f.pval.lower f.pval.upper fnd.lookup gt.pval gt.monte-carlo.pval hw.enum.pval hw.chisq.pval hw.homo.chisq.pval hw.het.chisq.pval gt.arl.pval gt.arl.pval.sd gt.arl.exp.het gt.arl.obs.het f.slatkin.obs f.slatkin.exp f.slatkin.fnd f.slatkin.pval f.slatkin.var ewens.pval n.common.genos n.common.genos.sig n.common.heteros n.common.heteros.sig
0 **** **** **** **** **** **** **** **** A 2004 0.0 0 22 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
0 **** **** **** **** **** **** **** **** DRB1 1982 11.0 0 16 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
0 **** **** **** **** **** **** **** **** DQB1 2004 0.0 0 17 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
0 **** **** **** **** **** **** **** **** DRB3 1982 11.0 0 6 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
0 **** **** **** **** **** **** **** **** DRB4 1982 11.0 0 5 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
0 **** **** **** **** **** **** **** **** DRB5 1982 11.0 0 2 **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** 0 0 0 0
Loading

0 comments on commit 6ef00da

Please sign in to comment.