Example #1
0
    def test_alignAllCluster_1(self):
        """Test the best cluster align
        
        This is using the best possible conditions with only 7 seconds retention time cutoff

          - Run1 : 100s     [threadRT = 100s] 
          - Run2 : 112s     [threadRT = 106s]
          - Run3 : 120s     [threadRT = 118s]
          - Run4 : xxx      [threadRT = 126s]  (should be around 130s)
          - Run5 : 139s     [threadRT = 133s]
        """

        spl_aligner = SplineAligner(self.initial_alignment_cutoff)
        tree = MinimumSpanningTree(
            algo.getDistanceMatrix(self.exp, self.multipeptides, spl_aligner))
        tree_mapped = [(self.exp.runs[a].get_id(), self.exp.runs[b].get_id())
                       for a, b in tree]

        alignment = algo.TreeConsensusAlignment(max_rt_diff=6,
                                                fdr_cutoff=0.1,
                                                aligned_fdr_cutoff=0.25,
                                                correctRT_using_pg=True,
                                                verbose=True)
        alignment.alignAllCluster(self.multipeptides, tree_mapped,
                                  self.tr_data)

        # We should have 4 peakgroups
        prec1 = self.mpep
        self.assertEqual(len(prec1.get_selected_peakgroups()), 4)

        # Check that we have all the correct ones (1,2,4,8)
        self.assertEqual(
            set(['peakgroup8', 'peakgroup2', 'peakgroup4', 'peakgroup1']),
            set([p.get_feature_id() for p in prec1.get_selected_peakgroups()]))
Example #2
0
    def test_alignBestCluster_1(self):
        """Test the best cluster align

        This is now using no correction of the alignment thread by using the
        found peakgroup. In this case it means that after finding the second
        peakgroup at 112 s, the search RT for run 2 is still at 106 seconds
        which gets mapped to 112 seconds in run 3 (but the next pg is at 120s,
        too far for 7 seconds tolerance).
        """

        spl_aligner = SplineAligner(self.initial_alignment_cutoff)
        tree = MinimumSpanningTree(
            algo.getDistanceMatrix(self.exp, self.multipeptides, spl_aligner))
        tree_mapped = [(self.exp.runs[a].get_id(), self.exp.runs[b].get_id())
                       for a, b in tree]

        alignment = algo.TreeConsensusAlignment(max_rt_diff=6,
                                                fdr_cutoff=0.1,
                                                aligned_fdr_cutoff=0.25,
                                                correctRT_using_pg=False)
        alignment.alignBestCluster_legacy(self.multipeptides, tree_mapped,
                                          self.tr_data)

        # Now only 2 peakgroups should be selected
        prec1 = self.mpep
        self.assertEqual(len(prec1.get_selected_peakgroups()), 2)

        # Check that we have all the correct ones (only 1,2)
        self.assertEqual(
            set(['peakgroup2', 'peakgroup1']),
            set([p.get_feature_id() for p in prec1.get_selected_peakgroups()]))
Example #3
0
    def test_alignBestCluster_2(self):
        """Test the best cluster align

        This is now using no correction of the alignment thread by using the
        found peakgroup (e.g. no correction of the threading). 

          - Run1 : 100s     [threadRT = 100s] 
          - Run2 : 112s     [threadRT = 106s]
          - Run3 : 120s     [threadRT = 112s]
          - Run4 : xxx      [threadRT = 118s]
          - Run5 : 139s     [threadRT = 124s]

        By using a larger tolerance of 15s, we can still manage to find all the correct peakgroups
        """

        spl_aligner = SplineAligner(self.initial_alignment_cutoff)
        tree = MinimumSpanningTree(
            algo.getDistanceMatrix(self.exp, self.multipeptides, spl_aligner))
        tree_mapped = [(self.exp.runs[a].get_id(), self.exp.runs[b].get_id())
                       for a, b in tree]

        alignment = algo.TreeConsensusAlignment(max_rt_diff=15,
                                                fdr_cutoff=0.1,
                                                aligned_fdr_cutoff=0.25,
                                                correctRT_using_pg=False)
        alignment.alignBestCluster_legacy(self.multipeptides, tree_mapped,
                                          self.tr_data)

        # Now only 2 peakgroups should be selected
        prec1 = self.mpep
        self.assertEqual(len(prec1.get_selected_peakgroups()), 4)

        # Check that we have all the correct ones (1,2,4,8)
        self.assertEqual(
            set(['peakgroup8', 'peakgroup2', 'peakgroup4', 'peakgroup1']),
            set([p.get_feature_id() for p in prec1.get_selected_peakgroups()]))