writeToTallyFile {h5vc} | R Documentation

## Writing data to an HDF5 tally file

### Description

This function is used to write the results of a call to `tallyRanges` to an HDF5 tally file.

### Usage

    writeToTallyFile( theData, file, study, ranges, samples = NULL )

### Arguments

`theData` | A `list` of `list`s of datasets as returned by a call to e.g. `tallyRanges`
`file` | The target filename
`study` | The location of the Group (within the HDF5 file) representing the study the data belongs to.
`ranges` | A `GRanges` object defining the ranges that the elements of `theData` correspond to
`samples` | The indexes of the samples that the data corresponds to, this can be extracted from the 'Column'-field in the sample metadata and is used to write data corresponding to subsets of the cohort samples. The default (`NULL`) indicates that all samples are present and will be written.

### Author(s)

Paul Theodor Pyl

### Examples

    suppressPackageStartupMessages(library("h5vc"))
    suppressPackageStartupMessages(library("rhdf5"))
    files <- list.files( system.file("extdata", package = "h5vcData"), "Pt.*bam$" )
    bamFiles <- file.path( system.file("extdata", package = "h5vcData"), files)
    suppressPackageStartupMessages(require(BSgenome.Hsapiens.NCBI.GRCh38))
    suppressPackageStartupMessages(require(GenomicRanges))
    dnmt3a <- read.table(system.file("extdata", "dnmt3a.txt", package = "h5vcData"), header=TRUE, stringsAsFactors = FALSE)
    dnmt3a <- with( dnmt3a, GRanges(seqname, ranges = IRanges(start = start, end = end)))
    dnmt3a <- reduce(dnmt3a)
    require(BiocParallel)
    register(MulticoreParam())
    theData <- tallyRanges( bamFiles, ranges = dnmt3a[1:3], reference = Hsapiens )
    chrom <- "2"
    chromlength <- 250e6
    study <- "/DNMT3A"
    tallyFile <- file.path( tempdir(), "DNMT3A.tally.hfs5" )
    if( file.exists(tallyFile) ){
      file.remove(tallyFile)
    }
    if( prepareTallyFile( tallyFile, study, chrom, chromlength, nsamples = length(files) ) ){
      h5ls(tallyFile)
    }else{
      message( paste( "Preparation of:", tallyFile, "failed" ) )
    }
    writeToTallyFile(theData, tallyFile, study = "/DNMT3A", ranges = dnmt3a[1:3])

[Package h5vc version 2.20.0 Index]