Skip to content

Commit

Permalink
fix: removed unused coloc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xyg123 committed Mar 12, 2024
1 parent e5c0e56 commit 8aa507d
Showing 1 changed file with 0 additions and 134 deletions.
134 changes: 0 additions & 134 deletions tests/gentropy/method/test_colocalisation_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,140 +54,6 @@ def test_single_snp_coloc(
assert difference.filter(f.abs(f.col(col)) > threshold).count() == 0


def test_single_snp_coloc(
spark: SparkSession,
threshold: float = 1e-5,
) -> None:
"""Test edge case of coloc where only one causal SNP is present in the StudyLocusOverlap."""
test_overlap_df = spark.createDataFrame(
[
{
"leftStudyLocusId": 1,
"rightStudyLocusId": 2,
"chromosome": "1",
"tagVariantId": "snp",
"left_logBF": 10.3,
"right_logBF": 10.5,
}
]
)
test_overlap = StudyLocusOverlap(
test_overlap_df.select(
"leftStudyLocusId",
"rightStudyLocusId",
"chromosome",
"tagVariantId",
f.struct(f.col("left_logBF"), f.col("right_logBF")).alias("statistics"),
),
StudyLocusOverlap.get_schema(),
)
test_result = Coloc.colocalise(test_overlap)

expected = spark.createDataFrame(
[
{
"h0": 9.254841951638903e-5,
"h1": 2.7517068829182966e-4,
"h2": 3.3609423764447284e-4,
"h3": 9.254841952564387e-13,
"h4": 0.9992961866536217,
}
]
)
difference = test_result.df.select("h0", "h1", "h2", "h3", "h4").subtract(expected)
for col in difference.columns:
assert difference.filter(f.abs(f.col(col)) > threshold).count() == 0


def test_single_snp_coloc_one_negative(
spark: SparkSession,
threshold: float = 1e-5,
) -> None:
"""Test edge case of coloc where only one causal SNP is present (On one side!) in the StudyLocusOverlap."""
test_overlap_df = spark.createDataFrame(
[
{
"leftStudyLocusId": 1,
"rightStudyLocusId": 2,
"chromosome": "1",
"tagVariantId": "snp",
"left_logBF": 18.3,
"right_logBF": 0.01,
}
]
)
test_overlap = StudyLocusOverlap(
test_overlap_df.select(
"leftStudyLocusId",
"rightStudyLocusId",
"chromosome",
"tagVariantId",
f.struct(f.col("left_logBF"), f.col("right_logBF")).alias("statistics"),
),
StudyLocusOverlap.get_schema(),
)
test_result = Coloc.colocalise(test_overlap)
test_result.df.show(1, False)
expected = spark.createDataFrame(
[
{
"h0": 1.0246538505087709e-4,
"h1": 0.9081680002273896,
"h2": 1.0349517929098209e-8,
"h3": 1.0246538506112363e-12,
"h4": 0.09172952403701702,
}
]
)
difference = test_result.df.select("h0", "h1", "h2", "h3", "h4").subtract(expected)
for col in difference.columns:
assert difference.filter(f.abs(f.col(col)) > threshold).count() == 0


def test_single_snp_coloc_both_negative(
spark: SparkSession,
threshold: float = 1e-5,
) -> None:
"""Test edge case of coloc where only one non-causal SNP overlaps in the StudyLocusOverlap."""
test_overlap_df = spark.createDataFrame(
[
{
"leftStudyLocusId": 1,
"rightStudyLocusId": 2,
"chromosome": "1",
"tagVariantId": "snp",
"left_logBF": 0.03,
"right_logBF": 0.01,
}
]
)
test_overlap = StudyLocusOverlap(
test_overlap_df.select(
"leftStudyLocusId",
"rightStudyLocusId",
"chromosome",
"tagVariantId",
f.struct(f.col("left_logBF"), f.col("right_logBF")).alias("statistics"),
),
StudyLocusOverlap.get_schema(),
)
test_result = Coloc.colocalise(test_overlap)
expected = spark.createDataFrame(
[
{
"h0": 0.9997855774090624,
"h1": 1.0302335812225042e-4,
"h2": 1.0098335895103664e-4,
"h3": 9.9978557750904e-9,
"h4": 1.0405876008495098e-5,
}
]
)
difference = test_result.df.select("h0", "h1", "h2", "h3", "h4").subtract(expected)
for col in difference.columns:
assert difference.filter(f.abs(f.col(col)) > threshold).count() == 0


def test_ecaviar(mock_study_locus_overlap: StudyLocusOverlap) -> None:
"""Test eCAVIAR."""
assert isinstance(ECaviar.colocalise(mock_study_locus_overlap), Colocalisation)

0 comments on commit 8aa507d

Please sign in to comment.