R/plot_gene_express.R
plot_gene_express.Rd
This function plots the expression of one or more genes as a violin plot,
over a user defined category, typically a cell type annotation. The plots are
made using ggplot2
.
plot_gene_express(
sce,
genes,
assay_name = "logcounts",
category = "cellType",
color_pal = NULL,
title = NULL,
plot_points = FALSE,
ncol = 2
)
A SummarizedExperiment-class object or one inheriting it.
A character()
vector specifying the genes to plot,
this should match the format of rownames(sce)
.
A character(1)
specifying the name of the
assay() in the
sce
object to use to rank expression values. Defaults to logcounts
since
it typically contains the normalized expression values.
A character(1)
specifying the name of the categorical
variable to group the cells or nuclei by. Defaults to cellType
.
A named character(1)
vector that contains a color pallet
matching the category
values.
A character(1)
to title the plot.
A logical(1)
indicating whether to plot points over the
violin, defaults to FALSE
as these often become over plotted and quite
large (especially when saved as PDF).
An integer(1)
specifying the number of columns for the facet in
the final plot. Defaults to 2.
A ggplot()
violin plot for selected genes.
Other expression plotting functions:
plot_marker_express()
,
plot_marker_express_ALL()
,
plot_marker_express_List()
## Using Symbol as rownames makes this more human readable
data(sce_ab)
plot_gene_express(sce = sce_ab, genes = c("G-D1_A"))
# Access example data
if (!exists("sce_DLPFC_example")) sce_DLPFC_example <- fetch_deconvo_data("sce_DLPFC_example")
#> 2024-12-16 18:01:03.645353 loading file /github/home/.cache/R/BiocFileCache/30161ee4ad2_sce_DLPFC_example.Rdata%3Frlkey%3Dv3z4u8ru0d2y12zgdl1az07q9%26st%3D1dcfqc1i%26dl%3D1
## plot expression of two genes
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22")
)
## plot points - note this creates large images and is easy to over plot
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"), plot_points = TRUE
)
## Add title
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"),
title = "My Genes"
)