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: adding data specific p-value filters #788

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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: 7 additions & 0 deletions src/gentropy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,16 @@ class GWASCatalogSumstatsPreprocessConfig(StepConfig):
class EqtlCatalogueConfig(StepConfig):
"""eQTL Catalogue step configuration."""

session: Any = field(
default_factory=lambda: {
"start_hail": True,
}
)
eqtl_catalogue_paths_imported: str = MISSING
eqtl_catalogue_study_index_out: str = MISSING
eqtl_catalogue_credible_sets_out: str = MISSING
mqtl_quantification_methods_blacklist: list[str] = field(default_factory=lambda: [])
eqtl_lead_pvalue_threshold: float = 1e-3
_target_: str = "gentropy.eqtl_catalogue.EqtlCatalogueStep"


Expand Down Expand Up @@ -169,6 +175,7 @@ class FinngenFinemappingConfig(StepConfig):
_target_: str = (
"gentropy.finngen_finemapping_ingestion.FinnGenFinemappingIngestionStep"
)
finngen_finemapping_lead_pvalue_threshold: float = 1e-5
Copy link
Contributor

Choose a reason for hiding this comment

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

There's one thing I'm not sure about. You have added finngen_finemapping_lead_pvalue_threshold to the relevant config, and refer to as pvalue_cutoff=FinngenFinemappingConfig().finngen_finemapping_lead_pvalue_threshold in the step. However, finngen_finemapping_lead_pvalue_threshold it not an argument for FinnGenFinemappingIngestionStep. Is it OK? Would all parameters in the config passed to the step? Would that cause any problem? @project-defiant , what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, double-checked with @project-defiant and @d0choa and all parameters in the setepConfig classes needs to be parameters in the init function of the step.



@dataclass
Expand Down
23 changes: 16 additions & 7 deletions src/gentropy/eqtl_catalogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from gentropy.common.session import Session
from gentropy.config import EqtlCatalogueConfig
from gentropy.datasource.eqtl_catalogue.finemapping import EqtlCatalogueFinemapping
from gentropy.datasource.eqtl_catalogue.study_index import EqtlCatalogueStudyIndex

Expand Down Expand Up @@ -58,13 +59,21 @@ def __init__(
processed_susie_df = EqtlCatalogueFinemapping.parse_susie_results(
credible_sets_df, lbf_df, studies_metadata
)
credible_sets = EqtlCatalogueFinemapping.from_susie_results(processed_susie_df)
study_index = EqtlCatalogueStudyIndex.from_susie_results(processed_susie_df)

# Load
study_index.df.write.mode(session.write_mode).parquet(
eqtl_catalogue_study_index_out
(
EqtlCatalogueStudyIndex.from_susie_results(processed_susie_df)
# Writing the output:
.df.write.mode(session.write_mode)
.parquet(eqtl_catalogue_study_index_out)
)
credible_sets.df.write.mode(session.write_mode).parquet(
eqtl_catalogue_credible_sets_out

(
EqtlCatalogueFinemapping.from_susie_results(processed_susie_df)
# Flagging sub-significnat loci:
.validate_lead_pvalue(
pvalue_cutoff=EqtlCatalogueConfig().eqtl_lead_pvalue_threshold
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment: EqtlCatalogueConfig().eqtl_lead_pvalue_threshold has to be passed as parameter of the step.

)
# Writing the output:
.df.write.mode(session.write_mode)
.parquet(eqtl_catalogue_credible_sets_out)
)
22 changes: 13 additions & 9 deletions src/gentropy/finngen_finemapping_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ def __init__(
"""
# Read finemapping outputs from the input paths.

finngen_finemapping_df = FinnGenFinemapping.from_finngen_susie_finemapping(
spark=session.spark,
finngen_susie_finemapping_snp_files=finngen_susie_finemapping_snp_files,
finngen_susie_finemapping_cs_summary_files=finngen_susie_finemapping_cs_summary_files,
)

# Write the output.
finngen_finemapping_df.df.write.mode(session.write_mode).parquet(
finngen_finemapping_out
(
FinnGenFinemapping.from_finngen_susie_finemapping(
spark=session.spark,
finngen_susie_finemapping_snp_files=finngen_susie_finemapping_snp_files,
finngen_susie_finemapping_cs_summary_files=finngen_susie_finemapping_cs_summary_files,
)
# Flagging sub-significnat loci:
.validate_lead_pvalue(
pvalue_cutoff=FinngenFinemappingConfig().finngen_finemapping_lead_pvalue_threshold
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment: FinngenFinemappingConfig().finngen_finemapping_lead_pvalue_threshold has to be an init parameter of the step.

)
# Writing the output:
.df.write.mode(session.write_mode)
.parquet(finngen_finemapping_out)
)
15 changes: 11 additions & 4 deletions src/gentropy/pics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

from gentropy.common.session import Session
from gentropy.config import WindowBasedClumpingStepConfig
from gentropy.dataset.study_locus import CredibleInterval, StudyLocus
from gentropy.method.pics import PICS

Expand All @@ -28,8 +29,14 @@ def __init__(
session, study_locus_ld_annotated_in
)
# PICS
picsed_sl = PICS.finemap(study_locus_ld_annotated).filter_credible_set(
credible_interval=CredibleInterval.IS99
(
PICS.finemap(study_locus_ld_annotated)
.filter_credible_set(credible_interval=CredibleInterval.IS99)
# Flagging sub-significnat loci:
.validate_lead_pvalue(
pvalue_cutoff=WindowBasedClumpingStepConfig().gwas_significance
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment.

)
# Writing the output:
.df.write.mode(session.write_mode)
.parquet(picsed_study_locus_out)
)
# Write
picsed_sl.df.write.mode(session.write_mode).parquet(picsed_study_locus_out)
Loading