View source: R/plot_gene_express.R
plot_gene_express | R Documentation |
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,
plot_type = c("violin", "boxplot")
)
sce |
A SummarizedExperiment-class object or one inheriting it. |
genes |
A |
assay_name |
A |
category |
A |
color_pal |
A named |
title |
A |
plot_points |
A |
ncol |
An |
plot_type |
A |
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"))
plot_gene_express(sce = sce_ab, genes = c("G-D1_A"), plot_type = "boxplot")
# Access example data
if (!exists("sce_DLPFC_example")) sce_DLPFC_example <- fetch_deconvo_data("sce_DLPFC_example")
## plot expression of two genes
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22")
)
## plot as boxplot
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"),
plot_type = "boxplot"
)
## 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
)
## with boxplot
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"),
plot_points = TRUE,
plot_type = "boxplot"
)
## Add title
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"),
title = "My Genes"
)
## Add color pallet
my_cell_colors <- create_cell_colors(cell_types = levels(sce_DLPFC_example$cellType_broad_hc))
plot_gene_express(
sce = sce_DLPFC_example,
category = "cellType_broad_hc",
genes = c("GAD2", "CD22"),
color_pal = my_cell_colors,
plot_type = "boxplot",
plot_points = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.