Run assocTest on an aggdb object. See the main assocTest page for details.

# S4 method for class 'aggdb'
assocTest(
  object,
  pheno,
  test,
  geneSet,
  gdb,
  cohort = "SM",
  name = "none",
  continuous = FALSE,
  covar = NULL,
  subtractCovar = NULL,
  dropUnits = NULL,
  maxitFirth = 1000L,
  keep = NULL,
  output = NULL,
  verbose = TRUE,
  strict = TRUE
)

Arguments

object

an aggdb object (generated using the aggregate method).

pheno

field to test as response variable. The response variable can either be binary (0/1) or continuous. If the response variable is continuous, set continuous to TRUE.

test

Vector of statistical tests to run, options include firth,glm,lm, and nbinom.

geneSet

a geneSetList or geneSetFile object.

gdb

a gdb object, this will be used to load the cohort data.

cohort

Cohort name (uploaded to the gdb).

name

Optional name of the analysis.

continuous

Is the response variable continuous? (TRUE/FALSE). Defaults to FALSE.

covar

Character vector of covariates, or list with multiple sets of covariates.

subtractCovar

Covariate from which aggregate should be subtracted. Useful when adjusting for total variant counts by specifying the total variant count variable here, the aggregate score of the gene set tested will be subtracted from the total count variable.

dropUnits

Optional, vector of units to exclude.

maxitFirth

Maximum number of iterations to use for estimating firth confidence intervals.

keep

vector of sample IDs to keep, defaults to NULL, in which case all samples are kept.

output

Output file path for results. Defaults to NULL, in which case results are not written but returned as a data.frame().

verbose

Should the function be verbose? (TRUE/FALSE), defaults to TRUE.

strict

Should strict checks be performed? Defaults to TRUE. Strict tests currently includes checking whether supplied aggdb was generated from the same gdb as specified in gdb.

Examples

library(rvatData)
gdb <- create_example_gdb()

# assocTest-aggdb allows for running association tests on pre-constructed aggregates.
# below we first generate the aggregates based on a varSetFile
varsetfile <- varSetFile(rvat_example("rvatData_varsetfile.txt.gz"))
varset <- getVarSet(
  varsetfile,
  unit = c("NEK1", "SOD1", "ABCA4"),
  varSetName = "High"
)
aggfile <- tempfile()
aggregate(
  x = gdb,
  varSet = varset,
  maxMAF = 0.001,
  output = aggfile,
  verbose = FALSE
)

# connect to aggdb, see ?aggdb for more details
aggdb <- aggdb(aggfile)

# build an example genesetlist, see ?buildGeneSet for details
genesetlist <- buildGeneSet(
  list(
    "geneset1" = c("SOD1", "NEK1"),
    "geneset2" = c("ABCA4", "SOD1", "NEK1")
  )
)

# perform association tests using assocTest
# note that this is very similar to running association tests on a genoMatrix (?`assocTest-genoMatrix`)
# or on a gdb (?`assocTest-gdb`). The main difference being that pre-constructed aggregates are used from
# the aggdb, and requires a genesetFile/geneSetList (?geneSetFile) to be provided to the `geneSet` argument.
aggAssoc <- assocTest(
  aggdb,
  gdb = gdb,
  test = c("glm", "firth"),
  cohort = "pheno",
  pheno = "pheno",
  geneSet = genesetlist,
  covar = paste0("PC", 1:4),
  verbose = FALSE
)