R/getRpkCumulativeReadCountFraction.R

Defines functions getRpkCumulativeReadCountFraction

Documented in getRpkCumulativeReadCountFraction

#' Helper function used in \code{readcountExpressionBoxplot}
#'
#' \code{getRpkCumulativeReadCountFraction} get the cumulative read count
#'   fraction
#'
#' @param p The vector of bins
#' @param DupMat The duplication matrix calculated by \code{analyzeDuprates}
#' @return The cumulative read count fraction
getRpkCumulativeReadCountFraction <- function(p, DupMat=DupMat) {

    ## generate a subset of the matrix for RPK values < than RPK percentile p
    tm <- DupMat[DupMat[,"RPK"] < quantile(DupMat[,"RPK"], p),]
    ## calculate the global duplication rate for the remaining values
    ReadFractionBelowP <- (sum(tm[,"dupsPerId"])/sum(tm[,"allCounts"]))
    
    return(ReadFractionBelowP)
}

Try the dupRadar package in your browser

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

dupRadar documentation built on Nov. 8, 2020, 5:41 p.m.