The spatial view behind plotResponseCurve(). For one image per condition
arm: a smooth kernel-density map of the neighbour type with the focal cells
overlaid and coloured by expression (top), and expression against neighbour
density for the same cells with a fitted line (bottom). Colour scales are
shared across the panels so the arms are directly comparable.
Usage
plotResponseMap(
object,
spe,
gene,
focal,
neighbour,
images = NULL,
kde_h = 60,
ngrid = 200,
scalebar_len = 100
)Arguments
- object
A PACEFit fitted with a
condition_col.- spe
The SpatialExperiment::SpatialExperiment that was fitted.
- gene, focal, neighbour
Gene, focal cell type and neighbour cell type.
- images
Optional named character vector of image identifiers, one per arm. The default picks, for each arm, the image with the most focal cells.
- kde_h, ngrid
Kernel bandwidth and grid size for the density map.
- scalebar_len
Scale-bar length in micrometres.
Examples
spe <- readRDS(system.file("extdata", "mel_cosmx_subset.rds", package = "PACE"))
# \donttest{
fit <- paceFit(spe, celltype_col = "cellType", condition_col = "Responder",
image_col = "image", kernel_per_image = TRUE,
image_re = "intercept", verbose = FALSE)
#> - Computing 180 x 298 likelihood matrix.
#> - Likelihood calculations took 0.04 seconds.
#> - Fitting model with 298 mixture components.
#> - Model fitting took 0.23 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:B_Cell: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 0, expected false sign = 0.0
#> - Computing 180 x 375 likelihood matrix.
#> - Likelihood calculations took 0.05 seconds.
#> - Fitting model with 375 mixture components.
#> - Model fitting took 0.38 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> - Computing 180 x 579 likelihood matrix.
#> - Likelihood calculations took 0.08 seconds.
#> - Fitting model with 579 mixture components.
#> - Model fitting took 0.68 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:Endothelial: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 24, expected false sign = 0.3
#> - Computing 180 x 364 likelihood matrix.
#> - Likelihood calculations took 0.05 seconds.
#> - Fitting model with 364 mixture components.
#> - Model fitting took 0.32 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:Fibroblast: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 1, expected false sign = 0.0
#> - Computing 180 x 243 likelihood matrix.
#> - Likelihood calculations took 0.03 seconds.
#> - Fitting model with 243 mixture components.
#> - Model fitting took 0.23 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> - Computing 180 x 375 likelihood matrix.
#> - Likelihood calculations took 0.05 seconds.
#> - Fitting model with 375 mixture components.
#> - Model fitting took 0.39 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:Macrophage: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 13, expected false sign = 0.1
#> - Computing 180 x 364 likelihood matrix.
#> - Likelihood calculations took 0.05 seconds.
#> - Fitting model with 364 mixture components.
#> - Model fitting took 0.21 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> - Computing 180 x 562 likelihood matrix.
#> - Likelihood calculations took 0.08 seconds.
#> - Fitting model with 562 mixture components.
#> - Model fitting took 0.28 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:T_Cell: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 13, expected false sign = 0.1
#> - Computing 180 x 265 likelihood matrix.
#> - Likelihood calculations took 0.04 seconds.
#> - Fitting model with 265 mixture components.
#> - Model fitting took 0.31 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> - Computing 180 x 409 likelihood matrix.
#> - Likelihood calculations took 0.06 seconds.
#> - Fitting model with 409 mixture components.
#> - Model fitting took 0.68 seconds.
#> - Computing posterior matrices.
#> - Computation allocated took 0.00 seconds.
#> [mashr] ResponderPD:Tumour: 180 genes shrunk; gene-focal calls (lfsr<0.05) = 25, expected false sign = 0.2
plotResponseMap(fit, spe, "SPP1", "Macrophage", "Tumour")
# }
