R/RcppExports.R

Defines functions sampleSinglets subsetSinglets calculateCost normalizeFractions adjustAccordingToFractions multipletSums vecToMat calculateCostDensity calculateLogRowMeans fixNegInf costNegSum costCalc cost

Documented in adjustAccordingToFractions calculateCost calculateCostDensity calculateLogRowMeans cost costCalc costNegSum fixNegInf multipletSums normalizeFractions sampleSinglets subsetSinglets vecToMat

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

#' sampleSinglets
#' 
#' This function takes a character vector of classes/cell with the same order
#' as the cells in the counts matrix. It returns one random index per unique
#' class and returns them as a integer vector.
#'
#' @param classes Character; a character vector of classes with length equal to
#' the number of cells for which counts exist.
#' @author Jason T. Serviss
#' @export
sampleSinglets <- function(classes) {
    .Call('_CIMseq_sampleSinglets', PACKAGE = 'CIMseq', classes)
}

#' subsetSinglets
#' 
#' This function takes a counts matrix and subsets the columns according to the
#' indices provided by the idxToSubset argument.
#'
#' @param singlets Matrix; a counts matrix with cells/samples as columns and 
#' genes as rows.
#' @param idxToSubset Integer; the indexes of cells/samples to be subset. 
#' @author Jason T. Serviss
#' @export
subsetSinglets <- function(singlets, idxToSubset) {
    .Call('_CIMseq_subsetSinglets', PACKAGE = 'CIMseq', singlets, idxToSubset)
}

#' calculateCost
#'
#' Wrapper for deconvolution cost function using the Armadillo C++ library.
#'
#' @param oneMultiplet Integer; a integer vector of rounded counts per million
#' for one multiplet.
#' @param singletSubset Matrix; Numeric matrix with the preallocated singlets.
#' Each of the n synthetic multiplets should be stacked, i.e. rbind.
#' @param fractions Numeric; a numeric vector with length equal to
#' ncol(singlets) indicating the fractions that each column should be
#' multiplied with.
#' @param n Integer; length 1 integer indicating the number of synthetic
#' multiplets to generate.
#' @author Jason T. Serviss
#' @export
calculateCost <- function(oneMultiplet, singletSubset, fractions, n) {
    .Call('_CIMseq_calculateCost', PACKAGE = 'CIMseq', oneMultiplet, singletSubset, fractions, n)
}

#' normalizeFractions
#'
#' Takes a numeric vector and scales to [0, 1] by dividing with its sum.
#'
#' @param fractions Numeric; a numeric vector.
#' @author Jason T. Serviss
#' @export
normalizeFractions <- function(fractions) {
    .Call('_CIMseq_normalizeFractions', PACKAGE = 'CIMseq', fractions)
}

#' adjustAccordingToFractions
#'
#' This function takes a counts matrix and subsets the columns according to the
#' indices provided by the idxToSubset argument.
#'
#' @param fractions Numeric; a numeric vector with length equal to
#' ncol(singlets) indicating the fractions that each column should be
#' multiplied with.
#' @param singlets Matrix; a counts matrix with cells/samples as columns and
#' genes as rows.
#' @author Jason T. Serviss
#' @export
adjustAccordingToFractions <- function(fractions, singlets) {
    .Call('_CIMseq_adjustAccordingToFractions', PACKAGE = 'CIMseq', fractions, singlets)
}

#' multipletSums
#'
#' This function takes a counts matrix and calculates the row sums. Output is
#' subsequently rounded for integration downstream.
#'
#' @param adjusted Matrix; a counts matrix with cells/samples as columns and
#' genes as rows.
#' @author Jason T. Serviss
#' @export
multipletSums <- function(adjusted) {
    .Call('_CIMseq_multipletSums', PACKAGE = 'CIMseq', adjusted)
}

