R/evalMetrics.R
distErrorPlot.RdGenerate violin plots or box plots to show how the errors are distributed by
proportion bins of 0.1. Errors can be displayed all mixed or split by cell
type (CellType) or number of cell types present in the samples
(nCellTypes). See the facet.by argument and examples for more
details.
distErrorPlot(
object,
error,
colors,
x.by = "pBin",
facet.by = NULL,
color.by = "nCellTypes",
filter.sc = TRUE,
error.label = FALSE,
pos.x.label = 4.6,
pos.y.label = NULL,
size.point = 0.1,
alpha.point = 1,
type = "violinplot",
ylimit = NULL,
nrow = NULL,
ncol = NULL,
title = NULL,
theme = NULL,
...
)DigitalDLSorter object with
trained.model slot containing metrics in the
test.deconv.metrics slot of a
DigitalDLSorterDNN object.
The error to be represented. Available errors are absolute error
('AbsErr'), proportional absolute error ('ppAbsErr'), squared
error ('SqrErr') and proportional squared error ('ppSqrErr').
Vector of colors to be used. Only vectors with a number of
colors equal to or greater than the levels of color.by will be
accepted. By default, a custom color list is used.
Variable used for the X-axis. When facet.by is not
NULL, the best choice is pBin (probability bins). The options
are nCellTypes (number of different cell types), CellType
(cell type) and pBin.
Variable used to display data in different panels. If
NULL, the plot is not split into different panels. Options are
nCellTypes (number of different cell types) and CellType
(cell type).
Variable used to color the data. Options are
nCellTypes and CellType.
Boolean indicating whether single-cell profiles are filtered
out and only errors associated with pseudo-bulk samples are displayed
(TRUE by default).
Boolean indicating whether to display the average error as
a plot annotation (FALSE by default).
X-axis position of error annotations.
Y-axis position of error annotations.
Size of points (0.1 by default).
Alpha of points (0.1 by default).
Type of plot: 'boxplot' or 'violinplot'. The latter
by default.
Upper limit in Y-axis if it is required (NULL by
default).
Number of rows if facet.by is not NULL.
Number of columns if facet.by is not NULL.
Title of the plot.
ggplot2 theme.
Additional arguments for the facet_wrap function
from ggplot2 if facet.by is not NULL.
A ggplot object with the representation of the desired errors.
if (FALSE) { # \dontrun{
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 <- createDDLSobject(
sc.data = sce,
sc.cell.ID.column = "Cell_ID",
sc.gene.ID.column = "Gene_ID",
sc.filt.genes.cluster = FALSE,
sc.log.FC = FALSE
)
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 <- trainDDLSModel(
object = DDLS,
on.the.fly = TRUE,
batch.size = 15,
num.epochs = 5
)
# evaluation using test data
DDLS <- calculateEvalMetrics(
object = DDLS
)
# representation, for more examples, see the vignettes
distErrorPlot(
object = DDLS,
error = "AbsErr",
facet.by = "CellType",
color.by = "nCellTypes",
error.label = TRUE
)
distErrorPlot(
object = DDLS,
error = "AbsErr",
x.by = "CellType",
facet.by = NULL,
filter.sc = FALSE,
color.by = "CellType",
error.label = TRUE
)
} # }