random_exp_dat<-format_data(random_df, type ="exposure")#> No phenotype name specified, defaulting to 'exposure'.#> Warning in format_data(random_df, type = "exposure"): The following columns are not present but are helpful for harmonisation#> other_alleleeaf
-#> Inferring p-values
-
-random_exp_dat
+#> Inferring p-values
+random_exp_dat#> SNP beta.exposure se.exposure effect_allele.exposure exposure#> 1 rs1 1 1 A exposure#> 2 rs2 2 2 T exposure
@@ -327,7 +325,7 @@
Obtaining instruments fr
A number of sources of instruments have already been curated and are
available for use. They are provided as data objects in the
MRInstruments package. To install:
-
+
remotes::install_github("MRCIEU/MRInstruments")
This package contains a number of data.frames, each of which is a
repository of SNP-trait associations. How to access the data frames is
@@ -342,7 +340,7 @@
Previously if a query to the database failed it didn’t give a reason,
hopefully there is more clarity regarding what is happening now. You can
-also check the status of the server here: https://gwas-api.mrcieu.ac.uk/
Drop duplicate exposure-ou
retained. This can be done by selecting the exposure-outcome summary set
with the largest sample size for the outcome, using the power_prune
function:
-
This drops the duplicate exposure-outcome sets with the smaller
outcome sample size (number of cases for binary outcomes). Remaining
@@ -315,7 +314,7 @@
Drop duplicate exposure-ou
on the basis of instrument strength (i.e. variation in exposure
explained by the instrumental SNPs) as well as sample size. This can be
done by setting the method argument to 2:
-
Heterogeneity statisticsAs with the mr() function, the
mr_heterogeneity() function can take an argument to only
perform heterogeneity tests using specified methods, e.g.
-
The mr_singlesnp() function calculates the full MR using
all available SNPs as well, and by default it uses the IVW and MR Egger
methods. This can be specified as so:
Lines are drawn for each method used in mr(dat), the
slope of the line corresponding to the estimated causal effect. To limit
which lines are drawn, simply specify the desired methods, e.g. to only
draw MR Egger and IVW:
-
+
res<-mr(dat, method_list =c("mr_egger_regression", "mr_ivw"))
-#> Analysing 'ieu-a-2' on 'ieu-a-7'
Ex
intervals. To specify the size of the point estimate, set the weight
argument to the name of the column in the data with the weight
information.
-
+
res<-subset_on_method(res)# default is to subset on either the IVW method (>1 instrumental SNP) or Wald ratio method (1 instrumental SNP). res<-sort_1_to_many(res, b ="b", sort_action =4)# this sorts results by decreasing effect size (largest effect at top of the plot)res<-split_exposure(res)# to keep the Y axis label clean we exclude the exposure ID labels from the exposure column
@@ -484,7 +481,7 @@
Ex
)
It is also possible to add additional columns and column titles and
to choose the size of the text in the columns:
res<-mr(dat2)res<-split_exposure(res)# to keep the Y axis label clean we exclude the exposure ID labels from the exposure column
@@ -583,7 +580,7 @@
Example 3. Stratify
for each unique exposure-outcome combination and sort the results by
decreasing effect size within each group (i.e. largest effect at the
top).
-
Example 4. Effect of BMI on 10
is much greater than 50, it is advisable to split the results across two
different plots. In the example below we select BMI as the exposure and
test this against 103 diseases in the IEU GWAS database:
-
Example 4. Effect of BMI on 10
also possible to change the colour of the plot and the shape of the
point estimates. Type ?forest_plot_1_to_many for further
details.
-
out<-directionality_test(dat)#> r.exposure and/or r.outcome not present.
-#> Calculating approximate SNP-exposure and/or SNP-outcome correlations, assuming all are quantitative traits. Please pre-calculate r.exposure and/or r.outcome using get_r_from_lor() for any binary traits
+#> Calculating approximate SNP-exposure and/or SNP-outcome correlations, assuming all are quantitative traits. Please pre-calculate r.exposure and/or r.outcome using get_r_from_lor() for any binary traits
+knitr::kable(out)
. The GWAS ID for coronary heart disease (CHD) is
ieu-a-7. In this example we will estimate the multivariable
effects of HDL, LDL and total cholesterol on CHD.
-
MR estimates when instrume
individual level genetic data for ~500 Europeans in 1000 genomes data,
and can obtain the LD matrix for a set of SNPs using these data. For
example:
-
Once downloaded, read in the object and use the mr_moe()
function to perform the analysis. An example is shown here, estimating
the causal effect of BMI on coronary heart disease:
-
+
# Extact instruments for BMIexposure_dat<-extract_instruments("ieu-a-2")
@@ -1052,7 +1048,7 @@