/
IUSSI2022.Rmd
944 lines (677 loc) · 26.9 KB
/
IUSSI2022.Rmd
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
---
title: "Demography data for IUSSI"
author:
- name: DEIJ Committee, IUSSI
affiliation: In case of questions, please contact [Biplabendu Das](https://biplabendu.github.io/homepage/)
date: Last updated on `r format(Sys.time(), "%d %B, %Y")`
output:
html_document:
toc: true
toc_depth: 3
toc_float: true
keep_md: no
code_folding: hide
includes:
in_header: analytics.html
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(warning = F)
knitr::opts_chunk$set(message = F)
## For more inspiration on customizing the html output, refer to the following:
# https://bookdown.org/yihui/rmarkdown/html-document.html#table-of-contents
```
***
> What is this document?
The goal:
Perform a rapid exploratory analyses of the demography data obtained from the survey performed on the audience interested in or/and attending the upcoming IUSSI international conference in 2022, San Diego.
```{r, include=F, echo=F}
# Let's load the data and get a glimpse.
rm(list = ls())
library(tidyverse)
library(kableExtra)
library(plot.matrix)
# Load custom functions
source("./functions/theme_publication.R")
# Load data
path_to_repo <- "/Users/biplabendudas/Documents/GitHub/homepage/"
folder.name <- "2022_demography_data/"
raw.dat <- read.csv(paste0(path_to_repo,
"data/",
folder.name,"iussi_2022_data_30Jul22.csv"),
header = T, stringsAsFactors = F,
na.strings = c("NA",""," "))
# Get a glimpse
raw.dat %>% as.tibble() %>% head()
# Let's rename the columns to simple, easy-to-read/access data names
colnames(raw.dat)
new.colnames <- c("time_of_entry",
"age",
"gender",
"add_gender",
"sex_orientation",
"add_sex_orientation",
"residence_location",
"research_location",
"ethnic_identity",
"add_ethnic_identity",
"religious_identity",
"add_religious_identity",
"disability_identity",
"add_disability_identity",
"written_english",
"spoken_english",
"children_responsibility",
"adult_responsibility",
"funds_for_care_inhibit",
"firstgen",
"current_position",
"which_attended_before",
"role_attended_before",
"current_institute_desc",
"barriers_what_degree",
"barriers_which",
"add_barriers_which")
## Rename column names
colnames(raw.dat) <- new.colnames
## Specify what to call the group in which we club everything else
## Some options: other, additional_category
other.var <- "additional_category"
```
***
## 01 Raw data
> Number of folks that took the survey: `r nrow(raw.dat)`
Let's take a look at few rows and columns of the raw data.
```{r raw_data, echo=F}
# get a glimpse of the column format features of the data
raw.dat[10:13,1:7] %>%
kable() %>%
kable_styling(bootstrap_options = c("striped"), full_width = F, position = "center", latex_options = "scaled_down")
raw.dat[10:13,8:13] %>%
kable() %>%
kable_styling(bootstrap_options = c("striped"), full_width = F, position = "center", latex_options = "scaled_down")
```
### What does each column contain?
**Column name: Description**
- time_of_entry:
- age:
- and so on..
***
## 02 Format data
> Get the data into a tidy format
- remove columns that are not useful for a first assessment
- time_of_entry
- add_xxx (all columns that contain additional response not listed)
- format each column by
- separating multiple choices into separate rows
- factorizing the variables
- checking for erronneous choices/inputs
```{r format_data}
## Tidy and save data
dat <-
raw.dat %>% as_tibble() %>%
## remove columns that you do not want
select(-time_of_entry) %>%
select(-starts_with("add")) %>%
## add a unique ID for each person
rownames_to_column("ID") %>%
## AGE
mutate(age = str_split_fixed(age, " ", n=2)[,1]) %>%
mutate(age = ifelse(age %in% c("","Prefer"), other.var, age)) %>%
mutate(age = as.factor(age)) %>%
# ## Plot: AGE
# group_by(age) %>%
# summarise(num = n()) %>%
# ##
# ggplot(aes(x=age, y=num)) +
# geom_point() +
# coord_flip() +
# theme_Publication()
## GENDER
# there are two entries that contains the following two responses for gender identity
# c("Cisgender woman;Prefer not to respond", "Transgender man;Cisgender woman")),
# five entries that stated "Prefer not to respond", and one which is NA.
# Rename all to "Other"
mutate(gender = ifelse(!gender %in% c("Cisgender man", "Cisgender woman", "Non-binary",
"Transgender man", "Transgender woman"), other.var, gender)) %>%
mutate(gender = as.factor(gender)) %>%
# ## Plot: GENDER
# group_by(gender) %>%
# summarise(num = n()) %>%
# na.omit() %>%
# ##
# ggplot(aes(x=gender, y=num/sum(num)*100)) +
# geom_point() +
# coord_flip() +
# theme_Publication()
## sex_orientation
mutate(sex_orientation = ifelse(sex_orientation %in% c("Additional identity not listed? (Please click next and share)","Prefer not to respond"), other.var, sex_orientation)) %>%
mutate(sex_orientation = as.factor(sex_orientation)) %>%
## residence_location
mutate(residence_location = ifelse(residence_location %in% c("Central America;Other",
"Continental US;South Asia",
"Europe;Middle East",
"Europe;Southeast Asia",
"Other"), other.var, residence_location)) %>%
mutate(residence_location = as.factor(residence_location)) %>%
## research location
# filter(research_location %in% c("Central America;Continental US", "Europe;South America")) %>%
separate_rows(research_location, sep = ";") %>%
mutate(research_location = as.factor(research_location)) %>%
## ethnic_identity
separate_rows(ethnic_identity, sep = ";") %>%
mutate(ethnic_identity = ifelse(ethnic_identity %in% c("A race or ethnicity not listed",
"Prefer not to respond"),
other.var, ethnic_identity)) %>%
mutate(ethnic_identity = as.factor(ethnic_identity)) %>%
## religious_identity
mutate(religious_identity = ifelse(religious_identity %in% c("An additional affiliation not listed",
"Prefer not to respond"),
other.var, religious_identity)) %>%
mutate(religious_identity = as.factor(religious_identity)) %>%
## disability_identity
separate_rows(disability_identity, sep = ";") %>%
mutate(disability_identity = as.factor(disability_identity)) %>%
## written_english
mutate(written_english = as.factor(written_english)) %>%
## spoken_english
mutate(spoken_english = as.factor(spoken_english)) %>%
## children_responsibility
mutate(children_responsibility = as.factor(children_responsibility)) %>%
## adult_responsibility
mutate(adult_responsibility = ifelse(adult_responsibility %in% c("Prefer not to respond", "Other"),
other.var, adult_responsibility)) %>%
mutate(adult_responsibility = as.factor(adult_responsibility)) %>%
## funds_for_care_inhibit
mutate(funds_for_care_inhibit = as.factor(funds_for_care_inhibit)) %>%
## firstgen
mutate(firstgen = as.factor(firstgen)) %>%
## current position
separate_rows(current_position, sep = ";") %>%
mutate(current_position = as.factor(current_position)) %>%
## which_attended_before
separate_rows(which_attended_before, sep = ";") %>%
mutate(which_attended_before = as.factor(which_attended_before)) %>%
## role_attended_before
separate_rows(role_attended_before, sep = ";") %>%
mutate(role_attended_before = as.factor(role_attended_before)) %>%
## current_institute_desc
separate_rows(current_institute_desc, sep = ";") %>%
mutate(current_institute_desc = as.factor(current_institute_desc)) %>%
## barriers_what_degree
mutate(barriers_what_degree = as.factor(barriers_what_degree)) %>%
## barriers_which
separate_rows(barriers_which, sep = ";") %>%
mutate(barriers_which = as.factor(barriers_which))
# ## get a glimpse of the tidy data
# dat[10:13,1:7] %>%
# kable() %>%
# kable_styling(bootstrap_options = c("striped"), full_width = F, position = "center", latex_options = "scaled_down")
#
# dat[10:13,8:13] %>%
# kable() %>%
# kable_styling(bootstrap_options = c("striped"), full_width = F, position = "center", latex_options = "scaled_down")
```
***
## 03 Visualize
```{r define_params}
## Use this code chunk to define paramaters, such as color palettes and such
## COLOR
# role attended before
roles.color <- c("#005C53", "#F2E744", "#D9814E", "#BF6854", "#261B1A", "grey60")
```
### Age & gender
```{r age_gender}
## AGE + GENDER
dat %>%
# remove the rows with no age/gender info
filter(age != other.var) %>%
filter(!is.na(gender)) %>%
# filter(gender != "Other") %>%
# tally the number of people in a given age group for a given gender
distinct(ID, age, gender) %>%
group_by(age, gender) %>%
summarize(num=n()) %>%
## Plot: AGE + GENDER
ggplot(aes(x=age, y=num, fill=gender, group=gender)) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
geom_bar(position="stack", stat="identity") +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
guides(fill = guide_legend(nrow = 3))
```
***
### Residence location & gender
```{r residence_location_gender}
# Residence location & gender
dat %>%
# filter(!residence_location %in% c("Other")) %>%
filter(!is.na(residence_location)) %>%
filter(!is.na(gender)) %>%
# filter(gender != "Other") %>%
distinct(ID, residence_location, gender) %>%
group_by(residence_location, gender) %>%
summarize(num = n()) %>%
ggplot(aes(x=residence_location, y=num, fill=gender, group=gender)) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
geom_bar(position="stack", stat="identity") +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
guides(fill = guide_legend(nrow = 3))
```
***
### Research location & gender
```{r research_location_gender}
## Plot: research_location + gender
dat %>%
filter(!is.na(research_location)) %>%
filter(!is.na(gender)) %>%
# filter(gender != "Other") %>%
distinct(ID, research_location, gender) %>%
group_by(research_location, gender) %>%
summarize(num = n()) %>%
ggplot(aes(x=research_location, y=num, fill=gender, group=gender)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
guides(fill = guide_legend(nrow = 3))
```
> A bunch of folks perform research in Central America, but there seems to be no representation from folks living in Central America. There is, of course, the possibility that folks residing in Central America did not take the survey.
***
### Role of attendee & gender
```{r role_attended_before_gender}
dat %>%
# remove the rows with no info
filter(!is.na(role_attended_before)) %>%
filter(!is.na(gender)) %>%
# filter(gender != "Other") %>%
distinct(ID, role_attended_before, gender) %>%
group_by(role_attended_before, gender) %>%
summarize(num = n()) %>%
## Plot: research_location + gender
ggplot(aes(x=role_attended_before, y=num, fill=gender, group=gender)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
guides(fill = guide_legend(nrow = 3))
```
***
### Current position & gender
```{r current_position_gender}
dat %>%
filter(!is.na(current_position)) %>%
filter(!is.na(gender)) %>%
# filter(gender != "Other") %>%
distinct(ID, current_position, gender) %>%
group_by(current_position, gender) %>%
summarize(num = n()) %>%
ggplot(aes(x=current_position, y=log2(num+1), fill=gender, group=gender)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
guides(fill = guide_legend(nrow = 3))
```
***
***
### Role of attendee & residence location
```{r role_attended_before_residence_location}
dat %>%
# remove the rows with no age/gender info
filter(!is.na(role_attended_before)) %>%
filter(!is.na(residence_location)) %>%
# filter(gender != "Other") %>%
distinct(ID, role_attended_before, residence_location) %>%
group_by(role_attended_before, residence_location) %>%
summarize(num = n()) %>%
ggplot(aes(x=residence_location, y=num, fill=role_attended_before, group=role_attended_before)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
# scale_fill_Publication() +
scale_fill_manual(values = roles.color) +
guides(fill = guide_legend(nrow = 3))
```
***
### Role of attendee & current position
```{r role_attended_before_current_position}
dat %>%
# remove the rows with no age/gender info
filter(!is.na(role_attended_before)) %>%
filter(!is.na(current_position)) %>%
# filter(gender != "Other") %>%
distinct(ID, role_attended_before, current_position) %>%
group_by(role_attended_before, current_position) %>%
summarize(num = n()) %>%
## Plot: research_location + gender
ggplot(aes(x=current_position, y=num, fill=role_attended_before, group=role_attended_before)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_manual(values = roles.color) +
guides(fill = guide_legend(nrow = 3))
# to do:
# normalize the number of roles undertaken by a person in past IUSSI
# number of past roles / number of past IUSSI attended
```
The above plot might be misleading since the higher number of roles assumed by (activity of) late, tenured Profs might be due to the higher number of previous conferences attened by them. So, it might make sense to have a standardized metric that gives us a better understanding of the activity of each group in IUSSI.
> Activity = number of roles assumed (including attendee) / number of IUSSIs attended
```{r role_attended_before_current_position_v2}
id <- character()
num_attended <- numeric()
for (i in 1:length(levels(as.factor(dat$ID)))) {
id[i] <- levels(as.factor(dat$ID))[i]
num_attended[i] <-
dat %>%
filter(ID == id[i]) %>%
# select(which_attended_before)
mutate(which_attended_before=as.character(which_attended_before)) %>%
pull(which_attended_before) %>%
unique() %>%
as.factor() %>%
levels() %>% length() %>%
as.numeric()
}
dummy.dat <- data.frame(ID=id, num_attended=num_attended)
## Add this information to the primary dataset
dat %>%
# add the num_attended column to dat
left_join(dummy.dat, by="ID") %>%
# check to see if it worked
# select(ID, which_attended_before, num_attended) %>% head(20)
# remove the rows with no info
filter(!is.na(role_attended_before)) %>%
filter(!is.na(current_position)) %>%
# filter(gender != "Other") %>%
select(ID, current_position, role_attended_before, num_attended) %>%
# head(20)
distinct(ID, role_attended_before, current_position, num_attended) %>%
group_by(ID, current_position, num_attended) %>%
summarize(num_roles = n()) %>%
arrange(as.numeric(ID)) %>%
# calculate activity
mutate(activity = num_roles/num_attended) %>%
## Plot: research_location + gender
ggplot(aes(x=current_position, y=activity)) +
# geom_bar(position="stack", stat="identity", size=2) +
geom_boxplot(alpha=0.7, outlier.colour = "darkred", fill=viridis::inferno(10)[4]) +
labs(y="# roles/attendance") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_Publication() +
# scale_fill_manual(values = roles.color) +
guides(fill = guide_legend(nrow = 8)) +
theme(legend.position = "none")
```
***
### Role of attendee & ethnic identity
```{r role_attended_before_ethnic_identity}
dat %>%
# remove the rows with no age/gender info
filter(!is.na(role_attended_before)) %>%
filter(!is.na(ethnic_identity)) %>%
# filter(gender != "Other") %>%
distinct(ID, role_attended_before, ethnic_identity) %>%
group_by(role_attended_before, ethnic_identity) %>%
summarize(num = n()) %>%
## Plot: research_location + gender
ggplot(aes(x=ethnic_identity, y=num, fill=role_attended_before, group=role_attended_before)) +
geom_bar(position="stack", stat="identity", size=2) +
labs(y="number of people") +
# geom_hline(yintercept = 5, col="grey60", alpha=0.7, size=1) +
coord_flip() +
theme_Publication() +
scale_colour_Publication() +
scale_fill_manual(values = roles.color) +
guides(fill = guide_legend(nrow = 3))
```
___
___
## 05 Over/Under-represented folks
> Check which groups are *over/under-represented* at IUSSI, and for which activities.
```{r over_v1}
# load the GeneOverlap package to perform pairwise Fisher's exact test
library(GeneOverlap)
# which variable do you need to use for the x-axis
names.x <- c("gender",
# "age",
"residence_location",
# "research_location",
# "current_position",
"ethnic_identity")
writeLines("Variables of interest:")
writeLines(names.x)
# initialize a list to hold all the possible groups that we want to plot
# on the x-axis
list.x <- list()
for (j in 1:length(names.x)) {
# what are the different groups in the filtering column
groups.x <- dat %>%
pull(names.x[j]) %>%
as.factor() %>%
levels()
# what is the name of the filtering column
var <- names.x[[j]]
list.sub <- list()
for (i in 1:length(groups.x)) {
list.sub[[i]] <-
dat %>% filter(.data[[var]] %in% groups.x[[i]] ) %>% pull(ID) %>% unique()
names(list.sub)[i] <- groups.x[[i]] %>% as.character()
}
# Save the results for the filtering column and name the different lists
list.x[[j]] <- list.sub
}
## DO THE SAME FOR THE Y-AXIS
names.y <- c("role_attended_before")
list.y <- list()
groups.y <- dat %>%
pull(names.y) %>%
as.factor() %>%
levels()
var <- names.y
list.sub <- list()
for (i in 1:length(groups.y)) {
list.sub[[i]] <-
dat %>% filter(.data[[var]] %in% groups.y[[i]] ) %>% pull(ID) %>% unique()
names(list.sub)[i] <- groups.y[[i]] %>% as.character()
}
# Save the results for the filtering column and name the different lists
list.y <- list.sub
## Run the pairwise Fisher's tests ##
## What is the total sample size
nFolks <- dat %>% pull(ID) %>% unique() %>% length()
## Remove the groups that contain less than 5 individuals
list.y <- list.y[sapply(list.y, length)>=5]
for (i in 1:length(list.x)) {
# remove for x
list.x[[i]] <- list.x[[i]][sapply(list.x[[i]], length)>=5]
if (i==4) {
names(list.x[[i]]) <- names(list.x[[i]]) %>% str_sub(end=9)
gom <- newGOM(list.y, list.x[[i]],
nFolks)
}
## Let's perform the pairwise Fisher's exact test
gom <- newGOM(list.x[[i]], list.y,
nFolks)
png(paste0(path_to_repo,
"images/", folder.name,
names.x[i],"_v_",names.y,"_gom.png"),
width = 30, height = 20, units = "cm", res = 300)
drawHeatmap(gom,
# adj.p=T,
cutoff=0.05,
what="odds.ratio",
# what="Jaccard",
log.scale = T,
grid.col="Oranges",
note.col="black")
trash <- dev.off()
}
```
```{r plot_gom_1, echo = FALSE, fig.align='center', fig.cap='gender', out.width="95%"}
# > Plots: Gender
# sapply(list.x[[1]], length) %>% as.data.frame() %>% select(how_many=".")
# knitr::include_graphics(paste0(path_to_repo,
# "images/", folder.name,
# names.x[1],"_v_",names.y,"_gom.png"))
```
```{r plot_gom_2, echo = FALSE, fig.align='center', fig.cap='residence_location', out.width="95%"}
# > Plots: Residence location
# sapply(list.x[[2]], length) %>% as.data.frame() %>% select(how_many=".")
# knitr::include_graphics(paste0(path_to_repo,
# "images/", folder.name,
# names.x[2],"_v_",names.y,"_gom.png"))
```
```{r plot_gom_3, echo = FALSE, fig.align='center', fig.cap='research_location', out.width="95%"}
# > Plots: Research location
# sapply(list.x[[3]], length) %>% as.data.frame() %>% select(how_many=".")
# knitr::include_graphics(paste0(path_to_repo,
# "images/", folder.name,
# names.x[3],"_v_",names.y,"_gom.png"))
```
```{r plot_gom_4, echo = FALSE, fig.align='center', fig.cap='current_position', out.width="95%"}
# > Plots: Current position
# sapply(list.x[[4]], length) %>% as.data.frame() %>% select(how_many=".")
# knitr::include_graphics(paste0(path_to_repo,
# "images/", folder.name,
# names.x[4],"_v_",names.y,"_gom.png"))
```
```{r plot_gom_5, echo = FALSE, fig.align='center', fig.cap='ethnic_identity', out.width="95%"}
# > Plots: Ethnic identity
# sapply(list.x[[5]], length) %>% as.data.frame() %>% select(how_many=".")
# knitr::include_graphics(paste0(path_to_repo,
# "images/", folder.name,
# names.x[5],"_v_",names.y,"_gom.png"))
```
___
The goal is to perform enrichment analyses (using hypergeometric analyses) to identify under (or over) represented groups (based on gender, ethnicity, etc) in different activities (roles) at IUSSI.
> We found several overrepresented groups for specific roles; we did not find any significantly underrepresented terms. The overrepresented groups in different IUSSI roles are shown in the table/figure below.
### Results in a table
```{r under_v1}
source(paste0(path_to_repo,"functions/underrepresentation_analyses.R"))
## Format the data
bg.dat <-
dat %>%
select(ID, role_attended_before) %>%
group_by(ID) %>%
summarize(role_attended_before = str_c(role_attended_before, collapse = "; ")) %>%
ungroup()
results.list <- list()
k <- 1
# get a list of all gender IDs
for (i in 1:length(list.x)) {
names.vars <- names(list.x[[i]])
for (j in 1:length(names.vars)) {
results.list[[k]] <-
list.x[[i]][[j]] %>%
check_under(.,
bg.file = bg.dat,
what = paste0(names.x[[i]],": ",names.vars[[j]]),
atleast = 3)
k <- k+1
}
}
bind_rows(results.list, .id = "column_label") %>%
dplyr::select(-column_label) %>%
as_tibble() %>%
filter(adj_pVal < 0.05) %>%
mutate(adj_pVal = round(adj_pVal,3)) %>%
filter(over_under=="over") %>%
filter(what_desc != other.var) %>%
filter(annot_term != "no_annot") %>%
select(annot_term:adj_pVal) %>%
arrange(annot_term, adj_pVal) %>%
DT::datatable()
```
---
> And, here are the results as a heatmap.
### Results as a figure
```{r under_v2}
results.dat <-
bind_rows(results.list, .id = "column_label") %>%
dplyr::select(-column_label) %>%
as_tibble() %>%
filter(adj_pVal < 0.05) %>%
mutate(adj_pVal = round(adj_pVal,3)) %>%
filter(over_under=="over") %>%
filter(what_desc != other.var) %>%
filter(annot_term != "no_annot") %>%
select(annot_term:adj_pVal) %>%
arrange(annot_term, adj_pVal)
mat <-
results.dat %>%
select(-over_under) %>%
pivot_wider(names_from = "what_desc",
values_from = "adj_pVal",
values_fn = list(adj_pVal = min)) %>%
as.data.frame() %>%
column_to_rownames("annot_term") %>%
as.matrix()
# Plot the matrix
### note:
### make sure the library "plot.matrix" is loaded
### see here for more params: https://cran.r-project.org/web/packages/plot.matrix/vignettes/plot.matrix.html
png(paste0(path_to_repo,
"images/", folder.name,
"enrichement_results.png"),
width = 30, height = 20, units = "cm", res = 300)
par(mar=c(10.1, 16.1, 4.1, 6.1))
mat %>%
t() %>%
plot(.,
# border=NA,
col=viridis::viridis(3),
spacing.key=1.5,
fmt.key="%.3f",
xlab = "",
ylab = "",
axis.col=list(side=1, las=2), axis.row = list(side=2, las=1))
trash <- dev.off()
```
```{r plot_enrichment, echo = FALSE, fig.align='center', fig.cap='Results of the enrichment test; colors indicate p-values returned by the hypergeometric test. Lower p-values suggest possible over-representation.', out.width="95%"}
knitr::include_graphics(paste0(path_to_repo,
"images/", folder.name,
"enrichement_results.png"))
```
> So, what does the data tell us?
Write down the possible interpretations here. For example, the above figure tells us that
- Folks of *ethnic_identity: white* are overrepresented in most roles at IUSSI,
- Folks that relate to *gender: Cisgender woman* and *residence_location: Middle East* participate in IUSSI as attendees more than expected at random,
- and so on.
___
## What next?
*My thoughts*: Once we, the committee, have all the summary statistics (and figures), and interpretations from the enrichment analyses, we should be ready to put together a brief document (pdf) for circulation. We might be able to highlight a few areas that we can improve on in the near future, and a few areas that we need to work on in the long-term.
___
## Supplementary
#### 1. Reproducibility
- All code used for this document is available on my [Github](https://github.com/biplabendu/homepage/blob/master/IUSSI2022.Rmd).
- The function to perform enrichment analyses can be found [here](https://github.com/biplabendu/homepage/blob/master/functions/underrepresentation_analyses.R)
#### 2. IUSSI 2014 & 2018
A summary of the demography data for folks that attended IUSSI 2014 and 2018 can be found [here](https://biplabendu.github.io/homepage/IUSSI.html).