runBayesSpaceClustering | R Documentation |
A wrapper around the BayesSpace clustering pipeline introduced by Zhao et al. (2021).
runBayesSpaceClustering(
object,
name = "bayes_space",
n.Pcs = 15,
n.HVGs = 2000,
skip.PCA = FALSE,
log.normalize = TRUE,
assay.type = "logcounts",
BSPARAM = BiocSingular::ExactParam(),
qs = 3:15,
burn.in = c(100, 1000),
nrep = c(1000, 50000),
use.dimred = "PCA",
d = 15,
init.method = "mclust",
model = "t",
gamma = 3,
mu0 = NULL,
lambda0 = NULL,
alpha = 1,
beta = 0.01,
save.chain = FALSE,
chain.fname = NULL,
prefix = "B",
return_model = TRUE,
empty_remove = FALSE,
overwrite = FALSE,
assign_sce = FALSE,
assign_envir = .GlobalEnv,
seed = 123,
verbose = NULL,
...
)
object |
An object of class |
name |
Character value. The name the cluster variable has in
the feature data of the |
n.HVGs |
Number of highly variable genes to run PCA upon. |
skip.PCA |
Skip PCA (if dimensionality reduction was previously computed.) |
log.normalize |
Whether to log-normalize the input data with scater. May be omitted if log-normalization previously computed. |
assay.type |
Name of assay in |
BSPARAM |
A BiocSingularParam object specifying which
algorithm should be used to perform the PCA. By default, an exact PCA is
performed, as current spatial datasets are generally small (<10,000 spots).
To perform a faster approximate PCA, please specify
|
qs |
The values of q to evaluate. If |
burn.in , nrep |
Integers specifying the range of repetitions to compute. |
use.dimred |
Name of a reduced dimensionality result in
|
d |
Number of top principal components to use when clustering. |
init.method |
If |
model |
Error model. ('normal' or 't') |
gamma |
Smoothing parameter. Defaults to 2 for |
mu0 |
Prior mean hyperparameter for mu. If not provided, mu0 is set to the mean of PCs over all spots. |
lambda0 |
Prior precision hyperparam for mu. If not provided, lambda0
is set to a diagonal matrix |
alpha |
Hyperparameter for Wishart distributed precision lambda. |
beta |
Hyperparameter for Wishart distributed precision lambda. |
save.chain |
If true, save the MCMC chain to an HDF5 file. |
chain.fname |
File path for saved chain. Tempfile used if not provided. |
prefix |
Character value. Prefix of the cluster groups. |
overwrite |
Logical value. If TRUE, |
assign_sce |
Character value or |
verbose |
Logical. If (Warning messages will always be printed.) |
... |
Additional arguments given to |
q_force |
Numeric value or |
This function is a wrapper around readVisium()
,
spatialPreprocess()
, qTune()
and spatialCluster()
of the BayesSpace
package. The results are stored in form of a grouping
variable in the feature data.frame of the returned SPATA2
object.
The updated input object, containing the added, removed or computed results.
Zhao E, Stone MR, Ren X, Guenthoer J, Smythe KS, Pulliam T, Williams SR, Uytingco CR, Taylor SEB, Nghiem P, Bielas JH, Gottardo R. Spatial transcriptomics at subspot resolution with BayesSpace. Nat Biotechnol. 2021 Nov;39(11):1375-1384. doi: 10.1038/s41587-021-00935-2. Epub 2021 Jun 3. PMID: 34083791; PMCID: PMC8763026.
plotLoglik()
, find_elbow_point()
library(SPATA2)
data("example_data")
object <- example_data$object_UKF313T_diet
# tests options for q from 3 to 15 and picks the best
object <- runBayesSpaceClustering(object, name = "new_bspace", qs = 3:15)
plotLoglik(object)
# run with q = 10 to force 10 clusters in the output
object <- runBayesSpaceClustering(object, name = "bspace_10", qs = 10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.