mr_2sls()
takes a distribution of PGS, an Exposure (Phenotype), an Outcome (Phenotype).
Returns a data frame of the result of the Mendelian Randomization 2SLS methods using PGS
mr_2sls(
df = NULL,
prs_col = "SCORESUM",
exposure_col = NA,
outcome_col = NA,
scale = TRUE,
verbose = TRUE,
log = ""
)
return a data frame with the Mendelian Randomization association result using 2SLS method with the following columns:
PGS: the name of the PGS used
Exposure: the name of Phenotype used as Exposure
Outcome: the name of Phenotype used as Outcome
Method: the MR method used (here 2SLS)
N_cases: if Phenotype_type is Cases/Controls, the number of cases
N_controls: if Phenotype_type is Cases/Controls, the number of controls
N: the number of individuals/samples
MR_estimate: the MR estimate (beta) using the ratio method
SE: the associated standard error (second order)
F_stat: the F-statistic of the Exposure ~ PGS association
a dataframe with individuals on each row, and at least the following columns:
one ID column,
one PGS column, with numerical continuous values following a normal distribution,
two Phenotype columns (for Exposure and Outcome), can be numeric (Continuous Phenotype), character, boolean or factors (Discrete Phenotype)
a character specifying the PGS column name
a character specifying the Exposure (Phenotype) column name
a character specifying the Outcome (Phenotype) column name
a boolean specifying if scaling of PGS should be done before testing
a boolean (TRUE by default) to write in the console/log messages.
a connection, or a character string naming the file to print to. If "" (by default), it prints to the standard output connection, the console unless redirected by sink.
result <- mr_2sls(
df = comorbidData,
prs_col = "ldl_PGS",
exposure_col = "log_ldl",
outcome_col = "bmi",
scale = TRUE
)
print(result)
Run the code above in your browser using DataLab