BB_Fun: Estimating size for each gene by either 1D or 2D maximization...

Description Usage Arguments Value Examples

View source: R/PRIOR_FUNCTIONS.R

Description

Estimating parameters of the prior distribution for each gene by maximizing marginal distribution: 1D (optimize with respect to size using MME estimate of mu, 2D (optimize with respect to both mu and size)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
BB_Fun(
  Data,
  BETA_vec,
  INITIAL_MU_vec,
  INITIAL_SIZE_vec,
  MU_lower = 0.01,
  MU_upper = 500,
  SIZE_lower = 0.01,
  SIZE_upper = 30,
  parallel = FALSE,
  NCores = 5,
  FIX_MU = TRUE,
  GR = FALSE
)

Arguments

Data

A matrix of single-cell expression where rows are genes and columns are samples (cells). Data can be of class SummarizedExperiment (the assays slot contains the expression matrix, is named "Counts"), just matrix or sparse matrix.

BETA_vec

A vector of capture efficiencies (probabilities) of cells.

INITIAL_MU_vec

Mean expression of genes, can be estimated from EstPrior.

INITIAL_SIZE_vec

size of genes (size is a parameter in NB distribution), can come from EstPrior.

MU_lower

The lower bound for the mu.(Only need it when you want to do 2D optimization). Default is 0.01.

MU_upper

The upper bound for the mu.(Only need it when you want to do 2D optimization). Default is 500.

SIZE_lower

The lower bound for the size. Default is 0.01.

SIZE_upper

The upper bound for the size. Default is 30.

parallel

If TRUE, NCores cores will be used for parallelization. Default is TRUE.

NCores

number of cores to use, default is 5. This will be used to set up a parallel environment using either MulticoreParam (Linux, Mac) or SnowParam (Windows) with NCores using the package BiocParallel.

FIX_MU

If TRUE, then 1D optimization, otherwise 2D optimization (slow).

GR

If TRUE, the gradient function will be used in optimization. However since the gradient function itself is very complicated, it does not help too much in speeding up. Default is FALSE.

Value

BB estimated size (1D optimization) or size and mu (2D optimization).

Examples

1
2
3
4
5
6
7
data('EXAMPLE_DATA_list')
BB_RESULT<-BB_Fun(Data=EXAMPLE_DATA_list$inputdata[,seq(1,30)],
BETA_vec = EXAMPLE_DATA_list$inputbeta[seq(1,30)],
INITIAL_MU_vec=EXAMPLE_DATA_list$mu,
INITIAL_SIZE_vec=EXAMPLE_DATA_list$size,
MU_lower=0.01,MU_upper=500,SIZE_lower=0.01,
SIZE_upper=30,parallel=FALSE,NCores=5,FIX_MU=TRUE,GR=FALSE)

bayNorm documentation built on Nov. 8, 2020, 8:25 p.m.