DLDAinterface {ClassifyR} | R Documentation

## An Interface for sparsediscrim Package's dlda Function

### Description

`DLDAtrainInterface` generates a trained diagonal LDA classifier and `DLDApredictInterface` uses it to make predictions on a test data set.

### Usage

      ## S4 method for signature 'matrix'
    DLDAtrainInterface(measurements, classes, ...)
      ## S4 method for signature 'DataFrame'
    DLDAtrainInterface(measurements, classes, verbose = 3)
      ## S4 method for signature 'MultiAssayExperiment'
    DLDAtrainInterface(measurements, targets = names(measurements), ...)
      ## S4 method for signature 'dlda,matrix'
    DLDApredictInterface(model, test, ...)
      ## S4 method for signature 'dlda,DataFrame'
    DLDApredictInterface(model, test, returnType = c("class", "score", "both"),
                                      verbose = 3)
      ## S4 method for signature 'dlda,MultiAssayExperiment'
    DLDApredictInterface(model, test, targets = names(test), ...)

### Arguments

`measurements` | Either a `matrix`, `DataFrame` or `MultiAssayExperiment` containing the training data. For a `matrix`, the rows are features, and the columns are samples. If of type `DataFrame`, the data set is subset to only those features of type `integer`.
`classes` | Either a vector of class labels of class `factor` of the same length as the number of samples in `measurements` or if the measurements are of class `DataFrame` a character vector of length 1 containing the column name in `measurement` is also permitted. Not used if `measurements` is a `MultiAssayExperiment` object.
`model` | A fitted model as returned by `DLDAtrainInterface`.
`test` | An object of the same class as `measurements` with no samples in common with `measurements` and the same number of features as it. Also, if a `DataFrame`, the `class` column must be absent.
`targets` | If `measurements` is a `MultiAssayExperiment`, the names of the data tables to be used. `"clinical"` is also a valid value and specifies that integer variables from the clinical data table will be used.
`...` | Variables not used by the `matrix` nor the `MultiAssayExperiment` method which are passed into and used by the `DataFrame` method (e.g. `verbose`).
`returnType` | Default: `"class"`. Either `"class"`, `"score"` or `"both"`. Sets the return value from the prediction to either a vector of class labels, matrix of scores for each class, or both labels and scores in a `data.frame`.
`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.

### Details

If `measurements` is an object of class `MultiAssayExperiment`, the factor of sample classes must be stored in the DataFrame accessible by the `colData` function with column name `"class"`.

### Value

For `DLDAtrainInterface`, a trained DLDA classifier. For `DLDApredictInterface`, either a factor vector of predicted classes, a matrix of scores for each class, or a table of both the class labels and class scores, depending on the setting of `returnType`.

### Author(s)

Dario Strbenac

### Examples

      # if(require(sparsediscrim)) Package currently removed from CRAN.
      #{
        # Genes 76 to 100 have differential expression.
        genesMatrix <- sapply(1:25, function(sample) c(rnorm(100, 9, 2)))
        genesMatrix <- cbind(genesMatrix, sapply(1:25, function(sample)
                                          c(rnorm(75, 9, 2), rnorm(25, 14, 2))))
        classes <- factor(rep(c("Poor", "Good"), each = 25))
        colnames(genesMatrix) <- paste("Sample", 1:ncol(genesMatrix))
        rownames(genesMatrix) <- paste("Gene", 1:nrow(genesMatrix))
        selected <- rownames(genesMatrix)[91:100]
        trainingSamples <- c(1:20, 26:45)
        testingSamples <- c(21:25, 46:50)

        classifier <- DLDAtrainInterface(genesMatrix[selected, trainingSamples],
                                         classes[trainingSamples])
        DLDApredictInterface(classifier, genesMatrix[selected, testingSamples])
      #}

[Package ClassifyR version 2.8.0 Index]