コード例 #1
0
ファイル: Annotator.py プロジェクト: trevismd/statannotations
    def _get_results(self,
                     num_comparisons,
                     pvalues=None,
                     **stats_params) -> List[Annotation]:

        test_result_list = []

        if num_comparisons == "auto":
            num_comparisons = len(self._struct_pairs)

        for group_struct1, group_struct2 in self._struct_pairs:
            group1 = group_struct1['group']
            group2 = group_struct2['group']

            if self.perform_stat_test:
                result = self._get_stat_result_from_test(
                    group_struct1, group_struct2, num_comparisons,
                    **stats_params)
            else:
                result = self._get_custom_results(group_struct1, pvalues)

            result.group1 = group1
            result.group2 = group2

            test_result_list.append(
                Annotation((group_struct1, group_struct2),
                           result,
                           formatter=self.pvalue_format))

        # Perform other types of correction methods for multiple testing
        self._apply_comparisons_correction(test_result_list)

        return test_result_list
コード例 #2
0
 def test_missing_formatter(self):
     res = StatResult("Custom test", None, pval=0.05, stat=None,
                      stat_str=None)
     with self.assertRaisesRegex(ValueError, "PValueFormat"):
         annotation = Annotation(("group1", "group2"),
                                 res)
         print(annotation.text)
コード例 #3
0
    def set_custom_annotations(self, text_annot_custom):
        """
        :param text_annot_custom: List of strings to annotate for each
            `pair`
        """
        self._check_has_plotter()

        self._check_correct_number_custom_annotations(text_annot_custom)
        self.annotations = [Annotation(struct, text) for
                            struct, text in zip(self._struct_pairs,
                                                text_annot_custom)]
        self.show_test_name = False
        self._deactivate_configured_warning()
        return self
コード例 #4
0
 def test_text_string(self):
     annotation_text = "p=0.05"
     annotation = Annotation(("group1", "group2"),
                             annotation_text)
     self.assertEqual(annotation.text, annotation_text)
     self.assertEqual(annotation.formatted_output, annotation_text)