From 8aa507d2892183402e9b4fb41bd3f879e0ded6b9 Mon Sep 17 00:00:00 2001 From: xyg123 Date: Tue, 12 Mar 2024 12:32:55 +0000 Subject: [PATCH] fix: removed unused coloc tests --- .../method/test_colocalisation_method.py | 134 ------------------ 1 file changed, 134 deletions(-) diff --git a/tests/gentropy/method/test_colocalisation_method.py b/tests/gentropy/method/test_colocalisation_method.py index f28ddf120..1f52244be 100644 --- a/tests/gentropy/method/test_colocalisation_method.py +++ b/tests/gentropy/method/test_colocalisation_method.py @@ -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)