AutoStatLib 0.2.12__tar.gz → 0.2.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of AutoStatLib might be problematic. Click here for more details.

Files changed (21) hide show
  1. {autostatlib-0.2.12/src/AutoStatLib.egg-info → autostatlib-0.2.14}/PKG-INFO +44 -46
  2. {autostatlib-0.2.12 → autostatlib-0.2.14}/README.md +43 -45
  3. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/AutoStatLib.py +5 -4
  4. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/StatPlots.py +85 -55
  5. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/_version.py +1 -1
  6. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/helpers.py +2 -2
  7. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/statistical_tests.py +37 -12
  8. {autostatlib-0.2.12 → autostatlib-0.2.14/src/AutoStatLib.egg-info}/PKG-INFO +44 -46
  9. {autostatlib-0.2.12 → autostatlib-0.2.14}/LICENSE +0 -0
  10. {autostatlib-0.2.12 → autostatlib-0.2.14}/MANIFEST.in +0 -0
  11. {autostatlib-0.2.12 → autostatlib-0.2.14}/pyproject.toml +0 -0
  12. {autostatlib-0.2.12 → autostatlib-0.2.14}/requirements.txt +0 -0
  13. {autostatlib-0.2.12 → autostatlib-0.2.14}/setup.cfg +0 -0
  14. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/__init__.py +0 -0
  15. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/__main__.py +0 -0
  16. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/normality_tests.py +0 -0
  17. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib/text_formatting.py +0 -0
  18. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib.egg-info/SOURCES.txt +0 -0
  19. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib.egg-info/dependency_links.txt +0 -0
  20. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib.egg-info/requires.txt +0 -0
  21. {autostatlib-0.2.12 → autostatlib-0.2.14}/src/AutoStatLib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AutoStatLib
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: AutoStatLib - a simple statistical analysis tool
5
5
  Author: Stemonitis, SciWare LLC
6
6
  Author-email: konung-yaropolk <yaropolk1995@gmail.com>
@@ -537,7 +537,7 @@ Requires-Dist: scikit-posthocs
537
537
  Requires-Dist: pandas
538
538
  Dynamic: license-file
539
539
 
540
- # AutoStatLib - python library for automated statistical analysis
540
+ # AutoStatLib - python library for automated statistical analysis
541
541
 
