mixmodels {ClassifyR} | R Documentation |
Fits mixtures of normals for every feature, separately for each class.
## S4 method for signature 'matrix' mixModelsTrain(measurements, ...) ## S4 method for signature 'DataFrame' mixModelsTrain(measurements, classes, ..., verbose = 3) ## S4 method for signature 'MultiAssayExperiment' mixModelsTrain(measurements, targets = names(measurements), ...) ## S4 method for signature 'list,matrix' mixModelsPredict(models, test, ...) ## S4 method for signature 'list,DataFrame' mixModelsPredict(models, test, weighted = c("both", "unweighted", "weighted"), weight = c("all", "height difference", "crossover distance", "sum differences"), densityXvalues = 1024, minDifference = 0, returnType = c("class", "score", "both"), verbose = 3) ## S4 method for signature 'list,MultiAssayExperiment' mixModelsPredict(models, test, targets = names(test), ...)
measurements |
Either a |
classes |
Either a vector of class labels of class |
test |
An object of the same class as |
targets |
If |
... |
Variables not used by the |
models |
A list of length 3 of models generated by the training function and training class information. The first element has mixture models the same length as the number of features in the expression data for one class. The second element has the same information for the other class. The third element has the class sizes of the classes in the training data. |
weighted |
Default: |
weight |
Default: |
densityXvalues |
Default: 1024. Only relevant when |
minDifference |
Default: 0. The minimum difference in sums of mixture densities within each class for a feature to be allowed to vote. Can be a vector of cutoffs. If no features for a particular sample have a difference large enough, the class predicted is simply the largest class. |
returnType |
Default: |
verbose |
Default: 3. A number between 0 and 3 for the amount of progress messages to give. This function only prints progress messages if the value is 3. |
If weighted
is TRUE
, then a sample's predicted class is the class with
the largest sum of weights, each scaled for the number of samples in
the training data of each class. Otherwise, when weighted
is FALSE
,
each feature has an equal vote, and votes for the class with the largest weight, scaled for
class sizes in the training set.
If weight
is "crossover distance"
, the crossover points are computed by considering the
distance between y values of the two densities at every x value. x values for which the sign of the difference
changes compared to the difference of the closest lower value of x are used as the crossover points.
Setting weight to "sum differences"
is intended to find a mix of features which are strongly
differentially expressed and differentially variable.
For mixModelsTrain
, a list of trained models of class MixmodCluster
.
For mixModelsPredict
, a vector or list of class prediction information, as long as the
number of samples in the test data, or lists of such information, if both weighted and unweighted voting
or a range of minDifference
values was provided.
Dario Strbenac
# First 25 samples and first 5 genes are mixtures of two normals. Last 25 samples are # one normal. genesMatrix <- sapply(1:25, function(geneColumn) c(rnorm(5, sample(c(5, 15), replace = TRUE, 5)))) genesMatrix <- cbind(genesMatrix, sapply(1:25, function(geneColumn) c(rnorm(5, 9, 1)))) genesMatrix <- rbind(genesMatrix, sapply(1:50, function(geneColumn) rnorm(5, 9, 1))) rownames(genesMatrix) <- paste("Gene", 1:10) colnames(genesMatrix) <- paste("Sample", 1:50) classes <- factor(rep(c("Poor", "Good"), each = 25), levels = c("Good", "Poor")) trainSamples <- c(1:15, 26:40) testSamples <- c(16:25, 41:50) trained <- mixModelsTrain(genesMatrix[, trainSamples], classes[trainSamples], nbCluster = 1:3) mixModelsPredict(trained, genesMatrix[, testSamples], minDifference = 0:3)