@@ -737,6 +737,7 @@ test_that(
737737test_that(
738738 ' apply.polygenic.score correctly handles strand flipping' , {
739739 load(' data/strand.flip.test.data.Rda' );
740+ # no strand flip correction
740741 strand.flip.raw.data <- apply.polygenic.score(
741742 vcf.data = strand.flip.test.data $ strand.flip.vcf.data ,
742743 pgs.weight.data = strand.flip.test.data $ strand.flip.pgs.weight.data ,
@@ -754,6 +755,7 @@ test_that(
754755 c(0 , 0 , 0 )
755756 );
756757
758+ # strand flip correction
757759 strand.flip.correct.flips <- apply.polygenic.score(
758760 vcf.data = strand.flip.test.data $ strand.flip.vcf.data ,
759761 pgs.weight.data = strand.flip.test.data $ strand.flip.pgs.weight.data ,
@@ -771,6 +773,7 @@ test_that(
771773 c(0 , 0 , 0 )
772774 );
773775
776+ # ambiguous allele matches removed
774777 strand.flip.remove.ambiguous <- apply.polygenic.score(
775778 vcf.data = strand.flip.test.data $ strand.flip.vcf.data ,
776779 pgs.weight.data = strand.flip.test.data $ strand.flip.pgs.weight.data ,
@@ -789,6 +792,28 @@ test_that(
789792 c(2 , 2 , 2 )
790793 );
791794
795+ # ambiguous allele matches not removed due to threshold
796+ strand.flip.threshold.ambiguous <- apply.polygenic.score(
797+ vcf.data = strand.flip.test.data $ strand.flip.vcf.data ,
798+ pgs.weight.data = strand.flip.test.data $ strand.flip.pgs.weight.data ,
799+ correct.strand.flips = TRUE ,
800+ missing.genotype.method = c(' none' , ' mean.dosage' , ' normalize' ),
801+ remove.ambiguous.allele.matches = TRUE ,
802+ max.strand.flips = 3 # there are two unambiguous strand flips in the test data, setting threshold above that
803+ );
804+
805+ # expect equal to not removing ambiguous allele matches
806+ expect_equal(
807+ strand.flip.threshold.ambiguous $ pgs.output $ PGS , # dosage is unaffected because unresolved mismatch does not contain an effect allele so dosage is 0
808+ strand.flip.correct.flips $ pgs.output $ PGS
809+ );
810+
811+ expect_equal(
812+ strand.flip.threshold.ambiguous $ pgs.output $ n.missing.genotypes ,
813+ c(1 , 1 , 1 ) # the unresolved mismatch is marked missing
814+ );
815+
816+ # indels removed
792817 strand.flip.remove.indel.mismatches <- apply.polygenic.score(
793818 vcf.data = strand.flip.test.data $ strand.flip.vcf.data ,
794819 pgs.weight.data = strand.flip.test.data $ strand.flip.pgs.weight.data ,
0 commit comments