| Title: | Tools for Analyses in Epidemiology |
|---|---|
| Description: | A selection of tools for analyses in epidemiology. |
| Authors: | Neil Wright [aut, cre], Derrick Bennett [aut], Jonathan Clarke [aut], Charlotte Clarke [aut], Andri Iona [aut], Christiana Kartsonaki [aut], Maryam Rahmati [aut], China Kadoorie Biobank Collaborative Group [aut], University of Oxford [cph] |
| Maintainer: | Neil Wright <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-10-11 10:26:05 UTC |
| Source: | https://github.com/ckbiobank/ckbtools |
Synthetic CKB ascertainment data for demoing functions
ckbtools_ascertainmentsckbtools_ascertainments
An object of class data.frame with 25000 rows and 3 columns.
Synthetic CKB baseline data for demoing functions
ckbtools_baselineckbtools_baseline
An object of class data.frame with 25000 rows and 26 columns.
Synthetic CKB endpoint definitions data for demoing functions
ckbtools_endpoint_definitionsckbtools_endpoint_definitions
An object of class data.frame with 2 rows and 2 columns.
Synthetic CKB endpoint data for demoing functions
ckbtools_endpointsckbtools_endpoints
An object of class data.frame with 25000 rows and 5 columns.
Synthetic CKB participant data for demoing functions
ckbtools_participant_datackbtools_participant_data
An object of class data.frame with 25000 rows and 47 columns.
Synthetic CKB Olink proteomics data for demoing functions
ckbtools_raw_olink_meta_datackbtools_raw_olink_meta_data
An object of class data.frame with 48 rows and 3 columns.
Synthetic CKB Olink proteomics data for demoing functions
ckbtools_raw_olink_protein_datackbtools_raw_olink_protein_data
An object of class tbl_df (inherits from tbl, data.frame) with 48000 rows and 11 columns.
Synthetic CKB SomaScan proteomics data for demoing functions
ckbtools_raw_somascan_meta_datackbtools_raw_somascan_meta_data
An object of class data.frame with 48 rows and 7 columns.
Synthetic CKB SomaScan proteomics data for demoing functions
ckbtools_raw_somascan_protein_datackbtools_raw_somascan_protein_data
An object of class tbl_df (inherits from tbl, data.frame) with 48000 rows and 4 columns.
Synthetic CKB SomaScan proteomics data for demoing functions
ckbtools_raw_somascan_sample_datackbtools_raw_somascan_sample_data
An object of class data.frame with 1000 rows and 5 columns.
This function is used to estimate the (adjusted) association between an exposure variable and an incident disease endpoint using a Cox proportional hazards model. It is a wrapper for the coxph function for convenience and provides results from some additional analysis steps if requested.
cox_model( data, exposure, outcome, outcome_date = paste0(outcome, "_date"), start_date = "study_date", time_in = NULL, time_out = NULL, adjust_for = NULL, exclude = NULL, exposure_term = exposure, cluster = NULL, init_values = c(0), additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, ... )cox_model( data, exposure, outcome, outcome_date = paste0(outcome, "_date"), start_date = "study_date", time_in = NULL, time_out = NULL, adjust_for = NULL, exclude = NULL, exposure_term = exposure, cluster = NULL, init_values = c(0), additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, ... )
data |
A data frame. |
exposure |
Name of column containing exposure variable. |
outcome |
Name of the column containing status indicator (normally 0 = no disease, 1 = disease). |
outcome_date |
Name of column containing date of event or censoring
date. (Default: |
start_date |
Name of column containing date of start of follow up. (Default: "study_date") |
time_in |
Name of column containing starting time for interval data. |
time_out |
Name of column containing follow up time (or ending time for interval data). |
adjust_for |
Character vector of terms to include in the model formula. |
exclude |
Names of columns that identify observations that should be excluded. |
exposure_term |
The term(s) to include in the model for the exposure. This can be a character vector or a function that take the exposure name as the argument and returns a character vector. (Default: exposure) |
cluster |
Name of column that clusters the observations, for the purposes of a robust variance. |
init_values |
A named vector of initial values for model coefficients. |
additional |
Extra results to include. See "Additional results" for details. |
return |
What should the function return:
|
return_fn |
If return="model", name of function to apply to model before it's returned. (Default: identity) |
... |
Arguments passed to |
Either a model object, reduced model object or data frame of coefficients.
For analysis of incident disease using time-on-study as the time scale,
outcome, outcome_date and start_date are used to define follow up
time (right censored data).
For other anlyses, the time_in and time_out arguments can be used.
If time_in and time_out are given, then these are starting and ending
time for interval survival data.
If time_out (but not time_in) is given, then this is the follow up time
(right censored data).
The additional argument is used to add results from additional analyses.
It must be a character vector containing one or more of:
"lrt": Likehood ratio test comparing the full model to one without the exposure. Output will have additional columns "Chisq" (chi-square test statistics), "Df" (degrees of freedom), "p_Chisq" (p-value).
"float": Standard errors for the exposure calculated by float. Output will have additional columns "float_estimate", "float_se" and "limits".
"qvcalc": Standard errors for the exposure calculated by qvcalc. Output will have additional columns "qvcalc_estimate", "quasi_se" and "worstErrors".
"" (default): Nothing.
These will only be included when relevant e.g. standard errors from
float when the exposure has more than two levels.
This only has an effect if return is "coefs" or "exposure".
See float and qvcalc for details about these results. Note that "limits" and "worstErrors" do not correspond to particular groups but accuracy other all contrasts.
cox_model(ckbtools_participant_data, exposure = "bmi_calc", outcome = "all_cause_mortality", adjust_for = c("age_at_study_date", "strata(sex)"), return = "coefs") cox_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "all_cause_mortality", adjust_for = c("age_at_study_date", "strata(sex)"), return = "coefs")cox_model(ckbtools_participant_data, exposure = "bmi_calc", outcome = "all_cause_mortality", adjust_for = c("age_at_study_date", "strata(sex)"), return = "coefs") cox_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "all_cause_mortality", adjust_for = c("age_at_study_date", "strata(sex)"), return = "coefs")
Lexis expansion of data by age-at-risk
expand_age_at_risk( data, col.id = "csid", col.dob = "dob_anon", col.entry_date = "study_date", col.exit_date = "endpoint_date", col.status = "endpoint", col.keep = NULL, ages = c(0, 100), age.labels = paste0(ages[-length(ages)], "-", ages[-1]), null.status = 0 )expand_age_at_risk( data, col.id = "csid", col.dob = "dob_anon", col.entry_date = "study_date", col.exit_date = "endpoint_date", col.status = "endpoint", col.keep = NULL, ages = c(0, 100), age.labels = paste0(ages[-length(ages)], "-", ages[-1]), null.status = 0 )
data |
A data frame |
col.id |
Name of column containing unique participant IDs |
col.dob |
Name of column containing date of birth (Must be of class |
col.entry_date |
Name of column containing entry date (Must be of class |
col.exit_date |
Name of column containing exit date (Must be of class |
col.status |
Name of column containing status |
col.keep |
Names of additional columns to include in the result (e.g. exposure and covariate variables) |
ages |
Vector of ages (years) to create age-at-risk strata. Any participant follow-up outside these ages is dropped. (Must be a numeric vector with distinct, increasing values. Default: c(0, 100)) |
age.labels |
Vector of name for age-at-risk strata (Default: |
null.status |
Value to use in status column for intervals before the final interval (Default: 0) |
Data frame expanded by age-at-risk
A chi-squared test (on degrees of freedom) for heterogeneity given a vector of independent estimates and their standard errors.
heterogeneity(beta, se)heterogeneity(beta, se)
beta |
vector of independent estimates |
se |
vector of their standard errors |
See vignette("trend_heterogeneity") for details.
A named list:
test statistic (chi-squared test statistic)
degrees of freedom (number of degrees of freedom used for the test, equal to length(beta)-1)
p (p-value)
Calculate standardised incidence rates
incidence_rates( data, col.dob = "dob_anon", col.entry_date = "study_date", col.exit_date = "endpoint_date", col.status = "endpoint", ages = c(0, 100), group = NULL, adjust_for = NULL, per_pyar = 1000, weights = NULL, method = c("norm", "gamma") )incidence_rates( data, col.dob = "dob_anon", col.entry_date = "study_date", col.exit_date = "endpoint_date", col.status = "endpoint", ages = c(0, 100), group = NULL, adjust_for = NULL, per_pyar = 1000, weights = NULL, method = c("norm", "gamma") )
data |
A data frame. |
col.dob |
Name of column containing date of birth. (Must be of class |
col.entry_date |
Name of column containing entry date. (Must be of class |
col.exit_date |
Name of column containing exit date. (Must be of class |
col.status |
Name of column containing status. This should be 1 if the event has occurred at the exit date, or 0 if it has not. |
ages |
Vector of ages (years) to create age-at-risk strata. (Must be a numeric vector with distinct, increasing values. Default: |
group |
Name of column containing groups to separately calculate incidence rates. |
adjust_for |
Vector of names of columns containing adjustment variables. Include "agegrp" to adjust for age-at-risk strata. |
per_pyar |
Crude and standardised incidence rates are given per |
weights |
A data frame with columns that match the |
method |
Method to calculate confidence intervals, one of "norm" or "gamma". Default "norm" is Normal approximation. |
A named list:
incidence_rates_in_all_strata
standardised_incidence_rates
See vignette("incidence_rates") for details.
This function is used to estimate the (adjusted) linear association between an exposure variable and a continuous outcome variable using a linear regression model. It is a wrapper for the lm function for convenience and provides results from some additional analysis steps if requested.
linear_model( data, exposure, outcome, adjust_for = NULL, exclude = NULL, exposure_term = exposure, additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, nuisance = character(0), ... )linear_model( data, exposure, outcome, adjust_for = NULL, exclude = NULL, exposure_term = exposure, additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, nuisance = character(0), ... )
data |
A data frame. |
exposure |
Name of column containing exposure variable. |
outcome |
Name of column containing outcome variable. |
adjust_for |
Character vector of terms to include in the model formula. |
exclude |
Names of columns that identify observations that should be excluded. |
exposure_term |
The term(s) to include in the model for the exposure. This can be a character vector or a function that take the exposure name as the argument and returns a character vector. (Default: exposure) |
additional |
Extra results to include. See "Additional results" for details. |
return |
What should the function return:
|
return_fn |
If return="model", name of function to apply to model before it's returned. (Default: identity) |
nuisance |
If "emmeans" is requested via the |
... |
Arguments passed to |
Either a model object, reduced model object or data frame of coefficients.
The additional argument is used to add results from additional analyses.
It must be a character vector containing one or more of:
"anova": ANOVA F-test comparing the full model to one without the exposure. Output will have additional columns "F" (F test statistics), "Df" (degrees of freedom), "p_F" (p-value).
"float": Standard errors for the exposure calculated by float. Output will have additional columns "float_estimate", "float_se" and "limits".
"qvcalc": Standard errors for the exposure calculated by qvcalc. Output will have additional columns "qvcalc_estimate", "quasi_se" and "worstErrors".
"emmeans": Estimated marginal means for the exposure calculated using emmeans with proportional weights for factor variables that are averaged over. Output will have additional columns "emmean", "emmean_se" and "emmean_quasi_se".
"" (default): Nothing.
These will only be included when relevant e.g. standard errors from
float when the exposure has more than two levels.
This only has an effect if return is "coefs" or "exposure".
See float and qvcalc for details about these results. Note that "limits" and "worstErrors" do not correspond to particular groups but accuracy other all contrasts.
linear_model(ckbtools_participant_data, exposure = "age_at_study_date", outcome = "sbp_mean", adjust_for = "sex", return = "coefs") # factor exposure, calculate estimated marginal means linear_model(ckbtools_participant_data, exposure = "smoking", outcome = "sbp_mean", adjust_for = c("age_at_study_date", "sex"), additional = "emmeans", return = "coefs") # return the model object linear_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "sbp_mean", adjust_for = c("age_at_study_date", "sex"), return = "model")linear_model(ckbtools_participant_data, exposure = "age_at_study_date", outcome = "sbp_mean", adjust_for = "sex", return = "coefs") # factor exposure, calculate estimated marginal means linear_model(ckbtools_participant_data, exposure = "smoking", outcome = "sbp_mean", adjust_for = c("age_at_study_date", "sex"), additional = "emmeans", return = "coefs") # return the model object linear_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "sbp_mean", adjust_for = c("age_at_study_date", "sex"), return = "model")
This function is used to estimate the (adjusted) association (log odds ratio)
between an exposure variable and a binary outcome variable using
a logistic regression model.
It is a wrapper for the glm function with family = "binomial"
for convenience and provides results from some additional analysis steps if
requested.
logistic_model( data, exposure, outcome, adjust_for = NULL, exclude = NULL, exclude_controls = NULL, exposure_term = exposure, additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, ... )logistic_model( data, exposure, outcome, adjust_for = NULL, exclude = NULL, exclude_controls = NULL, exposure_term = exposure, additional = "", return = c("model", "reduced-model", "coefs", "exposure"), return_fn = identity, ... )
data |
A data frame. |
exposure |
Name of column containing exposure variable. |
outcome |
Name of the column containing binary outcome variable. |
adjust_for |
Character vector of terms to include in the model formula. |
exclude |
Names of columns that identify observations that are to be excluded. |
exclude_controls |
Names of columns that identify observations that are to be exluded when outcome is equal to zero. |
exposure_term |
The term(s) to include in the model for the exposure. This can be a character vector or a function that take the exposure name as the argument and returns a character vector. (Default: exposure) |
additional |
Extra results to include. See "Additional results" for details. |
return |
What should the function return:
|
return_fn |
If return="model", name of function to apply to model before it's returned. (Default: identity) |
... |
Arguments passed to |
Either a model object, reduced model object or data frame of coefficients.
The additional argument is used to add results from additional analyses.
It must be a character vector containing one or more of:
"lrt": Likehood ratio test comparing the full model to one without the exposure. Output will have additional columns "Chisq" (chi-square test statistics), "Df" (degrees of freedom), "p_Chisq" (p-value).
"float": Standard errors for the exposure calculated by float or by ftrend if the model has no intercept term. Output will have additional columns "float_estimate", "float_se" and "limits".
"qvcalc": Standard errors for the exposure calculated by qvcalc. Output will have additional columns "qvcalc_estimate", "quasi_se" and "worstErrors".
"" (default): Nothing.
These will only be included when relevant e.g. standard errors from
float when the exposure has more than two levels.
This only has an effect if return is "coefs" or "exposure".
See float and qvcalc for details about these results. Note that "limits" and "worstErrors" do not correspond to particular groups but accuracy other all contrasts.
logistic_model(ckbtools_participant_data, exposure = "bmi_calc", outcome = "has_diabetes", adjust_for = c("age_at_study_date", "sex"), return = "coefs") logistic_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "has_diabetes", adjust_for = c("age_at_study_date", "sex"), return = "coefs")logistic_model(ckbtools_participant_data, exposure = "bmi_calc", outcome = "has_diabetes", adjust_for = c("age_at_study_date", "sex"), return = "coefs") logistic_model(ckbtools_participant_data, exposure = "bmi_grp", outcome = "has_diabetes", adjust_for = c("age_at_study_date", "sex"), return = "coefs")
Multiple linear, logistic or Cox proportional hazards regression models
multiple_models( data, model, exposures, outcomes, outcome_dates = paste0(outcomes, "_date"), start_date = "study_date", time_in = NULL, time_out = NULL, age_at_risk = NULL, by = NULL, exclude = NULL, exclude_controls = NULL, exclude_by_exposure = NULL, exclude_by_outcome = NULL, exclude_controls_by_outcome = NULL, adjust_for = list(none = NULL), remove_adjust_for = NULL, add_adjust_for = NULL, cluster = NULL, init_values = NULL, return = c("coefs", "exposure", "reduced-model", "model"), verbose = if (rlang::is_interactive()) "progress" else "updates", dryrun = FALSE, ... )multiple_models( data, model, exposures, outcomes, outcome_dates = paste0(outcomes, "_date"), start_date = "study_date", time_in = NULL, time_out = NULL, age_at_risk = NULL, by = NULL, exclude = NULL, exclude_controls = NULL, exclude_by_exposure = NULL, exclude_by_outcome = NULL, exclude_controls_by_outcome = NULL, adjust_for = list(none = NULL), remove_adjust_for = NULL, add_adjust_for = NULL, cluster = NULL, init_values = NULL, return = c("coefs", "exposure", "reduced-model", "model"), verbose = if (rlang::is_interactive()) "progress" else "updates", dryrun = FALSE, ... )
data |
A data frame. |
model |
Type of model to use:
|
exposures |
Names of columns containing exposure variables. |
outcomes |
Names of columns containing outcome variables. |
outcome_dates |
Names of columns containing outcome dates (for Cox model only). |
start_date |
Name of column containing date of start of follow up. (Default: "study_date") |
time_in |
Names of columns containing starting time for interval data (for Cox model only). |
time_out |
Names of columns containing follow up time (or ending time for interval data) (for Cox model only). |
age_at_risk |
A list of arguments for |
by |
Name of column (or multiple columns) to create subgroups. |
exclude |
Names of columns that identify observations that should be excluded. |
exclude_controls |
Names of columns that identify observations that are to be exluded when outcome is equal to zero. |
exclude_by_exposure |
A named list of character vectors of column names.
When the name of an element matches the exposure, the column names will be
added to |
exclude_by_outcome |
A named list of character vectors of column names.
When the name of an element matches the outcome, the column names will be
added to |
exclude_controls_by_outcome |
A named list of character vectors of
column names. When the name of an element matches the outcome, the column
names will be added to |
adjust_for |
A named list of character vectors of terms to include in model formulas. |
remove_adjust_for |
A named list of character vectors of terms.
When the name of an element matches either the outcome or exposure, terms
given in the character vector will be removed from every element of
|
add_adjust_for |
A named list of character vectors of terms.
When the name of an element matches either the outcome or exposure, terms
given in the character vector will be added to every element of |
cluster |
Name of column that clusters the observations, for the purposes of a robust variance. |
init_values |
For Cox models, initial values for model coefficients. This must be a data frame with columns "outcome", "subgroup", "adjustment", "term" and "estimate", where term and estimate are the coefficient names and initial values. |
return |
What should the model function return:
Note that R model objects can be very large (they can contain the model data,
residuals, fitted values, etc.) so it is not recommended to set
|
verbose |
"progress" (default) to show progress bars, "updates" for messages without progress bars, or "quiet" to hide. |
dryrun |
Return only the data frame of models to be run. Columns (except 'subgroup', 'adjustment' and 'outcome_name') are the arguments that will be used in the model function. (Default: FALSE) |
... |
Arguments passed to the model function. |
A "tibble" data frame. If return is "model" or "reduced-model"
then it will contain a list-column called "model".
This function provides a convenient way to iterate over models using
linear_model(), logistic_model() or cox_model(). First a data frame
defining all models is created. If the number of exposures is greater than or
equal to the number of outcomes (or Cox models with age-at-risk expansion are
used) then the models are split by outcome, otherwise they are split by
exposure. Within each set of models, purrr::pmap() is used to iterate over
the fitting of models. Results are then combined into a single data frame.
For iteration of other models or analyses, you must write your own code. The Iteration chapter of the first edition of “R for Data Science” provides an introduction to iteration using R: https://r4ds.had.co.nz/iteration.html
linear_model(), logistic_model(), cox_model(),
linear_model_safely(), logistic_model_safely(), cox_model_safely()
# linear regression models multiple_models( ckbtools_participant_data, model = "linear", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("sbp_mean") ) # logistic regression models multiple_models( ckbtools_participant_data, model = "logistic", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("has_diabetes") ) # Cox proportional hazards models multiple_models( ckbtools_participant_data, model = "cox", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("all_cause_mortality", "ihd") )# linear regression models multiple_models( ckbtools_participant_data, model = "linear", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("sbp_mean") ) # logistic regression models multiple_models( ckbtools_participant_data, model = "logistic", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("has_diabetes") ) # Cox proportional hazards models multiple_models( ckbtools_participant_data, model = "cox", exposures = c("age_at_study_date", "sex", "bmi_calc", "bmi_grp"), outcomes = c("all_cause_mortality", "ihd") )
Preparation of Olink protein data
prepare_olink_data( data, meta_data, transform = c("none"), qc = c("default", "none"), columns = NULL )prepare_olink_data( data, meta_data, transform = c("none"), qc = c("default", "none"), columns = NULL )
data |
Raw Olink protein data (imported from data_baseline_olink_explore.rds or data_baseline_olink_explore.csv) |
meta_data |
Olink meta data produced by |
transform |
Transformation to apply to protein values. Currently only "none" is available. |
qc |
QC steps to apply:
|
columns |
Other columns in raw data to include in output. For example, set to "lod" to include the limit of detection for each protein. |
Preparation of Olink meta data
prepare_olink_meta_data( data, raw_olink_protein_data, names = c("protein", "id"), columns = c("uniprot", "olinkid") )prepare_olink_meta_data( data, raw_olink_protein_data, names = c("protein", "id"), columns = c("uniprot", "olinkid") )
data |
Raw CKB Olink meta data (imported from olink_explore_meta.rds or olink_explore_meta.csv) |
raw_olink_protein_data |
Raw Olink protein data (imported from data_baseline_olink_explore.rds or data_baseline_olink_explore.csv) |
names |
Naming scheme to use for proteins: "protein" (default) to use assay names or "id" to use Olink IDs. |
columns |
Optional columns to include in the meta data. (Default: c("uniprot", "olinkid")) |
Preparation of a proteomics analysis data set
prepare_proteomics_analysis_dataset( participant_data, protein_data, protein_meta_data, plate_correction = c("none", "median-subcohort", "mean-subcohort"), scaling = c("none", "center-subcohort", "scale-subcohort", "center", "scale", "rint"), id = "csid" )prepare_proteomics_analysis_dataset( participant_data, protein_data, protein_meta_data, plate_correction = c("none", "median-subcohort", "mean-subcohort"), scaling = c("none", "center-subcohort", "scale-subcohort", "center", "scale", "rint"), id = "csid" )
participant_data |
A data frame of participant data |
protein_data |
Protein data produced by |
protein_meta_data |
Corresponding protein meta data produed by
|
plate_correction |
Type of plate correction to apply:
|
scaling |
Scaling to apply to values for each protein:
|
id |
Name of column used to join participant_data and protein_data. (Default: "csid") |
This functions prepares a data set of SomaScan protein data given the raw CKB SomaScan data.
prepare_somascan_data( data, sample_data, meta_data, transform = c("log2", "log", "log10", "none"), qc = c("default", "flagged", "none"), repeat_samples = c("remove", "retain"), columns = NULL )prepare_somascan_data( data, sample_data, meta_data, transform = c("log2", "log", "log10", "none"), qc = c("default", "flagged", "none"), repeat_samples = c("remove", "retain"), columns = NULL )
data |
Raw CKB SomaScan protein data (imported from data_baseline_somalogic.rds or data_baseline_somalogic.csv) |
sample_data |
Raw CKB SomaScan protein sample information data (imported from data_baseline_somalogic_samples.rds or data_baseline_somalogic_samples.csv) |
meta_data |
SomaScan meta data produced by
|
transform |
Transformation to apply to protein values:
|
qc |
QC steps to apply.
|
repeat_samples |
Default "remove" will remove data for the second sample for participants who had a sample run twice. Use "retain" to keep this data; the second samples will have sample_source=1. |
columns |
Names of any additional columns from sample_data to include in the output. |
Hybridization control scale factor (hybcontrolnormscale) and median signal
normalization scale factors (normscale_20, normscale_0_5,
normscale_0_005) have an acceptance range of 0.4-2.5.
Percentage of measurements used for ANML scale factor calculation
(anmlfractionused_20, anmlfractionused_0_5, anmlfractionused_0_005) has
a criteria of > 30% (0.3).
Samples that meet these criteria are given a PASS for normalization
acceptance criteria for all row scale factors (rowcheck), while samples
that are outside the criteria are given a FLAG.
Hybridization control scale factor out of range suggests a technical issue.
Set qc = "default" to exclude participant samples with hybridization
control scale factor (hybcontrolnormscale) out of range (i.e. less than 0.4
or greater than 2.5).
Other criteria out of range suggests that the sample is fairly different from
a typical population.
Set qc = "flagged" to exclude participant samples with a FLAG for
normalization acceptance criteria for all row scale factors (rowcheck).
Preparation of SomaScan meta data
prepare_somascan_meta_data( data, names = c("protein", "id"), columns = c("seqid", "somaid", "target_full_name", "target", "uniprot", "organism", "type", "dilution"), filter = "HumanProtein" )prepare_somascan_meta_data( data, names = c("protein", "id"), columns = c("seqid", "somaid", "target_full_name", "target", "uniprot", "organism", "type", "dilution"), filter = "HumanProtein" )
data |
Raw CKB SomaScan meta data (imported from somalogic_meta.rds or somalogic_meta.csv) |
names |
Naming scheme to use for proteins: "protein" (default) to use target name or "id" to use SomaLogic sequence IDs. |
columns |
Optional columns to include in the meta data. (Default: c("seqid", "somaid", "target_full_name", "target", "uniprot", "organism", "type", "dilution")) |
filter |
Filter to apply to rows:
|
These functions are wrappers around the regression model functions that will capture side-effects such as errors and warnings and return a list. This is particularly useful when using the model functions iteratively.
linear_model_safely(...) logistic_model_safely(...) cox_model_safely(...)linear_model_safely(...) logistic_model_safely(...) cox_model_safely(...)
... |
Arguments are passed to the model function. |
A named list:
result: What is returned by the model function.
errors: Errors produced by the model function as a character string.
warnings: Warnings produced by the model function as a character string.
messages: Messages produced by the model function as a character string.
output: Output produced by the model function as a character string.
linear_model(), logistic_model(), cox_model()
Summarise continuous variables
summarise_continuous(data, cols, by = NULL)summarise_continuous(data, cols, by = NULL)
data |
Data set
(e.g. produced by |
cols |
Names of columns containing continuous variables to be summarised. |
by |
Names of columns that contain categorical participant characteristics to produce subgroup summaries. |
A chi-squared test for trend (on 1 degree of freedom) given a vector of independent estimates and their standard errors.
trend(beta, se)trend(beta, se)
beta |
vector of independent estimates |
se |
vector of their standard errors |
See vignette("trend_heterogeneity") for details.
A named list:
test statistic (chi-squared test statistic)
p (p-value)