barErrorPlot: Generate bar error plots

View source: R/evalMetrics.R

barErrorPlotR Documentation

Generate bar error plots

Description

Generate bar error plots by cell type (CellType) or by number of different cell types (nCellTypes) on test pseudo-bulk samples.

Usage

barErrorPlot(
  object,
  error = "MSE",
  by = "CellType",
  dispersion = "se",
  filter.sc = TRUE,
  title = NULL,
  angle = NULL,
  theme = NULL
)

Arguments

object

DigitalDLSorter object with trained.model slot containing metrics in test.deconv.metrics slot.

error

'MAE' or 'MSE'.

by

Variable used to display errors. Available options are: 'nCellTypes', 'CellType'.

dispersion

Standard error ('se') or standard deviation ('sd'). The former is the default.

filter.sc

Boolean indicating whether single-cell profiles are filtered out and only correlation of results associated with bulk samples are displayed (TRUE by default).

title

Title of the plot.

angle

Angle of ticks.

theme

ggplot2 theme.

Value

A ggplot object with the mean and dispersion of the errors

See Also

calculateEvalMetrics corrExpPredPlot distErrorPlot blandAltmanLehPlot

Examples

## Not run: 
set.seed(123)
sce <- SingleCellExperiment::SingleCellExperiment(
  assays = list(
    counts = matrix(
      rpois(30, lambda = 5), nrow = 15, ncol = 20,
      dimnames = list(paste0("Gene", seq(15)), paste0("RHC", seq(20)))
    )
  ),
  colData = data.frame(
    Cell_ID = paste0("RHC", seq(20)),
    Cell_Type = sample(x = paste0("CellType", seq(6)), size = 20,
                       replace = TRUE)
  ),
  rowData = data.frame(
    Gene_ID = paste0("Gene", seq(15))
  )
)
DDLS <- loadSCProfiles(
  single.cell.data = sce,
  cell.ID.column = "Cell_ID",
  gene.ID.column = "Gene_ID"
)
probMatrixValid <- data.frame(
  Cell_Type = paste0("CellType", seq(6)),
  from = c(1, 1, 1, 15, 15, 30),
  to = c(15, 15, 30, 50, 50, 70)
)
DDLS <- generateBulkCellMatrix(
  object = DDLS,
  cell.ID.column = "Cell_ID",
  cell.type.column = "Cell_Type",
  prob.design = probMatrixValid,
  num.bulk.samples = 50,
  verbose = TRUE
)
# training of DDLS model
tensorflow::tf$compat$v1$disable_eager_execution()
DDLS <- trainDigitalDLSorterModel(
  object = DDLS,
  on.the.fly = TRUE,
  batch.size = 15,
  num.epochs = 5
)
# evaluation using test data
DDLS <- calculateEvalMetrics(
  object = DDLS
)
# bar error plots
barErrorPlot(
  object = DDLS,
  error = "MSE",
  by = "CellType"
)
barErrorPlot(
  object = DDLS,
  error = "MAE",
  by = "nCellTypes"
)

## End(Not run)


digitalDLSorteR documentation built on Oct. 5, 2022, 9:05 a.m.