Ejemplo n.º 1
0
    def test_e_v(self):
        #assert RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=3, p=0) == (27+27)/(9+9)
        assert RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=3,
                                 p=1) == (18 + 18) / (6 + 6)
        assert RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=3,
                                 p=2) == (9 + 9) / (3 + 3)
        assert np.isnan(RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=3, p=3))

        # change w
        assert RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=2,
                                 p=1) == (18 + 18) / 12
        assert np.isnan(RaoPeakCaller.e_v(self.m, 3, 3, self.e, w=1, p=1))
Ejemplo n.º 2
0
    def test_e_d(self):
        #assert RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=3, p=0) == (9+9+45+45)/(9*4)
        assert RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=3,
                                 p=1) == (7 + 7 + 41 + 41) / (8 * 4)
        assert RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=3,
                                 p=2) == (3 + 3 + 27 + 27) / (5 * 4)
        assert np.isnan(RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=3, p=3))

        # change w
        assert RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=2,
                                 p=1) == (4 + 4 + 14 + 14) / (3 * 4)
        assert np.isnan(RaoPeakCaller.e_d(self.m, 3, 3, self.e, w=1, p=1))
Ejemplo n.º 3
0
    def test_e_h(self):
        #assert RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=3, p=0) == (9+45)/(9+9)
        assert RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=3,
                                 p=1) == (3 + 33) / (6 + 6)
        assert RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=3,
                                 p=2) == (0 + 18) / (3 + 3)
        assert np.isnan(RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=3, p=3))

        # change w
        assert RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=2,
                                 p=1) == (3 + 15) / 6
        assert np.isnan(RaoPeakCaller.e_h(self.m, 3, 3, self.e, w=1, p=1))
Ejemplo n.º 4
0
 def test_find_chunk(self):
     assert RaoPeakCaller.find_chunk(None) is None
     assert RaoPeakCaller.find_chunk(0) == 0
     assert RaoPeakCaller.find_chunk(1) == 1
     assert RaoPeakCaller.find_chunk(1.001) == 1
     assert RaoPeakCaller.find_chunk(1.5) == 2
     assert RaoPeakCaller.find_chunk(1.7) == 3
     assert RaoPeakCaller.find_chunk(30) == 15
     assert RaoPeakCaller.find_chunk(1024) == 31
Ejemplo n.º 5
0
    def test_call_peaks(self):
        dir = os.path.dirname(os.path.realpath(__file__))
        hic_10kb = fanc.load(dir +
                             "/test_peaks/rao2014.chr11_77400000_78600000.hic",
                             mode='r')

        peak_caller = RaoPeakCaller()
        peaks = peak_caller.call_peaks(hic_10kb)

        assert len(peaks.edges) == 6525

        valid_peaks = []

        has_43_57 = False
        for peak in peaks.edges:
            if peak.fdr_ll < 0.1 and peak.fdr_v < 0.1 and peak.fdr_h < 0.1 and peak.fdr_d < 0.1:
                valid_peaks.append(peak)
            if peak.source == 43 and peak.sink == 57:
                has_43_57 = True

        assert len(valid_peaks) == 134
        assert has_43_57
        hic_10kb.close()
        peaks.close()
Ejemplo n.º 6
0
    def test_ll_sum(self):
        # change p
        #assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=3, p=0) == 9
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=3, p=1) == 7
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=3, p=2) == 3
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=3, p=3) == 0
        # change w
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=4, p=1) == 7
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=2, p=1) == 4
        assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=1, p=1) == 0
        # change p and w
        #assert RaoPeakCaller.ll_sum(self.m, 3, 3, w=1, p=0) == 2

        # edge case
        assert RaoPeakCaller.ll_sum(self.m, 2, 2, w=3, p=1) == 2
Ejemplo n.º 7
0
    def test_e_ll(self):
        #assert RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=3, p=0) == 1
        assert RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=3, p=1) == 7 / 8
        assert RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=3, p=2) == 3 / 5
        assert np.isnan(RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=3, p=3))

        # change w
        assert RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=2, p=1) == 4 / 3
        assert np.isnan(RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=1, p=1))
        # change p and w
        #assert RaoPeakCaller.e_ll(self.m, 3, 3, self.e, w=1, p=0) == 2

        # edge case
        assert RaoPeakCaller.e_ll(self.m, 2, 2, self.e, w=3, p=1) == 2 / 5