542
542
  [![pypi_version](https://img.shields.io/pypi/v/AutoStatLib?label=PyPI&color=green)](https://pypi.org/project/AutoStatLib)
543
543
  [![GitHub Release](https://img.shields.io/github/v/release/konung-yaropolk/AutoStatLib?label=GitHub&color=green&link=https%3A%2F%2Fgithub.com%2Fkonung-yaropolk%2FAutoStatLib)](https://github.com/konung-yaropolk/AutoStatLib)
@@ -545,17 +545,16 @@ Dynamic: license-file
545
545
  [![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/AutoStatLib)
546
546
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/AutoStatLib?label=PyPI%20stats&color=blue)](https://pypi.org/project/AutoStatLib)
547
547
 
548
-
549
548
  ### To install run the command:
549
+
550
550
  ```bash
551
551
  pip install autostatlib
552
552
  ```
553
553
 
554
-
555
554
  ### Example use case:
556
- See the /demo directory on Git repo or
557
- use the following example:
558
555
 
556
+ See the /demo directory on Git repo or
557
+ use the following example:
559
558
 
560
559
  ```python
561
560
  import numpy as np
@@ -584,11 +583,13 @@ analysis = AutoStatLib.StatisticalAnalysis(
584
583
  ```
585
584
 
586
585
  now you can preform automated statistical test selection:
586
+
587
587
  ```python
588
588
  analysis.RunAuto()
589
589
  ```
590
590
 
591
591
  or you can choose specific tests:
592
+
592
593
  ```python
593
594
  # 2 groups independent:
594
595
  analysis.RunTtest()
@@ -615,15 +616,18 @@ Test summary will be printed to the console.
615
616
  You can also get it as a python string via *GetSummary()* method.
616
617
 
617
618
  ---
619
+
618
620
  Test results are accessible as a dictionary via *GetResult()* method:
621
+
619
622
  ```python
620
623
  results = analysis.GetResult()
621
624
  ```
622
625
 
623
626
  The results dictionary keys with representing value types:
627
+
624
628
  ```
625
629
  {
626
- 'p-value' : String
630
+ 'p_value' : String
627
631
  'Significance(p<0.05)' : Boolean
628
632
  'Stars_Printed' : String
629
633
  'Test_Name' : String
@@ -633,7 +637,7 @@ The results dictionary keys with representing value types:
633
637
  'Parametric_Test_Applied' : Boolean
634
638
  'Paired_Test_Applied' : Boolean
635
639
  'Tails' : Integer (taken from the input)
636
- 'p-value_exact' : Float
640
+ 'p_value_exact' : Float
637
641
  'Stars' : Integer
638
642
  'Warnings' : String
639
643
  'Groups_N' : List of integers
@@ -649,50 +653,44 @@ The results dictionary keys with representing value types:
649
653
  'Posthoc_Matrix_stars': 2D List of String
650
654
  }
651
655
  ```
652
- If errors occured, *GetResult()* returns an empty dictionary
653
-
654
656
 
657
+ If errors occured, *GetResult()* returns an empty dictionary
655
658
 
659
+ ---
656
660
 
661
+ ## Pre-Alpha dev status.
657
662
 
663
+ ### TODO:
658
664
 
659
- ---
660
- ## Pre-Alpha dev status.
661
-
662
- ### TODO:
663
-
664
- -- Anova: posthocs
665
- -- Anova: add 2-way anova and 3-way anova
666
- -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
667
- -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
668
- -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
665
+ -- Anova: posthocs
666
+ -- Anova: add 2-way anova and 3-way anova
667
+ -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
668
+ -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
669
+ -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
669
670
  -- add Welch test (for norm data unequal variances)
670
- -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
671
- -- add independent t-test with Welch correction (do not assume equal SDs in groups)
672
- -- add correlation test, correlation diagram
673
- -- add linear regression, regression diagram
671
+ -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
672
+ -- add independent t-test with Welch correction (do not assume equal SDs in groups)
673
+ -- add correlation test, correlation diagram
674
+ -- add linear regression, regression diagram
674
675
  -- add QQ plot
675
676
  -- n-sample tests: add onetail option
676
-
677
- ✅ done -- detailed normality test results
678
- ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
679
-
680
-
681
- tests check:
682
- 1-sample:
683
- --Wilcoxon 2,1 tails - ok
684
- --t-tests 2,1 tails -ok
685
-
686
- 2-sample:
687
- --Wilcoxon 2,1 tails - ok
688
- --Mann-whitney 2,1 tails - ok
689
- --t-tests 2,1 tails -ok
690
-
691
- n-sample:
692
- --Kruskal-Wallis 2 tail - ok
693
- --Dunn's multiple comparisons - ??
694
- --Friedman 2 tail - ok
695
- --one-way ANOWA 2 tail - ok
696
-
697
-
698
677
 
678
+ ✅ done -- detailed normality test results
679
+ ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
680
+
681
+ tests check:
682
+ 1-sample:
683
+ --Wilcoxon 2,1 tails - ✅ok
684
+ --t-tests 2,1 tails -✅ok
685
+
686
+ 2-sample:
687
+ --Wilcoxon 2,1 tails - ✅ok
688
+ --Mann-whitney 2,1 tails - ✅ok
689
+ --t-tests 2,1 tails -✅ok
690
+
691
+ n-sample:
692
+ --Kruskal-Wallis 2 tail - ✅ok
693
+ --Dunn's multiple comparisons - ✅ok
694
+ --Friedman 2 tail - ✅ok
695
+ --one-way ANOWA 2 tail - ✅ok
696
+ --Tukey`s multiple comparisons - ✅ok
@@ -1,4 +1,4 @@
1
- # AutoStatLib - python library for automated statistical analysis
1
+ # AutoStatLib - python library for automated statistical analysis
2
2
 
3
3
  [![pypi_version](https://img.shields.io/pypi/v/AutoStatLib?label=PyPI&color=green)](https://pypi.org/project/AutoStatLib)
4
4
  [![GitHub Release](https://img.shields.io/github/v/release/konung-yaropolk/AutoStatLib?label=GitHub&color=green&link=https%3A%2F%2Fgithub.com%2Fkonung-yaropolk%2FAutoStatLib)](https://github.com/konung-yaropolk/AutoStatLib)
@@ -6,17 +6,16 @@
6
6
  [![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/AutoStatLib)
7
7
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/AutoStatLib?label=PyPI%20stats&color=blue)](https://pypi.org/project/AutoStatLib)
8
8
 
9
-
10
9
  ### To install run the command:
10
+
11
11
  ```bash
12
12
  pip install autostatlib
13
13
  ```
14
14
 
15
-
16
15
  ### Example use case:
17
- See the /demo directory on Git repo or
18
- use the following example:
19
16
 
17
+ See the /demo directory on Git repo or
18
+ use the following example:
20
19
 
21
20
  ```python
22
21
  import numpy as np
@@ -45,11 +44,13 @@ analysis = AutoStatLib.StatisticalAnalysis(
45
44
  ```
46
45
 
47
46
  now you can preform automated statistical test selection:
47
+
48
48
  ```python
49
49
  analysis.RunAuto()
50
50
  ```
51
51
 
52
52
  or you can choose specific tests:
53
+
53
54
  ```python
54
55
  # 2 groups independent:
55
56
  analysis.RunTtest()
@@ -76,15 +77,18 @@ Test summary will be printed to the console.
76
77
  You can also get it as a python string via *GetSummary()* method.
77
78
 
78
79
  ---
80
+
79
81
  Test results are accessible as a dictionary via *GetResult()* method:
82
+
80
83
  ```python
81
84
  results = analysis.GetResult()
82
85
  ```
83
86
 
84
87
  The results dictionary keys with representing value types:
88
+
85
89
  ```
86
90
  {
87
- 'p-value' : String
91
+ 'p_value' : String
88
92
  'Significance(p<0.05)' : Boolean
89
93
  'Stars_Printed' : String
90
94
  'Test_Name' : String
@@ -94,7 +98,7 @@ The results dictionary keys with representing value types:
94
98
  'Parametric_Test_Applied' : Boolean
95
99
  'Paired_Test_Applied' : Boolean
96
100
  'Tails' : Integer (taken from the input)
97
- 'p-value_exact' : Float
101
+ 'p_value_exact' : Float
98
102
  'Stars' : Integer
99
103
  'Warnings' : String
100
104
  'Groups_N' : List of integers
@@ -110,50 +114,44 @@ The results dictionary keys with representing value types:
110
114
  'Posthoc_Matrix_stars': 2D List of String
111
115
  }
112
116
  ```
113
- If errors occured, *GetResult()* returns an empty dictionary
114
-
115
117
 
118
+ If errors occured, *GetResult()* returns an empty dictionary
116
119
 
120
+ ---
117
121
 
122
+ ## Pre-Alpha dev status.
118
123
 
124
+ ### TODO:
119
125
 
120
- ---
121
- ## Pre-Alpha dev status.
122
-
123
- ### TODO:
124
-
125
- -- Anova: posthocs
126
- -- Anova: add 2-way anova and 3-way anova
127
- -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
128
- -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
129
- -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
126
+ -- Anova: posthocs
127
+ -- Anova: add 2-way anova and 3-way anova
128
+ -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
129
+ -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
130
+ -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
130
131
  -- add Welch test (for norm data unequal variances)
131
- -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
132
- -- add independent t-test with Welch correction (do not assume equal SDs in groups)
133
- -- add correlation test, correlation diagram
134
- -- add linear regression, regression diagram
132
+ -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
133
+ -- add independent t-test with Welch correction (do not assume equal SDs in groups)
134
+ -- add correlation test, correlation diagram
135
+ -- add linear regression, regression diagram
135
136
  -- add QQ plot
136
137
  -- n-sample tests: add onetail option
137
-
138
- ✅ done -- detailed normality test results
139
- ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
140
-
141
-
142
- tests check:
143
- 1-sample:
144
- --Wilcoxon 2,1 tails - ok
145
- --t-tests 2,1 tails -ok
146
-
147
- 2-sample:
148
- --Wilcoxon 2,1 tails - ok
149
- --Mann-whitney 2,1 tails - ok
150
- --t-tests 2,1 tails -ok
151
-
152
- n-sample:
153
- --Kruskal-Wallis 2 tail - ok
154
- --Dunn's multiple comparisons - ??
155
- --Friedman 2 tail - ok
156
- --one-way ANOWA 2 tail - ok
157
-
158
-
159
138
 
139
+ ✅ done -- detailed normality test results
140
+ ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
141
+
142
+ tests check:
143
+ 1-sample:
144
+ --Wilcoxon 2,1 tails - ✅ok
145
+ --t-tests 2,1 tails -✅ok
146
+
147
+ 2-sample:
148
+ --Wilcoxon 2,1 tails - ✅ok
149
+ --Mann-whitney 2,1 tails - ✅ok
150
+ --t-tests 2,1 tails -✅ok
151
+
152
+ n-sample:
153
+ --Kruskal-Wallis 2 tail - ✅ok
154
+ --Dunn's multiple comparisons - ✅ok
155
+ --Friedman 2 tail - ✅ok
156
+ --one-way ANOWA 2 tail - ✅ok
157
+ --Tukey`s multiple comparisons - ✅ok
@@ -2,6 +2,7 @@ from AutoStatLib.statistical_tests import StatisticalTests
2
2
  from AutoStatLib.normality_tests import NormalityTests
3
3
  from AutoStatLib.helpers import Helpers
4
4
  from AutoStatLib.text_formatting import TextFormatting
5
+ from AutoStatLib._version import __version__
5
6
 
6
7
 
7
8
  class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Helpers):
@@ -16,7 +17,7 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
16
17
  paired=False,
17
18
  tails=2,
18
19
  popmean=None,
19
- posthoc=True,
20
+ posthoc=False,
20
21
  verbose=True):
21
22
  self.results = None
22
23
  self.error = False
@@ -28,7 +29,7 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
28
29
  self.verbose = verbose
29
30
  self.n_groups = len(self.groups_list)
30
31
  self.warning_flag_non_numeric_data = False
31
- self.summary = ''
32
+ self.summary = 'AutoStatLib v{}'.format(__version__)
32
33
 
33
34
  # test IDs classification:
34
35
  self.test_ids_all = [ # in aplhabetical order
@@ -86,13 +87,13 @@ class StatisticalAnalysis(StatisticalTests, NormalityTests, TextFormatting, Help
86
87
  self.error = False
87
88
  self.warnings = []
88
89
  self.normals = []
89
- self.test_name = None
90
+ self.test_name = ''
90
91
  self.test_id = None
91
92
  self.test_stat = None
92
93
  self.p_value = None
93
94
  self.posthoc_matrix_df = None
94
95
  self.posthoc_matrix = []
95
- self.posthoc_name = None
96
+ self.posthoc_name = ''
96
97
 
97
98
  self.log('\n' + '-'*67)
98
99
  self.log('Statistical analysis initiated for data in {} groups\n'.format(
@@ -74,29 +74,41 @@ class BaseStatPlot(Helpers):
74
74
 
75
75
  def __init__(self,
76
76
  data_groups,
77
- p=None,
78
- testname='',
79
- dependent=False,
77
+ p_value_exact=None,
78
+ Test_Name='',
79
+ Paired_Test_Applied=False,
80
80
  plot_title='',
81
81
  x_label='',
82
82
  y_label='',
83
83
  print_x_labels=True,
84
84
  x_manual_tick_labels=None,
85
- posthoc_matrix=[],
85
+ Posthoc_Matrix=[],
86
+ Posthoc_Tests_Name='',
86
87
  colormap=None,
88
+ print_p_label=True,
89
+ print_stars=True,
90
+ figure_scale_factor=1,
91
+ figure_h=4,
92
+ figure_w=0, # 0 means auto
87
93
  **kwargs):
88
94
  self.data_groups = [group if group else [0, 0, 0, 0]
89
95
  for group in data_groups]
90
96
  self.n_groups = len(self.data_groups)
91
- self.p = p
92
- self.testname = testname
93
- self.posthoc_matrix = posthoc_matrix
97
+ self.p = p_value_exact
98
+ self.testname = Test_Name
99
+ self.posthoc_name = Posthoc_Tests_Name
100
+ self.posthoc_matrix = Posthoc_Matrix
94
101
  self.n_significance_bars = 1
95
- self.dependent = dependent
102
+ self.dependent = Paired_Test_Applied
96
103
  self.plot_title = plot_title
97
104
  self.x_label = x_label
98
105
  self.y_label = y_label
106
+ self.print_p_label = print_p_label
107
+ self.print_stars = print_stars
99
108
  self.print_x_labels = print_x_labels
109
+ self.figure_scale_factor = figure_scale_factor
110
+ self.figure_h = figure_h
111
+ self.figure_w = figure_w
100
112
 
101
113
  # sd sem mean and median calculation if they are not provided
102
114
  self.mean = [
@@ -126,13 +138,22 @@ class BaseStatPlot(Helpers):
126
138
  self.y_max = max([max(data) for data in self.data_groups])
127
139
 
128
140
  def setup_figure(self, ):
129
- fig, ax = plt.subplots(figsize=(0.5 + 0.9 * self.n_groups, 4))
141
+ fig, ax = plt.subplots(
142
+ dpi=100,
143
+ figsize=((0.5 + 0.9 * self.n_groups)
144
+ if not self.figure_w else self.figure_w, self.figure_h)
145
+ )
146
+
147
+ figure_size = plt.gcf().get_size_inches()
148
+ plt.gcf().set_size_inches(self.figure_scale_factor * figure_size)
149
+
130
150
  return fig, ax
131
151
 
132
152
  def add_scatter(self, ax,
133
153
  color='k',
134
154
  alpha=0.5,
135
155
  marker='o',
156
+ markersize=6,
136
157
  linewidth=1,
137
158
  zorder=1):
138
159
  # Generate x jitter pool.
@@ -147,7 +168,8 @@ class BaseStatPlot(Helpers):
147
168
  color=color,
148
169
  alpha=alpha,
149
170
  marker=marker,
150
- linewidth=linewidth,
171
+ markersize=markersize*self.figure_scale_factor,
172
+ linewidth=linewidth*self.figure_scale_factor,
151
173
  # Connect the data points if desired.
152
174
  linestyle='-' if self.dependent else '',
153
175
  zorder=zorder)
@@ -163,7 +185,7 @@ class BaseStatPlot(Helpers):
163
185
  facecolor=self.colors_fill[x % len(self.colors_fill)],
164
186
  edgecolor=self.colors_edge[x % len(self.colors_edge)],
165
187
  fill=fill,
166
- linewidth=linewidth,
188
+ linewidth=linewidth*self.figure_scale_factor,
167
189
  zorder=zorder)
168
190
 
169
191
  def add_violinplot(self, ax, x,
@@ -183,7 +205,7 @@ class BaseStatPlot(Helpers):
183
205
  for pc in vp['bodies']:
184
206
  pc.set_facecolor(self.colors_fill[x % len(self.colors_fill)])
185
207
  pc.set_edgecolor(self.colors_edge[x % len(self.colors_edge)])
186
- pc.set_linewidth(linewidth)
208
+ pc.set_linewidth(linewidth*self.figure_scale_factor)
187
209
 
188
210
  def add_boxplot(self, ax,
189
211
  # positions of boxes, defaults to range(1,n+1)
@@ -346,9 +368,9 @@ class BaseStatPlot(Helpers):
346
368
  ax.errorbar(x, self.mean[x],
347
369
  yerr=self.sd[x],
348
370
  fmt='none',
349
- capsize=capsize,
371
+ capsize=capsize*self.figure_scale_factor,
350
372
  ecolor=ecolor,
351
- linewidth=linewidth,
373
+ linewidth=linewidth*self.figure_scale_factor,
352
374
  zorder=zorder)
353
375
 
354
376
  def add_errorbar_sem(self, ax, x,
@@ -360,9 +382,10 @@ class BaseStatPlot(Helpers):
360
382
  ax.errorbar(x, self.mean[x],
361
383
  yerr=self.sem[x],
362
384
  fmt='none',
363
- capsize=capsize,
385
+ capsize=capsize*self.figure_scale_factor,
364
386
  ecolor=ecolor,
365
- linewidth=linewidth,
387
+ linewidth=linewidth*self.figure_scale_factor,
388
+ elinewidth=linewidth*self.figure_scale_factor,
366
389
  zorder=zorder)
367
390
 
368
391
  def add_mean_marker(self, ax, x,
@@ -376,8 +399,8 @@ class BaseStatPlot(Helpers):
376
399
  marker=marker,
377
400
  markerfacecolor=markerfacecolor,
378
401
  markeredgecolor=markeredgecolor,
379
- markersize=markersize,
380
- markeredgewidth=markeredgewidth)
402
+ markersize=markersize*self.figure_scale_factor,
403
+ markeredgewidth=markeredgewidth*self.figure_scale_factor)
381
404
 
382
405
  def add_median_marker(self, ax, x,
383
406
  marker='x',
@@ -390,15 +413,13 @@ class BaseStatPlot(Helpers):
390
413
  marker=marker,
391
414
  markerfacecolor=markerfacecolor,
392
415
  markeredgecolor=markeredgecolor,
393
- markersize=markersize,
394
- markeredgewidth=markeredgewidth)
416
+ markersize=markersize*self.figure_scale_factor,
417
+ markeredgewidth=markeredgewidth*self.figure_scale_factor)
395
418
 
396
419
  def add_significance_bars(self, ax,
397
420
  linewidth=2,
398
421
  capsize=0.01,
399
- col='k',
400
- label=''):
401
- '''label can be "p", "s", "both"'''
422
+ col='k'):
402
423
 
403
424
  # # Estimate how many bars needed
404
425
  # self.n_significance_bars = comb(
@@ -409,25 +430,28 @@ class BaseStatPlot(Helpers):
409
430
  posthoc_matrix_stars = [[self.make_stars_printed(self.make_stars(element)) for element in row]
410
431
  for row in self.posthoc_matrix] if self.posthoc_matrix else []
411
432
 
412
- def draw_bar(p, stars, order=0, x1=0, x2=self.n_groups-1, capsize=capsize, linewidth=linewidth, col=col, label=label):
413
- if label == 'p':
414
- vspace = capsize+0.03
415
- label = '{}'.format(p)
416
- elif label == 's':
417
- vspace = capsize+0.03
418
- label = '{}'.format(stars)
419
- else:
420
- vspace = capsize+0.06
421
- label = '{}\n{}'.format(p, stars)
422
-
423
- # Draw significance bar connecting x1 and x2 coords
424
- y, h = ((1.05 + (order*vspace)) *
425
- self.y_max), capsize * self.y_max
426
- ax.plot([x1, x1, x2, x2], [y, y + h, y + h, y],
427
- lw=linewidth, c=col)
428
-
429
- ax.text((x1 + x2) * 0.5, y + h, label,
430
- ha='center', va='bottom', color=col, fontweight='bold', fontsize=8)
433
+ def draw_bar(p, stars, order=0, x1=0, x2=self.n_groups-1, capsize=capsize, linewidth=linewidth, col=col):
434
+
435
+ match (self.print_p_label, self.print_stars):
436
+ case (True, True):
437
+ vspace = (capsize+0.06)*self.figure_scale_factor
438
+ label = '{}\n{}'.format(p, stars)
439
+ case (True, False):
440
+ vspace = (capsize+0.03)*self.figure_scale_factor
441
+ label = '{}'.format(p)
442
+ case (False, True):
443
+ vspace = (capsize+0.03)*self.figure_scale_factor
444
+ label = '{}'.format(stars)
445
+
446
+ if self.print_p_label or self.print_stars:
447
+ # Draw significance bar connecting x1 and x2 coords
448
+ y, h = ((1.05 + (order*vspace)) *
449
+ self.y_max), capsize * self.y_max
450
+ ax.plot([x1, x1, x2, x2], [y, y + h, y + h, y],
451
+ lw=linewidth*self.figure_scale_factor, c=col)
452
+
453
+ ax.text((x1 + x2) * 0.5, y + h, label,
454
+ ha='center', va='bottom', color=col, fontweight='bold', fontsize=8*self.figure_scale_factor)
431
455
 
432
456
  def draw_bar_from_posthoc_matrix(x1, x2, o):
433
457
  draw_bar(
@@ -499,7 +523,7 @@ class BaseStatPlot(Helpers):
499
523
  else:
500
524
  ax.set_xticks(range(self.n_groups))
501
525
  ax.set_xticklabels(['Group {}'.format(i + 1)
502
- for i in range(self.n_groups)], fontweight='regular', fontsize=8)
526
+ for i in range(self.n_groups)], fontweight='regular', fontsize=8*self.figure_scale_factor)
503
527
  else:
504
528
  plt.subplots_adjust(bottom=0.08)
505
529
  ax.tick_params(axis='x', which='both',
@@ -508,31 +532,37 @@ class BaseStatPlot(Helpers):
508
532
  # Additional formatting
509
533
  for ytick in ax.get_yticklabels():
510
534
  ytick.set_fontweight('bold')
511
- ax.tick_params(width=linewidth)
512
- ax.xaxis.set_tick_params(labelsize=10)
513
- ax.yaxis.set_tick_params(labelsize=12)
514
- ax.spines['left'].set_linewidth(linewidth)
535
+ ax.tick_params(width=linewidth*self.figure_scale_factor)
536
+ ax.xaxis.set_tick_params(labelsize=10*self.figure_scale_factor)
537
+ ax.yaxis.set_tick_params(labelsize=12*self.figure_scale_factor)
538
+ ax.spines['left'].set_linewidth(linewidth*self.figure_scale_factor)
515
539
  ax.tick_params(axis='y', which='both',
516
- length=linewidth * 2, width=linewidth)
540
+ length=linewidth * 2*self.figure_scale_factor, width=linewidth*self.figure_scale_factor)
517
541
  ax.tick_params(axis='x', which='both', length=0)
518
542
 
519
543
  def add_titles_and_labels(self, fig, ax):
520
544
  if self.plot_title:
521
- ax.set_title(self.plot_title, fontsize=12, fontweight='bold')
545
+ ax.set_title(self.plot_title, fontsize=12 *
546
+ self.figure_scale_factor, fontweight='bold')
522
547
  if self.x_label:
523
- ax.set_xlabel(self.x_label, fontsize=10, fontweight='bold')
548
+ ax.set_xlabel(self.x_label, fontsize=10 *
549
+ self.figure_scale_factor, fontweight='bold')
524
550
  if self.y_label:
525
- ax.set_ylabel(self.y_label, fontsize=10, fontweight='bold')
551
+ ax.set_ylabel(self.y_label, fontsize=10 *
552
+ self.figure_scale_factor, fontweight='bold')
526
553
  fig.text(0.95, 0.0,
527
- '{}\nn={}'.format(self.testname,
528
- str(self.n)[1:-1] if not self.dependent else str(self.n[0])),
529
- ha='right', va='bottom', fontsize=8, fontweight='regular')
554
+ '{}{}\nn={}'.format(self.testname, (', ' + self.posthoc_name) if self.posthoc_name else '',
555
+ str(self.n)[1:-1] if not self.dependent else str(self.n[0])),
556
+ ha='right', va='bottom', fontsize=8*self.figure_scale_factor, fontweight='regular')
530
557
 
531
558
  def show(self):
532
559
  plt.show()
533
560
 
534
561
  def save(self, path):
535
- plt.savefig(path)
562
+ plt.savefig(path,
563
+ pad_inches=0.1*self.figure_scale_factor,
564
+ transparent=True,
565
+ )
536
566
 
537
567
  def close(self):
538
568
  plt.close()
@@ -1,2 +1,2 @@
1
1
  # AutoStatLib package version:
2
- __version__ = "0.2.12"
2
+ __version__ = "0.2.14"
@@ -41,7 +41,7 @@ class Helpers():
41
41
  self.stars_str = self.make_stars_printed(self.stars_int)
42
42
 
43
43
  return {
44
- 'p-value': self.make_p_value_printed(self.p_value.item()),
44
+ 'p_value': self.make_p_value_printed(self.p_value.item()),
45
45
  'Significance(p<0.05)': True if self.p_value.item() < 0.05 else False,
46
46
  'Stars_Printed': self.stars_str,
47
47
  'Test_Name': self.test_name,
@@ -51,7 +51,7 @@ class Helpers():
51
51
  'Parametric_Test_Applied': True if self.test_id in self.test_ids_parametric else False,
52
52
  'Paired_Test_Applied': self.paired,
53
53
  'Tails': self.tails,
54
- 'p-value_exact': self.p_value.item(),
54
+ 'p_value_exact': self.p_value.item(),
55
55
  'Stars': self.stars_int,
56
56
  # 'Stat_Value': self.test_stat.item(),
57
57
  'Warnings': self.warnings,
@@ -1,7 +1,9 @@
1
1
  import numpy as np
2
+ import itertools
2
3
  import scikit_posthocs as sp
3
4
  from statsmodels.stats.anova import AnovaRM
4
5
  from statsmodels.stats.multicomp import pairwise_tukeyhsd
6
+ from statsmodels.stats.multitest import multipletests
5
7
  from scipy.stats import ttest_rel, ttest_ind, ttest_1samp, wilcoxon, mannwhitneyu, f_oneway, kruskal, friedmanchisquare
6
8
 
7
9
 
@@ -90,14 +92,19 @@ class StatisticalTests():
90
92
  # if self.tails == 1:
91
93
  # p_value /= 2
92
94
 
93
- # if p_value < 0.05 and self.posthoc:
94
- # data_flat = np.concatenate(self.data)
95
- # self.posthoc_name = 'Tukey`s multiple comparisons'
96
- # group_labels = np.concatenate(
97
- # [[f"Group_{i+1}"] * len(group) for i, group in enumerate(self.data)])
98
- # # Tukey's multiple comparisons
99
- # tukey_result = pairwise_tukeyhsd(data_flat, group_labels)
100
- # print(tukey_result)
95
+ if self.posthoc: # and p_value < 0.05:
96
+ data_flat = np.concatenate(self.data)
97
+ self.posthoc_name = 'Tukey`s posthoc'
98
+ group_labels = np.concatenate(
99
+ [[f"Group_{i+1}"] * len(group) for i, group in enumerate(self.data)])
100
+ # Tukey's multiple comparisons
101
+ tukey_result = pairwise_tukeyhsd(data_flat, group_labels)
102
+ p = tukey_result.pvalues.tolist()
103
+ self.posthoc_matrix = [
104
+ [p[2], p[0], p[1]],
105
+ [p[0], p[2], p[2]],
106
+ [p[1], p[2], p[2]],
107
+ ]
101
108
  return stat, p_value
102
109
 
103
110
  def anova_1w_rm(self):
@@ -110,8 +117,25 @@ class StatisticalTests():
110
117
 
111
118
  df = self.matrix_to_dataframe(self.data)
112
119
  res = AnovaRM(df, 'Value', 'Row', within=['Col']).fit()
113
- stat = res.anova_table['F Value'][0]
114
- p_value = res.anova_table['Pr > F'][0]
120
+ print(res)
121
+ stat = res.anova_table.iloc[0][0]
122
+ p_value = res.anova_table.iloc[0][3]
123
+
124
+ # # --- Posthocs: paired t-tests ---
125
+ # wide = df.pivot(index='Row', columns='Col', values='Value')
126
+ # conds = wide.columns
127
+ # pairs = list(itertools.combinations(conds, 2))
128
+
129
+ # pvals, stats = [], []
130
+ # for a, b in pairs:
131
+ # t, p = ttest_rel(wide[a], wide[b])
132
+ # stats.append(t)
133
+ # pvals.append(p)
134
+
135
+ # # Adjust p-values
136
+ # rej, p_corr, _, _ = multipletests(pvals, method='bonferroni')
137
+
138
+ # print(p_corr)
115
139
 
116
140
  self.tails = 2
117
141
  return stat, p_value
@@ -125,10 +149,11 @@ class StatisticalTests():
125
149
  stat, p_value = kruskal(*self.data)
126
150
 
127
151
  # Perform Dunn's multiple comparisons if Kruskal-Wallis is significant
128
- if p_value < 0.05 and self.posthoc:
152
+ if self.posthoc: # and p_value < 0.05:
129
153
  self.posthoc_matrix = sp.posthoc_dunn(
130
154
  self.data, p_adjust='bonferroni').values.tolist()
131
- self.posthoc_name = 'Dunn`s multiple comparisons'
155
+ self.posthoc_name = 'Dunn`s posthoc'
156
+ self.tails = 2
132
157
  return stat, p_value
133
158
 
134
159
  def mann_whitney(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AutoStatLib
3
- Version: 0.2.12
3
+ Version: 0.2.14
4
4
  Summary: AutoStatLib - a simple statistical analysis tool
5
5
  Author: Stemonitis, SciWare LLC
6
6
  Author-email: konung-yaropolk <yaropolk1995@gmail.com>
@@ -537,7 +537,7 @@ Requires-Dist: scikit-posthocs
537
537
  Requires-Dist: pandas
538
538
  Dynamic: license-file
539
539
 
540
- # AutoStatLib - python library for automated statistical analysis
540
+ # AutoStatLib - python library for automated statistical analysis
541
541
 
542
542
  [![pypi_version](https://img.shields.io/pypi/v/AutoStatLib?label=PyPI&color=green)](https://pypi.org/project/AutoStatLib)
543
543
  [![GitHub Release](https://img.shields.io/github/v/release/konung-yaropolk/AutoStatLib?label=GitHub&color=green&link=https%3A%2F%2Fgithub.com%2Fkonung-yaropolk%2FAutoStatLib)](https://github.com/konung-yaropolk/AutoStatLib)
@@ -545,17 +545,16 @@ Dynamic: license-file
545
545
  [![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/AutoStatLib)
546
546
  [![PyPI - Downloads](https://img.shields.io/pypi/dm/AutoStatLib?label=PyPI%20stats&color=blue)](https://pypi.org/project/AutoStatLib)
547
547
 
548
-
549
548
  ### To install run the command:
549
+
550
550
  ```bash
551
551
  pip install autostatlib
552
552
  ```
553
553
 
554
-
555
554
  ### Example use case:
556
- See the /demo directory on Git repo or
557
- use the following example:
558
555
 
556
+ See the /demo directory on Git repo or
557
+ use the following example:
559
558
 
560
559
  ```python
561
560
  import numpy as np
@@ -584,11 +583,13 @@ analysis = AutoStatLib.StatisticalAnalysis(
584
583
  ```
585
584
 
586
585
  now you can preform automated statistical test selection:
586
+
587
587
  ```python
588
588
  analysis.RunAuto()
589
589
  ```
590
590
 
591
591
  or you can choose specific tests:
592
+
592
593
  ```python
593
594
  # 2 groups independent:
594
595
  analysis.RunTtest()
@@ -615,15 +616,18 @@ Test summary will be printed to the console.
615
616
  You can also get it as a python string via *GetSummary()* method.
616
617
 
617
618
  ---
619
+
618
620
  Test results are accessible as a dictionary via *GetResult()* method:
621
+
619
622
  ```python
620
623
  results = analysis.GetResult()
621
624
  ```
622
625
 
623
626
  The results dictionary keys with representing value types:
627
+
624
628
  ```
625
629
  {
626
- 'p-value' : String
630
+ 'p_value' : String
627
631
  'Significance(p<0.05)' : Boolean
628
632
  'Stars_Printed' : String
629
633
  'Test_Name' : String
@@ -633,7 +637,7 @@ The results dictionary keys with representing value types:
633
637
  'Parametric_Test_Applied' : Boolean
634
638
  'Paired_Test_Applied' : Boolean
635
639
  'Tails' : Integer (taken from the input)
636
- 'p-value_exact' : Float
640
+ 'p_value_exact' : Float
637
641
  'Stars' : Integer
638
642
  'Warnings' : String
639
643
  'Groups_N' : List of integers
@@ -649,50 +653,44 @@ The results dictionary keys with representing value types:
649
653
  'Posthoc_Matrix_stars': 2D List of String
650
654
  }
651
655
  ```
652
- If errors occured, *GetResult()* returns an empty dictionary
653
-
654
656
 
657
+ If errors occured, *GetResult()* returns an empty dictionary
655
658
 
659
+ ---
656
660
 
661
+ ## Pre-Alpha dev status.
657
662
 
663
+ ### TODO:
658
664
 
659
- ---
660
- ## Pre-Alpha dev status.
661
-
662
- ### TODO:
663
-
664
- -- Anova: posthocs
665
- -- Anova: add 2-way anova and 3-way anova
666
- -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
667
- -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
668
- -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
665
+ -- Anova: posthocs
666
+ -- Anova: add 2-way anova and 3-way anova
667
+ -- onevay Anova: add repeated measures (for normal dependent values) with and without Gaisser-Greenhouse correction
668
+ -- onevay Anova: add Brown-Forsithe and Welch (for normal independent values with unequal SDs between groups)
669
+ -- paired T-test: add ratio-paired t-test (ratios of paired values are consistent)
669
670
  -- add Welch test (for norm data unequal variances)
670
- -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
671
- -- add independent t-test with Welch correction (do not assume equal SDs in groups)
672
- -- add correlation test, correlation diagram
673
- -- add linear regression, regression diagram
671
+ -- add Kolmogorov-smirnov test (unpaired nonparametric 2 sample, compare cumulative distributions)
672
+ -- add independent t-test with Welch correction (do not assume equal SDs in groups)
673
+ -- add correlation test, correlation diagram
674
+ -- add linear regression, regression diagram
674
675
  -- add QQ plot
675
676
  -- n-sample tests: add onetail option
676
-
677
- ✅ done -- detailed normality test results
678
- ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
679
-
680
-
681
- tests check:
682
- 1-sample:
683
- --Wilcoxon 2,1 tails - ok
684
- --t-tests 2,1 tails -ok
685
-
686
- 2-sample:
687
- --Wilcoxon 2,1 tails - ok
688
- --Mann-whitney 2,1 tails - ok
689
- --t-tests 2,1 tails -ok
690
-
691
- n-sample:
692
- --Kruskal-Wallis 2 tail - ok
693
- --Dunn's multiple comparisons - ??
694
- --Friedman 2 tail - ok
695
- --one-way ANOWA 2 tail - ok
696
-
697
-
698
677
 
678
+ ✅ done -- detailed normality test results
679
+ ✅ done -- added posthoc: Kruskal-Wallis Dunn's multiple comparisons
680
+
681
+ tests check:
682
+ 1-sample:
683
+ --Wilcoxon 2,1 tails - ✅ok
684
+ --t-tests 2,1 tails -✅ok
685
+
686
+ 2-sample:
687
+ --Wilcoxon 2,1 tails - ✅ok
688
+ --Mann-whitney 2,1 tails - ✅ok
689
+ --t-tests 2,1 tails -✅ok
690
+
691
+ n-sample:
692
+ --Kruskal-Wallis 2 tail - ✅ok
693
+ --Dunn's multiple comparisons - ✅ok
694
+ --Friedman 2 tail - ✅ok
695
+ --one-way ANOWA 2 tail - ✅ok
696
+ --Tukey`s multiple comparisons - ✅ok
File without changes
File without changes
File without changes