Package 'metaconfoundr'

Title: Visualize 'Confounder' Control in Meta-Analyses
Description: Visualize 'confounder' control in meta-analysis. 'metaconfoundr' is an approach to evaluating bias in studies used in meta-analyses based on the causal inference framework. Study groups create a causal diagram displaying their assumptions about the scientific question. From this, they develop a list of important 'confounders'. Then, they evaluate whether studies controlled for these variables well. 'metaconfoundr' is a toolkit to facilitate this process and visualize the results as heat maps, traffic light plots, and more.
Authors: Malcolm Barrett [aut, cre] , Julie M. Petersen [aut] , Ludovic Trinquart [aut]
Maintainer: Malcolm Barrett <[email protected]>
License: MIT + file LICENSE
Version: 0.1.2.9000
Built: 2024-11-07 03:12:45 UTC
Source: https://github.com/malcolmbarrett/metaconfoundr

Help Index


Count and plot non-confounders

Description

Count and plot non-confounders

Usage

count_non_confounders(.df)

plot_non_confounders(.df, ..., geom = ggplot2::geom_col, sort = TRUE)

Arguments

.df

A data frame, usually the result of metaconfoundr()

...

Arguments passed to geom

geom

The ggplot2 geom to use

sort

Logical. Should the results be sorted?

Value

a tibble or ggplot

Examples

ipi %>%
  metaconfoundr() %>%
  plot_non_confounders(size = 3, geom = ggplot2::geom_point)

Facet by constructs

Description

A helper function to facet by constructs in 'mc_heatmap() and mc_trafficlight()

Usage

facet_constructs(...)

Arguments

...

Arguments passed to ggplot2::facet_grid()

Value

a facet component

See Also

Other plots: geom_cochrane(), mc_heatmap(), scale_fill_cochrane(), theme_mc()


Add Cochrane-style symbols to heatmaps and traffic light plots

Description

Add Cochrane-style symbols to heatmaps and traffic light plots

Usage

