Package 'MRTool'

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

Help Index


calculates betacoefficients from explained variances

Description

For examples see vignette browseVignettes('MRTool')

Usage

cal_betas(pves, maf, gy_direct = T)

Arguments

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.

Value

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


Create MRInput Object

Description

For examples see vignette browseVignettes('MRTool')

Usage

CreateMRInputObject(MR_data = my_MR_data, MR_Scenario = "V1", correlation = T)

Arguments

correlation

calculate correlation for a datatable of snps

Description

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')

Usage

get_corrs(genedose_test, method = "pearson")

Arguments

genedose_test

snp datatable. first two columns identifiers

method

used to compute correlation coefficient. 'pearson' (default), 'kendall' or 'spearman'


MRTool: A package to simulate data for mendelian randomization

Description

For examples see vignette browseVignettes('MRTool')


Set MR Parameters (betacoefficients)

Description

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')

Usage

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
)

Arguments

maf

Simulate U,X and Y and run MR on them

Description

Simulates confounder U, exposure X and outcome Y based on genotype data and betacoefficients. For examples see vignette browseVignettes('MRTool')

Usage

sim_and_mr(SNP_data, SNP, my_Parameters, reverse = FALSE)

Arguments

reverse=FALSE

TRUE if MR should be conducted with X as putative outcome and Y as putative exposure

Value

list(reg_res,sim_data,mr_res)


Simulate MR Data

Description

For examples see vignette browseVignettes('MRTool')

Usage

SimulateMRData(SNP_data = SNP_data, SNP = NULL, Parameters = NULL)

Arguments

Parameters

Transform result of iterations of simulation and MR

Description

Transforms results of x iterations with each n scenario simulations into median per scenario for relevant variables. For examples see vignette browseVignettes('MRTool')

Usage

transform_results(results, SNP, iterations, pve_grid, rev = FALSE)

Arguments

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

Value

list(res_list,sim_data). res_list is list of regression results and mr results. sim_data is result of simulation