R/plotGeneExpressionDimred.R
plotGeneExpressionDimred.Rd
This function plots gene expression on a dimensional reduction plot using methods like t-SNE, UMAP, or PCA. Each single cell is color-coded based on the expression of a specific gene or feature.
plotGeneExpressionDimred(
se_object,
method = c("TSNE", "UMAP", "PCA"),
pc_subset = 1:5,
feature,
cell_type_col = NULL,
cell_types = NULL,
assay_name = "logcounts",
max_cells = 2500
)
An object of class SingleCellExperiment
containing log-transformed expression matrix and other metadata.
It can be either a reference or query dataset.
The reduction method to use for visualization. It should be one of the supported methods: "TSNE", "UMAP", or "PCA".
An optional vector specifying the principal components (PCs) to include in the plot if method = "PCA". Default is 1:5.
A character string representing the name of the gene or feature to be visualized.
The column name in the colData
of se_object
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".
Maximum number of cells to retain. If the object has fewer cells, it is returned unchanged. Default is 2500.
A ggplot object representing the dimensional reduction plot with gene expression.
# Load data
data("query_data")
# Plot gene expression on PCA plot
plotGeneExpressionDimred(se_object = query_data,
cell_type_col = "SingleR_annotation",
method = "PCA",
pc_subset = 1:5,
feature = "CD8A",
cell_types = "CD4")