geom_cochrane(
  mapping = ggplot2::aes(shape = control_quality),
  data = NULL,
  stat = "identity",
  position = "identity",
  ...,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

stat

The statistical transformation to use on the data for this layer, as a string.

position

Position adjustment, either as a string, or the result of a call to a position adjustment function.

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

Value

a geom

See Also

Other plots: facet_constructs(), mc_heatmap(), scale_fill_cochrane(), theme_mc()


IPI data

Description

These data represent 14 analyses (retrospective cohorts and sibling-matched designs) to evaluate the association between short interpregnancy interval (<6 months versus 18-23 months) and risk of preterm birth (<37 weeks gestation) and the adequacy of confounder control (Petersen et al.). Adequacy of confounder control was determined overall for each study as well as by variable and construct (groupings of conceptually related variables).These studies are a subset of studies originally identified in a systematic review by Ahrens et al. to summarize associations between short interpregnancy interval and a variety of perinatal outcomes in high-resource settings.

Usage

ipi

ipi_wide

ipi_metaanalysis

Format

An object of class tbl_df (inherits from tbl, data.frame) with 407 rows and 5 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 37 rows and 14 columns.

An object of class tbl_df (inherits from tbl, data.frame) with 11 rows and 9 columns.

Source

Ahrens et al. (2019)

References

Ahrens KA, Nelson H, Stidd RL, Moskosky S, Hutcheon JA. Short interpregnancy intervals and adverse perinatal outcomes in high-resource settings: An updated systematic review. Paediatr Perinat Epidemiol. 2019;33(1):O25-O47.

Petersen JM, Barrett M, Ahrens K, Murray EJ, Hogue C, Mumford S, Bryant Mantha A, Fox MP, Gadupudi S, Trinquart L. Confounder Matrix: A Tool to Assess Confounding Bias in Systematic Reviews of Observational Studies. 2020


Label values using ROBINS approach

Description

label_robins() is a helper function to modify metaconfoundr labels to use ROBINS-like labels: low risk, some concerns, high risk.

Usage

label_robins()

Value

a character vector of ROBINS labels

Examples

mc_heatmap(metaconfoundr(ipi)) +
  ggplot2::scale_fill_ordinal(labels = label_robins())

mc_heatmap(metaconfoundr(ipi)) +
  scale_fill_cochrane(labels = label_robins())

Launch metaconfoundr Shiny app

Description

launch_metaconfoundr_app() launches a Shiny app to create visualizations of confounding control in meta-analyses

Usage

launch_metaconfoundr_app()

Value

A Shiny app


Tidy metaconfoundr data layouts

Description

mc_longer() and mc_wider() are helper functions to put metaconfoundr() for long and wide data sets, respectively. results into a tidy format. mc_detect_layout() chooses between the two automatically based on the number of variables in the data frame. mc_study_values() helps standardize evaluations of control quality.

Usage

mc_detect_layout(...)

mc_longer(
  study = contains("construct"),
  construct = contains("construct"),
  variable = matches("variable|factor"),
  control_quality = contains("control_quality"),
  is_confounder = contains("confounder"),
  study_values = mc_study_values()
)

mc_study_values(inadequate = 0, some_concerns = 1, adequate = 2)

mc_wider(
  construct = contains("construct"),
  variable = matches("variable|factor"),
  is_confounder = contains("confounder"),
  study = everything(),
  study_values = mc_study_values()
)

Arguments

...

Additional arguments passed to mc_wider() or mc_longer()

study

The column with the name of the studies

construct

The domain or construct column

variable

The column that describes the confounding variables

control_quality

The column that describes the confounding control quality

is_confounder

The column that describes if a variable is a confounder

study_values

What are the levels of control_quality? Use mc_study_values() to set up.

inadequate

Which value signifies inadequate control?

some_concerns

Which value signifies control with some concerns?

adequate

Which value signifies adequate control?

Value

a function that tidies the data


Plot a heatmap or traffic light plot of metaconfoundr() summaries

Description

mc_heatmap() and mc_trafficlight() visualize the results of metaconfoundr(), summarizing the quality of confounder control in each study.

Usage

mc_heatmap(
  .df,
  legend_title = "control quality",
  sort = FALSE,
  by_group = FALSE,
  score = c("adequate", "sum", "controlled"),
  non_confounders = FALSE
)

mc_trafficlight(
  .df,
  size = 8,
  legend_title = "control quality",
  sort = FALSE,
  by_group = FALSE,
  score = c("adequate", "sum", "controlled"),
  non_confounders = FALSE
)

Arguments

.df

A data frame, usually the result of metaconfoundr()

legend_title

The legend title

sort

Logical. Sort by confounder score? Calculated by score_control()

by_group

Logical. If sorted, sort within domain?

score

The approach used to calculate the score. adequate tests if the study controlled at a strictly adequate level. sum treats control_quality as an ordinal integer, summing it's values such that a higher score has better control overall. controlled tests if any control, including ⁠some concerns⁠ control, is present.

non_confounders

Logical. Include non-confounders? Default is FALSE.

size

The size of the points in the traffic light plot

Value

a ggplot

See Also

Other plots: facet_constructs(), geom_cochrane(), scale_fill_cochrane(), theme_mc()

Examples

ipi %>%
  metaconfoundr() %>%
  dplyr::mutate(variable = stringr::str_wrap(variable, 10)) %>%
  mc_heatmap() +
  theme_mc() +
  facet_constructs() +
  ggplot2::guides(x = ggplot2::guide_axis(n.dodge = 2))

ipi %>%
  metaconfoundr() %>%
  mc_trafficlight() +
  geom_cochrane() +
  facet_constructs() +
  scale_fill_cochrane() +
  theme_mc() +
  ggplot2::guides(x = ggplot2::guide_axis(n.dodge = 2))

Prepare a meta-analysis data set for metaconfoundr

Description

metaconfoundr() standardizes data frames with information on how well a set of studies control for a set of variables. In this approach, a set of domain experts agree on the variables that are required to properly control for confounding for a scientific question. Then, for a given confounder, the studies are described as being adequately controlled, inadequately controlled, or controlled with some concerns. metaconfoundr() is intended to standardize data for use in mc_heatmap() and mc_trafficlight(). See the vignette on data preparation for more information on how to set up your evaluation.

Usage

metaconfoundr(.df, data_format = mc_detect_layout())

Arguments

.df

A data frame. See the vignette on data preparation for more details.

data_format

The format of the data. Detected automatically by default, but explicit options include mc_longer() and mc_wider()

Value

a tibble

Examples

metaconfoundr(ipi)

metaconfoundr(ipi_wide)

ipi_wide2 <- ipi_wide %>%
  dplyr::rename(scope = construct)

metaconfoundr(ipi_wide2, mc_wider(construct = "scope"))

Add Cochrane-style palettes to ggplots

Description

Add Cochrane-style palettes to ggplots

Usage

scale_fill_cochrane(...)

scale_color_cochrane(...)

scale_shape_cochrane(...)

Arguments

...

Arguments passed to the underline scale function

Value

scales for ggplot

See Also

Other plots: facet_constructs(), geom_cochrane(), mc_heatmap(), theme_mc()


Add a score of confounding control

Description

score_control() adds a variable, score, that summarizes how well a study controls for a domain or construct. Used to sort heatmaps and traffic light plots.

Usage

score_control(.df, score = c("adequate", "sum", "controlled"))

Arguments

.df

A data frame, usually the result of metaconfoundr()

score

The approach used to calculate the score. adequate tests if the study controlled at a strictly adequate level. sum treats control_quality as an ordinal integer, summing it's values such that a higher score has better control overall. controlled tests if any control, including ⁠some concerns⁠ control, is present.

Value

a tibble

Examples

library(dplyr)

ipi %>%
  metaconfoundr() %>%
  filter(is_confounder == "Y") %>%
  score_control("controlled") %>%
  arrange(desc(score))

Summarize the control quality of studies

Description

summarize_control_quality() allows you to summarize how well studies control for variables within one or more domains, and how well those domains are controlled for overall. Each logical statement is a domain and can be named.

Usage

summarize_control_quality(.df, ..., domains = TRUE)

Arguments

.df

A data frame, usually the result of metaconfoundr()

...

Boolean arguments to declare adequate control logic

domains

Logical. Include the domains in the output? If FALSE, only returns overall control quality.

Value

A tibble

Examples

summary_df <- summarize_control_quality(
  metaconfoundr(ipi),
  Sociodemographics = `Maternal age` & `Race/ethnicity` & `Marital status`,
  Socioeconomics = `SES category` | Insurance & Education,
  "Reproductive Hx" = `Prior pregnancy outcome`
)

summary_df

summary_df %>%
  mc_trafficlight() +
  theme_mc() +
  facet_constructs() +
  geom_cochrane() +
  scale_fill_cochrane()

A minimal theme for metaconfoundr plots

Description

A minimal theme for metaconfoundr plots

Usage

theme_mc(base_size = 14)

Arguments

base_size

base font size, given in pts.

Value

a ggplot theme

See Also

Other plots: facet_constructs(), geom_cochrane(), mc_heatmap(), scale_fill_cochrane()