Fit a bimodal gaussian distribution to a set of observations.

Fit a bimodal gaussian distribution to a set of observations.

fitBimodal(x, prob = 0.95, coverage = 0.8, size = 10,
  assign = FALSE, boolean = FALSE, verbose = TRUE, maxit = 5000,
  maxrestarts = 100, bySampling = FALSE, nsamp = 2000,
  force.tries = FALSE, ...)

fitModal(x, m, prob = 0.95, coverage = 0.8, size = 10,
  assign = FALSE, boolean = FALSE, verbose = TRUE, maxit = 5000,
  maxrestarts = 100, bySampling = FALSE, nsamp = 200, ...)

Arguments

x

a named numeric vector of cells/observations or a matrix of genes X cells (variables X observations). If the latter, the column means are first computed.

prob

a numeric value >= 0 and <= 1; the minimum posterior probability required for an observation to be assigned to a mode. Default: 0.95

coverage

the fraction of observations that must have a posterior probability higher than <prob> to one of two modes in order for the distribution to qualify as bimodal. Default: 0.8

size

the minimum number of observations that must be assigned to a mode in order for the distribution to qualify as bimodal. Default: 10

assign

if set to TRUE, returns a list of length two containing the vector names that were assigned to each mode. Default: FALSE

boolean

if set to TRUE, returns a boolean value indicating whether the distribution is bimodal. Default: FALSE

verbose

print progress messages. Default: TRUE

maxit

the maximum number of iterations. Default: 5000

maxrestarts

the maximum number of restarts allowed. See normalmixEM for details. Default: 100

m

number of components (modes). Default: 2

x

a named numeric vector of cells/observations or a matrix of genes X cells (variables X observations). If the latter, the column means are first computed.

m

numeric value indicating the modality to test; 1 for unimodal; 2 for bimodal; etc.

prob

a numeric value >= 0 and <= 1; the minimum posterior probability required for an observation to be assigned to a mode. Default: 0.95

coverage

the fraction of observations that must have a posterior probability higher than <prob> to one of two modes in order for the distribution to qualify as bimodal. Default: 0.8

size

the minimum number of observations that must be assigned to a mode in order for the distribution to qualify as bimodal. Default: 10

assign

if set to TRUE, returns a list of length two containing the vector names that were assigned to each mode. Default: FALSE

boolean

if set to TRUE, returns a boolean value indicating whether the distribution is bimodal. Default: FALSE

verbose

print progress messages. Default: TRUE

maxrestarts

the maximum number of restarts allowed. See normalmixEM for details. Default: 100

maxit

the maximum number of iterations. Default: 5000

m

number of components (modes). Default: 2

Value

The posterior probabilities of each observation to one of two modes. If boolean = TRUE, return a boolean value indicating whether bimodality was found. If assign = TRUE, return a list of length two with the observations (IDs) in each mode.

The posterior probabilities of each observation to one of two modes. If boolean = TRUE, return a boolean value indicating whether bimodality was found. If assign = TRUE, return a list of length two with the observations (IDs) in each mode.

See also

Examples

cna = infercna(m = useData(), dipcells = dipcells)
#> Error in infercna(m = useData(), dipcells = dipcells): unused argument (dipcells = dipcells)
# Malignant cells only (remove columns corresponding to dipcells) cna = cna[, !colnames(cna) %in% unlist(dipcells)]
#> Error in eval(expr, envir, enclos): object 'cna' not found
cnaByChr = splitGenes(cna, by = 'chr')
#> Error in splitGenes(cna, by = "chr"): object 'cna' not found
sapply(cnaByChr, fitBimodal, assign = TRUE)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found
sapply(cnaByChr, fitBimodal, boolean = TRUE)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found
sapply(cnaByChr, fitBimodal, boolean = TRUE, coverage = 0.5)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found
cna = infercna(m = useData(), dipcells = dipcells)
#> Error in infercna(m = useData(), dipcells = dipcells): unused argument (dipcells = dipcells)
# Malignant cells only (remove columns corresponding to dipcells) cna = cna[, !colnames(cna) %in% unlist(dipcells)]
#> Error in eval(expr, envir, enclos): object 'cna' not found
cnaByChr = splitGenes(cna, by = 'chr')
#> Error in splitGenes(cna, by = "chr"): object 'cna' not found
sapply(cnaByChr, fitBimodal, assign = TRUE)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found
sapply(cnaByChr, fitBimodal, boolean = TRUE)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found
sapply(cnaByChr, fitBimodal, boolean = TRUE, coverage = 0.5)
#> Error in lapply(X = X, FUN = FUN, ...): object 'cnaByChr' not found