@@ -11,12 +11,19 @@ class Bootstrap:
1111 containing parameter values.
1212 """
1313 def __init__ (self , bootfile ):
14+ """
15+ Constructor.
16+ """
1417 self .bootfile = bootfile
1518 self .breps = {}
1619 self .triples = []
1720 self ._read_bootstraps (bootfile )
1821
1922 def __call__ (self , attr , p1 , hyb , p2 ):
23+ """
24+ A callable method to access attributes rom a bootstrapped
25+ HyDe analysis. Returned as a list.
26+ """
2027 return [t [attr ] for t in self .breps [(p1 , hyb , p2 )]]
2128
2229 def _read_bootstraps (self , bootfile ):
@@ -64,7 +71,7 @@ def _boot_info(self, b):
6471
6572 def summarize (self ):
6673 """
67-
74+ Summarizes the results of a bootsrapped HyDe analysis.
6875 """
6976 summaries = {}
7077 for t in self .triples :
@@ -75,15 +82,28 @@ def summarize(self):
7582 return summaries
7683
7784 def gamma (self , p1 , hyb , p2 ):
85+ """
86+ Return the values of gamma for the triple (p1, hyb, p2).
87+ """
7888 return [t ['Gamma' ] for t in self .breps [(p1 , hyb , p2 )]]
7989
8090 def zscore (self , p1 , hyb , p2 ):
91+ """
92+ Return the values of the test statistic for the triple (p1, hyb, p2).
93+ """
8194 return [t ['Zscore' ] for t in self .breps [(p1 , hyb , p2 )]]
8295
8396 def pvalue (self , p1 , hyb , p2 ):
97+ """
98+ Return the p-values for the triple (p1, hyb, p2).
99+ """
84100 return [t ['Pvalue' ] for t in self .breps [(p1 , hyb , p2 )]]
85101
86102 def abba_baba (self , p1 , hyb , p2 ):
103+ """
104+ Calculate Patterson's D-Statistic for all bootstrap replicates
105+ for the triple (p1, hyb, p2). Uses vectorization with numpy arrays.
106+ """
87107 return ((np .array ([t ['ABBA' ] for t in self .breps [(p1 , hyb , p2 )]]) - np .array ([t ['ABAB' ] for t in self .breps [(p1 , hyb , p2 )]])) /
88108 (np .array ([t ['ABBA' ] for t in self .breps [(p1 , hyb , p2 )]]) + np .array ([t ['ABAB' ] for t in self .breps [(p1 , hyb , p2 )]])))
89109
0 commit comments