Title: | Simulating Data for Mendelian Randomization Scenarios Based on Genotype Data |
---|---|
Description: | This package can be used to simulate data in R for Mendelian Randomization scenarios including confounder, exposure and outcome. Recommended MR package is MendelianRandomization. |
Authors: | Anne-Sophie Kieslinger [aut, cre] (YOUR-ORCID-ID), Carl Beuchel [aut] (YOUR-ORCID-ID) |
Maintainer: | Anne-Sophie Kieslinger <[email protected]> |
License: | What license it uses |
Version: | 0.0.0.9000 |
Built: | 2024-11-25 04:24:57 UTC |
Source: | https://github.com/askieslinger/MRTool |
For examples see vignette browseVignettes('MRTool')
cal_betas(pves, maf, gy_direct = T)
cal_betas(pves, maf, gy_direct = T)
pves |
a named list of parameters and percentages of variance explained for each one. If multiple snps, each param is a list of snp-vectors, each vector the scenarios for this snp |
maf |
a named list of maf for every snp |
gy_direct |
should there be a direct effect of G on Y. default true. does not need to be changed. |
a list of two data.tables. a data.table containing all valid combinations of coefficients, one row is one snp in one scenario. A data.table with the adjusted combinations of percentages of variance explained
For examples see vignette browseVignettes('MRTool')
CreateMRInputObject(MR_data = my_MR_data, MR_Scenario = "V1", correlation = T)
CreateMRInputObject(MR_data = my_MR_data, MR_Scenario = "V1", correlation = T)
correlation |
returns 2 snps each that have lowest, positive high, positive low, negative high, negative low correlation. uses pearson correlation For examples see vignette browseVignettes('MRTool')
get_corrs(genedose_test, method = "pearson")
get_corrs(genedose_test, method = "pearson")
genedose_test |
snp datatable. first two columns identifiers |
method |
used to compute correlation coefficient. 'pearson' (default), 'kendall' or 'spearman' |
For examples see vignette browseVignettes('MRTool')
Create a testplan for different parameter combinations or create a custom plan for different IV parameters. If Vary_between_SNP, The Parameters set for G_U, G_X and G_Y will not create individual scenarios but one, where the different parameters are distributed to the individual SNP, cycled through all give SNP, based on the number of parameters provided by the user, accepting only one parameter (the first) for U_Y, U_X and X_Y For examples see vignette browseVignettes('MRTool')
SetMRParams( Vary_between_SNP = F, G_X_randomization = F, SNP = NULL, G_U = c(0, 0.1), G_Y = c(0, 0.1), X_Y = c(0, 0.1), G_X = c(0.03, 0.1), U_X = c(0, 0.1), U_Y = c(0, 0.1), sim_sd = 1, maf )
SetMRParams( Vary_between_SNP = F, G_X_randomization = F, SNP = NULL, G_U = c(0, 0.1), G_Y = c(0, 0.1), X_Y = c(0, 0.1), G_X = c(0.03, 0.1), U_X = c(0, 0.1), U_Y = c(0, 0.1), sim_sd = 1, maf )
maf |
Simulates confounder U, exposure X and outcome Y based on genotype data and betacoefficients. For examples see vignette browseVignettes('MRTool')
sim_and_mr(SNP_data, SNP, my_Parameters, reverse = FALSE)
sim_and_mr(SNP_data, SNP, my_Parameters, reverse = FALSE)
reverse=FALSE |
TRUE if MR should be conducted with X as putative outcome and Y as putative exposure |
list(reg_res,sim_data,mr_res)
For examples see vignette browseVignettes('MRTool')
SimulateMRData(SNP_data = SNP_data, SNP = NULL, Parameters = NULL)
SimulateMRData(SNP_data = SNP_data, SNP = NULL, Parameters = NULL)
Parameters |
Transforms results of x iterations with each n scenario simulations into median per scenario for relevant variables. For examples see vignette browseVignettes('MRTool')
transform_results(results, SNP, iterations, pve_grid, rev = FALSE)
transform_results(results, SNP, iterations, pve_grid, rev = FALSE)
results |
list of results of single iteration. result of single iteration is list(reg_res,sim_data,mr_res) |
SNP |
names of snps used |
iterations |
integer how many times the simulation was repeated |
pve_grid |
grid of percentages of variance explained as output of cal_betas |
rev |
true if mr was executed in the anticausal direction. false for causal direction |
list(res_list,sim_data). res_list is list of regression results and mr results. sim_data is result of simulation