tailor_learn: tailor_learn

Description Usage Arguments Value Examples

View source: R/tailor_methods.R

Description

This function learns a tailor model from input data. It computes a preliminary binning of the data, then computes a mixture model using a weighted version of the expectation-maximization (EM) algorithm, and finally merges mixture components which are positive/negative for the same markers, using adaptive thresholds.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
tailor_learn(
  data,
  params = NULL,
  mixtures_1D = NULL,
  mixture_components = 100,
  min_bin_size = NULL,
  max_bin_size = NULL,
  min_cluster_fraction = 0.001,
  parallel = FALSE,
  verbose = 0.5
)

Arguments

data

A flowSet, flowFrame or a matrix containing events along the rows, markers along columns.

params

A list of markers to use; must be subset of colnames(data).

mixtures_1D

Pre-computed 1D mixture models, to be used for binning. These are computed from scratch if not provided.

mixture_components

The number of mixture components to learn. Some of these are eventually merged, so it's a good idea to choose a number slightly larger than the number of clusters you expect to get.

min_bin_size

Bins with fewer events than this threshold are considered outliers, and are ignored during the weighted EM algorithm. These events can still be assigned to clusters during the prediction phase.

max_bin_size

Bins with more events than this threshold are split, to ensure that the weighted EM algorithm closely approximates a run of vanilla EM on the entire dataset.

min_cluster_fraction

Mixture components whose size is smaller than this fraction are dropped from further analysis, and a warning is returned.

parallel

Boolean flag; if true, uses multithreading to speed up computation.

verbose

If > 0, outputs milestone information. If >=1, also outputs information about running utilities. If >1, debugging mode.

Value

A tailor object containing:

fit

The tailor model, a named list containing the mixture proportions, means and variances of all mixture components.

mixtures_1D
cat_clusters

A named list containing information about the categorical clusters found by the model: phenotype, cluster centers, and a mapping from mixture components to categorical clusters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Load data and define analytical parameters
fileName <- system.file("extdata", "sampled_flowset_old.rda",
                        package = "Tailor")
load(fileName)
tailor_params <- flowCore::colnames(fs_old)[c(7:9, 11:22)]

# Run with default settings
tailor_obj <- tailor_learn(data = fs_old,
                          params = tailor_params,
                          mixture_components = 50)

# Alternatively, customize the 1D mixtures used for binning step
mixtures_1D <- get_1D_mixtures(fs_old, tailor_params)
to_customize <- list("CD127BV421" = 2)
mixtures_1D <- customize_1D_mixtures(fs_old, to_customize, mixtures_1D)

tailor_obj <- tailor_learn(data = fs_old,
                          params = tailor_params,
                          mixture_components = 50,
                          mixtures_1D = mixtures_1D)

matei-ionita/Tailor documentation built on Jan. 4, 2021, 11:47 a.m.