Creates feature plots for visualizing the average expression of gene modules across cells.
CustomModulePlot(
dat,
coord = NULL,
feature_partition,
reduction = NULL,
assays = "RNA"
)
A Seurat object or a matrix of gene expression data.
matrix; 2D coordinates of cells for visualization. Required if dat
is not a Seurat object.
factor; a vector indicating the partition of features (genes) into modules.
character; the name of the reduction embedding to use (e.g., "umap", "tsne"). Default is NULL.
character; the assay to use from the Seurat object. Default is "RNA".
A list of ggplot2 objects representing the feature plots for each module.
# Example with Seurat object
library(Seurat)
seurat_obj <- CreateSeuratObject(matrix(runif(2000), nrow = 200))
#> Error in CreateAssayObject(counts = counts, min.cells = min.cells, min.features = min.features, row.names = row.names): No cell names (colnames) names present in the input matrix
seurat_obj <- RunUMAP(seurat_obj, dims = 1:10)
#> Error in RunUMAP(seurat_obj, dims = 1:10): object 'seurat_obj' not found
feature_partition <- factor(sample(letters[1:3], 200, replace = TRUE))
plot_list <- CustomModulePlot(seurat_obj, feature_partition = feature_partition, reduction = "umap")
#> Error in CustomModulePlot(seurat_obj, feature_partition = feature_partition, reduction = "umap"): object 'seurat_obj' not found
lapply(plot_list, print)
#> Error in lapply(plot_list, print): object 'plot_list' not found
# Example with coordinate matrix
dat <- matrix(runif(2000), nrow = 200)
coord <- matrix(runif(400), nrow = 200, ncol = 2)
feature_partition <- factor(sample(letters[1:3], 200, replace = TRUE))
plot_list <- CustomModulePlot(dat, coord = coord, feature_partition = feature_partition)
#> Warning: the condition has length > 1 and only the first element will be used
lapply(plot_list, print)
#> named list()