|
a |
|
b/R/FourDegsVenn.R |
|
|
1 |
#' Function to Filter Differentially Expressed Genes (DEGs) |
|
|
2 |
#' |
|
|
3 |
#' This function filters out genes based on their expression change status. |
|
|
4 |
#' It returns the names of genes which are not "stable". |
|
|
5 |
#' |
|
|
6 |
#' @param df A data frame containing gene expression data. |
|
|
7 |
#' @return A vector of gene names that are differentially expressed. |
|
|
8 |
#' @examples |
|
|
9 |
#' DEG_deseq2_file <- system.file("extdata", "DEG_deseq2.rds", package = "TransProR") |
|
|
10 |
#' DEG_deseq2 <- readRDS(DEG_deseq2_file) |
|
|
11 |
#' DEG_deseq2_test <- deg_filter(DEG_deseq2) |
|
|
12 |
#' @export |
|
|
13 |
|
|
|
14 |
deg_filter <- function(df){ |
|
|
15 |
# Selecting gene names where change is not "stable" |
|
|
16 |
rownames(df)[df$change != "stable"] |
|
|
17 |
} |
|
|
18 |
|
|
|
19 |
#' Function to Create a Venn Diagram of DEGs |
|
|
20 |
#' |
|
|
21 |
#' This function creates a Venn Diagram using the ggVennDiagram package. |
|
|
22 |
#' It allows customization of various aesthetic elements of the diagram. |
|
|
23 |
#' @importFrom ggplot2 alpha scale_fill_gradient scale_color_manual scale_x_continuous expansion |
|
|
24 |
#' @importFrom ggVennDiagram ggVennDiagram |
|
|
25 |
#' @param degs_list A list of DEG sets for Venn Diagram creation. |
|
|
26 |
#' @return A ggplot object representing the Venn Diagram. |
|
|
27 |
#' @examples |
|
|
28 |
#' data("all_degs_venn", package = "TransProR") |
|
|
29 |
#' four_degs_venn <- four_degs_venn(all_degs_venn) |
|
|
30 |
#' @export |
|
|
31 |
|
|
|
32 |
four_degs_venn <- function(degs_list){ |
|
|
33 |
# Defining edge colors and alpha transparency for the Venn Diagram |
|
|
34 |
edge_colors <- c(ggplot2::alpha("#1b64bb", 0.5), ggplot2::alpha("#13828e", 0.5), |
|
|
35 |
ggplot2::alpha("#337c3a", 0.5), ggplot2::alpha("#9e9d39", 0.5)) |
|
|
36 |
edge_color <- ggplot2::alpha(c("#1b64bb","#13828e","#337c3a","#9e9d39"), 0.8) |
|
|
37 |
|
|
|
38 |
# Creating a Venn Diagram using 'ggVennDiagram' |
|
|
39 |
ggVennDiagram::ggVennDiagram( |
|
|
40 |
degs_list, |
|
|
41 |
set_size = 5, # Font size for group names |
|
|
42 |
set_color = edge_color, # Color for group names |
|
|
43 |
label_alpha= 0, # Transparency of background box for labels |
|
|
44 |
label_size = 4, # Font size for labels |
|
|
45 |
edge_size = 3 # Thickness of edges |
|
|
46 |
) + |
|
|
47 |
ggplot2::scale_fill_gradient(low="#e1f2f1", high = "#11786b") + # Gradient fill based on values |
|
|
48 |
ggplot2::scale_color_manual(values = edge_colors) + # Manually set edge colors |
|
|
49 |
ggplot2::scale_x_continuous(expand = ggplot2::expansion(mult = .3)) # Adjusting x-axis scaling |
|
|
50 |
} |
|
|
51 |
|