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(sumstats): correct study id for dir of finngen studies #551

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all 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
7 changes: 5 additions & 2 deletions src/gentropy/datasource/finngen/summary_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def from_source(
Returns:
SummaryStatistics: Processed summary statistics dataset
"""
study_id = raw_file.split("/")[-1].split(".")[0].upper()
processed_summary_stats_df = (
spark.read.schema(cls.raw_schema)
.option("delimiter", "\t")
Expand All @@ -59,7 +58,11 @@ def from_source(
.filter(f.col("pos").cast(t.IntegerType()).isNotNull())
.select(
# From the full path, extracts just the filename, and converts to upper case to get the study ID.
f.lit(study_id).alias("studyId"),
f.upper(
f.regexp_extract(
f.input_file_name(), r"([^/]+)(\.tsv\.gz|\.gz|\.tsv)", 1
)
).alias("studyId"),
# Add variant information.
f.concat_ws(
"_",
Expand Down