A simple wrapper function. Using a summary set, identify set of instruments for the traits, and perform SEM MR to test the association across the population.
Public fields
outputA list for the output
sourceThe source of the data.
exposure_idsExposures IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
outcome_idsOutcome IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
exposure_metadataExposure metadata
outcome_metadataOutcome metadata
radiusGenomic window size to extract SNPs
popsAncestry information for each population (i.e., AFR, AMR, EUR, EAS, SAS)
bfilesLocations of LD reference files for each population (Download from: http://fileserve.mrcieu.ac.uk/ld/1kg.v3.tgz)
plinkLocation of executable plink (version 1.90 is recommended)
clump_popReference population for clumping
instrument_rawInstruments for the exposures obtained from
extract_instruments()instrument_regionsGenomic regions around each instrument obtained from
extract_instrument_regions()ld_matricesLD matrices for each instrument region obtained from
regional_ld_matrices()susie_resultsFine-mapping results from
susie_finemap_regions()paintor_resultsFine-mapping results from
paintor_finemap_regions()mscaviar_resultsFine-mapping results from
MsCAVIAR_finemap_regions()expected_replicationsExpected replication of instruments across populations
instrument_region_zscoresZ scores for the SNPs in each instrument region obtained from
scan_regional_instruments()instrument_femaInstruments selected by meta-analysis across populations obtained from
fema_regional_instruments()instrument_fema_regionsMeta-analysis results for each instrument region obtained from
fema_regional_instruments()instrument_maxzInstruments selected by maximum Z score obtained from
scan_regional_instruments()instrument_susieInstruments selected by susieR fine-mapping obtained from
susie_finemap_regions()instrument_paintorInstruments selected by PAINTOR fine-mapping obtained from
paintor_finemap_regions()instrument_mscaviarInstruments selected by MsCAVIAR fine-mapping obtained from
MsCAVIAR_finemap_regions()harmonised_data_checkChecks of the harmonised data
standardised_instrument_rawStandardised
instrument_rawobtained fromstandardise_data()standardised_instrument_maxzStandardised
instrument_maxzobtained fromstandardise_data()standardised_instrument_susieStandardised
instrument_susieobtained fromstandardise_data()standardised_instrument_paintorStandardised
instrument_paintorobtained fromstandardise_data()standardised_instrument_mscaviarStandardised
instrument_mscaviarobtained fromstandardise_data()standardised_outcomeStandardised outcome data obtained from
standardise_data()instrument_specificityInstrument specificity results obtained from
estimate_instrument_specificity()instrument_specificity_summarySummary of the instrument specificity results obtained from
estimate_instrument_specificity()instrument_outcomeOutcome data for the instruments obtained from
make_outcome_data()instrument_outcome_regionsOutcome data for each instrument region imported with
import_from_local()harmonised_dat_semHarmonised data for the SEM analysis
harmonised_datHarmonised exposure and outcome data obtained from
harmonise()sem_resultSEM results obtained from
perform_basic_sem()pleiotropy_agreementAgreement of pleiotropy outlier effects across populations obtained from
pleiotropy()pleiotropy_outliersPleiotropy outliers obtained from
pleiotropy()pleiotropy_Q_outliersHeterogeneity for each pleiotropy outlier and population obtained from
pleiotropy()summarySummary of the exposure, outcome and population metadata obtained from
set_summary()mrresMR estimates obtained from
cross_estimate()instrument_heterogeneity_per_variantHeterogeneity of the instrument-exposure associations for each variant obtained from
estimate_instrument_heterogeneity_per_variant()mrgxe_resMR GxE results obtained from
mrgxe()
Methods
CAMERA$import_from_local()
Import instrument and outcome data from local summary statistics, e.g. as organised by CAMERA_local
Usage
CAMERA$import_from_local(
instrument_raw,
instrument_outcome,
instrument_regions,
instrument_outcome_regions,
exposure_ids,
outcome_ids,
pops,
...
)Arguments
instrument_rawData frame of instruments for the exposures
instrument_outcomeData frame of instrument associations with the outcomes
instrument_regionsList of genomic regions around each instrument for the exposures
instrument_outcome_regionsList of genomic regions around each instrument for the outcomes
exposure_idsExposures IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
exposure_idsID for the exposure. Default is x$exposure_ids.
exposure_idsIDs for the exposures. Default is
x$exposure_ids.outcome_idsOutcome IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
outcome_idsIDs for the outcomes. Default is
x$outcome_ids.popsAncestry information for each population (i.e., AFR, AMR, EUR, EAS, SAS)
...Further named arguments passed to
assign()
CAMERA$new()
Create a new dataset and initialise an R interface
Usage
CAMERA$new(
exposure_ids = NULL,
outcome_ids = NULL,
pops = NULL,
bfiles = NULL,
plink = NULL,
radius = NULL,
clump_pop = NULL,
x = NULL
)Arguments
exposure_idsExposures IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
exposure_idsID for the exposure. Default is x$exposure_ids.
exposure_idsIDs for the exposures. Default is
x$exposure_ids.outcome_idsOutcome IDs obtained from IEU GWAS database (https://gwas.mrcieu.ac.uk) for each population
outcome_idsIDs for the outcomes. Default is
x$outcome_ids.popsAncestry information for each population (i.e., AFR, AMR, EUR, EAS, SAS)
bfilesLocations of LD reference files for each population (Download from: http://fileserve.mrcieu.ac.uk/ld/1kg.v3.tgz)
plinkLocation of executable plink (version 1.90 is recommended)
radiusGenomic window size to extract SNPs
clump_popReference population for clumping
xImport data where available
CAMERA$instrument_heterogeneity()
The function evaluates heterogeneity in the association of selected instruments and the exposure/outcome between the populations. Heterogeneity (Q statistics) is calcuated based on an IVW or simple MODE MR estimator. The instruments can be identified using "Raw", "MaxZ", or fine-mapping (Susie, PAINTOR) methods.
Usage
CAMERA$instrument_heterogeneity(
instrument = self$instrument_raw,
alpha = "bonferroni",
method = "ivw",
outlier_removal = FALSE
)Arguments
instrumentIntsruments for the exposure that are selected by using the provided methods in CAMERA (x$instrument_raw, x$instrument_maxz, x$instrument_susie, x$instrument_paintor). Default is x$instrument_raw.
alphaStatistical threshold to determine significance. Default is "bonferroni", which is eqaul to 0.05/number of the instruments. For each pair of populations, the instruments that are significant (
p < alpha) in the reference population are taken and their associations in the replication population are regressed on their associations in the reference population. If the instruments have the same effects in both populations the slope (agreement) is expected to be close to 1.methodMethod used to estimate the agreement slope, either
"ivw"(inverse variance weighted, usingTwoSampleMR::mr_ivw()) or"simple_mode"(usingTwoSampleMR::mr_simple_mode()). Default is"ivw".outlier_removalRemove outliers identified by radial IVW MR before estimating heterogeneity. Only the first two exposures are used to identify outliers. Default is
FALSE.
Returns
Data frame with one row for each ordered pair of populations, with columns:
Reference,Replication: IDs of the reference and replication datasetsnsnp: number of instruments significant in the reference dataset that are also present in the replication datasetagreement: slope of the regression of the replication associations on the reference associationsse,pval: standard error ofagreementand p-value for the test of the null hypothesis that the slope is 0 (i.e. no association between the instrument associations in the two populations)Q,Q_pval("ivw"only): Cochran's Q statistic and its p-value for the null hypothesis that all instruments share the same slope, i.e. no heterogeneity in the agreement between populationsI2("ivw"only): the proportion of the variation in the ratio of the associations that is due to heterogeneity rather than chance, calculated as(Q - nsnp) / Q
CAMERA$estimate_instrument_specificity()
The function estimates what fraction of the instuments is expected to be replicated across the populations under the hypothesis that the effect estimates are the same.
Usage
CAMERA$estimate_instrument_specificity(
instrument,
alpha = "bonferroni",
winnerscurse = FALSE
)Arguments
instrumentIntsruments for the exposure that are selected by using the provided methods in CAMERA (x$instrument_raw, x$instrument_maxz, x$instrument_susie, x$instrument_paintor). Default is x$instrument_raw.
alphaStatistical threshold to determine significance. Default is "bonferroni", which is eqaul to 0.05/number of the instruments.
winnerscurseUse this option to correct winners' curse bias.
Details
For each pair of populations, the instruments that are significant (p < alpha) in the discovery population are compared with their associations in the replication population. Following Okbay et al. (2016), under the hypothesis that the instruments have the same effects in both populations, the expected number of instruments with the same sign, and the expected number with p < alpha, in the replication population are calculated taking account of the precision of the replication associations. These are compared with the observed numbers.
Returns
Data frame, also stored in x$instrument_specificity_summary, with columns:
discovery,replication: IDs of the discovery and replication datasetsmetric:"Sign"(the instrument has the same sign in both populations) or"P-value"(the instrument hasp < alphain the replication population)nsnp: number of instruments compareddatum,value: the"Expected"and"Observed"number of instruments meetingmetricpdiff: p-value from a binomial test of the null hypothesis that the observed number equals the expected number. A small p-value suggests the instruments replicate less (or more) than expected if their effects were the same in both populations.
Per variant results are stored in x$instrument_specificity, including the expected probabilities of sign agreement (sign) and replication (sig), and distinct, which flags instruments that were expected to replicate but did not (sig > 0.8 and replication p > 0.1), or were expected to have the same sign but did not (sign > 0.8).
CAMERA$replication_evaluation()
The function explains what contributes to the replication of gene-trait association between the populations, considering LD structure.
CAMERA$check_phenotypes()
This function evaluates how competitable genetic associations in population 1 are with those in population 2. The function checks whether 1) the chosen IDs for the exposure or outcome can be used for the further steps and 2) the units for the genetic associations are comparable between populations.
CAMERA$cross_estimate()
This method performs a IVW analysis on the harmonised data. It fits two linear models, one considering all populations and another considering each population separately. It then performs a fixed effects meta-analysis to estimate the heterogeneity across different populations. The results are stored in the mrres attribute of the CAMERA object.
Arguments
datA data frame containing the harmonised data. It should have the columns
beta.y,beta.x,se.y, andpops. If not provided, the method uses theharmonised_datattribute of theCAMERAobject.
Returns
Data frame, also stored in x$mrres, with one row for the estimate across all populations (pops == "All") and one row for each population, with columns:
pops: populationEstimate,Std. Error,t value,Pr(>|t|): the IVW MR estimate, i.e. the weighted regression of the SNP-outcome associations on the SNP-exposure associations through the origin with weights1 / se.y^2, its standard error, t statistic and p-valueQj,Qjpval,Qdf: for each population, the contribution of its estimate to the heterogeneity between populations and its p-value (1 degree of freedom), from a fixed effects meta analysis of the population estimates; a small p-value suggests the estimate in that population differs from the others. For the"All"row these are Cochran's Q statistic across all populations, its p-value (null hypothesis: the same causal effect in all populations) and its degrees of freedom.
CAMERA$plot_cross_estimate()
Plot the results from cross_estimate
CAMERA$extract_instruments()
This function searches for GWAS significant SNPs (P < 5E-8) for a specified set of the exposures. This method is equivalant to the instrumnet extraction method for Multivariable MR. Reference here: https://mrcieu.github.io/TwoSampleMR/reference/mv_extract_exposures.html.
Arguments
exposure_idsID for the exposure. Default is x$exposure_ids.
harmonise_strictnessPassed to
TwoSampleMR::mv_extract_exposures(). Default is 1, which assumes all alleles are on the forward strand, as they are in OpenGWAS. The TwoSampleMR default of 2 infers the strand of palindromic SNPs from their allele frequencies, which wrongly flips palindromic SNPs whose allele frequencies are on different sides of 0.5 in different populations, and drops palindromic SNPs with intermediate allele frequencies....Further arguments passed to
TwoSampleMR::mv_extract_exposures()
CAMERA$extract_instrument_regions()
This function extract genomic regions around each instrument (e.g. 50kb) obtained from x$extract_instruments().
Usage
CAMERA$extract_instrument_regions(
radius = self$radius,
instrument_raw = self$instrument_raw,
exposure_ids = self$exposure_ids
)CAMERA$scan_regional_instruments()
The function searches for a SNP that is best associated across the poupulations within the identified regions by using x$extract_instrument_regions().
Usage
CAMERA$scan_regional_instruments(
instrument_raw = self$instrument_raw,
instrument_regions = self$instrument_regions
)CAMERA$plot_regional_instruments_maxz()
The function draws a plot shows how CAMERA selected the instruments for the exposure from the selected genomic regions.
Arguments
instrument_region_zscoresY axis. Z scores based on the SNP-exposure associations.
instrumentsUse this option to draw a separate plot for the selcted instruments.
regionX axis. Number of genomic regions to be shown in the plot. Default is 10.
comparisonUse this option to compare the selected instruments by different instrument selection methods in one plot.
CAMERA$regional_ld_matrices()
Generate LD matrices for instrument regions. If we want to do fine mapping we need to get an LD matrix for the whole region (for each population) We then need to harmonise the LD matrix to the summary data, and the summary datasets to each other The function obtains an LD matrix for the selected genomic regions.
Usage
CAMERA$regional_ld_matrices(
instrument_regions = self$instrument_regions,
bfiles = self$bfiles,
pops = self$pops,
plink = self$plink
)Arguments
instrument_regionsGenomic regions identified by using
x$extract_instrument_regions()bfilesLocation of LD reference files for each population (Download from: http://fileserve.mrcieu.ac.uk/ld/1kg.v3.tgz)
popsAncestry information for each population (i.e. AFR, AMR, EUR, EAS, SAS)
plinkLocation of executable plink (version 1.90 is recommended)
CAMERA$susie_finemap_regions()
Fine-mapping using susieR (https://github.com/stephenslab/susieR) to extract instruments for the exposure for multiple populations. The function identifies credible sets that overlap between the populations and determine the best SNP in a genomic region to be used as instrument.
CAMERA$paintor_finemap_regions()
Fine-mapping using PAINTOR (https://github.com/gkichaev/PAINTOR_V3.0) to extract instruments for the exposure for multiple populations. The function chooses the SNP with highest posterior probability and associations in each exposure.
Usage
CAMERA$paintor_finemap_regions(
region = self$instrument_regions,
ld = self$ld_matrices,
PAINTOR = "PAINTOR",
workdir = tempdir()
)CAMERA$MsCAVIAR_finemap_regions()
Fine-mapping using MsCAVIAR (https://github.com/nlapier2/MsCAVIAR) to extract instruments for the exposure for multiple populations.
Usage
CAMERA$MsCAVIAR_finemap_regions(
region = self$instrument_regions,
ld = self$ld_matrices,
MsCAVIAR = "MsCAVIAR",
workdir = tempdir()
)CAMERA$fema_regional_instruments()
Identify the best variant for each region by meta-analysing the associations across the populations
Usage
CAMERA$fema_regional_instruments(
method = "fema",
instrument_regions = self$instrument_regions,
instrument_raw = self$instrument_raw,
n = self$exposure_metadata$sample_size
)Arguments
methodMeta-analysis method, either
"fema"(fixed effects meta-analysis) or"zma"(Z score meta-analysis). Default is"fema".instrument_regionsGenomic regions identified by using
x$extract_instrument_regions()instrument_rawInstruments for the exposures obtained from
x$extract_instruments()nSample sizes for each exposure, required for
method = "zma". Default is the sample sizes fromx$exposure_metadata.
CAMERA$plot_regional_instruments()
Plot the associations in a region for each population and for the meta-analysis
Usage
CAMERA$plot_regional_instruments(
region,
instrument_regions = self$instrument_regions,
meta_analysis_regions = self$instrument_fema_regions
)CAMERA$get_metadata()
Get metadata for the exposures and outcomes from the OpenGWAS API
CAMERA$estimate_instrument_heterogeneity_per_variant()
Test for heterogeneity of effect estimates between populations. For each SNP this function will provide a Cochran's Q test statistic - a measure of heterogeneity of effect sizes between populations. A low p-value means high heterogeneity. In addition, for every SNP it gives a per population p-value - this can be interpreted as asking for each SNP is a particular giving an outlier estimate.
CAMERA$mrgxe()
Estimate the pleiotropic effect of each variant using MR GxE across populations, see egger_bootstrap()
Usage
CAMERA$mrgxe(
dat = self$harmonised_dat,
variant_list = subset(self$instrument_heterogeneity_per_variant, Qfdr < 0.05)$SNP,
nboot = 100
)CAMERA$mrgxe_plot_variant()
Plot the instrument-exposure against instrument-outcome associations across populations for selected variants
CAMERA$make_outcome_data()
The function extracts summary statistics of given a list of instruments and the outcomes
Usage
CAMERA$make_outcome_data(exp = self$instrument_raw, p_exp = 0.05/nrow(exp))Arguments
expIntsruments for the exposure that are selected by using the provided methods in CAMERA (x$instrument_raw, x$instrument_maxz, x$instrument_susie, x$instrument_paintor). Default is x$instrument_raw.
p_expStatistical threshold to determine significance. Default is "bonferroni", which is eqaul to 0.05/number of the instruments.
CAMERA$make_outcome_local()
The function extracts summary statistics of given a list of instruments and the outcomes from local data
Usage
CAMERA$make_outcome_local(
exp = self$instrument_raw,
out = self$instrument_outcome_regions,
p_exp = 0.05/nrow(exp)
)Arguments
expIntsruments for the exposure that are selected by using the provided methods in CAMERA (x$instrument_raw, x$instrument_fema, x$instrument_susie, x$instrument_paintor). Default is x$instrument_raw.
outOutcome data for each instrument region. Default is x$instrument_outcome_regions.
p_expStatistical threshold to determine significance. Default is "bonferroni", which is eqaul to 0.05/number of the instruments.
CAMERA$harmonise()
This function harmonises the alleles and effects between the exposure and outcome.
Arguments
expIntsruments for the exposure that are selected by using the provided methods in CAMERA (x$instrument_raw, x$instrument_fema, x$instrument_susie, x$instrument_paintor). Default is x$instrument_raw.
outIntsruments for the outcome by using
make_outcome_data(). Default is x$instrument_outcome.
CAMERA$pleiotropy()
Estimate similarity of horizontal pleiotropy across ancestries. For each ancestry, identify outliers in the MR analysis based on per-variatn Q statistics. Then estimate the deviation from the main estimates for all outliers across all ancestries. Finally, determine if the pleiotropy deviation is consistent across all ancestries
CAMERA$plot_pleiotropy_heterogeneity()
Plot pleiotropy results per variant
CAMERA$perform_basic_sem()
Perform basic SEM analysis of the joint estimates in multiple ancestries.
CAMERA$runsem()
Fit an SEM model using lavaan
CAMERA$standardise_data()
This function standardises the betas and SEs for the instruments-exposure/outcome associations when unit information is not matched across the populations. In case of large differences in genetic effects observed between the populations (e.g. due to sample size difference), the function scales the betas and SEs.
Usage
CAMERA$standardise_data(
dat = self$instrument_raw,
standardise_unit = FALSE,
standardise_scale = FALSE,
scaling_method = "simple_mode"
)Arguments
datInstruments for the exposure that are selected by using the provided methods in CAMERA (
x$instrument_raw,x$instrument_maxz,x$instrument_susie,x$instrument_paintor). Default isx$instrument_raw.datA data frame containing the harmonised data. It should have the columns
beta.y,beta.x,se.y, andpops. If not provided, the method uses theharmonised_datattribute of theCAMERAobject.datGenomic regions identified by using
x$extract_instrument_regions()datHarmonised data. Default is
x$harmonised_dat.standardise_unitUse this option if unit information is not matched.
standardise_scaleUse this option if genetic effects are substantially different due to study power.
scaling_methodChoose the methods to obtain scaling units (MR estimates of exposure 1 and exposure 2 or outcome 1 and outcome 2). Default is
"simple_mode".