samplesMetricMap {ClassifyR} | R Documentation

## Plot a Grid of Sample Error Rates or Accuracies

### Description

A grid of coloured tiles is drawn. There is one column for each sample and one row for each classification result.

### Usage

      ## S4 method for signature 'list'
    samplesMetricMap(results,
                         comparison = c("classificationName", "datasetName", "selectionName",
                                    "validation"),
                     metric = c("error", "accuracy"), featureValues = NULL, featureName = NULL,
                         metricColours = list(c("#3F48CC", "#6F75D8", "#9FA3E5", "#CFD1F2", "#FFFFFF"),
                                            c("#880015", "#A53F4F", "#C37F8A", "#E1BFC4", "#FFFFFF")),
                         classColours = c("#3F48CC", "#880015"), groupColours = c("darkgreen", "yellow2"),
                         fontSizes = c(24, 16, 12, 12, 12),
                      mapHeight = 4, title = "Error Comparison", showLegends = TRUE,
                     xAxisLabel = "Sample Name", showXtickLabels = TRUE,
                     yAxisLabel = "Analysis", showYtickLabels = TRUE,
                     legendSize = grid::unit(1, "lines"), plot = TRUE)
      ## S4 method for signature 'matrix'
    samplesMetricMap(results, classes,
                         metric = c("error", "accuracy"),
                         featureValues = NULL, featureName = NULL,
                         metricColours = list(c("#3F48CC", "#6F75D8", "#9FA3E5", "#CFD1F2", "#FFFFFF"),
                                            c("#880015", "#A53F4F", "#C37F8A", "#E1BFC4", "#FFFFFF")),
                         classColours = c("#3F48CC", "#880015"), groupColours = c("darkgreen", "yellow2"),
                         fontSizes = c(24, 16, 12, 12, 12),
                      mapHeight = 4, title = "Error Comparison", showLegends = TRUE,
                     xAxisLabel = "Sample Name", showXtickLabels = TRUE,
                     yAxisLabel = "Analysis", showYtickLabels = TRUE,
                     legendSize = grid::unit(1, "lines"), plot = TRUE)

### Arguments

`results` | A list of `ClassifyResult` objects. Could also be a matrix, for backwards compatibility.
`classes` | If `results` is a matrix, this is a factor vector of the same length as the number of columns that `results` has.
`comparison` | The aspect of the experimental design to compare.
`metric` | The sample-wise metric to plot.
`featureValues` | If not NULL, can be a named factor or named numeric vector specifying some variable of interest to plot underneath the class bar.
`featureName` | A label describing the information in `featureValues`. It must be specified if `featureValues` is.
`metricColours` | A vector of colours for metric levels.
`classColours` | Either a vector of colours for class levels if both classes should have same colour, or a list of length 2, with each component being a vector of the same length. The vector has the colour gradient for each class.
`groupColours` | A vector of colours for group levels. Only useful if `groups` is not NULL.
`fontSizes` | A vector of length 5. The first number is the size of the title. The second number is the size of the axes titles. The third number is the size of the axes values. The fourth number is the size of the legends' titles. The fifth number is the font size of the legend labels.
`mapHeight` | Height of the map, relative to the height of the class colour bar.
`title` | The title to place above the plot.
`showLegends` | Logical. IF FALSE, the legend is not drawn.
`xAxisLabel` | The name plotted for the x-axis. NULL suppresses label.
`showXtickLabels` | Logical. IF FALSE, the x-axis labels are hidden.
`showYtickLabels` | Logical. IF FALSE, the y-axis labels are hidden.
`yAxisLabel` | The name plotted for the y-axis. NULL suppresses label.
`legendSize` | The size of the boxes in the legends.
`plot` | Logical. IF `TRUE`, a plot is produced on the current graphics device.

### Details

The names of `results` determine the row names that will be in the plot. The length of `metricColours` determines how many bins the metric values will be discretised to.

### Value

A plot is produced and a grob is returned that can be saved to a graphics device.

### Author(s)

Dario Strbenac

### Examples

      predicted <- data.frame(sample = LETTERS[sample(10, 100, replace = TRUE)],
                              class = rep(c("Healthy", "Cancer"), each = 50))
      actual <- factor(rep(c("Healthy", "Cancer"), each = 5), levels = c("Healthy", "Cancer"))
      features <- sapply(1:100, function(index) paste(sample(LETTERS, 3), collapse = ''))
      result1 <- ClassifyResult("Example", "Differential Expression", "t-test",
                                LETTERS[1:10], features, 100, list(1:100), list(sample(10, 10)),
                                list(function(oracle){}), list(predicted), actual,
                                list("permuteFold", 100, 5))
      predicted[, "class"] <- sample(predicted[, "class"])
      result2 <- ClassifyResult("Example", "Differential Variability", "Bartlett Test",
                                LETTERS[1:10], features, 100, list(1:100), list(sample(10, 10)),
                                list(function(oracle){}), list(predicted), actual,
                                validation = list("leave", 2))
      result1 <- calcCVperformance(result1, "sample error")
      result2 <- calcCVperformance(result2, "sample error")
      groups <- factor(rep(c("Male", "Female"), length.out = 10))
      names(groups) <- LETTERS[1:10]
      cholesterol <- c(4.0, 5.5, 3.9, 4.9, 5.7, 7.1, 7.9, 8.0, 8.5, 7.2)
      names(cholesterol) <- LETTERS[1:10]

      wholePlot <- samplesMetricMap(list(Gene = result1, Protein = result2))
      wholePlot <- samplesMetricMap(list(Gene = result1, Protein = result2),
                                    featureValues = groups, featureName = "Gender")
      wholePlot <- samplesMetricMap(list(Gene = result1, Protein = result2),
                                    featureValues = cholesterol, featureName = "Cholesterol")

[Package ClassifyR version 2.8.0 Index]