Through deconvolution and clustering information, the SpaTopic obtains CellTopics representing the spatial domains.
Usage
CellTopic(
spot_celltype,
spot_clusters,
cluster = NULL,
num_topics = NULL,
percent = NULL,
Binarization = FALSE,
meta.cell = FALSE,
k = NULL,
method = "complete"
)
Arguments
- spot_celltype
A data frame of the result of deconvolution, row is spot, col is celltype.
- spot_clusters
A data frame contains clustering information for spots, row is spots.
- cluster
A character. Use the first column in spot_clusters as the column name if
NULL
. Or provide your own column names that represent clustering information in spot_clusters.- num_topics
A integer or a vector of integer. The number of topics. default is
NULL
, find the best number of topics by default. if a vector of integer, find the best number of topics by the given range.- percent
A numeric from
0
to1
. The percent of topics. Default is0.6
.- Binarization
Logical indicating if to choose one topic for each CellTopic. Default is
FALSE
.- meta.cell
Logical indicating if return MetaTopic, which is a data frame of the cluster result of CellTopic.
- k
A integer of how much MetaTopic to choose. If
meta.cell = TRUE
,k
is Requested to given. Default is4
.- method
See
hclust
.
Value
A list with three data frame and one vector. "CellTopic" is a data frame which can be add to a Seurat object. The "domain_topic" is a data frame, row is CellTopic and col is domain. The "celltype_topic" is a data frame, row is celltype and col is CellTopic. The "Cell_topic" is a vector of which topic be chosen in each CellTopic. If meta.cell = TRUE, the "MetaTopic" will be given, which is a data frame of the cluster result of CellTopic.
Examples
options (warn = -1)
result_list <- CellTopic(spot_celltype,
spot_clusters,
cluster = "spatial.cluster",
num_topics = 13,
percent = 0.7,
Binarization = FALSE,
meta.cell = FALSE,
k = NULL)
head(result_list[["CellTopic"]])
#> CellTopic CellTopic1 CellTopic2 CellTopic3
#> 10x10 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> 10x13 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> 10x14 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> 10x15 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> 10x16 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> 10x17 CellTopic2 0.577382618544806 0.787303032098643 0.00801702438657219
#> CellTopic4
#> 10x10 0.0853445821596951
#> 10x13 0.0853445821596951
#> 10x14 0.0853445821596951
#> 10x15 0.0853445821596951
#> 10x16 0.0853445821596951
#> 10x17 0.0853445821596951
print(result_list[["domain_topic"]])
#> spot_domain_1 spot_domain_2 spot_domain_3 spot_domain_4
#> CellTopic1 0.78207686 0.577382619 0.174953872 0.10799194
#> CellTopic2 0.44211741 0.787303032 0.007438506 0.06603564
#> CellTopic3 0.12712585 0.008017024 0.787181571 0.03422577
#> CellTopic4 0.05105707 0.085344582 0.018005238 0.78840065
print(result_list[["celltype_topic"]])
#> CellTopic1 CellTopic2 CellTopic3 CellTopic4
#> Acinar_cells 0.04503436 0.03515437 5.404895e-02 0.170331437
#> Ductal_cells 0.11062714 0.14213899 3.273553e-06 0.028090541
#> Cancer_clone_A 0.03090381 0.02157599 1.770954e-01 0.015409246
#> Cancer_clone_B 0.02943409 0.01671419 1.662732e-01 0.010863856
#> DCs 0.07268275 0.06557971 2.767503e-02 0.141798548
#> Tuft_cells 0.06113322 0.04374492 5.155769e-02 0.141003229
#> pDCs 0.07777535 0.08179763 6.142109e-02 0.033754490
#> Endocrine_cells 0.07244471 0.06235805 3.860767e-02 0.144523396
#> Endothelial_cells 0.05015768 0.07488563 4.325394e-02 0.119765243
#> Macrophages 0.07516032 0.07263288 6.357115e-02 0.023052507
#> Mast_cells 0.09171737 0.06166093 5.590543e-02 0.053970823
#> T_cells_._NK_cells 0.08466616 0.06391425 4.966116e-02 0.020327972
#> Monocytes 0.07849903 0.09473090 5.823277e-02 0.056077913
#> RBCs 0.08112008 0.10899827 4.804330e-02 0.001741445
#> Fibroblasts 0.03864393 0.05411328 1.046500e-01 0.039289352
print(result_list[["Cell_topic"]])
#> CellTopic1 CellTopic2 CellTopic3 CellTopic4
#> "3_11_4_5_7_2" "2_8_1_11_3" "9_12" "13_10"