Calculate MR-MEGA MDS coordinates from allele frequency data
Source:R/calculate_mr_mega_mds.R
calculate_mr_mega_mds.RdComputes multidimensional scaling (MDS) coordinates from study-level effect allele frequency (EAF) data. The approach follows the MR-MEGA method (Mägi et al. 2017): a population-genetic distance matrix is computed from EAF values, double-centred, and decomposed via SVD to produce principal coordinates.
Usage
calculate_mr_mega_mds(
common_variants_data,
pcCount = 4,
chr_col = CHR,
pos_col = POS_38,
rsid_col = RSID,
ea_col = EffectAllele,
oa_col = OtherAllele,
eaf_col = minor_af,
file_col = file
)Arguments
- common_variants_data
A data frame (long format) with one row per variant × study combination. Must contain columns identified by
chr_col,pos_col,ea_col,oa_col,eaf_col, andfile_col. Typically the output ofextract_common_variants().- pcCount
Number of principal coordinates to return. Default
4.- chr_col
Bare column name for chromosome. Default
CHR.- pos_col
Bare column name for position. Default
POS_38.- rsid_col
Bare column name for rsid. Default
RSID.- ea_col
Bare column name for effect allele. Default
EffectAllele.- oa_col
Bare column name for other allele. Default
OtherAllele.- eaf_col
Bare column name for EAF. Default
minor_af.- file_col
Bare column name for study/file identifier. Default
file.
Value
A named list with elements:
pc_coordinatesData frame of MDS coordinates (
pcCountcolumns).distance_matrixPopulation-genetic distance matrix.
centered_distance_matrixDouble-centred distance matrix.
eigenvaluesEigenvalues from SVD.
eaf_matrixWide EAF matrix (variants × studies).
used_variantsVariants with complete EAF data.
studiesCharacter vector of study names.
summaryList with
n_studies,n_variants_used,n_variants_total,pc_count.
References
Mägi R, et al. (2017). Trans-ethnic meta-regression of genome-wide association studies accounting for ancestry increases power for discovery and improves fine-mapping resolution. Hum Mol Genet, 26(18), 3639–3650.
Examples
if (FALSE) { # \dontrun{
common <- extract_common_variants(files, trait_type = "binary")
mds <- calculate_mr_mega_mds(common)
} # }