Skip to content

Commit 6871d7d

Browse files
fix: fixed selection of major ancestry for finemapper (#685)
1 parent 421a5fe commit 6871d7d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/gentropy/susie_finemapper.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
)
2323

2424
from gentropy.common.session import Session
25-
from gentropy.common.spark_helpers import neglog_pvalue_to_mantissa_and_exponent
25+
from gentropy.common.spark_helpers import (
26+
neglog_pvalue_to_mantissa_and_exponent,
27+
order_array_of_structs_by_field,
28+
)
2629
from gentropy.dataset.study_index import StudyIndex
2730
from gentropy.dataset.study_locus import StudyLocus
2831
from gentropy.dataset.summary_statistics import SummaryStatistics
@@ -1263,9 +1266,9 @@ def susie_finemapper_one_sl_row_v4_ss_gathered_boundaries(
12631266
study_index_df = study_index_df.filter(f.col("studyId") == studyId)
12641267
major_population = study_index_df.select(
12651268
"studyId",
1266-
f.array_max(f.col("ldPopulationStructure"))
1267-
.getItem("ldPopulation")
1268-
.alias("majorPopulation"),
1269+
order_array_of_structs_by_field(
1270+
"ldPopulationStructure", "relativeSampleSize"
1271+
)[0]["ldPopulation"].alias("majorPopulation"),
12691272
).collect()[0]["majorPopulation"]
12701273

12711274
region = chromosome + ":" + str(int(locusStart)) + "-" + str(int(locusEnd))

0 commit comments

Comments
 (0)