-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNature Comms NINDS MECFS Figure Creation.R
3694 lines (3019 loc) · 164 KB
/
Nature Comms NINDS MECFS Figure Creation.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Sam LaMunion; [email protected]
rm(list=ls()) # start with a clean environment
# list.of.packages <- c("ggplot2", "stats", "tidyr", "dplyr", "magrittr", "reshape2", "janitor", "broom", "ggpubr", "ggpmisc", "readxl", "patchwork")
# new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
# if(length(new.packages)) install.packages(new.packages) #install/load required and supporting packages
if (!require("pacman")) install.packages("pacman")
pacman::p_load(ggplot2, stats, tidyr, dplyr, magrittr, reshape2, janitor, broom, ggpubr, ggpmisc, readxl, patchwork, showtext, openxlsx, purrr)
setwd("Z:/ME-CFS/Figures/final_figures/Sam - Revisions/Current Versions/Compiled Versions/Individual Figure Panels/Figures Source Data Files/Nature Comms MECFS/Data")
# List all .xlsx files in the directory
##xlsx_files_to_share <- list.files(pattern = "\\.xlsx$", full.names = TRUE)
# Read all .xlsx files into a named list
##xlsx_list <- map(xlsx_files_to_share, ~ read.xlsx(.x))
# Name the list elements based on file names
##names(xlsx_list) <- tools::file_path_sans_ext(basename(xlsx_files_to_share))
# Save the list as RData
##saveRDS(xlsx_list, file = "Nature Comms MECFS Source Data.RData")
##### Start Here #####
# Load the RData file containing the individual source data files
# source_data <- readRDS("Nature Comms MECFS Source Data.RData")
# once the source data are loaded you can save them as individual .xlsx files to a directory of your choosing.
# source_data is the list of data frames
# Create a directory to save the output files
#output_dir <- "output_directory" # set this to be where you want the files written to
#dir.create(output_dir, showWarnings = FALSE) # this creates that directory to save the .xlsx files to
# purrr::walk iterates over the source_data list of data frames and writes each data frame to a separate .xlsx file
#purrr::walk(names(xlsx_list), ~ openxlsx::write.xlsx(xlsx_list[[.x]], file.path(output_dir, paste0(.x, ".xlsx")), row.names = FALSE))
# If you want to just extract all files into separate data frames in the current global environment
# list2env(xlsx_list, envir = .GlobalEnv)
##### set content so it is loaded for use where relevant
formula = y ~ x # sets the formula for regression
showtext_auto() # enables the use of custom fonts in ggplot2
female = intToUtf8(9792) # sets symbol for female
male = intToUtf8(9794) # sets symbol for male
##### Figure 1C - PROMIS Fatigue #####
data <- readxl::read_excel("Figure 1C.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
bw = 1 # sets binwidth
n_obs_hv <- length(which(data$group == "HV")) # gets number of HV in sample
n_obs_cfs <- length(which(data$group == "PI-ME/CFS")) # gets number of CFS in sample
fig1c.1 <- ggplot2::ggplot(data, aes(x = promis_fatigue_short_form, fill = group)) + #
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$promis_fatigue_short_form), sd = sd(subset(data, group == "HV")$promis_fatigue_short_form)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$promis_fatigue_short_form), sd = sd(subset(data, group == "PI-ME/CFS")$promis_fatigue_short_form)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "PROMIS Fatigue", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.2e-5"))
fig1c.1
ggsave(fig1c.1, file = "Figure_1C - PROMIS Fatigue.png")
ggsave(fig1c.1, file = "Figure_1C - PROMIS Fatigue.eps", device = "eps")
##### Figure 1C - PROMIS Emotional Distress #####
fig1c.2 <- ggplot2::ggplot(data, aes(x = promis_emotional_distress_depression_t_score, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$promis_emotional_distress_depression_t_score), sd = sd(subset(data, group == "HV")$promis_emotional_distress_depression_t_score)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$promis_emotional_distress_depression_t_score), sd = sd(subset(data, group == "PI-ME/CFS")$promis_emotional_distress_depression_t_score)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "PROMIS Emotional Distress", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.03"))
fig1c.2
ggsave(fig1c.2, file = "Figure_1C - PROMIS Emotional Distress.png")
ggsave(fig1c.2, file = "Figure_1C - PROMIS Emotional Distress.eps", device = "eps")
##### Figure 1C - PROMIS Sleep Disturbance #####
fig1c.3 <- ggplot2::ggplot(data, aes(x = promis_sleep_disturbance_short_form, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$promis_sleep_disturbance_short_form), sd = sd(subset(data, group == "HV")$promis_sleep_disturbance_short_form)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$promis_sleep_disturbance_short_form), sd = sd(subset(data, group == "PI-ME/CFS")$promis_sleep_disturbance_short_form)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "PROMIS Sleep Disturbance", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.2e-4"))
fig1c.3
ggsave(fig1c.3, file = "Figure_1C - PROMIS Sleep Disturbance.png")
ggsave(fig1c.3, file = "Figure_1C - PROMIS Sleep Disturbance.eps", device = "eps")
##### Figure 1D - PROMIS Anxiety #####
fig1c.4 <- ggplot2::ggplot(data, aes(x = promis_emotional_distress_anxiety_t_score, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$promis_emotional_distress_anxiety_t_score), sd = sd(subset(data, group == "HV")$promis_emotional_distress_anxiety_t_score)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$promis_emotional_distress_anxiety_t_score), sd = sd(subset(data, group == "PI-ME/CFS")$promis_emotional_distress_anxiety_t_score)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "PROMIS Anxiety", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.007"))
fig1c.4
ggsave(fig1c.4, file = "Figure_1C - PROMIS Anxiety.png")
ggsave(fig1c.4, file = "Figure_1C - PROMIS Anxiety.eps", device = "eps")
##### Figure 1C - PHQ15 #####
fig1c.5 <- ggplot2::ggplot(data, aes(x = physical_symptoms_phq_15, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$physical_symptoms_phq_15), sd = sd(subset(data, group == "HV")$physical_symptoms_phq_15)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$physical_symptoms_phq_15), sd = sd(subset(data, group == "PI-ME/CFS")$physical_symptoms_phq_15)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "PHQ 15", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.7e-6"))
fig1c.5
ggsave(fig1c.5, file = "Figure_1C - PHQ 15.png")
ggsave(fig1c.5, file = "Figure_1C - PHQ 15.eps", device = "eps")
##### Figure 1C - MASQ Language #####
fig1c.6 <- ggplot2::ggplot(data, aes(x = multiple_ability_self_report_qnr_masq_language, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_language), sd = sd(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_language)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_language), sd = sd(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_language)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "MASQ Lanugage", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.4e-4"))
fig1c.6
ggsave(fig1c.6, file = "Figure_1C - MASQ Language.png")
ggsave(fig1c.6, file = "Figure_1C - MASQ Language.eps", device = "eps")
##### Figure 1C - MASQ Attention #####
fig1c.7 <- ggplot2::ggplot(data, aes(x = multiple_ability_self_report_qnr_masq_attention, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_attention), sd = sd(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_attention)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_attention), sd = sd(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_attention)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "MASQ Attention", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.5e-3"))
fig1c.7
ggsave(fig1c.7, file = "Figure_1C - MASQ Attention.png")
ggsave(fig1c.7, file = "Figure_1C - MASQ Attention.eps", device = "eps")
##### Figure 1C - MASQ Verbal Memory #####
fig1c.8 <- ggplot2::ggplot(data, aes(x = multiple_ability_self_report_qnr_masq_verbal_memory, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_verbal_memory), sd = sd(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_verbal_memory)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_verbal_memory), sd = sd(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_verbal_memory)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "MASQ Verbal Memory", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.2e-3"))
fig1c.8
ggsave(fig1c.8, file = "Figure_1C - MASQ Verbal Memory.png")
ggsave(fig1c.8, file = "Figure_1C - MASQ Verbal Memory.eps", device = "eps")
##### Figure 1C - MASQ Visual Memory #####
fig1c.9 <- ggplot2::ggplot(data, aes(x = multiple_ability_self_report_qnr_masq_visual_memory, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_visual_memory), sd = sd(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_visual_memory)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_visual_memory), sd = sd(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_visual_memory)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "MASQ Visual Memory", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.09"))
fig1c.9
ggsave(fig1c.9, file = "Figure_1C - MASQ Visual Memory.png")
ggsave(fig1c.9, file = "Figure_1C - MASQ Visual Memory.eps", device = "eps")
##### Figure 1C - MASQ Visual Perception #####
fig1c.10 <- ggplot2::ggplot(data, aes(x = multiple_ability_self_report_qnr_masq_visuoperceptual, fill = group)) +
geom_histogram(binwidth = bw, position = "dodge", alpha = 1) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_visuoperceptual), sd = sd(subset(data, group == "HV")$multiple_ability_self_report_qnr_masq_visuoperceptual)) * bw * n_obs_hv,
aes(color = "HV"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
stat_function(
fun = function(x) dnorm(x, mean = mean(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_visuoperceptual), sd = sd(subset(data, group == "PI-ME/CFS")$multiple_ability_self_report_qnr_masq_visuoperceptual)) * bw * n_obs_cfs,
aes(color = "PI-ME/CFS"),
linewidth = 1,
geom = "line",
alpha = 0.1,
show.legend = F
) +
scale_color_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
scale_fill_manual(values = c("HV" = "blue", "PI-ME/CFS" = "red")) +
labs(x = "MASQ Visual Perception", y = "Frequency") +
theme_classic() +
theme(legend.title = element_blank(),
axis.title.x = element_text(face = "bold", color = "black", size = 16),
axis.title.y = element_text(face = "bold", color = "black", size = 16),
axis.text.x = element_text(color = "black", size = 13),
axis.text.y = element_text(color = "black", size = 13)) +
ggpp::geom_text_npc(aes(npcx = "right", npcy = "top", label = "p = 0.02"))
fig1c.10
ggsave(fig1c.10, file = "Figure_1C - MASQ Visual Perception.png")
ggsave(fig1c.10, file = "Figure_1C - MASQ Visual Perception.eps", device = "eps")
##### Figure 1C #####
fig1c <- ((fig1c.1 / fig1c.2 / fig1c.3 / fig1c.4 / fig1c.5) | (fig1c.6 / fig1c.7 / fig1c.8 / fig1c.9 / fig1c.10)) + plot_layout(guides = "collect")
ggsave(fig1c, file = "Figure 1C.png", width = 10, height = 16, dpi = 300)
ggsave(fig1c, file = "Figure 1C.eps", width = 10, height = 16, dpi = 300, device = "eps")
##### Figure 2A #####
# please see the line by line comments in this figure for guidance on the structure
# this assumes you have the .xlsx files downloaded
data <- readxl::read_excel("Figure 2A.xlsx", col_names = TRUE) %>% # reads in the .xlsx file of the formatted data for the specified figure number and panel
janitor::clean_names() %>% # cleans the column names
na.omit() # removes any rows with missing data, occasional spacing between groups in source data files, otherwise source data are complete
colnames(data) <- c("group", "var") # renames the columns in the data frame for plotting
fig2A <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) + # creates the ggplot object
geom_boxplot(outlier.shape = NA) + # creates the boxplot
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) + # adds the error bars
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) + # adds the individual data points
theme_classic() + # sets the theme
scale_color_manual(values = c("blue", "red")) + # sets the colors
labs(y = "24 Hr Heart Rate (bpm)") + # sets the y-axis label
theme(legend.position = "none", # removes the legend
axis.title.x = element_blank(), # removes the x-axis label
axis.title.y = element_text(face = "bold", color = "black", size = 28), # sets the y-axis label
axis.text.x = element_text(face = "bold", color = "black", size = 22), # sets the x-axis text
axis.text.y = element_text(color = "black", size = 22)) #+ # sets the y-axis text
# ggsignif::geom_signif(test = "wilcox.test", # adds the significance test where relevant
# comparisons = list(c("HV", "PI-ME/CFS")), # sets the comparisons to test
# map_signif_level = function(p) sprintf("p = %.1g", p), # sets the significance level
# color = "black", # sets the color of the p-value
# textsize = 8) # sets the size of the p-value
ggsave(fig2A, file = "Figure_2A.png", width = 500, height = 700, dpi = 300, units = "px") # saves the figure as a .png
ggsave(fig2A, file = "Figure_2A.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px") # saves the figure as a .eps
##### Figure 2B #####
data <- readxl::read_excel("Figure 2B.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig2b <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "SDNN Index (msec)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 28),
axis.text.x = element_text(face = "bold", color = "black", size = 22),
axis.text.y = element_text(color = "black", size = 22)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black",
textsize = 8)
fig2b
ggsave(fig2b, file = "Figure_2B.png", width = 500, height = 700, dpi = 300, units = "px") # saves the figure as a .png
ggsave(fig2b, file = "Figure_2B.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px") # saves the figure as a .eps
##### Figure 2C #####
data <- readxl::read_excel("Figure 2C.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig2c <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "rMSSD (msec)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig2c
ggsave(fig2c, file = "Figure_2C.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig2c, file = "Figure_2C.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 2D #####
data <- readxl::read_excel("Figure 2D.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig2d <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "pNN50 (%)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig2d
ggsave(fig2d, file = "Figure_2D.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig2d, file = "Figure_2D.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 2H #####
data <- readxl::read_excel("Figure 2H.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig2h <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Baroslope (ms/Hg)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig2h
ggsave(fig2h, file = "Figure_2H.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig2h, file = "Figure_2H.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 3C #####
data <- readxl::read_excel("Figure 3C.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig3c <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Maximum Grip Force (kg)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) #+
# ggsignif::geom_signif(test = "wilcox.test",
# comparisons = list(c("HV", "PI-ME/CFS")),
# map_signif_level = function(p) sprintf("p = %.1g", p),
# color = "black", textsize = 8)
fig3c
ggsave(fig3c, file = "Figure_3C.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig3c, file = "Figure_3C.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 3D #####
data <- readxl::read_excel("Figure 3D.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig3d <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Time to Failure (seconds)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig3d
ggsave(fig3d, file = "Figure_3D.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig3d, file = "Figure_3D.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 3E #####
data <- readxl::read_excel("Figure 3E.xlsx", col_names = TRUE) %>% # read in data
janitor::clean_names() %>% # clean column names
na.omit() # remove NA values
colnames(data) <- c("group", "xvar", "yvar") # rename columns
fig3e <- ggplot2::ggplot(data, aes(x = xvar, y = yvar, color = group)) + # create plot
geom_point(size = 1) + # add points
geom_smooth(method= "lm", se = FALSE) + # add regression line
ggpmisc::stat_correlation(exact = TRUE, # add correlation
label.x = "right", # set label position
label.y = "bottom", # set label position
r.digits = 2, # set digits
p.digits = 2, # set digits
small.p = TRUE, # set small p,
size = 6,
use_label(c("R", "P", "n"))) + # set label
theme_classic() + # set theme
scale_color_manual(values = c("blue", "red")) + # set colors
labs(y = "Proportion of Hard-Task Choices (%)", # set y label
x = "Time to Failure (seconds)") + # set x label
theme(legend.title = element_blank(), legend.position = "none", # remove legend title
axis.title.x = element_text(face = "bold", color = "black", size = 18), # set x axis title
axis.title.y = element_text(face = "bold", color = "black", size = 18), # set y axis title
axis.text.x = element_text(color = "black", size = 15), # set x axis text
axis.text.y = element_text(color = "black", size = 15),
legend.text=element_text(size=12)) # set y axis text
fig3e
ggsave(fig3e, file = "Figure_3E.png", width = 1600, height = 1600, dpi = 300, units = "px") # save figure as .png
ggsave(fig3e, file = "Figure_3E.eps", width = 1600, height = 1600, dpi = 300, units = "px", device = "eps") # save figure as .eps
##### Figure 5C #####
data <- readxl::read_excel("Figure 5C.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig5c <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Peak Heart Rate (bpm)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) #+
# ggsignif::geom_signif(test = "wilcox.test",
# comparisons = list(c("HV", "PI-ME/CFS")),
# map_signif_level = function(p) sprintf("p = %.1g", p),
# color = "black", textsize = 8)
fig5c
ggsave(fig5c, file = "Figure_5C.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig5c, file = "Figure_5C.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 5D #####
data <- readxl::read_excel("Figure 5D.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig5d <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Peak VO2 (mL/kg/min)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig5d
ggsave(fig5d, file = "Figure_5D.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig5d, file = "Figure_5D.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 5E #####
data <- readxl::read_excel("Figure 5E.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig5e <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Percent of Predicted VO2peak (%)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig5e
ggsave(fig5e, file = "Figure_5E.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig5e, file = "Figure_5E.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 5F #####
data <- readxl::read_excel("Figure 5F.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig5f <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Heart Rate Reserve (peak-resting; bpm)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 24),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig5f
ggsave(fig5f, file = "Figure_5F.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig5f, file = "Figure_5F.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 5H #####
data <- readxl::read_excel("Figure 5H.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig5h <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "VO2 at Anerobic Threshold \n (mL/kg/min)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26, lineheight = 0.35),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig5h
ggsave(fig5h, file = "Figure_5H.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig5h, file = "Figure_5H.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 6A #####
data <- readxl::read_excel("Figure 6A.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig6a <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Cerebrospinal Fluid DOPA (pg/mL)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig6a
ggsave(fig6a, file = "Figure_6A.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig6a, file = "Figure_6A.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 6B #####
data <- readxl::read_excel("Figure 6B.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig6b <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Cerebrospinal Fluid DOPAC (pg/mL)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig6b
ggsave(fig6b, file = "Figure_6B.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig6b, file = "Figure_6B.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 6C #####
data <- readxl::read_excel("Figure 6C.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "var")
fig6c <- ggplot2::ggplot(data, aes(x = group, y = var, color = group)) +
geom_boxplot(outlier.shape = NA, coef = NULL) +
stat_boxplot(geom = 'errorbar', width = 0.5, coef = NULL) +
geom_point(shape=19, position=position_jitter(width = 0.25, height = 0.25), size = 1) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Cerebrospinal Fluid DHPG (pg/mL)") +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_text(face = "bold", color = "black", size = 26),
axis.text.x = element_text(face = "bold", color = "black", size = 20),
axis.text.y = element_text(color = "black", size = 20)) +
ggsignif::geom_signif(test = "wilcox.test",
comparisons = list(c("HV", "PI-ME/CFS")),
map_signif_level = function(p) sprintf("p = %.1g", p),
color = "black", textsize = 8)
fig6c
ggsave(fig6c, file = "Figure_6C.png", width = 500, height = 700, dpi = 300, units = "px")
ggsave(fig6c, file = "Figure_6C.eps", width = 500, height = 700, dpi = 300, device = "eps", units= "px")
##### Figure 6D #####
data <- readxl::read_excel("Figure 6D.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "xvar", "yvar")
fig6d <- ggplot2::ggplot(data, aes(x = xvar, y = yvar, color = group)) +
geom_point(size = 1) +
geom_smooth(method= "lm", se = FALSE) +
ggpmisc::stat_correlation(exact = TRUE,
label.x = "right",
label.y = "bottom",
r.digits = 2,
p.digits = 2,
small.p = TRUE,
size = 6,
use_label(c("R", "P", "n"))) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Time to Failure (seconds)",
x = "Cerebrospinal fluid NE (pg/mL)") +
theme(legend.title = element_blank(), legend.position = "none",
axis.title.x = element_text(face = "bold", color = "black", size = 22),
axis.title.y = element_text(face = "bold", color = "black", size = 22),
axis.text.x = element_text(color = "black", size = 18),
axis.text.y = element_text(color = "black", size = 18)) #legend.position = "none",
fig6d
ggsave(fig6d, file = "Figure_6D.png", width = 800, height = 800, dpi = 300, units = "px")
ggsave(fig6d, file = "Figure_6D.eps", width = 800, height = 800, dpi = 300, units = "px", device = "eps")
##### Figure 6E #####
data <- readxl::read_excel("Figure 6E.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "xvar", "yvar")
fig6e <- ggplot2::ggplot(data, aes(x = xvar, y = yvar, color = group)) +
geom_point(size = 1) +
geom_smooth(method= "lm", se = FALSE) +
ggpmisc::stat_correlation(exact = TRUE,
label.x = "right",
label.y = "bottom",
r.digits = 2,
p.digits = 2,
small.p = TRUE,
size = 6,
use_label(c("R", "P", "n"))) +
theme_classic() +
scale_color_manual(values = c("blue", "red")) +
labs(y = "Proportion Hard Trials (%)",
x = "Cerebrospinal fluid NE (pg/mL)") +
theme(legend.title = element_blank(), legend.position = "none",
axis.title.x = element_text(face = "bold", color = "black", size = 22),
axis.title.y = element_text(face = "bold", color = "black", size = 22),
axis.text.x = element_text(color = "black", size = 18),
axis.text.y = element_text(color = "black", size = 18)) #legend.position = "none",
fig6e
ggsave(fig6e, file = "Figure_6E.png", width = 800, height = 800, dpi = 300, units = "px")
ggsave(fig6e, file = "Figure_6E.eps", width = 800, height = 800, dpi = 300, units = "px", device = "eps")
##### Figure 6F #####
data <- readxl::read_excel("Figure 6F.xlsx", col_names = TRUE) %>%
janitor::clean_names() %>%
na.omit()
colnames(data) <- c("group", "xvar", "yvar")
fig6f <- ggplot2::ggplot(data, aes(x = xvar, y = yvar, color = group)) +
geom_point(size = 1) +
geom_smooth(method= "lm", se = FALSE) +
ggpmisc::stat_correlation(exact = TRUE,
label.x = "right",
label.y = "bottom",
r.digits = 2,
p.digits = 2,
small.p = TRUE,
size = 6,
use_label(c("R", "P", "n"))) +
theme_classic() +