Skip to content
/ spASE Public

detecting spatial patterns of allele-specific expression

License

Notifications You must be signed in to change notification settings

lulizou/spASE

Repository files navigation

spASE

R package for detecting 2D spatial patterns of allele-specific expression in spatial transcriptomics data while controlling for cell type. Provides functions for estimating, plotting, and testing for significant ASE patterns. This repository also contains the code to reproduce the results in the manuscript.

Installation

devtools::install_github("lulizou/spASE")

Quick start

The main input to spASE includes:

  • maternal counts matrix (rows are genes, columns are spots or cells)
  • paternal counts matrix
  • spatial coordinates.

Note that spASE currently modifies many functions from the spacexr package, so it is always good to load them in order so that the spASE version is used:

library(spacexr)
library(spASE)

Hypothesis testing

Testing for…

  1. Overall bias (i.e. pseudo-bulk):
bias_results <- scase(
  matrix1 = maternal_counts_matrix,
  matrix2 = paternal_counts_matrix,
  min.cells = 100, # set to something reasonable
  cores = 1, # can add more
  verbose = T # to enable progress bar
)

Note that this can also be run on a subset of genes by specifying them as a string vector using the genes = c(...) argument.

  1. Overall spatial pattern (i.e. no cell type effect):
overall_spatial_results <- spase(
  matrix1 = maternal_counts_matrix,
  matrix2 = paternal_counts_matrix,
  covariates = coords,
  min.pixels = 100, # set to something reasonable
  cores = 1, # can add more
  verbose = T # to enable progress bar
)

Note that coords must have the first column as the pixel ID (matching the column names of the count matrices) and the second two columns as the spatial coordinates.

Visualization

Once you have overall_spatial_results, we can visualize using the plotSpase function as follows:

plotSpase(
  matrix1 = maternal_counts_matrix,
  matrix2 = paternal_counts_matrix,
  covariates = coords,
  spasefit = overall_spatial_results,
  coords = NULL, # to downsample could set e.g coords = coords |> sample_n(1e4)
)

Reproducibility

The data is available in the Broad single cell portal at SCP1692.

To reproduce the results in the manuscript, see the analysis folder. To see the knitted Quarto documents, see:

Citation

The (old) pre-print is here.

About

detecting spatial patterns of allele-specific expression

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages