knitr::opts_chunk$set(echo = FALSE)
library(screenviz)
library(tidyverse)
library(cowplot)

df <- load_data("Shared/screenviz/combined_effects.rds")
df <- tidy_data_effects(df)

Scenarios

There are two groups of users we think might want to access the system. Example use cases are given below.

Scenario One

Users: Parents

A parent wants to explore the types of exposure. The select a particular exposure (e.g., TV) might impact their child. They search for the exposure and are given an overview of the known outcome categories. Visualise info about the uncertainty for each effect. They filter the results for their child's age. They click into an outcome category to get more information on the result (e.g., text summary, info about reason for the uncertainty).

Scenario Two

Users: Researchers/clinicians

A domain expert wants to explore evidence for screen time in more detail. Use the system to get an overview of the evidence (exposure, outcome, effect size). They search for the exposure and/or the outcome, and optionally filter by age. They click into a relationship and can access the forest plot of the original studies, and the link to the original meta-analysis (and other, related studies, uncertainty). Three levels: evidence, uncertainty, meta-data.

Tasks/Screens

Task One

Explore the exposures that there are evidence for.

Proposed Idiom: Heatmap

Counts

df_p <- df %>%
  mutate(
    general_exposure = as_factor(general_exposure),
    general_outcome = as_factor(general_outcome)
  ) %>%
  group_by(general_exposure, general_outcome, .drop = FALSE) %>%
  summarise(n = n())

hm_n <- ggplot(df_p, aes(x = general_exposure, y = general_outcome)) +
  geom_tile(
    data = subset(df_p, n > 0), aes(fill = n),
    color = "white",
    lwd = 1.5,
    linetype = 1
  ) +
  geom_tile(
    data = subset(df_p, n == 0), aes(fill = NA),
    fill = "grey", color = "grey",
    lwd = 1.5,
    linetype = 0
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 30, vjust = 0.5),
    panel.grid.major = element_blank(), panel.grid.minor = element_blank()
  )
hm_n

Effect sizes

df_p <- df %>%
  mutate(
    general_exposure = as_factor(general_exposure),
    general_outcome = as_factor(general_outcome)
  ) %>%
  group_by(general_exposure, general_outcome, .drop = FALSE) %>%
  summarise(r = mean(r))

hm_es <- ggplot(df_p, aes(x = general_exposure, y = general_outcome)) +
  geom_tile(
    data = subset(df_p, !is.na(r)), aes(fill = r),
    color = "white",
    lwd = 1.5,
    linetype = 1
  ) +
  geom_tile(
    data = subset(df_p, is.na(r)), aes(fill = NA),
    fill = "grey", color = "white",
    lwd = 1.5,
    linetype = 0
  ) +
  scale_fill_distiller(palette = "RdBu", limits = c(-.5, .5)) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 30, vjust = 0.5),
    panel.grid.major = element_blank(), panel.grid.minor = element_blank()
  )
hm_es

Side-by-side

plot_grid(hm_es, hm_n)

Notes

Task Two

Explore an overview of the outcome categories for the selected exposure category.

(E.g., if they have chosen 'video games')

Option One (Heatmap)

df %>%
  filter(general_exposure == "Video games") %>%
  group_by(plain_language_exposure, plain_language_outcome) %>%
  summarise(r = mean(r)) %>%
  ggplot(aes(
    x = plain_language_exposure,
    y = plain_language_outcome, fill = r
  )) +
  geom_tile() +
  scale_fill_distiller(palette = "RdBu", limits = c(-.5, .5)) +
  theme_minimal()

Option Two (Line Range)

p_df <- df %>%
  filter(general_exposure == "Video games") %>%
  select(
    general_exposure, general_outcome, plain_language_exposure,
    plain_language_outcome, r, ciub95, cilb95, age_group, n
  ) %>%
  mutate(plain_language_outcome = fct_reorder(plain_language_outcome, r)) %>%
  arrange(plain_language_outcome, r) %>%
  group_by(general_exposure, plain_language_outcome) %>%
  mutate(
    effect_id = row_number(),
    group_id = cur_group_id(),
    median_effect = median(r)
  ) %>%
  ungroup() %>%
  arrange(desc(median_effect), plain_language_outcome, desc(r)) %>%
  mutate(
    aux = row_number()
  ) %>%
  group_by(plain_language_outcome) %>%
  mutate(breaks = median(aux)) %>%
  ungroup() %>%
  mutate(
    stripe = factor(if_else(group_id %% 2 == 0, 1, 0))
  )

ggplot(p_df, aes(
  x = aux,
  y = r
)) +
  geom_linerange(aes(
    ymin = cilb95,
    ymax = ciub95,
    col = age_group
  ), size = 3) +
  geom_point(aes(
    size = log(n)
  ),
  shape = 21,
  color = "white", stroke = 0.5, fill = "black"
  ) +
  geom_rect(
    aes(
      xmax = aux + 0.5, xmin = aux - 0.5,
      ymin = -1, ymax = 1, fill = stripe
    ),
    alpha = 0.4
  ) +
  scale_y_continuous(name = "Correlation", limits = c(-1, 1)) +
  scale_x_continuous("Outcome",
    labels = unique(p_df$plain_language_outcome),
    breaks = unique(p_df$breaks)
  ) +
  scale_fill_manual(values = c("white", "grey50"), guide = "none") +
  scale_size(guide = "none") +
  coord_flip() +
  theme_minimal()

Notes

Task Three

Show detailed information about the effect

TODO - I think this will likely be a formatted page with an interpretation, plus original forest plot and links to studies for 'expert' users.



tarensanders/screen_viz documentation built on June 18, 2022, 11:25 p.m.