Diff of /man/compare_merge.Rd [000000] .. [0f2269]

Switch to unified view

a b/man/compare_merge.Rd
1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/CompareMerge.R
3
\name{compare_merge}
4
\alias{compare_merge}
5
\title{Compare and merge specific columns from two DEG data frames}
6
\usage{
7
compare_merge(df1, df2, by_gene, compare_col, suffixes, df_name)
8
}
9
\arguments{
10
\item{df1}{First data frame.}
11
12
\item{df2}{Second data frame.}
13
14
\item{by_gene}{Column name by which to join the data frames, typically "Gene".}
15
16
\item{compare_col}{Column to compare for identity, which will also be the name of the merged column.}
17
18
\item{suffixes}{Suffixes to use for non-identical column names in the joined data frame.}
19
20
\item{df_name}{Name to assign to the resulting data frame for identification.}
21
}
22
\value{
23
A data frame with processed columns.
24
}
25
\description{
26
This function takes two DEG data frames, inner joins them by a specified gene column,
27
checks if a specified column is identical across both data frames, and merges them if they are.
28
The resulting data frame will have a merged column named after the compared column.
29
}
30
\examples{
31
# Create simulated DESeq2 data
32
DEG_deseq2 <- data.frame(
33
  Gene = c("Gene1", "Gene2", "Gene3", "Gene4", "Gene5"),
34
  change = c("up", "down", "no_change", "up", "down"),
35
  log2FoldChange = c(2.5, -3.2, 0.1, 1.8, -2.5),
36
  pvalue = c(0.01, 0.05, 0.9, 0.02, 0.03)
37
)
38
39
# Display the first 5 rows of the DESeq2 data
40
head(DEG_deseq2, 5)
41
42
# Create simulated edgeR data
43
DEG_edgeR <- data.frame(
44
  Gene = c("Gene1", "Gene2", "Gene3", "Gene4", "Gene5"),
45
  change = c("up", "down", "no_change", "no_change", "up"),
46
  log2FoldChange = c(2.3, -3.1, 0.2, 0.1, 2.7),
47
  pvalue = c(0.02, 0.04, 0.8, 0.6, 0.01)
48
)
49
50
# Display the first 5 rows of the edgeR data
51
head(DEG_edgeR, 5)
52
53
# Merge the DESeq2 and edgeR data
54
deseq2_edgeR <- compare_merge(
55
  df1 = DEG_deseq2,
56
  df2 = DEG_edgeR,
57
  by_gene = "Gene",
58
  compare_col = "change",
59
  suffixes = c("_1", "_2"),
60
  df_name = "deseq2_edgeR"
61
)
62
63
}