R/chromosomeCoverage.R

Defines functions chromosomeCoverage

Documented in chromosomeCoverage

#' CpG covergae in each chromosome
#'
#'Provides Coverage metrics for each sample by the chromosome
#'@param bs bsseq object
#'@return matrix of chromsome covergae with
#'column and rows indicating the samples and the chromosome respectively
#'@examples
#'directory <- system.file("extdata/bismark_data",package='scmeth')
#'bs <- HDF5Array::loadHDF5SummarizedExperiment(directory)
#'chromosomeCoverage(bs)
#'@importFrom bsseq getCoverage
#'@export


chromosomeCoverage <- function(bs) {
    bs <- GenomeInfoDb::keepStandardChromosomes(bs)
    covMatrix <- bsseq::getCoverage(bs)
    Granges <- GenomicRanges::granges(bs)
    standardChr <- GenomeInfoDb::seqnames(Granges)
    chrCov <- by(covMatrix>0, standardChr, colSums)
    chrCov <- do.call("rbind", chrCov)
    return(chrCov)
}

Try the scmeth package in your browser

Any scripts or data that you put into this service are public.

scmeth documentation built on Nov. 8, 2020, 6:21 p.m.