
Generate correlation plots between predicted and expected cell type
proportions of test data. Correlation plots can be shown all mixed or either
split by cell type (CellType
) or the number of different cell types
present in the spots (nCellTypes
).
corrExpPredPlot(
object,
colors,
facet.by = NULL,
color.by = "CellType",
corr = "both",
filter.sc = TRUE,
pos.x.label = 0.01,
pos.y.label = 0.95,
sep.labels = 0.15,
size.point = 0.1,
alpha.point = 1,
ncol = NULL,
nrow = NULL,
title = NULL,
theme = NULL,
...
)
A ggplot object.
SpatialDDLS
object with
trained.model
slot containing metrics in the
test.deconv.metrics
slot of a DeconvDLModel
object.
Vector of colors to be used.
Show data in different panels. Options are nCellTypes
(number of different cell types) and CellType
(cell type)
(NULL
by default).
Variable used to color data. Options are nCellTypes
and CellType
.
Correlation value shown as an annotation on the plot. Available
metrics are Pearson's correlation coefficient ('pearson'
) and
concordance correlation coefficient ('ccc'
). It can be
'pearson'
, 'ccc'
or 'both'
(by default).
Boolean indicating whether single-cell profiles are filtered
out and only mixed transcriptional profile errors are shown (TRUE
by
default).
X-axis position of correlation annotations (0.95 by default).
Y-axis position of correlation annotations (0.1 by default).
Space separating annotations if corr
is equal to
'both'
(0.15 by default).
Size of points (0.1 by default).
Alpha of points (0.1 by default).
Number of columns if facet.by
is other than NULL
.
Number of rows if facet.by
is different from NULL
.
Title of the plot.
ggplot2 theme.
Additional arguments for the facet_wrap function
of ggplot2 if facet.by
is not NULL
.
calculateEvalMetrics
distErrorPlot
blandAltmanLehPlot
barErrorPlot
# \donttest{
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))
)
)
SDDLS <- createSpatialDDLSobject(
sc.data = sce,
sc.cell.ID.column = "Cell_ID",
sc.gene.ID.column = "Gene_ID",
sc.filt.genes.cluster = FALSE
)
SDDLS <- genMixedCellProp(
object = SDDLS,
cell.ID.column = "Cell_ID",
cell.type.column = "Cell_Type",
num.sim.spots = 50,
train.freq.cells = 2/3,
train.freq.spots = 2/3,
verbose = TRUE
)
SDDLS <- simMixedProfiles(SDDLS)
# training of DDLS model
SDDLS <- trainDeconvModel(
object = SDDLS,
batch.size = 15,
num.epochs = 5
)
# evaluation using test data
SDDLS <- calculateEvalMetrics(object = SDDLS)
# correlations by cell type
corrExpPredPlot(
object = SDDLS,
facet.by = "CellType",
color.by = "CellType",
corr = "both"
)
# correlations of all samples mixed
corrExpPredPlot(
object = SDDLS,
facet.by = NULL,
color.by = "CellType",
corr = "ccc",
pos.x.label = 0.2,
alpha.point = 0.3
)
# }
Run the code above in your browser using DataLab