Skip to contents

paceFit() runs the full pipeline in one call: paceModel() -> paceShrink() -> paceDecompose() -> paceDrivers(). For step-by-step control (inspecting the fitted model, re-running the downstream without refitting), call those stages directly.

Usage

paceFit(object, ...)

# S4 method for class 'SpatialExperiment'
paceFit(object, ..., pairs = NULL)

Arguments

object

A SpatialExperiment::SpatialExperiment.

...

Arguments passed to paceModel() (celltype_col, image_col, contamination, dispersion, ...).

pairs

Optional list of focal-neighbour pairs for the driver tables.

Value

A fully populated PACEFit.

Examples

spe <- readRDS(system.file("extdata", "bc_xenium_subset.rds", package = "PACE"))
# \donttest{
fit <- paceFit(spe, celltype_col = "cellType", verbose = FALSE)
#>  - Computing 278 x 313 likelihood matrix.
#>  - Likelihood calculations took 0.09 seconds.
#>  - Fitting model with 313 mixture components.
#>  - Model fitting took 0.22 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] B_Cell: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 0, expected false sign = 0.0
#>   [mashr] term 'Dendritic_Cell': fewer than two varying conditions, using independence
#>  - Computing 278 x 92 likelihood matrix.
#>  - Likelihood calculations took 0.02 seconds.
#>  - Fitting model with 92 mixture components.
#>  - Model fitting took 0.06 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] Dendritic_Cell: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 0, expected false sign = 0.0
#>  - Computing 278 x 404 likelihood matrix.
#>  - Likelihood calculations took 0.11 seconds.
#>  - Fitting model with 404 mixture components.
#>  - Model fitting took 0.28 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] Endothelial: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 2, expected false sign = 0.0
#>  - Computing 278 x 417 likelihood matrix.
#>  - Likelihood calculations took 0.12 seconds.
#>  - Fitting model with 417 mixture components.
#>  - Model fitting took 0.46 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] Macrophage: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 5, expected false sign = 0.0
#>   [mashr] term 'Myoepithelial': fewer than two varying conditions, using independence
#>  - Computing 278 x 92 likelihood matrix.
#>  - Likelihood calculations took 0.00 seconds.
#>  - Fitting model with 92 mixture components.
#>  - Model fitting took 0.05 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] Myoepithelial: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 0, expected false sign = 0.0
#>  - Computing 278 x 391 likelihood matrix.
#>  - Likelihood calculations took 0.11 seconds.
#>  - Fitting model with 391 mixture components.
#>  - Model fitting took 0.25 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] Stromal: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 3, expected false sign = 0.0
#>  - Computing 278 x 430 likelihood matrix.
#>  - Likelihood calculations took 0.12 seconds.
#>  - Fitting model with 430 mixture components.
#>  - Model fitting took 0.26 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>  - Computing 278 x 628 likelihood matrix.
#>  - Likelihood calculations took 0.17 seconds.
#>  - Fitting model with 628 mixture components.
#>  - Model fitting took 0.39 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.00 seconds.
#>   [mashr] T_Cell: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 21, expected false sign = 0.1
#>  - Computing 278 x 404 likelihood matrix.
#>  - Likelihood calculations took 0.11 seconds.
#>  - Fitting model with 404 mixture components.
#>  - Model fitting took 0.57 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.01 seconds.
#>  - Computing 278 x 590 likelihood matrix.
#>  - Likelihood calculations took 0.16 seconds.
#>  - Fitting model with 590 mixture components.
#>  - Model fitting took 0.82 seconds.
#>  - Computing posterior matrices.
#>  - Computation allocated took 0.01 seconds.
#>   [mashr] Tumour: 278 genes shrunk; gene-focal calls (lfsr<0.05) = 30, expected false sign = 0.1
head(neighbourSlopes(fit))
#>     gene  focal neighbour   term      estimate   std.error estimate_shrunk
#> 1 ABCC11 B_Cell    B_Cell B_Cell -1.968907e-05 0.001376136               0
#> 2  ACTA2 B_Cell    B_Cell B_Cell -9.976959e-05 0.004245639               0
#> 3  ACTG2 B_Cell    B_Cell B_Cell  1.418293e-03 0.005170493               0
#> 4  ADAM9 B_Cell    B_Cell B_Cell  3.277669e-05 0.003072945               0
#> 5 ADGRE5 B_Cell    B_Cell B_Cell  8.125366e-04 0.005304314               0
#> 6  ADH1B B_Cell    B_Cell B_Cell -3.142857e-05 0.002131910               0
#>   sd_shrunk lfsr
#> 1         0    1
#> 2         0    1
#> 3         0    1
#> 4         0    1
#> 5         0    1
#> 6         0    1
# }