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
)
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.)
list of LD matrices
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
name of A in columns of sum_stat
("eQTL")
name of B ("GWAS")
name of reference allele
name of effect allele
name of estimated coefficient
name of standard error
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
name of the column representing
the a2 allele for the second LD matrix, ld_mat2
(needed only if ld_mat2
was specified)
name of SNP id
character separator in column names that involve A/B
logical, A/B descriptor is last in column names (e.g. "beta_eqtl", "se_eqtl"))
logical, A/B/LD matrix alleles are identical
logical, draw a scatterplot of the flipped betas
list with estimated coefficients, standard errors, LD matrix, and alleles data.frame