py2ls 0.1.9.4__py3-none-any.whl → 0.1.9.5__py3-none-any.whl
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.
- py2ls/.DS_Store +0 -0
- py2ls/data/styles/example/style1.pdf +0 -0
- py2ls/data/styles/example/style2.pdf +0 -0
- py2ls/data/styles/example/style3.pdf +0 -0
- py2ls/data/styles/example/style4.pdf +0 -0
- py2ls/data/styles/example/style5.pdf +0 -0
- py2ls/data/styles/example/style6.pdf +0 -0
- py2ls/data/styles/example/style7.pdf +0 -0
- py2ls/data/styles/example/style8.pdf +0 -0
- py2ls/data/styles/example/style9.pdf +0 -0
- py2ls/data/styles/style6.json +31 -20
- py2ls/data/styles/style7.json +201 -0
- py2ls/data/styles/style8.json +199 -0
- py2ls/data/styles/style9.json +215 -0
- py2ls/plot.py +394 -35
- py2ls/stats.py +130 -340
- {py2ls-0.1.9.4.dist-info → py2ls-0.1.9.5.dist-info}/METADATA +1 -1
- {py2ls-0.1.9.4.dist-info → py2ls-0.1.9.5.dist-info}/RECORD +19 -7
- {py2ls-0.1.9.4.dist-info → py2ls-0.1.9.5.dist-info}/WHEEL +0 -0
py2ls/stats.py
CHANGED
@@ -37,6 +37,7 @@ def FuncStars(
|
|
37
37
|
report=None,
|
38
38
|
report_scale=-0.1,
|
39
39
|
report_loc=None,
|
40
|
+
**kwargs
|
40
41
|
):
|
41
42
|
if ax is None:
|
42
43
|
ax = plt.gca()
|
@@ -54,136 +55,136 @@ def FuncStars(
|
|
54
55
|
else:
|
55
56
|
y_loc=y_loc+(1-yscale) * np.abs(np.diff(ylim))+0.1 *y_loc
|
56
57
|
xcenter = np.mean([x1, x2])
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
if pval is not None:
|
59
|
+
# ns / *
|
60
|
+
if alpha < pval:
|
61
|
+
if nsshow == "on":
|
62
|
+
ns_str = f"p={round(pval, 3)}" if pval < 0.9 else "ns"
|
63
|
+
color = "m" if pval < 0.1 else "k"
|
64
|
+
ax.text(
|
65
|
+
xcenter,
|
66
|
+
y_loc,
|
67
|
+
ns_str,
|
68
|
+
ha="center",
|
69
|
+
va="bottom", # 'center_baseline',
|
70
|
+
fontsize=fontsize - 6 if fontsize > 6 else fontsize,
|
71
|
+
fontname=fontname,
|
72
|
+
color=color,
|
73
|
+
rotation=rotation,
|
74
|
+
# bbox=dict(facecolor=None, edgecolor=None, color=None, linewidth=None)
|
75
|
+
)
|
76
|
+
elif 0.01 < pval <= alpha:
|
63
77
|
ax.text(
|
64
78
|
xcenter,
|
65
79
|
y_loc,
|
66
|
-
|
80
|
+
symbol,
|
67
81
|
ha="center",
|
68
|
-
va="
|
69
|
-
fontsize=fontsize
|
82
|
+
va="top",#"center_baseline",
|
83
|
+
fontsize=fontsize,
|
70
84
|
fontname=fontname,
|
71
|
-
color=
|
72
|
-
rotation=rotation,
|
73
|
-
# bbox=dict(facecolor=None, edgecolor=None, color=None, linewidth=None)
|
85
|
+
color=symbolcolor,
|
74
86
|
)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
)
|
86
|
-
elif 0.001 < pval <= 0.01:
|
87
|
-
ax.text(
|
88
|
-
xcenter,
|
89
|
-
y_loc,
|
90
|
-
symbol * 2,
|
91
|
-
ha="center",
|
92
|
-
va="top",#"center_baseline",
|
93
|
-
fontsize=fontsize,
|
94
|
-
fontname=fontname,
|
95
|
-
color=symbolcolor,
|
96
|
-
)
|
97
|
-
elif 0 < pval <= 0.001:
|
98
|
-
ax.text(
|
99
|
-
xcenter,
|
100
|
-
y_loc,
|
101
|
-
symbol * 3,
|
102
|
-
ha="center",
|
103
|
-
va="top",#"center_baseline",
|
104
|
-
fontsize=fontsize,
|
105
|
-
fontname=fontname,
|
106
|
-
color=symbolcolor,
|
107
|
-
)
|
108
|
-
# lines indicators
|
109
|
-
if linego and 0 < pval <= 0.05:
|
110
|
-
# horizontal line
|
111
|
-
if yscale <= 0.99:
|
112
|
-
ax.plot(
|
113
|
-
[x1 + np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
114
|
-
[
|
115
|
-
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
116
|
-
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
117
|
-
],
|
118
|
-
linestyle=linestyle,
|
119
|
-
color=linecolor,
|
120
|
-
linewidth=linewidth,
|
121
|
-
)
|
122
|
-
# vertical line
|
123
|
-
ax.plot(
|
124
|
-
[x1 + np.abs(np.diff(xlim)) * 0.01, x1 + np.abs(np.diff(xlim)) * 0.01],
|
125
|
-
[
|
126
|
-
y_loc - np.abs(np.diff(ylim)) * tailindicator[0],
|
127
|
-
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
128
|
-
],
|
129
|
-
linestyle=linestyle,
|
130
|
-
color=linecolor,
|
131
|
-
linewidth=linewidth,
|
132
|
-
)
|
133
|
-
ax.plot(
|
134
|
-
[x2 - np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
135
|
-
[
|
136
|
-
y_loc - np.abs(np.diff(ylim)) * tailindicator[1],
|
137
|
-
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
138
|
-
],
|
139
|
-
linestyle=linestyle,
|
140
|
-
color=linecolor,
|
141
|
-
linewidth=linewidth,
|
142
|
-
)
|
143
|
-
else:
|
144
|
-
ax.plot(
|
145
|
-
[x1 + np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
146
|
-
[
|
147
|
-
np.min(ylim)
|
148
|
-
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
149
|
-
- np.abs(np.diff(ylim)) * 0.002,
|
150
|
-
np.min(ylim)
|
151
|
-
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
152
|
-
- np.abs(np.diff(ylim)) * 0.002,
|
153
|
-
],
|
154
|
-
linestyle=linestyle,
|
155
|
-
color=linecolor,
|
156
|
-
linewidth=linewidth,
|
157
|
-
)
|
158
|
-
# vertical line
|
159
|
-
ax.plot(
|
160
|
-
[x1 + np.abs(np.diff(xlim)) * 0.01, x1 + np.abs(np.diff(xlim)) * 0.01],
|
161
|
-
[
|
162
|
-
np.min(ylim)
|
163
|
-
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
164
|
-
- np.abs(np.diff(ylim)) * tailindicator[0],
|
165
|
-
np.min(ylim)
|
166
|
-
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
167
|
-
- np.abs(np.diff(ylim)) * 0.002,
|
168
|
-
],
|
169
|
-
linestyle=linestyle,
|
170
|
-
color=linecolor,
|
171
|
-
linewidth=linewidth,
|
87
|
+
elif 0.001 < pval <= 0.01:
|
88
|
+
ax.text(
|
89
|
+
xcenter,
|
90
|
+
y_loc,
|
91
|
+
symbol * 2,
|
92
|
+
ha="center",
|
93
|
+
va="top",#"center_baseline",
|
94
|
+
fontsize=fontsize,
|
95
|
+
fontname=fontname,
|
96
|
+
color=symbolcolor,
|
172
97
|
)
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
linestyle=linestyle,
|
184
|
-
color=linecolor,
|
185
|
-
linewidth=linewidth,
|
98
|
+
elif 0 < pval <= 0.001:
|
99
|
+
ax.text(
|
100
|
+
xcenter,
|
101
|
+
y_loc,
|
102
|
+
symbol * 3,
|
103
|
+
ha="center",
|
104
|
+
va="top",#"center_baseline",
|
105
|
+
fontsize=fontsize,
|
106
|
+
fontname=fontname,
|
107
|
+
color=symbolcolor,
|
186
108
|
)
|
109
|
+
# lines indicators
|
110
|
+
if linego and 0 < pval <= 0.05:
|
111
|
+
# horizontal line
|
112
|
+
if yscale <= 0.99:
|
113
|
+
ax.plot(
|
114
|
+
[x1 + np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
115
|
+
[
|
116
|
+
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
117
|
+
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
118
|
+
],
|
119
|
+
linestyle=linestyle,
|
120
|
+
color=linecolor,
|
121
|
+
linewidth=linewidth,
|
122
|
+
)
|
123
|
+
# vertical line
|
124
|
+
ax.plot(
|
125
|
+
[x1 + np.abs(np.diff(xlim)) * 0.01, x1 + np.abs(np.diff(xlim)) * 0.01],
|
126
|
+
[
|
127
|
+
y_loc - np.abs(np.diff(ylim)) * tailindicator[0],
|
128
|
+
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
129
|
+
],
|
130
|
+
linestyle=linestyle,
|
131
|
+
color=linecolor,
|
132
|
+
linewidth=linewidth,
|
133
|
+
)
|
134
|
+
ax.plot(
|
135
|
+
[x2 - np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
136
|
+
[
|
137
|
+
y_loc - np.abs(np.diff(ylim)) * tailindicator[1],
|
138
|
+
y_loc - np.abs(np.diff(ylim)) * 0.03,
|
139
|
+
],
|
140
|
+
linestyle=linestyle,
|
141
|
+
color=linecolor,
|
142
|
+
linewidth=linewidth,
|
143
|
+
)
|
144
|
+
else:
|
145
|
+
ax.plot(
|
146
|
+
[x1 + np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
147
|
+
[
|
148
|
+
np.min(ylim)
|
149
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
150
|
+
- np.abs(np.diff(ylim)) * 0.002,
|
151
|
+
np.min(ylim)
|
152
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
153
|
+
- np.abs(np.diff(ylim)) * 0.002,
|
154
|
+
],
|
155
|
+
linestyle=linestyle,
|
156
|
+
color=linecolor,
|
157
|
+
linewidth=linewidth,
|
158
|
+
)
|
159
|
+
# vertical line
|
160
|
+
ax.plot(
|
161
|
+
[x1 + np.abs(np.diff(xlim)) * 0.01, x1 + np.abs(np.diff(xlim)) * 0.01],
|
162
|
+
[
|
163
|
+
np.min(ylim)
|
164
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
165
|
+
- np.abs(np.diff(ylim)) * tailindicator[0],
|
166
|
+
np.min(ylim)
|
167
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
168
|
+
- np.abs(np.diff(ylim)) * 0.002,
|
169
|
+
],
|
170
|
+
linestyle=linestyle,
|
171
|
+
color=linecolor,
|
172
|
+
linewidth=linewidth,
|
173
|
+
)
|
174
|
+
ax.plot(
|
175
|
+
[x2 - np.abs(np.diff(xlim)) * 0.01, x2 - np.abs(np.diff(xlim)) * 0.01],
|
176
|
+
[
|
177
|
+
np.min(ylim)
|
178
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
179
|
+
- np.abs(np.diff(ylim)) * tailindicator[1],
|
180
|
+
np.min(ylim)
|
181
|
+
+ 0.95 * (np.max(ylim) - np.min(ylim))
|
182
|
+
- np.abs(np.diff(ylim)) * 0.002,
|
183
|
+
],
|
184
|
+
linestyle=linestyle,
|
185
|
+
color=linecolor,
|
186
|
+
linewidth=linewidth,
|
187
|
+
)
|
187
188
|
if values_below is not None:
|
188
189
|
ax.text(
|
189
190
|
xcenter,
|
@@ -519,12 +520,12 @@ def FuncMultiCmpt(
|
|
519
520
|
if "np" in cfg_pair: # 'unpaired'
|
520
521
|
res_tab = run_kruskal(data, dv, factor)
|
521
522
|
notes_stat = f"Non-parametric Kruskal: {data[factor].nunique()} Way ANOVA"
|
522
|
-
notes_APA = f'H({res_tab.ddof1[0]},
|
523
|
+
notes_APA = [f'H({res_tab.ddof1[0]},N={data.shape[0]})={round(res_tab.H[0],3)},p={round(res_tab["p-unc"][0],3)}']
|
523
524
|
|
524
525
|
elif "pa" in cfg_pair and "np" not in cfg_pair: # 'paired'
|
525
526
|
res_tab = run_friedman(data, dv, factor, subject, method="chisq")
|
526
527
|
notes_stat = f"Non-parametric {data[factor].nunique()} Way Friedman repeated measures ANOVA"
|
527
|
-
notes_APA = f'X^2({res_tab.ddof1[0]})={round(res_tab.Q[0],3)},p={round(res_tab["p-unc"][0],3)}'
|
528
|
+
notes_APA = [f'X^2({res_tab.ddof1[0]})={round(res_tab.Q[0],3)},p={round(res_tab["p-unc"][0],3)}']
|
528
529
|
|
529
530
|
# =============================================================================
|
530
531
|
# # Post-hoc
|
@@ -705,6 +706,8 @@ def extract_apa(res_tab):
|
|
705
706
|
note_tmp = f'{res_tab.Source[irow]}:F{round(res_tab.ddof1[irow]),round(res_tab.ddof2[irow])}={round(res_tab.F[irow],3)},p={round(res_tab["p-unc"][irow],3)}'
|
706
707
|
notes_APA.append(note_tmp)
|
707
708
|
elif "DF" in res_tab:
|
709
|
+
print("here")
|
710
|
+
display(res_tab)
|
708
711
|
for irow in range(res_tab.shape[0] - 1):
|
709
712
|
note_tmp = f'{res_tab.Source[irow]}:F{round(res_tab.DF[irow]),round(res_tab.DF[res_tab.shape[0]-1])}={round(res_tab.F[irow],3)},p={round(res_tab["p-unc"][irow],3)}'
|
710
713
|
notes_APA.append(note_tmp)
|
@@ -866,220 +869,7 @@ def df_wide_long(df):
|
|
866
869
|
elif rows > columns:
|
867
870
|
return "Long"
|
868
871
|
|
869
|
-
|
870
|
-
# =============================================================================
|
871
|
-
# # One-way ANOVA
|
872
|
-
# =============================================================================
|
873
|
-
# url = "http://stats191.stanford.edu/data/rehab.csv"
|
874
|
-
# rehab_table = pd.read_table(url, delimiter=",")
|
875
|
-
# rehab_table.to_csv("rehab.table")
|
876
|
-
# fig, ax = plt.subplots(figsize=(8, 6))
|
877
|
-
# fig = rehab_table.boxplot("Time", "Fitness", ax=ax, grid=False)
|
878
|
-
# # fig, ax = plt.subplots(figsize=(8, 6))
|
879
|
-
# # set_pub()
|
880
|
-
# # sns.boxenplot(x="Time",y="Fitness",data = rehab_table)
|
881
|
-
|
882
|
-
# out2 = FuncMultiCmpt(pmc='pmc', pair='unpair',
|
883
|
-
# data=rehab_table, dv='Time', factor='Fitness')
|
884
|
-
# # print(out2['res_tab'])
|
885
|
-
# # print(out2['APA'])
|
886
|
-
# out2['res_posthoc']
|
887
|
-
# out2['res_posthoc']['p-unc'][0]
|
888
|
-
# out2['res_posthoc']['p-adjust'][0]
|
889
|
-
# out2['res_posthoc']['p-corr'][0]
|
890
|
-
|
891
|
-
|
892
|
-
# =============================================================================
|
893
|
-
# # Interactions and ANOVA
|
894
|
-
# https://www.statsmodels.org/dev/examples/notebooks/generated/interactions_anova.html
|
895
|
-
# url = "http://stats191.stanford.edu/data/salary.table"
|
896
|
-
# fh = urlopen(url)
|
897
|
-
# df = pd.read_table(fh)
|
898
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='unpaired', data=df,
|
899
|
-
# dv='S', factor=['X', 'E', 'M'], group='M')
|
900
|
-
# # # two-way anova
|
901
|
-
# # https://www.statology.org/two-way-anova-python/
|
902
|
-
# # =============================================================================
|
903
|
-
# # df = pd.DataFrame({'water': np.repeat(['daily', 'weekly'], 15),
|
904
|
-
# # 'sun': np.tile(np.repeat(['low', 'med', 'high'], 5), 2),
|
905
|
-
# # 'height': [6, 6, 6, 5, 6, 5, 5, 6, 4, 5,
|
906
|
-
# # 6, 6, 7, 8, 7, 3, 4, 4, 4, 5,
|
907
|
-
# # 4, 4, 4, 4, 4, 5, 6, 6, 7, 8]})
|
908
|
-
# # out1 = FuncMultiCmpt(pmc='pmc', pair='unpaired', data=df,
|
909
|
-
# # dv='height', factor=['water','sun'],group='water')
|
910
|
-
|
911
|
-
|
912
|
-
# =============================================================================
|
913
|
-
# # two way anova
|
914
|
-
# https://www.geeksforgeeks.org/how-to-perform-a-two-way-anova-in-python/
|
915
|
-
# =============================================================================
|
916
|
-
# df1=pd.DataFrame({'Fertilizer': np.repeat(['daily', 'weekly'], 15),
|
917
|
-
# 'Watering': np.repeat(['daily', 'weekly'], 15),
|
918
|
-
# 'height': [14, 16, 15, 15, 16, 13, 12, 11,
|
919
|
-
# 14, 15, 16, 16, 17, 18, 14, 13,
|
920
|
-
# 14, 14, 14, 15, 16, 16, 17, 18,
|
921
|
-
# 14, 13, 14, 14, 14, 15]})
|
922
|
-
|
923
|
-
# df1['subject'] = np.tile(range(0, 15), (1, 2)).T
|
924
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='unpaired', data=df1,
|
925
|
-
# dv='height', factor=['Fertilizer','Watering'],group='Watering')
|
926
|
-
# # print(out1['stat'])
|
927
|
-
# # print(out1['res_tab'])
|
928
|
-
|
929
|
-
# =============================================================================
|
930
|
-
# # welch anova
|
931
|
-
# https://www.geeksforgeeks.org/how-to-perform-welchs-anova-in-python/
|
932
|
-
# =============================================================================
|
933
|
-
# df = pd.DataFrame({'score': [64, 66, 68, 75, 78, 94, 98, 79, 71, 80,
|
934
|
-
# 91, 92, 93, 90, 97, 94, 82, 88, 95, 96,
|
935
|
-
# 79, 78, 88, 94, 92, 85, 83, 85, 82, 81],
|
936
|
-
# 'group': np.repeat(['strat1', 'strat2', 'strat3'],repeats=10)})
|
937
|
-
# out1 = FuncMultiCmpt(pmc='auto',pair='unpaired',data=df, dv='score', factor='group', group='group')
|
938
|
-
# =============================================================================
|
939
|
-
# # two way anova
|
940
|
-
# https://www.statology.org/two-way-anova-python/
|
941
|
-
# =============================================================================
|
942
|
-
# df = pd.DataFrame({'water': np.repeat(['daily', 'weekly'], 15),
|
943
|
-
# 'sun': np.tile(np.repeat(['low', 'med', 'high'], 5), 2),
|
944
|
-
# 'height': [6, 6, 6, 5, 6, 5, 5, 6, 4, 5,
|
945
|
-
# 6, 6, 7, 8, 7, 3, 4, 4, 4, 5,
|
946
|
-
# 4, 4, 4, 4, 4, 5, 6, 6, 7, 8]})
|
947
|
-
# df['subject'] = np.tile(range(0, 15), (1, 2)).T
|
948
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='unpaired', data=df,
|
949
|
-
# dv='height', factor=['water', 'sun'], subject='subject', group='water')
|
950
|
-
# # print(out1['stat'])
|
951
|
-
# # print(out1['res_tab'])
|
952
|
-
|
953
|
-
# =============================================================================
|
954
|
-
# # 3-way ANOVA
|
955
|
-
# =============================================================================
|
956
|
-
# df = pd.DataFrame({'program': np.repeat([1, 2], 20),
|
957
|
-
# 'gender': np.tile(np.repeat(['M', 'F'], 10), 2),
|
958
|
-
# 'division': np.tile(np.repeat([1, 2], 5), 4),
|
959
|
-
# 'height': [7, 7, 8, 8, 7, 6, 6, 5, 6, 5,
|
960
|
-
# 5, 5, 4, 5, 4, 3, 3, 4, 3, 3,
|
961
|
-
# 6, 6, 5, 4, 5, 4, 5, 4, 4, 3,
|
962
|
-
# 2, 2, 1, 4, 4, 2, 1, 1, 2, 1]})
|
963
|
-
# df['subject'] = np.tile(range(0, 20), (1, 2)).T
|
964
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='unpaired', data=df,
|
965
|
-
# dv='height', factor=['gender', 'program', 'division'], subject='subject', group='program')
|
966
|
-
# # print(out1['stat'])
|
967
|
-
# # print(out1['res_tab'])
|
968
|
-
|
969
|
-
# =============================================================================
|
970
|
-
# # Repeated Measures ANOVA in Python
|
971
|
-
# =============================================================================
|
972
|
-
# df = pd.DataFrame({'patient': np.repeat([1, 2, 3, 4, 5], 4),
|
973
|
-
# 'drug': np.tile([1, 2, 3, 4], 5),
|
974
|
-
# 'response': [30, 28, 16, 34,
|
975
|
-
# 14, 18, 10, 22,
|
976
|
-
# 24, 20, 18, 30,
|
977
|
-
# 38, 34, 20, 44,
|
978
|
-
# 26, 28, 14, 30]})
|
979
|
-
# # df['subject'] = np.tile(range(0, 20), (1, 2)).T
|
980
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='paired', data=df,
|
981
|
-
# dv='response', factor=['drug'], subject='patient', group='drug')
|
982
|
-
# print(out1['stat'])
|
983
|
-
# print(out1['res_tab'])
|
984
|
-
# print(out1['APA'])
|
985
|
-
|
986
|
-
# =============================================================================
|
987
|
-
# # repeated anova
|
988
|
-
# https://www.geeksforgeeks.org/how-to-perform-a-repeated-measures-anova-in-python/
|
989
|
-
# =============================================================================
|
990
|
-
# df = pd.DataFrame({'Cars': np.repeat([1, 2, 3, 4, 5], 4),
|
991
|
-
# 'Engine Oil': np.tile([1, 2, 3, 4], 5),
|
992
|
-
# 'Mileage': [36, 38, 30, 29,
|
993
|
-
# 34, 38, 30, 29,
|
994
|
-
# 34, 28, 38, 32,
|
995
|
-
# 38, 34, 20, 44,
|
996
|
-
# 26, 28, 34, 50]})
|
997
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='paired', data=df,
|
998
|
-
# dv='Mileage', factor=['Engine Oil'], subject='Cars', group='Cars')
|
999
|
-
# =============================================================================
|
1000
|
-
# #two-way repeated anova
|
1001
|
-
# =============================================================================
|
1002
|
-
# df = pd.read_csv(
|
1003
|
-
# "https://reneshbedre.github.io/assets/posts/anova/plants_leaves_two_within.csv")
|
1004
|
-
# df
|
1005
|
-
# # df['subject'] = np.tile(range(0, 20), (1, 2)).T
|
1006
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='paired', data=df,
|
1007
|
-
# dv='num_leaves', factor=['year', 'time'], subject='plants', group='year')
|
1008
|
-
# print(out1['stat'])
|
1009
|
-
# print(out1['res_tab'])
|
1010
|
-
# print(out1['APA'])
|
1011
|
-
|
1012
|
-
# =============================================================================
|
1013
|
-
# # repeated anova
|
1014
|
-
# =============================================================================
|
1015
|
-
# df = pd.read_csv('/Users/macjianfeng/Desktop/test.csv')
|
1016
|
-
# df.head()
|
1017
|
-
# df.loc[df['animal'].str.contains('Sleep'), 'experiment'] = 'sleep'
|
1018
|
-
# df.loc[df['animal'].str.contains('Wake'), 'experiment'] = 'wake'
|
1019
|
-
# df.loc[df['variable'].str.contains('hypo'), 'region'] = 'hypo'
|
1020
|
-
# df.loc[df['variable'].str.contains('cort'), 'region'] = 'cort'
|
1021
|
-
# df
|
1022
|
-
# for i in range(4):
|
1023
|
-
# match i:
|
1024
|
-
# case 0:
|
1025
|
-
# prot_name = 'A1'
|
1026
|
-
# case 1:
|
1027
|
-
# prot_name = 'A2'
|
1028
|
-
# case 2:
|
1029
|
-
# prot_name = '845'
|
1030
|
-
# case 3:
|
1031
|
-
# prot_name = '831'
|
1032
|
-
# df_tmp = df[df["variable"].str.contains(prot_name)]
|
1033
|
-
# df_tmp['protein'] = prot_name
|
1034
|
-
# df_tmp = df_tmp.reset_index()
|
1035
|
-
# print(df_tmp)
|
1036
|
-
|
1037
|
-
# out1 = FuncMultiCmpt(pmc='pmc', pair='mix', data=df_tmp,
|
1038
|
-
# dv='value', between='experiment', within='region', subject='animal', group='experiment')
|
1039
|
-
# print(out1['stat'])
|
1040
|
-
# print(out1['res_tab'])
|
1041
|
-
# # =============================================================================
|
1042
|
-
# One-way ANOVA
|
1043
|
-
# df1 = pd.read_csv('/Users/macjianfeng/Desktop/Book2.csv')
|
1044
|
-
# df2 = df1.melt()
|
1045
|
-
# out1 = FuncMultiCmpt(pmc='npmc', pair='unpaired', data=df2,
|
1046
|
-
# dv='libido', factor=['brand x', 'brand y', 'brand z'], subject='participant')
|
1047
|
-
# print(out1['stat'])
|
1048
|
-
# print(out1['res_tab'])
|
1049
|
-
# =============================================================================
|
1050
|
-
|
1051
|
-
|
1052
|
-
# =============================================================================
|
1053
|
-
# # #One-way ANOVA new example: https://www.pythonfordatascience.org/anova-python/
|
1054
|
-
# =============================================================================
|
1055
|
-
# df1 = pd.read_csv(
|
1056
|
-
# "https://raw.githubusercontent.com/researchpy/Data-sets/master/difficile.csv")
|
1057
|
-
# df1.drop('person', axis=1, inplace=True)
|
1058
|
-
# # Recoding value from numeric to string
|
1059
|
-
# df1['dose'].replace({1: 'placebo', 2: 'low', 3: 'high'}, inplace=True)
|
1060
|
-
# df1.head(10)
|
1061
|
-
|
1062
|
-
# out3= FuncMultiCmpt(pmc='pmc', data=df1, dv='libido', factor='dose')
|
1063
|
-
# # print(out3['res_tab'])
|
1064
|
-
# # # print(out3['res_posthoc'])
|
1065
|
-
# # print(out3['APA'])
|
1066
|
-
|
1067
|
-
# =============================================================================
|
1068
|
-
# https://lifewithdata.com/2023/06/08/how-to-perform-a-two-way-anova-in-python/
|
1069
|
-
# =============================================================================
|
1070
|
-
# data = {
|
1071
|
-
# 'Diet': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C'],
|
1072
|
-
# 'Workout': ['Low', 'Medium', 'High', 'Low', 'Medium', 'High', 'Low', 'Medium', 'High', 'Low', 'Medium', 'High'],
|
1073
|
-
# 'WeightLoss': [3, 4, 5, 3.2, 5, 6, 5.2, 6, 5.5, 4, 5.5, 6.2]
|
1074
|
-
# }
|
1075
|
-
# df = pd.DataFrame(data)
|
1076
|
-
# out4= FuncMultiCmpt(pmc='pmc', pair='unpaired',data=df, dv='WeightLoss', factor=['Diet','Workout'],group='Diet')
|
1077
|
-
|
1078
|
-
# =============================================================================
|
1079
|
-
# # convert to list to string
|
1080
|
-
# =============================================================================
|
1081
|
-
|
1082
|
-
|
872
|
+
|
1083
873
|
def sort_rows_move_nan(arr, sort=False):
|
1084
874
|
# Handle edge cases where all values are NaN
|
1085
875
|
if np.all(np.isnan(arr)):
|
@@ -1116,11 +906,11 @@ def sort_rows_move_nan(arr, sort=False):
|
|
1116
906
|
return clean_arr_
|
1117
907
|
|
1118
908
|
|
1119
|
-
def df2array(data: pd.DataFrame, x, y, hue=None, sort=False):
|
909
|
+
def df2array(data: pd.DataFrame, x=None, y=None, hue=None, sort=False):
|
1120
910
|
if hue is None:
|
1121
911
|
a = []
|
1122
912
|
if sort:
|
1123
|
-
np.sort(data[x].unique().tolist()).tolist()
|
913
|
+
cat_x=np.sort(data[x].unique().tolist()).tolist()
|
1124
914
|
else:
|
1125
915
|
cat_x = data[x].unique().tolist()
|
1126
916
|
for i, x_ in enumerate(cat_x):
|
@@ -1,4 +1,4 @@
|
|
1
|
-
py2ls/.DS_Store,sha256=
|
1
|
+
py2ls/.DS_Store,sha256=TrIRWvsmm5K2ZOHOl-Xg5QGwFENxbPivhMQVowzk3qw,6148
|
2
2
|
py2ls/.git/COMMIT_EDITMSG,sha256=5xj-jWMbrdOc9m7gSn-UcsAQ9FMNvWSbLWSsrOUIO5w,7
|
3
3
|
py2ls/.git/FETCH_HEAD,sha256=6cJaQzb6VhkvNNm-KsABX6R28FNKZB8qMmqacDEP_dQ,100
|
4
4
|
py2ls/.git/HEAD,sha256=KNJb-Cr0wOK3L1CVmyvrhZ4-YLljCl6MYD2tTdsrboA,21
|
@@ -151,24 +151,36 @@ py2ls/data/.DS_Store,sha256=iH2O541jT_5mlTPavY_d5V2prS9zhNx4Pv7yhmbwaHI,6148
|
|
151
151
|
py2ls/data/db2ls_sql_chtsht.json,sha256=ls9d7Sm8TLeujanWHfHlWhU85Qz1KnAizO_9X3wUH7E,6933
|
152
152
|
py2ls/data/docs_links.json,sha256=kXgbbWo0b8bfV4n6iuuUNLnZipIyLzokUO6Lzmf7nO4,101829
|
153
153
|
py2ls/data/lang_code_iso639.json,sha256=qZiU7H2RLJjDMXK22C-jhwzLJCI5vKmampjB1ys4ek4,2157
|
154
|
+
py2ls/data/styles/example/style1.pdf,sha256=Pt_qQJ5kiCSIPiz3TWSwEffHUdj75kKXnZ4MPqpEx4I,29873
|
155
|
+
py2ls/data/styles/example/style2.pdf,sha256=0xduPLPulET38LEP2V2H_q70wqlrrBEo8ttqO-FMrfQ,25449
|
156
|
+
py2ls/data/styles/example/style3.pdf,sha256=010-Pm2BUowAt0XDkJWZTR5rAszLqmI1DO3209sIFWs,65536
|
157
|
+
py2ls/data/styles/example/style4.pdf,sha256=dn4bPTLiwMF9d9U32LOaJGvluEkBwKMC079kvQJPd6s,19093
|
158
|
+
py2ls/data/styles/example/style5.pdf,sha256=ZFq5vYmGEfCSfUrh2mBOz_mQ8MwebcbOqaV-0eIEK2s,29610
|
159
|
+
py2ls/data/styles/example/style6.pdf,sha256=cjkWkeN1B5S6E1fs29kr0yxq36VD2nE-kKkcpsXRRwA,52648
|
160
|
+
py2ls/data/styles/example/style7.pdf,sha256=Sz54Qzvt6k6fCkvvZd6S4RSZjVZvxPxIx_uvGDP96v0,54468
|
161
|
+
py2ls/data/styles/example/style8.pdf,sha256=8As6rsajoqQEU9hUy4YDHOsXYpD4PJcbWMz-4iV77gI,62296
|
162
|
+
py2ls/data/styles/example/style9.pdf,sha256=uT4_9bZaoBB7aXoobIY8-k_OX7TNxJ_Zwqvr7o9deO0,65828
|
154
163
|
py2ls/data/styles/style1.json,sha256=Q3tdH0Sf08FjNUZE5mELA45JEw3BXjSAL2nLfFDn1bU,3101
|
155
164
|
py2ls/data/styles/style2.json,sha256=2xhDv-_qQOKaODy8fWRoaQk_W5-I3EdA6uh4JNnINGg,3124
|
156
165
|
py2ls/data/styles/style3.json,sha256=0lHmjFGqlf1c7HLllsgGVNFkuEsqSCicBv-iOTB9hRk,3126
|
157
166
|
py2ls/data/styles/style4.json,sha256=G8thPHwmJyS3kDletrh3NkapZ03bNfey2-zpG4erBfk,3072
|
158
167
|
py2ls/data/styles/style5.json,sha256=0bqt3CYM1iBtu_7D8LmurnZ2mlrw-zOdUMUpnUADih4,3069
|
159
|
-
py2ls/data/styles/style6.json,sha256=
|
168
|
+
py2ls/data/styles/style6.json,sha256=tu-MYOT9x5Rorc-2IK6sy-J-frmz0RNdm65XAsDQKX4,3280
|
169
|
+
py2ls/data/styles/style7.json,sha256=StdUFwIVrS7T_6CDrADHMorzc0WZFWBM7IyYdO1TPHg,4447
|
170
|
+
py2ls/data/styles/style8.json,sha256=8XUgkZtew8ebvjbAHlDHCSWUqNra3ktDvMCO4vNh-CM,4456
|
171
|
+
py2ls/data/styles/style9.json,sha256=PLxvntbH_kfzZlnCTtCEAUVBGi5m6Lngb9C01rArQog,4769
|
160
172
|
py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
|
161
173
|
py2ls/doc.py,sha256=xN3g1OWfoaGUhikbJ0NqbN5eKy1VZVvWwRlhHMgyVEc,4243
|
162
174
|
py2ls/export_requirements.py,sha256=x2WgUF0jYKz9GfA1MVKN-MdsM-oQ8yUeC6Ua8oCymio,2325
|
163
175
|
py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
|
164
176
|
py2ls/ips.py,sha256=N7MdOCgJXDQu73YkJQTtDN3RSntzXX7V0MOJ1NYBLEk,100572
|
165
177
|
py2ls/netfinder.py,sha256=KJIvg3JZSsy1dJZHNJvd9Y3oyYG0mbdTjtXimdRs8e8,49182
|
166
|
-
py2ls/plot.py,sha256=
|
178
|
+
py2ls/plot.py,sha256=DeGchynrr5KHivV-vgrOj3pUMi75SaBVRbUc3XkZe7c,82630
|
167
179
|
py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
|
168
180
|
py2ls/sleep_events_detectors.py,sha256=bQA3HJqv5qnYKJJEIhCyhlDtkXQfIzqksnD0YRXso68,52145
|
169
|
-
py2ls/stats.py,sha256=
|
181
|
+
py2ls/stats.py,sha256=U2yeTYUkInI4JXtfhdSbSAzna_h8rh8MZmY31o51_EU,38169
|
170
182
|
py2ls/translator.py,sha256=bc5FB-wqC4TtQz9gyCP1mE38HqNRJ_pmuRIgKnAlMzM,30581
|
171
183
|
py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
|
172
|
-
py2ls-0.1.9.
|
173
|
-
py2ls-0.1.9.
|
174
|
-
py2ls-0.1.9.
|
184
|
+
py2ls-0.1.9.5.dist-info/METADATA,sha256=sQK7r2gM_Az7cKffERl81if1FJ7Qn0viiNTkijjcmvI,20017
|
185
|
+
py2ls-0.1.9.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
186
|
+
py2ls-0.1.9.5.dist-info/RECORD,,
|
File without changes
|