Add ggplot contact matrix heatmaps to explain symmetry in contact-matrices episode
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- r
- Domain
- data-visualization, documentation
Research direction
Read the contact-matrices episode and the referenced 73-socialmixr-ggplot.R script, then run the episode through the existing contacts_byage setup. Add one chunk producing heatmaps for contacts_byage$matrix and the population-weighted matrix, and confirm that the plots visibly contrast asymmetric rates with symmetric total contacts.
Written by the indexing model from the issue text.
Description
Context
The contact-matrices episode explains symmetric contact matrices but currently lacks a visual comparison that makes the symmetry argument concrete.
The script 73-socialmixr-ggplot.R in epicatador has two helper functions (format_big_mark, matrix_to_ggplot) that produce ggplot heatmaps of the contact matrix.
Plan
Add a single chunk (on a new branch) that:
- Defines
format_big_mark()— formats tile labels as human-readable numbers (K/M). - Defines
matrix_to_ggplot()— converts a contact matrix to ageom_tileheatmap usingcolorspace::scale_fill_continuous_sequential(palette = "OrYel"). - Produces two plots side by side or sequentially:
- Plot 1:
contacts_byage$matrix— mean contacts (asymmetric rates). - Plot 2:
contacts_byage$matrix * contacts_byage$demography$population— total contacts (symmetric).
- Plot 1:
The contrast between the two plots makes the symmetry argument visual and explicit.
Adaptations from source
- Uses standard
contacts_byageobject (already loaded upstream viacontactsurveyspattern). - Uses
|>instead of%>%. - Explicit
pkg::namespacing. - No
socialmixr::get_survey()— survey loaded upstream.
Dependencies
colorspace(forscale_fill_continuous_sequential)scales(forlabel_number)ggplot2,dplyr(already used in the episode)
- Dominant language
- R
- Stars
- 2
- Forks
- 5
- Avg merge
- 4m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from epiverse-trace/tutorials-late
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
epiverse-trace/tutorials-late#176 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
epiverse-trace/tutorials-late#173 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
epiverse-trace/tutorials-late#166 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
epiverse-trace/tutorials-late#147 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
epiverse-trace/tutorials-late#184 ·
All issues in epiverse-trace/tutorials-late
Similar issues
-
documentation pkg infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100