a b/man/merge_density_foldchange.Rd
1
% Generated by roxygen2: do not edit by hand
2
% Please edit documentation in R/MergeDensityFoldchange.R
3
\name{merge_density_foldchange}
4
\alias{merge_density_foldchange}
5
\title{Create high-density region plot with optional points, density rugs, and contours}
6
\usage{
7
merge_density_foldchange(
8
  data,
9
  x_var,
10
  y_var,
11
  group_var,
12
  palette = c("#3949ab", "#1e88e5", "#039be5", "#00897b", "#43a047", "#7cb342"),
13
  show_points = FALSE,
14
  point_size = 2.5,
15
  point_alpha = 0.2,
16
  x_lim = c(0, 20),
17
  y_lim = c(0, 20),
18
  cor_method = "pearson",
19
  line_size = 1.6,
20
  cor_label_pos = c("left", 0.97)
21
)
22
}
23
\arguments{
24
\item{data}{Data frame containing variables for plotting.}
25
26
\item{x_var}{Name of the x-axis variable as a string.}
27
28
\item{y_var}{Name of the y-axis variable as a string.}
29
30
\item{group_var}{Name of the grouping variable for color mapping as a string.}
31
32
\item{palette}{Color palette for the plot as a character vector.}
33
34
\item{show_points}{Logical, if TRUE adds points to the plot.}
35
36
\item{point_size}{Size of the points, relevant if show_points is TRUE.}
37
38
\item{point_alpha}{Transparency level of the points, relevant if show_points is TRUE.}
39
40
\item{x_lim}{Numeric vector of length 2, giving the x-axis limits.}
41
42
\item{y_lim}{Numeric vector of length 2, giving the y-axis limits.}
43
44
\item{cor_method}{Method to calculate correlation ("pearson" or "spearman").}
45
46
\item{line_size}{Size of the smoothing line.}
47
48
\item{cor_label_pos}{Vector of length 2 indicating the position of the correlation label (x and y).}
49
}
50
\value{
51
A ggplot object representing the high-density region plot.
52
}
53
\description{
54
This function creates a high-density region plot using hdr methods to
55
add density rug and filled contours. It also adds a regression line
56
and Pearson correlation label. Points can be added to the plot optionally.
57
}
58
\examples{
59
combined_df_file <- system.file("extdata", "combined_df.rds", package = "TransProR")
60
combined_df <- readRDS(combined_df_file)
61
pal1 = c("#3949ab","#1e88e5","#039be5","#00897b","#43a047","#7cb342")
62
63
all_density_foldchange_name1 <- merge_density_foldchange(
64
  data = combined_df,
65
  x_var = "log2FoldChange_1",
66
  y_var = "log2FoldChange_2",
67
  group_var = "name",
68
  palette = pal1,
69
  show_points = FALSE,
70
  point_size = 2.5,
71
  point_alpha = 0.1,
72
  x_lim = c(0, 20),
73
  y_lim = c(0, 20),
74
  cor_method = "pearson",
75
  line_size = 1.6,
76
  cor_label_pos = c("left", "top")
77
)
78
79
}