knitr::opts_chunk$set(echo = TRUE)
R
is required to use scDist
. In development, R
version 4.0.0 and greater were used, but there may be compatibility with previous versions.
From the R console, devtools::install_github("phillipnicol/scDist")
. Installation should take less than a minute on a standard machine.
The input to scDist
is a normalized count matrix and correpsonding metadata that describes what condition and patient each cell belongs to. In this demo, we create a simulated dataset with 10 cell types. The demo should take less than a minute to run on a standard machine. The code is also modifiable to see how scDist
performs for different parameter values.
library(scDist) set.seed(1126490984)
Generate simulated data with 10 cell types and 5 patients in each group:
sim <- simData(nct=10,N1=5,N2=5) dim(sim$Y) #Normalized counts rownames(sim$Y) <- 1:1000 head(sim$meta.data)
Now we apply scDist:
out <- scDist(sim$Y,sim$meta.data,fixed.effects = "response", random.effects="patient", clusters="clusters")
The results data frame gives a summary of the estimated distance and uncertainty for each cell type
out$results
The true distances are
names(sim$D.true) <- letters[1:length(sim$D.true)] sim$D.true
We can also plot the results
DistPlot(out)
To get a plot of genes that are associated with the perturbation use distGenes
:
distGenes(out, cluster = "a")
If you use scDist
in your work, please cite:
Nicol, P.B., Paulson, D., Qian, G., Liu, X.S., Irizarry, R.A., and Sahu, A.D. (2024). Robust identification of perturbed cell types in single-cell RNA-seq data. Nature Communications. Vol 15(7610). https://doi.org/10.1038/s41467-024-51649-3.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.