A helper function to flip alleles from eQTL and GWAS datasets, such that they agree on the effect allele, that the SNPs in a signal cluster are in postive correlation with the index SNP (eQTL), and that the effect allele is coded such that it is the expression increasing allele. This is recommended to run after collapseHighCorSNPs, and before fitBetaColoc.

flipAllelesAndGather(
  sum_stat,
  ld_mat,
  ld_mat2 = NULL,
  a,
  b,
  ref,
  eff,
  beta,
  se,
  a2_plink,
  a2_plink_mat2 = NULL,
  snp_id,
  sep,
  ab_last = TRUE,
  alleles_same = FALSE,
  plot = TRUE
)

Arguments

sum_stat

list of summary statistic tables. A list over signal clusters, where each element is a data.frame with summary statistics from eQTL and GWAS datasets. The names of the columns are specified by arguments below (e.g. a, b, ref, eff, etc.)

ld_mat

list of LD matrices

ld_mat2

optional second list of LD matrices (for different populations). it will be returned alongside the first ld_mat, which is used for the allele flipping. the second list of LD matrices is just flipped in the same way

a

name of A in columns of sum_stat ("eQTL")

b

name of B ("GWAS")

ref

name of reference allele

eff

name of effect allele

beta

name of estimated coefficient

se

name of standard error

a2_plink

name of the column representing the a2 allele (reference allele) according to plink. the default for plink v1.9 and earlier was to reset a2 to the major allele, unless an optional flag was used. in plink v2.0 and onward, one should check to see which allele is used as reference for calculating the LD matrix. If plink was not used, this argument should just point to the reference allele that was used for LD calculation

a2_plink_mat2

name of the column representing the a2 allele for the second LD matrix, ld_mat2 (needed only if ld_mat2 was specified)

snp_id

name of SNP id

sep

character separator in column names that involve A/B

ab_last

logical, A/B descriptor is last in column names (e.g. "beta_eqtl", "se_eqtl"))

alleles_same

logical, A/B/LD matrix alleles are identical

plot

logical, draw a scatterplot of the flipped betas

Value

list with estimated coefficients, standard errors, LD matrix, and alleles data.frame