Skip to content

Instantly share code, notes, and snippets.

@aghaynes
Last active January 8, 2019 13:06
Show Gist options
  • Save aghaynes/50ff06201cdf782a656c7c221e27dd8c to your computer and use it in GitHub Desktop.
Save aghaynes/50ff06201cdf782a656c7c221e27dd8c to your computer and use it in GitHub Desktop.
REDCap metaanalysis data dictionary
# Download data
token <- readLines("PATH/TO/TOKEN")
library(httr)
url <- "PATH/TO/API"
# data itself
x <- POST(url,
config = httr::config(SSL_VERIFYPEER = FALSE),
body = list(token = token,
content = "record", type = "flat",
format = "csv"))
x <- as.character(x)
con <- textConnection(x)
dat <- read.csv(con, head = TRUE, na.strings = "", stringsAsFactors = FALSE)
# metadata
x <- POST(url,
config = httr::config(SSL_VERIFYPEER = FALSE),
body = list(token = token,
content = "metadata", type = "flat",
format = "csv"))
x <- as.character(x)
con <- textConnection(x)
meta <- read.csv(con, head = TRUE, na.strings = "", stringsAsFactors = FALSE)
# filter data
bias <- meta[meta$form_name == "bias_assessment", ]
bias <- bias[bias$field_type == "radio", ]
bias_dat <- dat[is.na(dat$redcap_repeat_instrument), c("record_id", "author_short", bias$field_name)]
N <- nrow(bias_dat)
# function to split string at space after half way
X <- function(string){
require(stringr)
str <- string
chars <- nchar(str)
spaces <- str_locate_all(str, " ")
mapply(function(str, x, y) {
l <- x[, 1]
s <- l[l > y/2][1]
if(!is.na(s)){
r <- gsub(paste0("^(.{", s, "})(.*)$"), "\\1\n\\2", str)
} else {
r <- str
}
r
}, str, spaces, chars)
}
X(bias$field_label)
# plot matrix of colours
par(mai = c(2,2,.1,.1), xaxt = "n", yaxt = "n")
image(t(as.matrix(bias_dat[, 3:9])),
col = c("green", "orange", "red"),
bty = "n")
# author labels
text(y = seq(0, 1, length.out = N),
x = par("usr")[1],
labels = bias_dat$author_short,
pos = 2,
xpd = "n")
# questions
par(lheight=.8)
text(y = par("usr")[3],
x = seq(0, 1, length.out = 7),
labels = X(bias$field_label),
pos = 2,
xpd = "n", srt = 60)
Variable / Field Name Form Name Section Header Field Type Field Label Choices, Calculations, OR Slider Labels Field Note Text Validation Type OR Show Slider Number Text Validation Min Text Validation Max Identifier? Branching Logic (Show field only if...) Required Field? Custom Alignment Question Number (surveys only) Matrix Group Name Matrix Ranking? Field Annotation
record_id study_details text Record ID
author study_details text Authors
year study_details text Year
author_short study_details text Short identifier How it should appear in journal (e.g. Muller2018)
doi study_details text DOI
title study_details text Title
journal study_details text Journal
issue study_details text Issue
pages study_details text Pages
total_n study_details text Total participants
treatments_n study_details text Number of treatments
inc1 inclusionexclusion yesno Paper considers XXXX
excl1 inclusionexclusion yesno Paper reports XXXX
reject_message inclusionexclusion descriptive <font size="3" color="red"><center>Paper is not suitable... do not go further</center></font> [inc1] = '0' or [excl1] = '1'
reject_message_2 inclusionexclusion descriptive <font size="3" color="green"><center>Paper is suitable... continue</center></font> [inc1] = '1' and [excl1] = '0'
followup inclusionexclusion sql Second follow up of record select value from redcap_data where project_id = '197' and field_name = 'record_id'
message continuous_endpoint_separate_means descriptive <font size="3" color="red"><center>Complete for each treatment and endpoint!</center></font>
endpoint_sep continuous_endpoint_separate_means radio Endpoint 1, Endpoint 1 | 2, Endpoint 2 | N, Endpoint N
treatment continuous_endpoint_separate_means radio Treatment 1, Control | 2, Experimental
treatment_unit continuous_endpoint_separate_means radio Units 1, XXX | 2, YYY
treatment_n continuous_endpoint_separate_means text Number of participants integer
min continuous_endpoint_separate_means text Minimum number
p25 continuous_endpoint_separate_means text 25th percentile number
mean continuous_endpoint_separate_means text Mean number
median continuous_endpoint_separate_means text Median number
p75 continuous_endpoint_separate_means text 75th percentile number
max continuous_endpoint_separate_means text Maximum number
sd continuous_endpoint_separate_means text SD number
se continuous_endpoint_separate_means text SE number
lci continuous_endpoint_separate_means text Lower confidence interval number
uci continuous_endpoint_separate_means text Upper confidence interval number
ci_p continuous_endpoint_separate_means text Confidence interval percentage e.g. 95% CI would be 95 number
messaged continuous_endpoints_difference descriptive <font size="3" color="red"><center>Complete for each treatment and endpoint!</center></font>
endpoint_diff continuous_endpoints_difference radio Endpoint 1, Endpoint 1 | 2, Endpoint 2 | N, Endpoint N
endpoint_diff_unit continuous_endpoints_difference radio Units 1, XXX | 2, YYY
direction continuous_endpoints_difference dropdown Direction 1, Treatment/Control | 2, Control/Treatment
mean_diff continuous_endpoints_difference text Mean difference number
med_diff continuous_endpoints_difference text Median difference number
se_diff continuous_endpoints_difference text SE difference number
lci_diff continuous_endpoints_difference text Lower confidence interval number
uci_diff continuous_endpoints_difference text Upper confidence interval number
ci_diff_perc continuous_endpoints_difference text Confidence interval percentage number 0 100
p_diff continuous_endpoints_difference text P-value number 0 1
test continuous_endpoints_difference radio Test type 1, Non-parametric | 2, t-test | 3, z-test | 4, Wald test | 5, Likelihood ratio test (LRT) [p_diff] <> ''
messageb binary_endpoints descriptive <font size="3" color="red"><center>Complete for each treatment and endpoint!</center></font>
endpoint_bin binary_endpoints radio Endpoint 1, Endpoint 1 | 2, Endpoint 2 | N, Endpoint N
n_total binary_endpoints Cell Frequencies text Total participants integer
n_control binary_endpoints text Total control participants integer
n_ev_control binary_endpoints text Events in control arm
perc_ev_control binary_endpoints text Percentage of participants from control arm with event
n_exp binary_endpoints text Total experimental participants integer
n_ev_exp binary_endpoints text Events in experimental arm
perc_ev_exp binary_endpoints text Percentage of participants from experimental arm with event
direction_bin binary_endpoints Odds ratio dropdown Direction 1, Treatment/Control | 2, Control/Treatment
or binary_endpoints text Odds ratio (OR) number
or_se binary_endpoints text OR SE
or_lci binary_endpoints text OR lower confidence interval
or_uci binary_endpoints text OR upper confidence interval
or_ci_perc binary_endpoints text OR confidence interval percentage
or_p binary_endpoints text OR P value number 0 1
or_test binary_endpoints radio OR test type 1, Fishers exact test | 2, Chi2 test | 3, Wald test | 4, Likelihood ratio test
rr binary_endpoints Risk ratio text Risk ratio (RR) number
rr_se binary_endpoints text RR SE
rr_lci binary_endpoints text RR lower confidence interval
rr_uci binary_endpoints text RR upper confidence interval
rr_ci_perc binary_endpoints text RR confidence interval percentage
rr_p binary_endpoints text RR P value number 0 1
rr_test binary_endpoints radio RR test type 1, Fishers exact test | 2, Chi2 test | 3, Wald test | 4, Likelihood ratio test
this_section_is_based_on_h bias_assessment descriptive This section is based on Higgins et al (2011) The Cochrane Collaboration's tool for assessing risk of bias in randomised trials. BMJ 343. DOI: 10.1136/bmj.d5928
rando_judge bias_assessment Selection bias radio Random sequence generation 1, low | 2, unclear | 3, high Selection bias (biased allocation to interventions) due to inadequate generation of a randomised sequence
rando_support bias_assessment text Support for random sequence generation judgement Describe the method used to generate the allocation sequence in sifficient detail to allow an assessment of whether it should produce comparable groups
alloc_judge bias_assessment radio Allocation concealment 1, low | 2, unclear | 3, high Selection bias (biased allocation to interventions) due to inadequate concealment of allocations before assignment
alloc_support bias_assessment text Support for allocation concealment judgement Describe the method used to conceal the allocation sequence in sufficient detail to determine whether intervention allocations could have been foreseen before or during enrolment
blinding_judge bias_assessment Performance bias radio Blinding of participants and personnel 1, low | 2, unclear | 3, high Performance bias due to knowledge of the allocated interventions by participants and personnel during the study
blinding_support bias_assessment text Support for blinding of participants and personnel Describe all measures used, if any, to blind trial participants and researchers from knowledge of which intervention a participant received. Provide any information relating to whether the intended blinding was effective
detection_judge bias_assessment Detection bias radio Blinding of outcome assessment 1, low | 2, unclear | 3, high Detection bias due to knowledge of the allocated interventions by outcome assessment
detection_support bias_assessment text Support for blinding of outcome assessment Describe all measures used, if any, to blind outcome assessment from knowledge of which intervention a participant received. Provide any information relating to whether the intended blinding was effective
attrition_judge bias_assessment Attrition bias radio Incomplete outcome data 1, low | 2, unclear | 3, high Attrition bias due to amount, nature, or handling of incomplete outcome data
attrition_support bias_assessment text Support for incomplete outcome data Describe the completeness of outcome data for each main outcome, including attrition and exclusions from the analysis. State whether attrition and exclusions were reported, the numbers in each intervention group (compared with total randomised participants), reasons for attrition or exclusions where reported, and any reinclusions in analyses for the review
reporting_judge bias_assessment Reporting bias radio Selective reporting 1, low | 2, unclear | 3, high Reporting bias due to selective outcome reporting
reporting_support bias_assessment text Support for selective reporting State how selective outcome reporting was examined and what was found
other_judge bias_assessment Other bias radio Anything else, ideally prespecified 1, low | 2, unclear | 3, high Bias due to problems not covered elsewhere
other_support bias_assessment text Support for other bias State any important concerns about bias not covered in the other domains in the tool
@aghaynes
Copy link
Author

Added field for DOI and fields for units

@aghaynes
Copy link
Author

Forms other than inclusionexclusion and study_details should be set as repeating instruments

@aghaynes
Copy link
Author

inclusion/exclusion/units/endpoints need to be defined for each project

@aghaynes
Copy link
Author

aghaynes commented Jan 8, 2019

added bias assessment

@aghaynes
Copy link
Author

aghaynes commented Jan 8, 2019

Added code to show bias assessment results (see fig 1 from here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment