| Title: | CAMeRa (Cross Ancestral Mendelian Randomisation) |
|---|---|
| Description: | CAMERA estimates joint causal effect in multiple ancestries and detects pleiotropy via the zero relevance model. |
| Authors: | Yoonsu Cho [aut], Gibran Hemani [aut, cre] (ORCID: <https://orcid.org/0000-0003-0920-1055>), Tom Palmer [aut] (ORCID: <https://orcid.org/0000-0003-4655-4511>), Amy Mason [ctb] (ORCID: <https://orcid.org/0000-0002-8019-0777>), Mercy Kimani [ctb] |
| Maintainer: | Gibran Hemani <g.hemani@bristol.ac.uk> |
| License: | MIT + file LICENSE |
| Version: | 0.1.4 |
| Built: | 2026-10-08 15:40:11 UTC |
| Source: | https://github.com/MRCIEU/CAMERA |
CAMERA estimates joint causal effect in multiple ancestries and detects pleiotropy via the zero relevance model.
Maintainer: Gibran Hemani g.hemani@bristol.ac.uk (ORCID)
Authors:
Gibran Hemani g.hemani@bristol.ac.uk (ORCID)
Yoonsu Cho yoonsu.cho@bristol.ac.uk
Tom Palmer remlapmot@hotmail.com (ORCID)
Other contributors:
Amy Mason am2609@medschl.cam.ac.uk (ORCID) [contributor]
Mercy Kimani [contributor]
Useful links:
Report bugs at https://github.com/MRCIEU/CAMERA/issues/
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.
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_raw obtained from standardise_data()
standardised_instrument_maxzStandardised instrument_maxz obtained from standardise_data()
standardised_instrument_susieStandardised instrument_susie obtained from standardise_data()
standardised_instrument_paintorStandardised instrument_paintor obtained from standardise_data()
standardised_instrument_mscaviarStandardised instrument_mscaviar obtained from standardise_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()
CAMERA$import()Migrate the results from a previous CAMERA
CAMERA$import(x)
xA CAMERA object to import results from
CAMERA$assign()Assign values to fields of the CAMERA object
CAMERA$assign(...)
...Named arguments, where each name is a field and each value is assigned to it
CAMERA$import_from_local()Import instrument and outcome data from local summary statistics, e.g. as organised by CAMERA_local
CAMERA$import_from_local( instrument_raw, instrument_outcome, instrument_regions, instrument_outcome_regions, exposure_ids, outcome_ids, pops, ... )
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
CAMERA$new( exposure_ids = NULL, outcome_ids = NULL, pops = NULL, bfiles = NULL, plink = NULL, radius = NULL, clump_pop = NULL, x = NULL )
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.
CAMERA$instrument_heterogeneity( instrument = self$instrument_raw, alpha = "bonferroni", method = "ivw", outlier_removal = FALSE )
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, using TwoSampleMR::mr_ivw()) or "simple_mode" (using TwoSampleMR::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.
Data frame with one row for each ordered pair of populations, with columns:
Reference, Replication: IDs of the reference and replication datasets
nsnp: number of instruments significant in the reference dataset that are also present in the replication dataset
agreement: slope of the regression of the replication associations on the reference associations
se, pval: standard error of agreement and 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 populations
I2 ("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.
CAMERA$estimate_instrument_specificity( instrument, alpha = "bonferroni", winnerscurse = FALSE )
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.
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.
Data frame, also stored in x$instrument_specificity_summary, with columns:
discovery, replication: IDs of the discovery and replication datasets
metric: "Sign" (the instrument has the same sign in both populations) or "P-value" (the instrument has p < alpha in the replication population)
nsnp: number of instruments compared
datum, value: the "Expected" and "Observed" number of instruments meeting metric
pdiff: 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$replication_evaluation( instrument = self$instrument_raw, ld = self$ld_matrices )
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.
ldLD matrix obtained by using x$regional_ld_matrices()
Table of the regression result
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$check_phenotypes(ids = self$exposure_ids)
idsID for the exposure or the outcome. Default is x$exposure_ids.
Table of the result.
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.
CAMERA$cross_estimate(dat = self$harmonised_dat)
datA data frame containing the harmonised data. It should have the columns beta.y, beta.x, se.y, and pops. If not provided, the method uses the harmonised_dat attribute of the CAMERA object.
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: population
Estimate, 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 weights 1 / se.y^2, its standard error, t statistic and p-value
Qj, 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$plot_cross_estimate(est = self$mrres, qj_alpha = 0.05)
estResults from cross_estimate(). Default is x$mrres.
qj_alphaSignificance threshold for highlighting heterogeneous estimates. Default is 0.05.
Plot
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.
CAMERA$extract_instruments( exposure_ids = self$exposure_ids, harmonise_strictness = 1, ... )
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()
Data frame in x$instrument_raw
CAMERA$extract_instrument_regions()This function extract genomic regions around each instrument (e.g. 50kb) obtained from x$extract_instruments().
CAMERA$extract_instrument_regions( radius = self$radius, instrument_raw = self$instrument_raw, exposure_ids = self$exposure_ids )
radiusSet a range of the region to search
instrument_rawA set of instruments obtained from x$extract_instruments()
exposure_idsID for the exposure. Default is x$exposure_ids.
Data frame in x$instrument_regions
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().
CAMERA$scan_regional_instruments( instrument_raw = self$instrument_raw, instrument_regions = self$instrument_regions )
instrument_rawInstruments for the exposures by using x$extract_instrument()
instrument_regionsGenomic regions identified by using x$extract_instrument_regions()
List of z scores for the chosen SNPs in x$instrument_region_zscores. Data frame in x$instrument_maxz
CAMERA$plot_regional_instruments_maxz()The function draws a plot shows how CAMERA selected the instruments for the exposure from the selected genomic regions.
CAMERA$plot_regional_instruments_maxz( instrument_region_zscores = self$instrument_region_zscores, instruments = self$instrument_raw, region = 1:min(10, nrow(instruments)), comparison = FALSE )
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.
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.
CAMERA$regional_ld_matrices( instrument_regions = self$instrument_regions, bfiles = self$bfiles, pops = self$pops, plink = self$plink )
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)
Data frame of LD matrix (x$ld_matrices)
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$susie_finemap_regions( dat = self$instrument_regions, ld = self$ld_matrices )
datGenomic regions identified by using x$extract_instrument_regions()
ldLD matrix obtained by using x$regional_ld_matrices()
Result from susieR in x$susie_results. Data frame in x$instrument_susie
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.
CAMERA$paintor_finemap_regions( region = self$instrument_regions, ld = self$ld_matrices, PAINTOR = "PAINTOR", workdir = tempdir() )
regionGenomic regions identified by using x$extract_instrument_regions()
ldLD matrix obtained by using x$regional_ld_matrices()
PAINTORPath to executable PAINTOR. Default="PAINTOR"
workdirWorking directory to save the output. Default=tempdir()
Result from PAINTOR in x$paintor_results. Data frame in x$instrument_paintor
CAMERA$MsCAVIAR_finemap_regions()Fine-mapping using MsCAVIAR (https://github.com/nlapier2/MsCAVIAR) to extract instruments for the exposure for multiple populations.
CAMERA$MsCAVIAR_finemap_regions( region = self$instrument_regions, ld = self$ld_matrices, MsCAVIAR = "MsCAVIAR", workdir = tempdir() )
regionGenomic regions identified by using x$extract_instrument_regions()
ldLD matrix obtained by using x$regional_ld_matrices()
MsCAVIARPath to executable MsCAVIAR. Default="MsCAVIAR"
workdirWorking directory to save the output. Default=tempdir()
Result from MsCAVIAR in x$mscaviar_results. Data frame in x$instrument_mscaviar
CAMERA$fema_regional_instruments()Identify the best variant for each region by meta-analysing the associations across the populations
CAMERA$fema_regional_instruments( method = "fema", instrument_regions = self$instrument_regions, instrument_raw = self$instrument_raw, n = self$exposure_metadata$sample_size )
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 from x$exposure_metadata.
Data frame of the selected instruments, also stored in x$instrument_fema
CAMERA$plot_regional_instruments()Plot the associations in a region for each population and for the meta-analysis
CAMERA$plot_regional_instruments( region, instrument_regions = self$instrument_regions, meta_analysis_regions = self$instrument_fema_regions )
regionName of the region to plot, i.e. one of names(x$instrument_regions)
instrument_regionsGenomic regions identified by using x$extract_instrument_regions()
meta_analysis_regionsMeta-analysis results for each region obtained from x$fema_regional_instruments()
Plot
CAMERA$get_metadata()Get metadata for the exposures and outcomes from the OpenGWAS API
CAMERA$get_metadata( exposure_ids = self$exposure_ids, outcome_ids = self$outcome_ids )
exposure_idsIDs for the exposures. Default is x$exposure_ids.
outcome_idsIDs for the outcomes. Default is x$outcome_ids.
List of the exposure and outcome metadata, also stored in x$exposure_metadata and x$outcome_metadata
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$estimate_instrument_heterogeneity_per_variant(dat = self$harmonised_dat)
datHarmonised data. Default is x$harmonised_dat.
Data frame of the Q statistic, its p-value and FDR adjusted p-value for each SNP, also stored in x$instrument_heterogeneity_per_variant
CAMERA$mrgxe()Estimate the pleiotropic effect of each variant using MR GxE across populations, see egger_bootstrap()
CAMERA$mrgxe( dat = self$harmonised_dat, variant_list = subset(self$instrument_heterogeneity_per_variant, Qfdr < 0.05)$SNP, nboot = 100 )
datHarmonised data. Default is x$harmonised_dat.
variant_listSNPs to analyse. Default is the SNPs with FDR < 0.05 in x$instrument_heterogeneity_per_variant.
nbootNumber of bootstraps. Default is 100.
Data frame of the MR GxE results, also stored in x$mrgxe_res
CAMERA$mrgxe_plot()Plot the MR GxE pleiotropy estimates for each variant
CAMERA$mrgxe_plot(mrgxe_res = self$mrgxe_res)
mrgxe_resResults from mrgxe(). Default is x$mrgxe_res.
Plot
CAMERA$mrgxe_plot_variant()Plot the instrument-exposure against instrument-outcome associations across populations for selected variants
CAMERA$mrgxe_plot_variant(
variant = self$mrgxe_res %>% dplyr::ungroup() %>% dplyr::filter(p.adjust(a_pval,
"fdr") < 0.05) %>% {
.$SNP
},
dat = self$harmonised_dat
)
variantSNPs to plot. Default is the SNPs with FDR < 0.05 for the pleiotropy estimate in x$mrgxe_res.
datHarmonised data. Default is x$harmonised_dat.
Plot
CAMERA$make_outcome_data()The function extracts summary statistics of given a list of instruments and the outcomes
CAMERA$make_outcome_data(exp = self$instrument_raw, p_exp = 0.05/nrow(exp))
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.
Data frame in x$instrument_outcome
CAMERA$make_outcome_local()The function extracts summary statistics of given a list of instruments and the outcomes from local data
CAMERA$make_outcome_local( exp = self$instrument_raw, out = self$instrument_outcome_regions, p_exp = 0.05/nrow(exp) )
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.
Data frame in x$instrument_outcome
CAMERA$harmonise()This function harmonises the alleles and effects between the exposure and outcome.
CAMERA$harmonise(exp = self$instrument_raw, out = self$instrument_outcome)
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.
Data frame in x$harmonised_dat_sem
CAMERA$set_summary()Generate summary of exposure, outcome and population metadata
CAMERA$set_summary()
data frame
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$pleiotropy(harmonised_dat = self$harmonised_dat, mrres = self$mrres)
harmonised_datOutcome from harmonise function
mrresOutcome from cross_estimate
data frame of outliers pleiotropy_outliers
data frame of heterogeneity for each outlier / ancestry combination pleiotropy_Q_outliers
data frame of agreement of outlier effects pleiotropy_agreement
CAMERA$plot_pleiotropy()Plot pleiotropy results
CAMERA$plot_pleiotropy(dat = self$pleiotropy_outliers)
datOutput from pleiotropy - pleiotropy_outliers
plot
CAMERA$plot_pleiotropy_heterogeneity()Plot pleiotropy results per variant
CAMERA$plot_pleiotropy_heterogeneity( dat = self$pleiotropy_Q_outliers, pthresh = 0.05 )
datOutput from pleiotropy - pleiotropy_Q_outliers
pthreshp-value from Q statistic for inclusion in plots
plot
CAMERA$perform_basic_sem()Perform basic SEM analysis of the joint estimates in multiple ancestries.
CAMERA$perform_basic_sem(harmonised_dat = self$harmonised_dat_sem)
harmonised_datHarmonised dataset obtained by using harmonised_dat()
Table of the SEM results. Summary of the results available in x$sem_result.
CAMERA$runsem()Fit an SEM model using lavaan
CAMERA$runsem(model, data, modname)
modellavaan model syntax
dataData frame of the data for the model
modnameName of the model used to label the results
Data frame of the SEM estimates for each population
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.
CAMERA$standardise_data( dat = self$instrument_raw, standardise_unit = FALSE, standardise_scale = FALSE, scaling_method = "simple_mode" )
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 is x$instrument_raw.
datA data frame containing the harmonised data. It should have the columns beta.y, beta.x, se.y, and pops. If not provided, the method uses the harmonised_dat attribute of the CAMERA object.
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".
CAMERA$clone()The objects of this class are cloneable with this method.
CAMERA$clone(deep = FALSE)
deepWhether to make a deep clone.
A simple wrapper function for importing data from local files for use with the CAMERA class.
Create the object with CAMERA_local$new() and then call its organise() method. This reads the summary statistics files listed in metadata, finds and clumps the top hits for each dataset, pools them across populations, and extracts the region around each instrument from every dataset. The results are stored in the instrument_raw, instrument_outcome, instrument_regions and instrument_outcome_regions fields, which can be passed to the import_from_local() method of a CAMERA object.
See vignette("import-local", package = "CAMeRa") for a worked example.
metadata must be a data frame with one row per summary statistics file (i.e. per trait and population) and the following columns:
what: either "exposure" or "outcome"
trait: name of the trait, the same for all populations of a trait
pop: population, e.g. "EUR"; must match the pop column of ld_ref
id: a unique identifier for the dataset
fn: path to the summary statistics file, which is read with data.table::fread()
chr_col, pos_col, ea_col, oa_col, eaf_col, beta_col, se_col, pval_col: the name or number of the column in the file containing the chromosome, base pair position, effect allele, other allele, effect allele frequency, effect estimate, standard error, and p-value respectively
Other columns are ignored. Variants are identified by chromosome, position and alleles (as chr:pos_a1_a2, with the alleles in alphabetical order), so all files must use the same genome build.
ld_ref must be a data frame with columns pop and bfile, giving for each population the path to a PLINK binary fileset (without the .bed/.bim/.fam extension) used as the LD reference for clumping.
Top hits are only taken from datasets with at least two variants with p-value below pthresh. Currently organise() uses the first exposure trait and the first outcome trait in metadata.
metadataData frame with information about the data. One row per dataset. See Details for the required columns
ld_refData frame with two columns - pop = population (referencing the pop values in metadata), bfile = path to plink file for that reference
mc.coresThe number of processor cores to use
plink_binLocation of executable plink (version 1.90 is recommended)
radiusGenomic window size to extract SNPs
minmafMinimum allele frequency per dataset
pthreshP-value threshold for instrument inclusion
instrument_rawA data frame of pooled instruments across all ancestries, that has been extracted from each ancestry for the exposure traits
instrument_outcomeInstruments in instrument_raw extracted from the outcome datasets
instrument_regionsNamed list of data frames of length number of unique instruments in instrument_raw. Names of each item are the instruments. Each item is a list of regional extracts around the instrument from each population exposure study.
instrument_outcome_regionsAs per instrument_regions but for the outcome datasets.
CAMERA_local$new()Create a new CAMERA_local object
CAMERA_local$new( metadata, ld_ref, plink_bin, mc.cores = 1, radius = 25000, pthresh = 5e-08, minmaf = 0.01 )
metadataData frame with information about the data. One row per dataset. See Details for the required columns
ld_refData frame with two columns - pop = population (referencing the pop values in metadata), bfile = path to plink file for that reference. See Details
plink_binLocation of executable plink (version 1.90 is recommended)
mc.coresNumber of cores to use
radiusGenomic window size to extract SNPs
radiusDefault 250000
pthreshP-value threshold for instrument inclusion
minmafMinimum allele frequency per dataset
CAMERA_local$standardise()Standardise the allele coding so that the effect allele is the alphabetically first allele, flipping the effect estimate and allele frequency where needed, and create a variant ID of the form chr:pos_ea_oa
CAMERA_local$standardise( d, ea_col = "ea", oa_col = "oa", beta_col = "beta", eaf_col = "eaf", chr_col = "chr", pos_col = "pos", vid_col = "vid" )
ddata.frame
ea_colColumn name for effect allele
oa_colColumn name for other allele
beta_colColumn name containing beta coefficients
eaf_colColumn name containing allele frequency for effect allele
chr_colColumn name containing chromosome
pos_colColumn name containing position
vid_colColumn name containing variant ID
d with standardised alleles and a variant ID column
CAMERA_local$read_file()Read in the summary statistics file for one dataset, drop variants with minor allele frequency below minmaf, and standardise the alleles
CAMERA_local$read_file(m, minmaf = self$minmaf)
mFile object
minmafMinimum allele frequency per dataset
A tibble with columns chr, pos, eaf, beta, se, pval, ea, oa and vid
CAMERA_local$pool_tophits()Pool the top hits across datasets. For each trait, the regions within radius of its top hits are merged, and the variants in each region are extracted from every dataset. Within each region the variant with the largest absolute z-score for the trait is selected, considering only variants present in a number of datasets for which at least one such variant has p-value below pthresh
CAMERA_local$pool_tophits( rawdat, tophits, metadata, radius = 250000, pthresh = 5e-08, mc.cores = 1 )
rawdatThe raw data
tophitsThe top hits
metadataData frame with information about the data. One row per dataset. See Details for the required columns
radiusGenomic window size to extract SNPs
radiusDefault 250000
pthreshP-value threshold for instrument inclusion
mc.coresNumber of cores to use
A list with elements region_list (the merged regions for each trait), region_extract (the extracted variants in each region) and tophit_pool (the selected variant from each region in every dataset)
CAMERA_local$organise_data()Read in the data (unless rawdat is supplied), find the top hits in each dataset by clumping the variants with p-value below pthresh using ieugwasr::ld_clump(), and pool them with pool_tophits()
CAMERA_local$organise_data( metadata = self$metadata, plink_bin = self$plink_bin, ld_ref = self$ld_ref, pthresh = self$pthresh, minmaf = self$minmaf, radius = self$radius, mc.cores = self$mc.cores, rawdat = NULL )
metadataData frame with information about the data. One row per dataset. See Details for the required columns
plink_binLocation of executable plink (version 1.90 is recommended)
ld_refData frame with two columns - pop = population (referencing the pop values in metadata), bfile = path to plink file for that reference. See Details
pthreshP-value threshold for instrument inclusion
minmafMinimum allele frequency per dataset
radiusGenomic window size to extract SNPs
radiusDefault 250000
mc.coresNumber of cores to use
rawdatThe raw data
As for pool_tophits()
CAMERA_local$fixed_effects_meta_analysis_fast()Fixed effect inverse variance weighted meta-analysis of each row of beta_mat and se_mat
CAMERA_local$fixed_effects_meta_analysis_fast(beta_mat, se_mat)
beta_matMatrix of beta coefficients
se_matMatrix of SEs
A vector of p-values, one per row
CAMERA_local$organise()Organise the data for the exposure and outcome, populating the instrument_raw, instrument_outcome, instrument_regions and instrument_outcome_regions fields
CAMERA_local$organise()
CAMERA_local$clone()The objects of this class are cloneable with this method.
CAMERA_local$clone(deep = FALSE)
deepWhether to make a deep clone.
CAMERA, vignette("import-local", package = "CAMeRa")
For a single variant estimated in different sub groups.
egger_bootstrap(b_gx, se_gx, b_gy, se_gy, nboot = 1000)egger_bootstrap(b_gx, se_gx, b_gy, se_gy, nboot = 1000)
b_gx |
Vector of instrument-exposure associations, one for each sub group |
se_gx |
Vector of standard errors to b_gx |
b_gy |
Vector of instrument-outcome associations, one for each sub group |
se_gy |
Vector of standard errors for b_gy |
nboot |
Number of bootstraps. Default=1000 |
Estimate the degree of pleiotropy using MR GxE. This method uses a negative control type approach based on an assumption that the instrument-exposure association is uncorrelated with the pleiotropic effect. Therefore, as the instrument-exposure association reduces in magnitude, the effect on the outcome will reduce towards an intercept term which represents the pleiotropic effect.
Standard errors are obtained from parametric bootstrap
List
a = intercept estimate (pleiotropy)
b = slope estimate (b_iv effect)
a_se = standard error of intercept
b_se = standard error of slope
a_pval = p-value of intercept estimate
b_pval = p-value of slope estimate
a_mean = mean value of intercept from bootstraps
b_mean = mean value of slope estimates from bootstraps
Perform fixed effects meta analysis for one association
fixed_effects_meta_analysis(beta_vec, se_vec, infl = 10000)fixed_effects_meta_analysis(beta_vec, se_vec, infl = 10000)
beta_vec |
Vector of betas |
se_vec |
Vector of ses |
infl |
Inflation factor - how much larger is the estimate than the estimate of the tightest SE - for use in removing unreliable estimates |
list of results
Assumes effects across studies are all on the same scale
fixed_effects_meta_analysis_fast(beta_mat, se_mat)fixed_effects_meta_analysis_fast(beta_mat, se_mat)
beta_mat |
Matrix of betas - rows are SNPs, columns are studies |
se_mat |
Matrix of SEs - rows are SNPs, columns are studies |
list of meta analysis betas and SEs
Sometimes estimates appear unstable. They are likely unreliable and best to not use for heterogeneity analyses etc.
identify_blownup_estimates(b, se, infl)identify_blownup_estimates(b, se, infl)
b |
Vector of betas |
se |
Vector of SEs |
infl |
Inflation factor - how much larger is the estimate than the estimate of the tightest SE |
index of betas to remove
Taken from Okbay et al 2016. Under the assumption that all discovery effects are unbiased, what fraction of associations would replicate in the replication dataset, given the differential power of the discovery and replication datasets. Uses standard error of the replication dataset to account for differences in sample size and distribution of independent variable
prop_overlap(b_disc, b_rep, se_disc, se_rep, alpha)prop_overlap(b_disc, b_rep, se_disc, se_rep, alpha)
b_disc |
Vector of discovery betas |
b_rep |
Vector of replication betas |
se_disc |
Vector of discovery standard errors |
se_rep |
Vector of replication standard errors |
alpha |
Nominal replication significance threshold |
List of results
res: aggregate expected replication rate vs observed replication rate
variants: per variant expected replication rates
Uses weighted Z scores following advice from https://onlinelibrary.wiley.com/doi/full/10.1111/j.1420-9101.2005.00917.x Suggested weights are 1/se^2 However se is scale dependent and it would be ideal to avoid scale issues at this stage So using instead calculate expected se based on n and af. Assumes continuous traits in the way it uses n (i.e. not case control aware at the moment)
z_meta_analysis(beta_mat, se_mat, n, eaf_mat)z_meta_analysis(beta_mat, se_mat, n, eaf_mat)
beta_mat |
Matrix of betas - rows are SNPs, columns are studies |
se_mat |
Matrix of SEs - rows are SNPs, columns are studies |
n |
Vector of sample sizes for each |
eaf_mat |
Matrix of allele frequencies - rows are SNPs, columns are studies |