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: repair SusieFinemapperStep to work with new SL schema and fix lo… #957

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions src/gentropy/susie_finemapper.py
Daniel-Considine marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
from pyspark.sql import DataFrame, Row, Window
from pyspark.sql.functions import desc, row_number
from pyspark.sql.types import (
ArrayType,
DoubleType,
FloatType,
IntegerType,
StringType,
StructField,
Expand Down Expand Up @@ -273,7 +275,7 @@ def susie_inf_to_studylocus( # noqa: C901
),
"variantId",
)
.sort(f.desc("posteriorProbability"))
.sort(f.desc(f.col("posteriorProbability").cast("double")))
.withColumn(
"locus",
f.collect_list(
Expand Down Expand Up @@ -896,7 +898,63 @@ def susie_finemapper_one_sl_row_gathered_boundaries( # noqa: C901
logging.warning("Analysis Flags check failed for this study")
return None

schema = StudyLocus.get_schema()
schema = StructType(
Daniel-Considine marked this conversation as resolved.
Show resolved Hide resolved
[
StructField("studyLocusId", StringType(), True),
StructField("studyType", StringType(), True),
StructField("variantId", StringType(), True),
StructField("chromosome", StringType(), True),
StructField("position", IntegerType(), True),
StructField("region", StringType(), True),
StructField("studyId", StringType(), True),
StructField("beta", DoubleType(), True),
StructField("zScore", DoubleType(), True),
StructField("pValueMantissa", FloatType(), True),
StructField("pValueExponent", IntegerType(), True),
StructField("effectAlleleFrequencyFromSource", FloatType(), True),
StructField("standardError", DoubleType(), True),
StructField("subStudyDescription", StringType(), True),
StructField("qualityControls", ArrayType(StringType(), True), True),
StructField("finemappingMethod", StringType(), True),
StructField("credibleSetIndex", IntegerType(), True),
StructField("credibleSetlog10BF", DoubleType(), True),
StructField("purityMeanR2", DoubleType(), True),
StructField("purityMinR2", DoubleType(), True),
StructField("locusStart", IntegerType(), True),
StructField("locusEnd", IntegerType(), True),
StructField("sampleSize", IntegerType(), True),
StructField(
"ldSet",
ArrayType(
StructType(
[
StructField("tagVariantId", StringType(), True),
StructField("r2Overall", DoubleType(), True),
]
),
True,
),
True,
),
StructField(
"locus",
ArrayType(
StructType(
[
StructField("variantId", StringType(), True),
StructField("beta", DoubleType(), True),
StructField("pValueMantissa", FloatType(), True),
StructField("pValueExponent", IntegerType(), True),
StructField("standardError", DoubleType(), True),
]
),
False,
),
True,
),
StructField("confidence", StringType(), True),
]
)
gwas_df = session.spark.createDataFrame([study_locus_row], schema=schema)
exploded_df = gwas_df.select(f.explode("locus").alias("locus"))

Expand Down
Loading