CytoSignal provides quantitative inference on ligand-receptor interactions at cell/spot level within a single spatial transcriptomics dataset, with dedicated modeling to diffusion-dependent and contact-dependent molecules. This has been demonstrated in the basic tutorial.
In this tutorial, we further extend our analysis to combine covariates contributed from multiple datasets. We use a negative binomial regression model to estimate the effect size of each covariate on the LRscore for each interaction. This allows us to flexibly incorporate any information available, including cell type or region annotations, case/control status, replicate structure, and other covariates such as age or sex.
In this tutorial, we present the analysis performed on a mouse model of Parkinson’s disease, which is described in our manuscript in detail. The published dataset contains Stereo-Seq data from the brains of 18 mice (9 young and 9 old) (Kilfeather, P., et. al. Cell Reports, 2024). We take the subset of 9 samples, OLD_OVX_1-5 and YOUNG_OVX_1-4, that harbor a genetic knockout that results in age-related pathology similar to Parkinson’s disease in humans. We will show how to use CytoSignal to identify ligand/receptor interactions showing significant changes in signaling activity between the young and old mouse brains.
Click to download the preprocessed example dataset: Fig5_PKdataset_sub.RDS /TODO/
Optionally, users can download the dataset with the following R commands:
saveDir <- tempdir()
# Or optionally
# saveDir <- '/path/to/your/directory'
destfile <- file.path(saveDir, 'Fig5_PKdataset_sub.RDS')
destfile <- '/Users/wangych/work/Welch_Lab/cytosignal/Fig5_PKdataset_sub.RDS' # TODO to be deleted when finished
if (!file.exists(destfile)) {
download.file('https://path/to/filename.rds', destfile = destfile)
}
The RDS file provided contains a mergedCytoSignal
object, which is produced by merging 9 individual
CytoSignal objects analyzed following the basic
tutorial. We directly load the prepared
mergedCytoSignal object for convenience, while the method
to create such an object is introduced in the following sub-section.
library(cytosignal)
multics <- readRDS(destfile)
multics
#> An object of class mergedCytoSignal
#> - Number of spots: 178166
#> - Number of datasets (9): "OLD_OVX_1", "OLD_OVX_2", "OLD_OVX_3", "OLD_OVX_4", "OLD_OVX_5", "YOUNG_OVX_1", "YOUNG_OVX_2", "YOUNG_OVX_3", "YOUNG_OVX_4"
#> - Metadata variables (9): "originalID", "sample_name", "dataset", "clusters", "x", "y", "age", "genotype", "total_counts"
#> - Number of diffusible ligand-receptor pairs: 215
#> - Number of contact-dependent ligand-receptor pairs: 50
mergedCytoSignal objectThe multi-dataset analysis starts with CytoSignal
objects for each. Please review the basic
tutorial for details on how to create these objects. The individual
CytoSignal objects are not required to be fully analyzed but only
preprocessing is needed, including call of functions
addIntrDB(), removeLowQuality(),
changeUniprot() and inferEpsParams().
# NOT EXECUTED, EXAMPLE ONLY
# For each dataset
cs1 <- createCytoSignal(
raw.data = raw.counts.dgCMatrix,
clusters = cluster.factor.named,
cells.loc = spatial.coords.cell.on.row.matrix
)
cs1 <- addIntrDB(cs1, g_to_u, db.diff, db.cont, inter.index)
cs1 <- removeLowQuality(cs1)
cs1 <- changeUniprot(cs1)
cs1 <- inferEpsParams(cs1, scale.factor = how.many.um.per.unit)
Assuming that we have four datasets, preprocessed and loaded as
cs1, cs2, cs3 and
cs4. Representing conditions of two controls and two
diseases. We then construct a mergedCytoSignal object by
combining the four datasets. The function mergeCytoSignal()
takes a list of CytoSignal objects and a metadata
data.frame describing the covariates on each dataset.
Preprocessing on each dataset will be automatically conducted to ensure
LRscores being tested against are tuned for the negative binomial
regression model.
# NOT EXECUTED, EXAMPLE ONLY
dataset.meta <- data.frame(
condition = factor(c("control", "control", "disease", "disease"))#,
# can also include
# age = factor(c('young', 'old', 'young', 'old')),
# ...
)
multics <- mergeCytoSignal(list(cs1, cs2, cs3, cs4), metadata = dataset.meta)
The multi-dataset test is implemented with the function
runNEBULA(). NEBULA is an external tool that powers the
fast nagative binomial mixed model (He, L. et.
al. Commun Biol, 2021). The function takes the
mergedCytoSignal object as an input and test over one or
more covariates specified with argument covariates. In this
example, we test with covariates = c('clusters', 'age'),
which means we will test the effect of each cell type and each age class
on the LRscores of the interactions. Argument cpc_thresh
sets a cutoff on the total sum of one interaction divided by the number
of all cells/spots in the object. We set a low cpc_thresh
value here to have as many interactions to be tested as possible.
multics <- runNEBULA(multics, covariates = c('clusters', 'age'), cpc_thresh = 0.001, ncore = 4)
During the test, categorical variables will be decomposed to as many binary variables as the number of classes minus one, while continuous variables will be treated as is. There will be a statistics table generated for each variable. To show all available variable names:
showCov(multics)
#> [1] "clusters_ASTRO 1" "clusters_ASTRO 2" "clusters_Cartpt+"
#> [4] "clusters_CORTEX ERYTH" "clusters_CORTEX Tshz2+" "clusters_DG GRANULE"
#> [7] "clusters_DOPA SN" "clusters_DOPA VTA" "clusters_DORSAL SUBIC"
#> [10] "clusters_EX CA1" "clusters_EX CA3" "clusters_EX L1"
#> [13] "clusters_EX L2/3" "clusters_EX L4" "clusters_EX L5"
#> [16] "clusters_EX L6" "clusters_EX MB" "clusters_IN Adarb2+"
#> [19] "clusters_IN MB" "clusters_IN Pvalb+" "clusters_IN Sst+"
#> [22] "clusters_MB ERYTH" "clusters_MENINGES" "clusters_MICROGLIA"
#> [25] "clusters_OLIGO" "clusters_OPC" "clusters_THALAMUS"
#> [28] "clusters_VENTRAL SUBIC" "age_YOUNG"
To fetch the statistics table for a specific variable shown above
(e.g. "age_YOUNG", standing for class “YOUNG” in original
covariate “age”), for diffusion-dependent interactions (use slot
diff.results here, cont.results for
contact-dependent ones), users need to access the
diff.results slot and fetch the item
"age_YOUNG". Below is an example of showing the top 5
significant interactions affected by the variable
"age_YOUNG".
diff_age_YOUNG <- multics@diff.results$age_YOUNG
diff_age_YOUNG[order(diff_age_YOUNG$padj)[1:5],]
#> interaction logFC se p padj
#> 91 NRG3-ERBB4 -0.7631994 0.08772026 3.307835e-18 3.208599e-16
#> 54 FGF2-CD44 -1.9592813 0.38328976 3.191885e-07 1.548064e-05
#> 48 OSTP-CD44 -1.4926857 0.30005447 6.534338e-07 2.112769e-05
#> 51 HGF-CD44 -2.0971903 0.43369987 1.327581e-06 3.219384e-05
#> 79 RSPO3-LGR4 -1.6062999 0.34893512 4.155803e-06 8.062257e-05
We provide function plotNebulaVolcano() to visualize all
interactions affected by a single variable on a volcano plot. Here we
separately make the volcano plots for diffusion-dependent and
contact-dependent interactions. This function also features interactive
browser mode, powered by Plotly, when setting
interactive = TRUE.
plotNebulaVolcano(
multics, covariate = 'age_YOUNG', intr.type = 'diff',
fdrThresh = 0.05, logfcThresh = 0.1, interactive = FALSE
)
#> Warning: ggrepel: 37 unlabeled data points (too many overlaps). Consider
#> increasing max.overlaps
plotNebulaVolcano(
multics, covariate = 'age_YOUNG', intr.type = 'cont',
fdrThresh = 0.05, logfcThresh = 0.1, interactive = FALSE
)
Positive logFC values indicate up-regulated signaling within the class specified by the variable. In the example above, interaction ‘OSTP-CD44’, a.k.a. Spp1-Cd44 signaling in mouse, is tested with negative logFC value and high -log10(padj). This indicates its significant up-regulation in non-YOUNG group, which is “OLD”. This observation of increased signaling activity in the old mice is consistent with the finding reported in the original study.
Furthermore, we also provide a faceted bubble plot to show the result of all variables. This can be helpful for quickly identifying the variable that has the most differentially signaling interactions.
plotNebulaAll(multics, intr.type = 'diff')
plotNebulaAll(multics, intr.type = 'cont')