View source: R/CellChat_class.R
createCellChat | R Documentation |
Create a new CellChat object from a data matrix, Seurat or SingleCellExperiment object
createCellChat(
object,
meta = NULL,
group.by = NULL,
datatype = c("RNA", "spatial"),
coordinates = NULL,
scale.factors = NULL,
assay = NULL,
do.sparse = T
)
object |
a normalized (NOT count) data matrix (genes by cells), Seurat or SingleCellExperiment object |
meta |
a data frame (rows are cells with rownames) consisting of cell information, which will be used for defining cell groups. If input is a Seurat or SingleCellExperiment object, the meta data in the object will be used |
group.by |
a char name of the variable in meta data, defining cell groups. If input is a data matrix and group.by is NULL, the input ‘meta' should contain a column named ’labels', If input is a Seurat or SingleCellExperiment object, USER must provide 'group.by' to define the cell groups. e.g, group.by = "ident" for Seurat object |
datatype |
By default datatype = "RNA"; when running CellChat on spatial imaging data, set datatype = "spatial" and input 'scale.factors' |
coordinates |
a data matrix in which each row gives the spatial locations/coordinates of each cell/spot |
scale.factors |
a list containing the scale factors and spot diameter for the full/high/low resolution images. USER must input this list when datatype = "spatial". scale.factors must contain an element named 'spot.diameter', which is the theoretical spot size; e.g., 10x Visium (spot.size = 65 microns), and another element named 'spot', which is the number of pixels that span the diameter of a theoretical spot size in the original, full-resolution image. For 10X visium, scale.factors are in the 'scalefactors_json.json'. scale.factors$spot is the 'spot.size.fullres ' |
assay |
Assay to use when the input is a Seurat object. NB: The data in the 'integrated' assay is not suitable for CellChat analysis because it contains negative values. |
do.sparse |
whether use sparse format |
## Not run:
Create a CellChat object from single-cell transcriptomics data
# Input is a data matrix
## create a dataframe consisting of the cell labels
meta = data.frame(labels = cell.labels, row.names = names(cell.labels))
cellChat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
# input is a Seurat object
## use the default cell identities of Seurat object
cellChat <- createCellChat(object = seurat.obj, group.by = "ident", assay = "RNA")
## use other meta information as cell groups
cellChat <- createCellChat(object = seurat.obj, group.by = "seurat.clusters")
# input is a SingleCellExperiment object
cellChat <- createCellChat(object = sce.obj, group.by = "sce.clusters")
Create a CellChat object from spatial imaging data
# Input is a data matrix
cellChat <- createCellChat(object = data.input, meta = meta, group.by = "labels",
datatype = "spatial", coordinates = coordinates, scale.factors = scale.factors)
# input is a Seurat object
cellChat <- createCellChat(object = seurat.obj, group.by = "ident", assay = "SCT",
datatype = "spatial", scale.factors = scale.factors)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.