Skip to content

Instantly share code, notes, and snippets.

@krassowski
Last active April 16, 2020 22:55
Show Gist options
  • Save krassowski/c71a5a75b47dce1349f48ebcc74db76c to your computer and use it in GitHub Desktop.
Save krassowski/c71a5a75b47dce1349f48ebcc74db76c to your computer and use it in GitHub Desktop.
ComplexUpset with icons
# for indvs and symptoms see https://github.com/kjhealy/covid_symptoms
mapping = list(
'Fatigue'='tired-regular',
'Anosmia'='socks-solid',
'Cough'='head-side-cough-solid',
'Fever'='thermometer-full-solid',
'Diarrhea'='toilet-solid',
'Breath'='lungs-solid'
)
map_to_icon = function(x) {
# download from https://fontawesome.com/
paste0("<img src='archive/font-awesome-icons/", mapping[x], ".png'>")
}
patchwork::wrap_elements(
patchwork::wrap_elements(
upset(
indvs, symptoms,
name="Symptom Groupings by Frequency. Total pool is 1,764 individuals. Combinations with <10 not shown,",
min_size = 10,
width_ratio = 0.125,
labeller=map_to_icon,
queries=list(
upset_query(
set='Anosmia',
fill='red',
only_components=c('overall_sizes')
),
upset_query(
intersect=c('Fatigue', 'Fever', 'Cough'),
fill='blue', color='blue'
)
)
)
+ labs(
title = "Co-Occurence of COVID-19 Symptoms",
caption = "Data: covid.joinzoe.com/us | Graph: @kjhealy + @krassowski | Icons: FontAwesome CC BY 4.0"
)
+ theme(
axis.text.y = ggtext::element_markdown(color = "black", size = 11, hjust = 0.5)
)
)
+ (
ggplot(data.frame(symptom=symptoms), aes(y=symptom))
+ ggtext::geom_richtext(
aes(label=map_to_icon(symptoms)),
x=0.15,
label.color=NA
)
+ ggtext::geom_richtext(
aes(label=symptom),
x=0.3,
hjust=0,
label.color=NA
)
+ xlim(0, 1.5)
+ theme_void()
+ ggtitle('Symptoms')
)
+ patchwork::plot_layout(design=c(
patchwork::area(t=1, l=1, b=12, r=60),
patchwork::area(t=2, l=2, b=5, r=8)
))
) + labs(
title='Loss of smell (anosmia, in red) was highlighted as a strong predictor of COVID-19 infection in a recent preprint by (Menni, et al, 2020)',
subtitle='Having all three "frequent" symptoms (according to WHO, as per 2020-04-16) is rare (blue)'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment