blandAltmanLehPlot: Generate Bland-Altman agreement plots between predicted and...

Description Usage Arguments Value See Also Examples

View source: R/evalMetrics.R

Description

Generate Bland-Altman agreement plots between predicted and expected cell type proportions from test data results. The Bland-Altman agreement plots can be displayed all mixed or split by cell type (CellType) or the number of cell types present in samples (nCellTypes). See the facet.by argument and examples for more information.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
blandAltmanLehPlot(
  object,
  colors,
  color.by = "CellType",
  facet.by = NULL,
  log.2 = FALSE,
  filter.sc = TRUE,
  density = TRUE,
  color.density = "darkblue",
  size.point = 0.05,
  alpha.point = 1,
  ncol = NULL,
  nrow = NULL,
  title = NULL,
  theme = NULL,
  ...
)

Arguments

object

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

colors

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.

color.by

Variable used to color data. Options are nCellTypes and CellType.

facet.by

Variable used to display the data in different panels. If NULL, the plot is not split into different panels. Options are nCellTypes (by number of different cell types) and CellType (by cell type).

log.2

Whether to display the Bland-Altman agreement plot in log2 space (FALSE by default).

filter.sc

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

density

Boolean indicating whether density lines must be displayed (TRUE by default).

color.density

Color of density lines if the density argument is TRUE.

size.point

Size of the points (0.1 by default).

alpha.point

Alpha of the points (0.1 by default).

ncol

Number of columns if facet.by is used.

nrow

Number of rows if facet.by is used.

title

Title of the plot.

theme

ggplot2 theme.

...

Additional argument for the facet_wrap function from ggplot2 if facet.by is not NULL.

Value

A ggplot object with Bland-Altman agreement plots between expected and actual proportions.

See Also

calculateEvalMetrics corrExpPredPlot distErrorPlot barErrorPlot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## 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
)
# Bland-Altman plot by cell type
blandAltmanLehPlot(
  object = DDLS,
  facet.by = "CellType",
  color.by = "CellType"
)
# Bland-Altman plot of all samples mixed
blandAltmanLehPlot(
  object = DDLS,
  facet.by = NULL,
  color.by = "CellType",
  alpha.point = 0.3,
  log2 = TRUE
)

## End(Not run)

digitalDLSorteR documentation built on Oct. 20, 2021, 1:07 a.m.