Skip to contents

The ctar package provides a number of cross-trait association methods. The methods were written to follow a similar structure for their input arguments. Furthermore, the methods benefit from various enhancements such as parallel processing and speed optimization. If you want to use this package, please make sure that you are aware of how cross-trait association methods work.

Installation

if (!require("devtools", quietly = TRUE))
  install.packages("devtools")
devtools::install_github("slamballais/ctar")

Overview

Data preparation

We will look at four datasets: anx, bip, dep, and scz. Let’s explore one of them:

ss <- list(anx, bip, dep, scz)
names(ss) <- c("anx", "bip", "dep", "scz")
print(ss$anx)
#>   SNP A1 A2     Z            P     N
#> 1 rs1  T  G  0.39 6.965365e-01 25000
#> 2 rs2  G  A -1.15 2.501439e-01 25000
#> 3 rs3  C  A -1.52 1.285110e-01 25000
#> 4 rs4  G  A  1.03 3.030100e-01 25000
#> 5 rs5  G  T  4.22 2.443023e-05 25000
#> 6 rs6  C  T -0.61 5.418618e-01 25000
#> 7 rs7  A  C -1.59 1.118348e-01 25000

The dataset represents a GWAS for anxiety. The six columns represent:

  • SNP: Each row is one SNP, identified by their rs-id.
  • A1: The effect allele.
  • A2: The non-effect allele.
  • Z: The z-value.
  • P: The corresponding p-value.
  • N: The sample size.

Restrict to overlapping SNPs

All four datasets have the same columns. They have also have the same and for each overlapping SNP. They do not, however, cover the same SNPs. We first have to make sure that the sets that we analyze only cover the same SNPs. Here, we show one possible way to do that:

common_snps <- Reduce(intersect, lapply(ss, function(x) x$SNP))
print(common_snps)
#> [1] "rs3" "rs4" "rs5" "rs6" "rs7"

ss_common <- lapply(ss, function(x) subset(x, SNP %in% common_snps))
names(ss_common) <- names(ss)
print(ss_common$anx)
#>   SNP A1 A2     Z            P     N
#> 3 rs3  C  A -1.52 1.285110e-01 25000
#> 4 rs4  G  A  1.03 3.030100e-01 25000
#> 5 rs5  G  T  4.22 2.443023e-05 25000
#> 6 rs6  C  T -0.61 5.418618e-01 25000
#> 7 rs7  A  C -1.59 1.118348e-01 25000

Prepare the p-values and z-scores

Next, we need to make the , , and variables, depending on which cross-trait association methods we want to use (for example, only needs ).

p <- lapply(ss_common, `[[`, "P")
str(p)
#> List of 4
#>  $ anx: num [1:5] 1.29e-01 3.03e-01 2.44e-05 5.42e-01 1.12e-01
#>  $ bip: num [1:5] 0.802587 0.133614 0.000104 0.133614 0.000191
#>  $ dep: num [1:5] 0.51569 0.16151 0.00128 0.41222 0.09103
#>  $ scz: num [1:5] 2.30e-01 2.30e-01 9.11e-07 9.12e-01 2.92e-05

z <- lapply(ss_common, `[[`, "Z")
str(z)
#> List of 4
#>  $ anx: num [1:5] -1.52 1.03 4.22 -0.61 -1.59
#>  $ bip: num [1:5] -0.25 1.5 3.88 1.5 -3.73
#>  $ dep: num [1:5] 0.65 1.4 3.22 0.82 1.69
#>  $ scz: num [1:5] -1.2 -1.2 4.91 -0.11 -4.18

z_var <- sapply(z, var)
print(z_var)
#>      anx      bip      dep      scz 
#>  5.90293  7.96195  1.04343 10.95973
# normally, z_var values are much closer to 1, so we'll change it:
z_var <- rep(1, 4)

Running cross-trait association methods

SumRank

res_sumrank <- sumrank(p)
print(res_sumrank)
#> $p
#> [1] 6.431502e-02 1.961062e-02 1.654865e-13 1.336144e-01 2.433895e-08
#> 
#> $n
#> [1] 0 0 4 0 2
#> 
#> $traits
#> $traits[[1]]
#> integer(0)
#> 
#> $traits[[2]]
#> integer(0)
#> 
#> $traits[[3]]
#> [1] 4 1 2 3
#> 
#> $traits[[4]]
#> integer(0)
#> 
#> $traits[[5]]
#> [1] 4 2
#> 
#> 
#> $p_exp
#> [1]  1.1916876  1.7075087 12.7812374  0.8741467  7.6136982

FCT

res_fct <- fct(p)
print(res_fct)
#> $p
#> [1] 1.285110e-01 1.012015e-01 3.518240e-14 1.336144e-01 1.116571e-07
#> 
#> $n
#> [1] 0 0 4 0 0
#> 
#> $traits
#> $traits[[1]]
#> integer(0)
#> 
#> $traits[[2]]
#> integer(0)
#> 
#> $traits[[3]]
#> [1] 4 1 2 3
#> 
#> $traits[[4]]
#> integer(0)
#> 
#> $traits[[5]]
#> integer(0)
#> 
#> 
#> $p_exp
#> [1]  0.8910598  0.9948129 13.4536746  0.8741467  6.9521135

CPMA

res_cpma <- cpma(p)
print(res_cpma)
#> $p
#> [1] 3.773109e-01 2.753689e-01 1.794078e-13 4.286261e-01 5.697714e-07
#> 
#> $n
#> [1] 0 0 4 0 0
#> 
#> $traits
#> $traits[[1]]
#> integer(0)
#> 
#> $traits[[2]]
#> integer(0)
#> 
#> $traits[[3]]
#> [1] 4 1 2 3
#> 
#> $traits[[4]]
#> integer(0)
#> 
#> $traits[[5]]
#> integer(0)
#> 
#> 
#> $p_exp
#> [1]  0.4233006  0.5600851 12.7461587  0.3679214  6.2442993

PLACO

# for bip and scz
res_placo <- placo(z[c(2, 4)], z_var[c(2, 4)], n_cores = 2)
print(res_placo)
#> [1] 5.531158e-01 7.827930e-02 9.439345e-10 6.927382e-01 3.296773e-08