Merge Gene and Transcript Level Differential Expression Tables
Source:R/functions.R
join_DEG_DET.Rd
Combines gene-level and transcript-level differential expression results into a single table, annotates the combined data with significance labels based on specified cutoffs, and filters transcripts based on their types.
Arguments
- DEG_tab
A
data.frame
ortibble
containing gene-level differential expression results, includinggene_id
,gene_name
,log2FC
, andpvalue
columns.- DET_final_tab
A
data.frame
ortibble
containing transcript-level differential expression results, includingtranscript_id
,transcript_name
,transcript_type
,log2FC
, andpvalue
columns.- logfc_cut
A numeric value specifying the absolute log2 fold-change cutoff for significance.
- pval_cut
A numeric value specifying the p-value cutoff for significance.
Value
A tibble
combining gene and transcript differential expression results, with additional columns:
id
: gene or transcript ID.name
: gene or transcript name.transcript_type
: type of transcript or"gene"
for gene-level entries.abs_log2FC
: absolute value of log2 fold-change.significance
:"sig"
if significant based on cutoffs,"not_sig"
otherwise.
Examples
# Sample gene-level data
DEG_tab <- data.frame(
gene_id = c("gene1", "gene2"),
gene_name = c("GeneA", "GeneB"),
log2FC = c(1.5, -2.0),
pvalue = c(0.01, 0.04)
)
# Sample transcript-level data
DET_final_tab <- data.frame(
transcript_id = c("tx1", "tx2", "tx3"),
transcript_name = c("Transcript1", "Transcript2", "Transcript3"),
transcript_type = c("protein_coding", "lncRNA", "processed_transcript"),
log2FC = c(1.2, -1.8, 0.5),
pvalue = c(0.02, 0.03, 0.2)
)
# Merge and annotate differential expression results
DEGs_DETs_table <- join_DEG_DET(
DEG_tab = DEG_tab,
DET_final_tab = DET_final_tab,
logfc_cut = 1,
pval_cut = 0.05
)
#> Warning: Unknown columns: `DEG_sig`
# View the result
print(DEGs_DETs_table)
#> id name log2FC pvalue transcript_type abs_log2FC significance
#> 1 gene1 GeneA 1.5 0.01 gene 1.5 sig
#> 2 gene2 GeneB -2.0 0.04 gene 2.0 sig
#> 3 tx1 Transcript1 1.2 0.02 protein_coding 1.2 sig
#> 4 tx2 Transcript2 -1.8 0.03 lncRNA 1.8 sig
#> 5 tx3 Transcript3 0.5 0.20 processed_transcript 0.5 not_sig