R/RcppExports.R

Defines functions em_count effective_lengths

Documented in effective_lengths em_count

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Calculate the effective transcript lengths. This is the mean number of
#' positions in the transcript the fragment could map to.
#'
#' @param txlengths The sequence lengths for each transcript.
#' @param rdlengths The length of all mapped fragments. Mapped length of the
#'  read after accounting for mismatches and indels.
#' @return The effective lengths.
effective_lengths <- function(txlengths, rdlengths) {
    .Call(`_mbtools_effective_lengths`, txlengths, rdlengths)
}

#' Count transcripts using an Expectation Maximization (EM) algorithm.
#'
#' @param txreads A minimal matrix where each row corresponds to an
#'   alignment. The first column denotes transcript indices in [0, ntx-1] and
#'   the second column denotes read indices in [0, nr -1].
#' @param txlengths The sequence lengths for each transcript. Ideally those
#'   should be the effective transcript lengths meaning the overall number
#'   of possible alignment start positions in a transcript.
#' @param weights Weights for individual alignments.
#' @param ntx The total number of unique transcripts.
#' @param nr The total number of unique reads.
#' @param maxit Maximum number of EM iterations.
#' @param reltol The relative tolerance for convergence.
#' @param abstol The absolute tolerance for convergence.
#' @return A list with the following components.
#'     \describe{
#'      \item{p}{The length-normalized and read scaled transcript counts}
#'      \item{iterations}{The number of used EM iterations}
#'      \item{num_ecs}{The number of equivalence classes}
#'      \item{change}{The last osbserved absolute change in transcript counts}
#'     }
em_count <- function(txreads, txlengths, weights, ntx, nr, maxit = 1000L, reltol = 0.01, abstol = 0.01) {
    .Call(`_mbtools_em_count`, txreads, txlengths, weights, ntx, nr, maxit, reltol, abstol)
}
Gibbons-Lab/mbtools documentation built on Jan. 28, 2024, 11:08 a.m.