Skip to contents

Data preparation

Quality control of genes, the tissue boundary, gridding of cell locations and expression, and the Stan data with the inputs of the Hilbert space Gaussian process (HSGP).

denmark_from_seurat()
Cell table from a Seurat object
denmark_filter_genes()
Quality-control filter for genes
denmark_alpha_shape()
Tissue boundary as an alpha shape of the cell locations
buildgridpp()
Discretize cell locations and expression on a regular grid
grid_pts_centroid()
Grid centroids, grid area and number of grids
denmark_hsgp_indices()
HSGP basis-function index matrix
denmark_prepare()
Build the Stan data list for DenMark

Model fitting

Fit the DenMark model, which estimates the density-expression correlation rho.

DenMark() print(<denmark>)
Fit DenMark to one gene
DenMarkmain()
Backward-compatible wrapper of the original DenMark interface
denmark_model()
Compile (once) and return the DenMark cmdstanr model
denmark_init()
Initial values for DenMark

Posterior summaries and interpretation

Posterior summaries, draws of rho and the coregionalization coefficients, latent-field decomposition, spatial correlation decay and checks of the HSGP approximation.

denmark_summary()
Posterior summary of the key DenMark parameters
denmark_draws()
Harmonized posterior draws
denmark_fields()
Latent-field decomposition for every grid cell
denmark_decay()
Spatial correlation decay of the two latent processes
denmark_check_hsgp()
Rule-of-thumb check of the HSGP approximation

DCG discovery

Fit many genes and call positively and negatively density-correlated genes from the credible interval of rho.

denmark_scan()
Fit DenMark gene by gene and call density-correlated genes (DCG)
denmark_annotate()
Write DenMark scan results into a Seurat object

Visualization

plot_denmark_boundary()
Tissue boundary and grid classification
plot_denmark_grid()
Gridded cell counts (Y) and summed expression (M)
plot_denmark_fields()
Latent-field decomposition maps (posterior means)
plot_denmark_decay()
Spatial correlation decay curves with posterior bands
plot_denmark_scan()
Forest plot of rho across genes from denmark_scan()

Simulation and toy data

denmark_simulate()
Simulate a marked point pattern from the DenMark data-generating process
denmark_toy_data()
Toy data with a known answer

Utilities

denmark_save() denmark_load()
Save and load a DenMark fit
matern32()
Matern (nu = 3/2) covariance
q2.5() q25() q50() q75() q97.5()
Posterior quantile helpers