
Create Gene Exploration Plot
make_gene_exploration_plot.Rd
This function generates a scatter plot that visualizes the relationship between experimental p-values and tKOI-adjusted false discovery rates (FDR) for genes in the network. The plot highlights significantly upregulated and downregulated genes based on user-defined thresholds for log fold change and p-values.
Arguments
- tkoi_list
An object of class
tKOIList
. This object must contain the following slots:expression_data
: Adata.frame
containing experimental data with columnsgene_name
,logfc
, andpvalue
.network_summary_statistics
: A list with adata.frame
for gene-level statistics, includingnode_id
andfdr
.pvalue_threshold
: A numeric value specifying the p-value threshold.logfc_threshold
: A numeric value specifying the log fold change threshold.
- sig_color
A character string specifying the color for significant genes in the plot. Default is
"#F39B7FB2"
.- non_sig_color
A character string specifying the color for non-significant genes in the plot. Default is
"gray"
.
Details
The function performs the following steps:
Merges the
expression_data
from thetKOIList
object with gene metadata usinginner_join
.Merges the result with gene-level network data using
right_join
.Filters and annotates the data to classify genes as upregulated or downregulated based on the sign of
logfc
.Colors genes based on their significance determined by
logfc_threshold
.Generates a scatter plot with ggplot2, where:
The x-axis represents
-log10(pvalue)
(experimental p-value).The y-axis represents
-log10(fdr)
(tKOI-adjusted FDR).Points are colored and categorized into upregulated and downregulated facets.
The plot includes vertical and horizontal dashed lines to indicate the thresholds for p-value and FDR.
Examples
if (FALSE) { # \dontrun{
# Create a dummy tKOIList object
tkoi_list <- new("tKOIList",
expression_data = data.frame(
gene_name = c("gene1", "gene2", "gene3"),
logfc = c(1.2, -0.8, 0.5),
pvalue = c(0.01, 0.03, 0.2)
),
network_summary_statistics = list(
Gene = data.frame(
node_id = c(1, 2, 3),
fdr = c(0.02, 0.05, 0.1)
)
),
pvalue_threshold = 0.05,
logfc_threshold = 0.5)
# Generate the plot
plt <- make_gene_exploration_plot(tkoi_list)
print(plt)
} # }