This function creates boxplots showing the expression levels of selected genes across groups. It can optionally add statistical significance indicators between groups.
Usage
plot_gene_exprs(
dds,
res = NULL,
group_by,
genes,
plot_name,
pal = NULL,
save_plot = T,
save_dir = getwd()
)Arguments
- dds
DESeq2 object containing the expression data
- res
Optional differential expression results data frame
- group_by
Column name in colData(dds) to group by.
- genes
Vector of gene names to plot
- plot_name
Name for the output plot
- pal
Vector of colors to use for groups. If NULL, uses default ggplot2 colors. Default is NULL
- save_plot
Logical. If TRUE, saves the plot to PDF. Default is TRUE
- save_dir
Directory to save the plot. Default is current working directory
Examples
if (FALSE) { # \dontrun{
# Basic expression plot
p <- plot_gene_exprs(dds, genes = c("GENE1", "GENE2"), plot_name = "my_genes")
# Expression plot with statistical significance
p <- plot_gene_exprs(dds, res = res, genes = c("GENE1", "GENE2"), plot_name = "my_genes")
# Expression plot with custom colors
p <- plot_gene_exprs(dds, genes = c("GENE1", "GENE2"), plot_name = "my_genes", pal = c("red", "blue", "green"))
} # }