Radial MR: A package for implementing radial inverse variance weighted and MR-Egger methods
导入数据
library(RadialMR)
View(data_radial)
1. 分析
1.1 egger_radial
Example using format_radial data
ldl.dat <- data_radial[data_radial[,10]<5*10^-8,]
ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9],
ldl.dat[,15], ldl.dat[,21],
ldl.dat[,1])
egger_radial(ldl.fdat, 0.05, 1, TRUE)
# Radial MR-Egger
# Estimate Std. Error t value
# (Intercept) -0.4303552 0.3244151 -1.326557
# Wj 0.6129126 0.1109369 5.524877
# Pr(>|t|)
# (Intercept) 1.884296e-01
# Wj 3.988423e-07
# Residual standard error: 1.537 on 80 degrees of freedom
# F-statistic: 30.52 on 1 and 80 DF, p-value: 3.99e-07
# Q-Statistic for heterogeneity: 188.9285 on 80 DF , p-value: 8.445607e-11
# Outliers detected
Example using TwoSampleMR format data
Example with one exposure-outcome pair
bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2')
chd_out_dat <- TwoSampleMR::extract_outcome_data(
snps = bmi_exp_dat$SNP,
outcomes = 'ieu-a-7')
tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat,
outcome_dat = chd_out_dat)
egger_radial(r_input = tsmrdat, alpha = 0.05,
weights = 1, summary = TRUE)
# Radial MR-Egger
# Estimate Std. Error t value
# (Intercept) -0.4523432 0.3949287 -1.145379
# Wj 0.6071217 0.1525641 3.979452
# Pr(>|t|)
# (Intercept) 0.2555995047
# Wj 0.0001550786
# Residual standard error: 1.354 on 77 degrees of freedom
# F-statistic: 15.84 on 1 and 77 DF, p-value: 0.000155
# Q-Statistic for heterogeneity: 141.2444 on 77 DF , p-value: 1.129761e-05
# Outliers detected
Example using MendelianRandomization format data
dat <- data_radial[data_radial[,10] < 5e-8,]
mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta,
bxse = dat$ldlcse,
by = dat$chdbeta,
byse = dat$chdse,
snps = dat$rsid)
egger_radial(r_input = mrdat, alpha = 0.05,
weights = 1, summary = TRUE)
# Radial MR-Egger
# Estimate Std. Error
# (Intercept) -0.4303552 0.3244151
# Wj 0.6129126 0.1109369
# t value Pr(>|t|)
# (Intercept) -1.326557 1.884296e-01
# Wj 5.524877 3.988423e-07
# Residual standard error: 1.537 on 80 degrees of freedom
# F-statistic: 30.52 on 1 and 80 DF, p-value: 3.99e-07
# Q-Statistic for heterogeneity: 188.9285 on 80 DF , p-value: 8.445607e-11
# Outliers detected
1.2 format_radial
ldl.dat <- data_radial[data_radial[,10]<5*10^-8,]
ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9],
ldl.dat[,15], ldl.dat[,21], ldl.dat[,1])
head(ldl.fdat)
# SNP beta.exposure beta.outcome se.exposure se.outcome
# 1 rs10903129 -0.033 -0.012 0.003692528 0.01366904
# 2 rs1998013 -0.380 -0.150 0.021953470 0.09647707
# 3 rs4587594 -0.049 0.017 0.003842235 0.01509245
# 4 rs6603981 0.034 0.012 0.004444080 0.01698989
# 5 rs646776 0.160 0.094 0.004375672 0.01724356
# 6 rs1010167 -0.025 -0.028 0.003969023 0.01897288
class(ldl.fdat)
# [1] "data.frame" "rmr_format"
1.3 ivw_radial
# Example using format_radial data
ldl.dat <- data_radial[data_radial[,10]<5*10^-8,]
ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9],
ldl.dat[,15], ldl.dat[,21], ldl.dat[,1])
ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE)
# Example using TwoSampleMR format data
## Not run:
# Example with one exposure-outcome pair
bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2')
chd_out_dat <- TwoSampleMR::extract_outcome_data(
snps = bmi_exp_dat$SNP,
outcomes = 'ieu-a-7')
tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat,
outcome_dat = chd_out_dat)
ivw_radial(r_input = tsmrdat, alpha = 0.05,
weights = 1, tol = 0.0001, summary = TRUE)
## End(Not run)
# Example using MendelianRandomization format data
dat <- data_radial[data_radial[,10] < 5e-8,]
mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta,
bxse = dat$ldlcse,
by = dat$chdbeta,
byse = dat$chdse,
snps = dat$rsid)
ivw_radial(r_input = mrdat, alpha = 0.05,
weights = 1, tol = 0.0001, summary = TRUE)
2. mrinput_to_rmr_format
Convert an object of class MRInput from the MendelianRandomization package to the RadialMR rmr_format class
dat <- data_radial[data_radial[,10] < 5e-8,]
dat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta,
bxse = dat$ldlcse,
by = dat$chdbeta,
byse = dat$chdse,
snps = dat$rsid)
dat <- mrinput_to_rmr_format(dat)
head(dat)
# SNP beta.exposure beta.outcome se.exposure se.outcome
# 1 rs10903129 -0.033 -0.012 0.003692528 0.01366904
# 2 rs1998013 -0.380 -0.150 0.021953470 0.09647707
# 3 rs4587594 -0.049 0.017 0.003842235 0.01509245
# 4 rs6603981 0.034 0.012 0.004444080 0.01698989
# 5 rs646776 0.160 0.094 0.004375672 0.01724356
# 6 rs1010167 -0.025 -0.028 0.003969023 0.01897288
class(dat)
# [1] "data.frame" "rmr_format"
3. 绘图
plotly_radial {RadialMR}
ldl.dat <- data_radial[data_radial[,10]<5*10^-8,]
ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9],
ldl.dat[,15], ldl.dat[,21], ldl.dat[,1])
ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE)
# Radial IVW
# Estimate Std.Error t value Pr(>|t|)
# Effect (1st) 0.4874900 0.05830409 8.361163 6.210273e-17
# Iterative 0.4873205 0.05827885 8.361874 6.172955e-17
# Exact (FE) 0.4958973 0.03804168 13.035630 7.673061e-39
# Exact (RE) 0.4910400 0.05451396 9.007602 7.682743e-14
# Residual standard error: 1.544 on 81 degrees of freedom
# F-statistic: 69.91 on 1 and 81 DF, p-value: 1.46e-12
# Q-Statistic for heterogeneity: 193.0843 on 81 DF , p-value: 3.827332e-11
# Outliers detected
# Number of iterations = 3
plotly_radial(ivw.object)
ldl.dat <- data_radial[data_radial[,10]<5*10^-8,]
ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9],
ldl.dat[,15], ldl.dat[,21], ldl.dat[,1])
ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE)
# Radial IVW
# Estimate Std.Error t value Pr(>|t|)
# Effect (1st) 0.4874900 0.05830409 8.361163 6.210273e-17
# Iterative 0.4873205 0.05827885 8.361874 6.172955e-17
# Exact (FE) 0.4958973 0.03804168 13.035630 7.673061e-39
# Exact (RE) 0.4910400 0.05483473 8.954910 9.769963e-14
# Residual standard error: 1.544 on 81 degrees of freedom
# F-statistic: 69.91 on 1 and 81 DF, p-value: 1.46e-12
# Q-Statistic for heterogeneity: 193.0843 on 81 DF , p-value: 3.827332e-11
# Outliers detected
# Number of iterations = 3
plot_radial(ivw.object)
4. tsmr_to_rmr_format
Convert a data.frame containing a single exposure - outcome pair generated by TwoSampleMR::harmonise_data() to the RadialMR rmr_format class
## Not run:
# Example with one exposure-outcome pair
bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2')
chd_out_dat <- TwoSampleMR::extract_outcome_data(
snps = bmi_exp_dat$SNP,
outcomes = 'ieu-a-7')
dat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat,
outcome_dat = chd_out_dat)
dat <- tsmr_to_rmr_format(dat)
class(dat)
# [1] "data.frame" "rmr_format"
head(dat)
# SNP beta.exposure beta.outcome se.exposure se.outcome
# 1 rs1000940 0.0184 -0.014538 0.0033 0.0098395
# 2 rs10132280 -0.0221 -0.012169 0.0033 0.0106640
# 3 rs1016287 -0.0228 -0.014087 0.0033 0.0105738
# 4 rs10182181 0.0309 0.018295 0.0029 0.0092790
# 5 rs10733682 -0.0188 -0.004541 0.0030 0.0095245
# 6 rs10840100 0.0206 0.014599 0.0030 0.0095234
## End(Not run)