This function facilitates the assessment of similarity between reference and query datasets through Multidimensional Scaling (MDS) scatter plots. It allows the visualization of cell types, color-coded with user-defined custom colors, based on a dissimilarity matrix computed from a user-selected gene set.
plotCellTypeMDS(
query_data,
reference_data,
query_cell_type_col,
ref_cell_type_col,
cell_types = NULL,
assay_name = "logcounts"
)
A SingleCellExperiment
containing the single-cell
expression data and metadata.
A SingleCellExperiment
object containing the single-cell
expression data and metadata.
The column name in the colData
of query_data
that identifies the cell types.
The column name in the colData
of reference_data
that identifies the cell types.
A character vector specifying the cell types to include in the plot. If NULL, all cell types are included.
Name of the assay on which to perform computations. Default is "logcounts".
A ggplot object representing the MDS scatter plot with cell type coloring.
To evaluate dataset similarity, the function selects specific subsets of cells from both reference and query datasets. It then calculates Spearman correlations between gene expression profiles, deriving a dissimilarity matrix. This matrix undergoes Classical Multidimensional Scaling (MDS) for visualization, presenting cell types in a scatter plot, distinguished by colors defined by the user.
Kruskal, J. B. (1964). "Multidimensional scaling by optimizing goodness of fit to a nonmetric hypothesis". *Psychometrika*, 29(1), 1-27. doi:10.1007/BF02289565.
Borg, I., & Groenen, P. J. F. (2005). *Modern multidimensional scaling: Theory and applications* (2nd ed.). Springer Science & Business Media. doi:10.1007/978-0-387-25975-1.
# Load data
data("reference_data")
data("query_data")
# Generate the MDS scatter plot with cell type coloring
mds_plot <- plotCellTypeMDS(query_data = query_data,
reference_data = reference_data,
cell_types = c("CD4", "CD8", "B_and_plasma", "Myeloid")[1:4],
query_cell_type_col = "SingleR_annotation",
ref_cell_type_col = "expert_annotation")
mds_plot