compare_merge | R Documentation |
This function takes two DEG data frames, inner joins them by a specified gene column, checks if a specified column is identical across both data frames, and merges them if they are. The resulting data frame will have a merged column named after the compared column.
compare_merge(df1, df2, by_gene, compare_col, suffixes, df_name)
df1 |
First data frame. |
df2 |
Second data frame. |
by_gene |
Column name by which to join the data frames, typically "Gene". |
compare_col |
Column to compare for identity, which will also be the name of the merged column. |
suffixes |
Suffixes to use for non-identical column names in the joined data frame. |
df_name |
Name to assign to the resulting data frame for identification. |
A data frame with processed columns.
# Create simulated DESeq2 data
DEG_deseq2 <- data.frame(
Gene = c("Gene1", "Gene2", "Gene3", "Gene4", "Gene5"),
change = c("up", "down", "no_change", "up", "down"),
log2FoldChange = c(2.5, -3.2, 0.1, 1.8, -2.5),
pvalue = c(0.01, 0.05, 0.9, 0.02, 0.03)
)
# Display the first 5 rows of the DESeq2 data
head(DEG_deseq2, 5)
# Create simulated edgeR data
DEG_edgeR <- data.frame(
Gene = c("Gene1", "Gene2", "Gene3", "Gene4", "Gene5"),
change = c("up", "down", "no_change", "no_change", "up"),
log2FoldChange = c(2.3, -3.1, 0.2, 0.1, 2.7),
pvalue = c(0.02, 0.04, 0.8, 0.6, 0.01)
)
# Display the first 5 rows of the edgeR data
head(DEG_edgeR, 5)
# Merge the DESeq2 and edgeR data
deseq2_edgeR <- compare_merge(
df1 = DEG_deseq2,
df2 = DEG_edgeR,
by_gene = "Gene",
compare_col = "change",
suffixes = c("_1", "_2"),
df_name = "deseq2_edgeR"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.