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.
Details
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 traitpop: population, e.g."EUR"; must match thepopcolumn ofld_refid: a unique identifier for the datasetfn: path to the summary statistics file, which is read withdata.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.
Public fields
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_rawextracted from the outcome datasetsinstrument_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_regionsbut for the outcome datasets.
Methods
CAMERA_local$new()
Create a new CAMERA_local object
Usage
CAMERA_local$new(
metadata,
ld_ref,
plink_bin,
mc.cores = 1,
radius = 25000,
pthresh = 5e-08,
minmaf = 0.01
)Arguments
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
Usage
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"
)Arguments
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
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$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
Usage
CAMERA_local$pool_tophits(
rawdat,
tophits,
metadata,
radius = 250000,
pthresh = 5e-08,
mc.cores = 1
)Arguments
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
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()
Usage
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
)Arguments
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
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$organise()
Organise the data for the exposure and outcome, populating the instrument_raw, instrument_outcome, instrument_regions and instrument_outcome_regions fields