Collapse aggDbs by aggregating values across aggdbs. This will result in one aggregate score for each sample, representing the aggregate value across aggregate dbs. The output will be a two-column matrix including sample IDs and aggregate scores respectively.

collapseAggDbs(object, output = NULL, overWrite = FALSE, verbose = TRUE)

Arguments

object

an aggdbList object.

output

Output file name (output will be gz compressed text). Defaults to NULL, in which case a data.frame will be returned.

overWrite

Should existing output files be overwritten? Defaults to FALSE.

verbose

Should the function be verbose? Defaults to TRUE.

Examples

library(rvatData)
gdb <- create_example_gdb()

# generate two aggregate files
varsetfile <- varSetFile(rvat_example("rvatData_varsetfile.txt.gz"))
aggdb1 <- tempfile()
aggregate(
  x = gdb,
  varSet = getVarSet(varsetfile, unit = c("SOD1", "FUS"), varSetName = "High"),
  maxMAF = 0.001,
  output = aggdb1,
  verbose = FALSE
)

aggdb2 <- tempfile()
aggregate(
  x = gdb,
  varSet = getVarSet(varsetfile, unit = c("NEK1"), varSetName = "High"),
  maxMAF = 0.001,
  output = aggdb2,
  verbose = FALSE
)

# collapse aggdbs
aggdb <- tempfile()
collapseAggDbs(
  aggdbList(c(aggdb1, aggdb2)),
  output = aggdb
)
#> Processing aggdb 1/2: 'file1539345db0349'
#> Processing aggdb 2/2: 'file153937c458732'
#> Writing merged aggregates to: /tmp/RtmpvjdKWE/file153935fc07379
aggregates <- read.table(aggdb, header = TRUE)
head(aggregates)
#>    IID    aggregate
#> 1 ALS1 0.0000000000
#> 2 ALS2 0.0010542500
#> 3 ALS3 0.0002103009
#> 4 ALS4 0.0000000000
#> 5 ALS5 0.0000000000
#> 6 ALS6 0.0000851209