#' vecToMat
#'
#' This function takes a vector and reformats it to a matrix in a column-wise
#' fashion. Since Armadillo "builds" the matrix column-wise, some code tricks
#' are employed to automagically deliever the expected result.
#'
#' @param vec Numeric; the vector to reformat.
#' @param nr integer; length 1 integer indicating the number of matrix rows.
#' @param nc integer; length 1 integer indicating the number of matrix columns.
#' @author Jason T. Serviss
#' @export
vecToMat <- function(vec, nr, nc) {
    .Call('_CIMseq_vecToMat', PACKAGE = 'CIMseq', vec, nr, nc)
}

#' calculateCostDensity
#'
#' This function takes a vector of gene counts per million for one multiplet
#' that is being deconvoluted and a matrix of synthetic multiplets. It then
#' calculates the poisson density for each gene count and each corresponding
#' value in the matrix row.
#'
#' @param oneMultiplet Numeric; a numeric vector of counts per million for one
#' multiplet.
#' @param syntheticMultiplets Matrix; a numeric matrix of synthetic multiplets
#' with samples as columns and genes as rows.
#' @author Jason T. Serviss
calculateCostDensity <- function(oneMultiplet, syntheticMultiplets) {
    .Call('_CIMseq_calculateCostDensity', PACKAGE = 'CIMseq', oneMultiplet, syntheticMultiplets)
}

#' calculateLogRowMeans
#'
#' This function takes a matrix of poisson densities and calculates the row
#' means and subsequently their log10 values.
#'
#' @param densities Numeric; a numeric vector of densities.
#' @author Jason T. Serviss
calculateLogRowMeans <- function(densities) {
    .Call('_CIMseq_calculateLogRowMeans', PACKAGE = 'CIMseq', densities)
}

#' fixNegInf
#'
#' This function takes a numeric vector and replaces -Inf values with
#' -323.0052. Note: since log10(10^-324) gives -Inf but log10(10^-323)
#' gives -323.0052
#'
#' @param means Numeric; a numeric vector of log10 row means.
#' @author Jason T. Serviss
fixNegInf <- function(means) {
    .Call('_CIMseq_fixNegInf', PACKAGE = 'CIMseq', means)
}

#' costNegSum
#'
#' This function takes a numeric vector and calculates the negative sum.
#'
#' @param means Numeric; a numeric vector of log10 row means.
#' @author Jason T. Serviss
costNegSum <- function(means) {
    .Call('_CIMseq_costNegSum', PACKAGE = 'CIMseq', means)
}

#' costCalc
#'
#' This function takes a vector of gene counts per million for one multiplet
#' that is being deconvoluted and a matrix of synthetic multiplets and
#' calculates the cost which is returned to the optimization algorithm during
#' deconvolution.
#'
#' @param oneMultiplet Numeric; a numeric vector of counts per million for one
#' multiplet.
#' @param syntheticMultiplets Matrix; a numeric matrix of synthetic multiplets
#' with samples as columns and genes as rows.
#' @author Jason T. Serviss
#' @export
costCalc <- function(oneMultiplet, syntheticMultiplets) {
    .Call('_CIMseq_costCalc', PACKAGE = 'CIMseq', oneMultiplet, syntheticMultiplets)
}

#' cost
#'
#' Wrapper for deconvolution cost function using the Armadillo C++ library.
#'
#' @param oneMultiplet Integer; a integer vector of rounded counts per million
#' for one multiplet.
#' @param singletSubset Matrix; a counts matrix or pre-subsetted singlets. 
#' Typically from the .subsetSinglets function.
#' @param fractions Numeric; a numeric vector with length equal to
#' ncol(singlets) indicating the fractions that each column should be
#' multiplied with.
#' @param n Integer; length 1 integer indicating the number of synthetic
#' multiplets to generate.
#' @author Jason T. Serviss
#' @export
cost <- function(oneMultiplet, singletSubset, fractions, n) {
    .Call('_CIMseq_cost', PACKAGE = 'CIMseq', oneMultiplet, singletSubset, fractions, n)
}
jasonserviss/CIMseq documentation built on Jan. 11, 2020, 4:42 a.m.