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

collapseAggregateFiles(object, output = NULL, verbose = TRUE)

Arguments

object

an aggregateFileList object.

output

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

verbose

Should the function be verbose? Defaults to TRUE.

Examples

library(rvatData)
gdb <- gdb(rvat_example("rvatData.gdb"))

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

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

# collapse aggregatefiles
aggregatefile <- tempfile()
collapseAggregateFiles(
  aggregateFileList(c(aggregatefile1, aggregatefile2)),
  output = aggregatefile
)
#> 1/2
#> 2/2
aggregates <- read.table(aggregatefile, 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