Creates a bar plot of log2 fold-change values for transcripts of a selected gene, differentiating transcript types and significance levels.
Arguments
- DEG_DET_table
A
data.frame
ortibble
containing combined gene and transcript differential expression results, includingname
,log2FC
,transcript_type
,significance
, andgene_name
columns.- selected_gene
A character string specifying the gene name to plot.
- custom_colors
An optional named vector of colors for different transcript types.
Details
The function filters the input table for the selected gene and creates a bar plot of log2 fold-change values.
If all transcripts are significant, it plots without adjusting alpha transparency; otherwise, it adjusts alpha
based on significance. The function uses predefined colors for transcript types, which can be overridden
by providing custom_colors
.
Examples
# Sample data
DEGs_DETs_table <- data.frame(
name = c("Transcript1", "Transcript2", "GeneA"),
log2FC = c(1.5, -2.0, 0.8),
transcript_type = c("protein_coding", "lncRNA", "gene"),
significance = c("sig", "not_sig", "sig"),
gene_name = c("GeneA", "GeneA", "GeneA")
)
# Plot log2 fold-change for the selected gene
plot_obj <- plot_log2FC(
DEG_DET_table = DEGs_DETs_table,
selected_gene = "GeneA"
)
#> Error in plot_log2FC(DEG_DET_table = DEGs_DETs_table, selected_gene = "GeneA"): object 'tx_type_color_names' not found
# Display the plot
print(plot_obj)
#> Error: object 'plot_obj' not found