#Making of UP and Down regulated genes
# Load libraries
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.2
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggrepel)
library(readxl)
diffEx_N_Term_vs_C <- read_excel("diffEx-N.Term.vs.C.xlsx")
## Warning: Expecting numeric in B1420 / R1420C2: got 'NA'
## Warning: Expecting numeric in C1420 / R1420C3: got 'NA'
## Warning: Expecting numeric in D1420 / R1420C4: got 'NA'
## New names:
## • `` -> `...1`
View(diffEx_N_Term_vs_C)
diffEx_N_Term_vs_C <- as.data.frame(diffEx_N_Term_vs_C)
row.names(diffEx_N_Term_vs_C) <- make.unique(diffEx_N_Term_vs_C$...1)
# Classify significance based on adjusted p-value and fold change threshold
results <- diffEx_N_Term_vs_C %>% mutate(significance = case_when(diffEx_N_Term_vs_C$`N.Terminal-C.Terminal` < 0.05 & diffEx_N_Term_vs_C$`diff N.Terminal-C.Terminal` > 0 ~ "Upregulated", diffEx_N_Term_vs_C$`N.Terminal-C.Terminal` < 0.05 & diffEx_N_Term_vs_C$`diff N.Terminal-C.Terminal` < 0 ~ "Downregulated", TRUE ~ "Non-significant"))
table(results$significance)
##
## Downregulated Non-significant Upregulated
## 362 1846 362
results2 <- data.frame(
gene = row.names(results),
diff_p_value = results$`N.Terminal-C.Terminal`,
log2FC = results$`diff N.Terminal-C.Terminal`,
significance = results$significanc)
head (results2)
## gene diff_p_value log2FC significance
## 1 TAF1 0.706247658 0.3702192 Non-significant
## 2 UBA6 0.011915849 1.2952802 Upregulated
## 3 UHRF1BP1L 0.007333088 -3.4895278 Downregulated
## 4 SHTN1 0.126183295 -0.5989817 Non-significant
## 5 ILVBL 0.155210564 2.4629884 Non-significant
## 6 NBAS 0.102068514 0.8630593 Non-significant
# Convert FDR (BH) to -log10(p-value) for plotting
results2$neg_log10_pval <- -log10(results2$diff_p_value)
library(ggplot2)
library(ggrepel)
library(dplyr)
# Assuming 'results2' is your data frame
# Identify the top 15 upregulated and top 15 downregulated proteins
top_upregulated <- results2 %>%
filter(significance == "Upregulated") %>%
arrange(desc(log2FC)) %>%
head(10)
top_downregulated <- results2 %>%
filter(significance == "Downregulated") %>%
arrange(log2FC) %>%
head(10)
# Combine the top proteins into one data frame
top_proteins <- bind_rows(top_upregulated, top_downregulated)
# Count total upregulated and downregulated DEPs
total_upregulated <- results2 %>%
filter(significance == "Upregulated") %>%
nrow()
total_downregulated <- results2 %>%
filter(significance == "Downregulated") %>%
nrow()
# Create the plot object
volcano_plot <- ggplot(results2, aes(x = log2FC, y = neg_log10_pval)) +
geom_point(aes(color = significance), alpha = 0.6, size = 3) +
scale_color_manual(values = c("Upregulated" = "red", "Downregulated" = "blue", "Non-significant" = "grey")) +
geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "black") + # Common p-value threshold
geom_vline(xintercept = c(-1, 1), linetype = "dashed", color = "black") + # Common log2FC thresholds
geom_text_repel(data = top_proteins, aes(label = gene),
size = 5, box.padding = 0.35, point.padding = 0.3,
segment.color = 'black', segment.size = 0.5) + # Adding connectors
labs(title = "N-Terminal vs. C-Terminal",
x = "Difference, log2 N.Terminal vs C.Terminal",
y = "-log10 p-value",
color = "Significant DEPs") + # Change legend title
annotate("text", x = -2.5, y = 5, label = paste("Downregulated:", total_downregulated), color = "blue", size = 6) +
annotate("text", x = 2.5, y = 5, label = paste("Upregulated:", total_upregulated), color = "red", size = 6) +
theme_minimal() +
theme(
text = element_text(size = 16), # Increase font size for all text
axis.title = element_text(size = 18), # Increase font size for axis titles
plot.title = element_text(size = 20, hjust = 0.5), # Increase title size and center it
legend.title = element_text(size = 18), # Increase font size for legend title
legend.text = element_text(size = 16) # Increase font size for legend text
)
volcano_plot
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_point()`).

library(clusterProfiler)
## Warning: package 'clusterProfiler' was built under R version 4.3.1
##
## Registered S3 methods overwritten by 'treeio':
## method from
## MRCA.phylo tidytree
## MRCA.treedata tidytree
## Nnode.treedata tidytree
## Ntip.treedata tidytree
## ancestor.phylo tidytree
## ancestor.treedata tidytree
## child.phylo tidytree
## child.treedata tidytree
## full_join.phylo tidytree
## full_join.treedata tidytree
## groupClade.phylo tidytree
## groupClade.treedata tidytree
## groupOTU.phylo tidytree
## groupOTU.treedata tidytree
## inner_join.phylo tidytree
## inner_join.treedata tidytree
## is.rooted.treedata tidytree
## nodeid.phylo tidytree
## nodeid.treedata tidytree
## nodelab.phylo tidytree
## nodelab.treedata tidytree
## offspring.phylo tidytree
## offspring.treedata tidytree
## parent.phylo tidytree
## parent.treedata tidytree
## root.treedata tidytree
## rootnode.phylo tidytree
## sibling.phylo tidytree
## clusterProfiler v4.8.3 For help: https://yulab-smu.top/biomedical-knowledge-mining-book/
##
## If you use clusterProfiler in published research, please cite:
## T Wu, E Hu, S Xu, M Chen, P Guo, Z Dai, T Feng, L Zhou, W Tang, L Zhan, X Fu, S Liu, X Bo, and G Yu. clusterProfiler 4.0: A universal enrichment tool for interpreting omics data. The Innovation. 2021, 2(3):100141
##
## Attaching package: 'clusterProfiler'
## The following object is masked from 'package:stats':
##
## filter
library(org.Hs.eg.db)
## Loading required package: AnnotationDbi
## Warning: package 'AnnotationDbi' was built under R version 4.3.2
## Loading required package: stats4
## Loading required package: BiocGenerics
## Warning: package 'BiocGenerics' was built under R version 4.3.1
##
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:dplyr':
##
## combine, intersect, setdiff, union
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## anyDuplicated, aperm, append, as.data.frame, basename, cbind,
## colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
## get, grep, grepl, intersect, is.unsorted, lapply, Map, mapply,
## match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
## Position, rank, rbind, Reduce, rownames, sapply, setdiff, sort,
## table, tapply, union, unique, unsplit, which.max, which.min
## Loading required package: Biobase
## Warning: package 'Biobase' was built under R version 4.3.1
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
## Loading required package: IRanges
## Warning: package 'IRanges' was built under R version 4.3.1
## Loading required package: S4Vectors
## Warning: package 'S4Vectors' was built under R version 4.3.2
##
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:clusterProfiler':
##
## rename
## The following objects are masked from 'package:dplyr':
##
## first, rename
## The following object is masked from 'package:utils':
##
## findMatches
## The following objects are masked from 'package:base':
##
## expand.grid, I, unname
##
## Attaching package: 'IRanges'
## The following object is masked from 'package:clusterProfiler':
##
## slice
## The following objects are masked from 'package:dplyr':
##
## collapse, desc, slice
##
## Attaching package: 'AnnotationDbi'
## The following object is masked from 'package:clusterProfiler':
##
## select
## The following object is masked from 'package:dplyr':
##
## select
##
library(dplyr)
# Prepare the upregulated and downregulated gene lists
upregulated_genes <- results2 %>%
filter(significance == "Upregulated") %>%
pull(gene)
downregulated_genes <- results2 %>%
filter(significance == "Downregulated") %>%
pull(gene)
# GO enrichment for upregulated genes (ALL ontologies: BP, CC, MF)
go_up <- enrichGO(gene = upregulated_genes,
OrgDb = org.Hs.eg.db,
keyType = "SYMBOL",
ont = "ALL",
pAdjustMethod = "BH",
pvalueCutoff = 0.05,
qvalueCutoff = 0.05)
# GO enrichment for downregulated genes (ALL ontologies: BP, CC, MF)
go_down <- enrichGO(gene = downregulated_genes,
OrgDb = org.Hs.eg.db,
keyType = "SYMBOL",
ont = "ALL",
pAdjustMethod = "BH",
pvalueCutoff = 0.05,
qvalueCutoff = 0.05)
# Convert gene symbols to Entrez IDs for KEGG analysis
upregulated_genes_entrez <- bitr(upregulated_genes, fromType = "SYMBOL",
toType = "ENTREZID", OrgDb = org.Hs.eg.db) %>% pull(ENTREZID)
## 'select()' returned 1:1 mapping between keys and columns
## Warning in bitr(upregulated_genes, fromType = "SYMBOL", toType = "ENTREZID", :
## 1.66% of input gene IDs are fail to map...
downregulated_genes_entrez <- bitr(downregulated_genes, fromType = "SYMBOL",
toType = "ENTREZID", OrgDb = org.Hs.eg.db) %>% pull(ENTREZID)
## 'select()' returned 1:1 mapping between keys and columns
## Warning in bitr(downregulated_genes, fromType = "SYMBOL", toType = "ENTREZID",
## : 3.59% of input gene IDs are fail to map...
# KEGG enrichment for upregulated genes
kegg_up <- enrichKEGG(gene = upregulated_genes_entrez,
organism = 'hsa',
pvalueCutoff = 0.05)
## Reading KEGG annotation online: "https://rest.kegg.jp/link/hsa/pathway"...
## Reading KEGG annotation online: "https://rest.kegg.jp/list/pathway/hsa"...
# KEGG enrichment for downregulated genes
kegg_down <- enrichKEGG(gene = downregulated_genes_entrez,
organism = 'hsa',
pvalueCutoff = 0.05)
# Convert GO results to data frames
go_up_df <- as.data.frame(go_up)
go_down_df <- as.data.frame(go_down)
# Add a column to distinguish between upregulated and downregulated
go_up_df <- go_up_df %>% mutate(Regulation = "Upregulated")
go_down_df <- go_down_df %>% mutate(Regulation = "Downregulated")
# Combine GO results
combined_go <- bind_rows(go_up_df, go_down_df)
# Select the top 15 GO terms based on adjusted p-value
top_go <- combined_go %>%
arrange(p.adjust) %>%
head(15)
# Convert KEGG results to data frames
kegg_up_df <- as.data.frame(kegg_up)
kegg_down_df <- as.data.frame(kegg_down)
# Add a column to distinguish between upregulated and downregulated
kegg_up_df <- kegg_up_df %>% mutate(Regulation = "Upregulated")
kegg_down_df <- kegg_down_df %>% mutate(Regulation = "Downregulated")
# Combine KEGG results
combined_kegg <- bind_rows(kegg_up_df, kegg_down_df)
# Select the top 15 KEGG pathways based on adjusted p-value
top_kegg <- combined_kegg %>%
arrange(p.adjust) %>%
head(15)
#Combine GO and KEGG Top Pathways for Visualization
# Combine top GO and KEGG pathways
top_combined <- bind_rows(top_go, top_kegg)
head(top_combined, 20)
## ONTOLOGY ID
## GO:0005681 CC GO:0005681
## GO:0005769 CC GO:0005769
## GO:0000377 BP GO:0000377
## GO:0000398 BP GO:0000398
## GO:0000375 BP GO:0000375
## GO:0008380 BP GO:0008380
## GO:0071013 CC GO:0071013
## GO:0005684 CC GO:0005684
## GO:0030695 MF GO:0030695
## GO:0060589 MF GO:0060589
## GO:0016197 BP GO:0016197
## GO:0071826 BP GO:0071826
## GO:0071005 CC GO:0071005
## GO:0098687 CC GO:0098687
## GO:0022618 BP GO:0022618
## hsa03040 <NA> hsa03040
## hsa03013 <NA> hsa03013
## hsa04144 <NA> hsa04144
## hsa03050 <NA> hsa03050
## hsa05014 <NA> hsa05014
## Description
## GO:0005681 spliceosomal complex
## GO:0005769 early endosome
## GO:0000377 RNA splicing, via transesterification reactions with bulged adenosine as nucleophile
## GO:0000398 mRNA splicing, via spliceosome
## GO:0000375 RNA splicing, via transesterification reactions
## GO:0008380 RNA splicing
## GO:0071013 catalytic step 2 spliceosome
## GO:0005684 U2-type spliceosomal complex
## GO:0030695 GTPase regulator activity
## GO:0060589 nucleoside-triphosphatase regulator activity
## GO:0016197 endosomal transport
## GO:0071826 protein-RNA complex organization
## GO:0071005 U2-type precatalytic spliceosome
## GO:0098687 chromosomal region
## GO:0022618 protein-RNA complex assembly
## hsa03040 Spliceosome
## hsa03013 Nucleocytoplasmic transport
## hsa04144 Endocytosis
## hsa03050 Proteasome
## hsa05014 Amyotrophic lateral sclerosis
## GeneRatio BgRatio pvalue p.adjust qvalue
## GO:0005681 36/355 205/19886 2.236838e-25 9.752615e-23 6.616332e-23
## GO:0005769 46/344 427/19886 1.991766e-23 8.903195e-21 6.059163e-21
## GO:0000377 42/351 332/18870 5.573737e-23 8.800931e-20 7.445339e-20
## GO:0000398 42/351 332/18870 5.573737e-23 8.800931e-20 7.445339e-20
## GO:0000375 42/351 336/18870 8.929106e-23 9.399372e-20 7.951604e-20
## GO:0008380 49/351 478/18870 1.337903e-22 1.056274e-19 8.935781e-20
## GO:0071013 24/355 91/19886 1.017937e-21 2.219102e-19 1.505475e-19
## GO:0005684 23/355 92/19886 2.771285e-20 4.027600e-18 2.732389e-18
## GO:0030695 44/338 486/18496 1.391274e-18 4.222516e-16 3.382992e-16
## GO:0060589 44/338 486/18496 1.391274e-18 4.222516e-16 3.382992e-16
## GO:0016197 33/343 253/18870 5.720629e-19 2.118921e-15 1.796277e-15
## GO:0071826 31/351 243/18870 2.576051e-17 1.627034e-14 1.376425e-14
## GO:0071005 16/355 50/19886 2.156913e-16 1.922050e-14 1.303950e-14
## GO:0098687 37/355 399/19886 2.204186e-16 1.922050e-14 1.303950e-14
## GO:0022618 30/351 235/18870 8.422719e-17 4.433158e-14 3.750326e-14
## hsa03040 37/234 218/8843 3.926163e-20 9.383529e-18 7.645685e-18
## hsa03013 21/234 108/8843 4.902228e-13 5.858163e-11 4.773222e-11
## hsa04144 26/202 252/8843 8.747095e-11 2.213015e-08 1.951983e-08
## hsa03050 10/234 46/8843 2.454534e-07 1.955446e-05 1.593294e-05
## hsa05014 28/234 371/8843 4.795213e-07 2.865140e-05 2.334512e-05
## geneID
## GO:0005681 DHX15/SART1/PRPF3/PLRG1/HTATSF1/PRPF40A/SF3B1/SNRNP200/PRPF6/HNRNPA1/HSPA8/HNRNPH1/HNRNPA3/HNRNPM/ADAR/SNU13/HNRNPK/SNRPE/SNRPF/SNRPD2/SF3B2/SNW1/DDX39B/EFTUD2/SF3B3/SF3A1/SMU1/USP39/CTNNBL1/MAGOHB/SNRNP40/RBM17/GPATCH1/XAB2/PRPF19/SRRM2
## GO:0005769 HGS/STX7/AP1G1/SNX3/TOM1/LRP6/FLOT1/TFRC/HSPD1/INPP5B/NF2/NUMB/CXCR4/ATP11A/OCRL/PICALM/SNX1/SNX17/SLC39A14/LLGL1/GRIPAP1/FKBP15/WASHC2A/ZFYVE16/STX12/LMTK2/VPS8/ATP11C/AP3S1/RUBCN/SORL1/STAM/ITCH/KIF16B/ANKRD27/RPS6KC1/RAB11FIP5/TOLLIP/VPS33B/VPS16/PTPN23/EHD1/APPL1/ATP11B/NISCH/PIKFYVE
## GO:0000377 DHX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NX1/SCRIB/SNX17/CLEC16A/TBC1D10B/GRIPAP1/WASHC2A/LAMTOR1/ZFYVE16/STX12/LMTK2/VPS37A/TBC1D5/SORL1/STAM/REPS1/MVB12A/ANKRD27/TBC1D10A/VPS16/PTPN23/EHD1/UBAP1/CHMP2B/PIKFYVE
## GO:0071826 SART1/PRPF3/HTATSF1/PSIP1/SF3B1/PRKRA/SNRNP200/PRPF6/RPSA/XRCC5/VCP/ADAR/SNU13/EIF6/SNRPE/SNRPF/SNRPD2/DHX9/NCBP1/SF3B2/DDX39B/EIF3A/PTGES3/SF3B3/SF3A1/CPSF6/USP39/CPSF7/XAB2/PRPF19/RUVBL2
## GO:0071005 SART1/PRPF3/SF3B1/SNRNP200/PRPF6/SNU13/SNRPE/SNRPF/SNRPD2/SF3B2/EFTUD2/SF3B3/SF3A1/SMU1/MAGOHB/SRRM2
## GO:0098687 SMCHD1/MEN1/XPO1/SMARCA5/CDK1/TOP2A/PCNA/XRCC6/XRCC5/RPA2/CDK2/APEX1/PPP2R1A/MCM5/MCM7/MCM2/MRE11/PPP1CA/PPP1CB/RBBP4/NUP160/CBX3/SEPTIN6/CHD4/NCAPD2/PTGES3/NUP43/THOC2/NUP133/NUDCD2/AHCTF1/HDAC2/CHAMP1/NUP85/INCENP/PDS5B/SUGT1
## GO:0022618 SART1/PRPF3/HTATSF1/PSIP1/SF3B1/PRKRA/SNRNP200/PRPF6/RPSA/XRCC5/ADAR/SNU13/EIF6/SNRPE/SNRPF/SNRPD2/DHX9/NCBP1/SF3B2/DDX39B/EIF3A/PTGES3/SF3B3/SF3A1/CPSF6/USP39/CPSF7/XAB2/PRPF19/RUVBL2
## hsa03040 1665/9092/9129/5356/55660/23451/23020/24148/3178/3312/3310/3305/58517/220988/4670/4809/3190/6635/6636/6633/4686/10992/22938/7919/9343/23450/10291/10713/10523/57187/56259/55110/9410/84991/56949/22985/27339
## hsa03013 3843/30000/7514/9631/5903/3838/1915/4686/23279/7919/3837/348995/57187/55746/25909/3842/55110/79902/22985/10762/23534
## hsa04144 9146/8724/7037/3561/157/4218/7852/6642/9815/387680/80223/22841/9765/23111/23550/137492/8027/30011/93343/83737/26056/10938/51324/25978/10564/29924
## hsa03050 5709/5702/5696/5714/5691/5690/5720/5707/5721/5719
## hsa05014 5709/9631/203068/5216/3178/5702/836/5714/5691/5690/5903/220988/7415/10121/10376/10383/4686/23279/347688/348995/55746/5707/30849/79902/55860/10762/5719/84790
## Count Regulation
## GO:0005681 36 Upregulated
## GO:0005769 46 Downregulated
## GO:0000377 42 Upregulated
## GO:0000398 42 Upregulated
## GO:0000375 42 Upregulated
## GO:0008380 49 Upregulated
## GO:0071013 24 Upregulated
## GO:0005684 23 Upregulated
## GO:0030695 44 Downregulated
## GO:0060589 44 Downregulated
## GO:0016197 33 Downregulated
## GO:0071826 31 Upregulated
## GO:0071005 16 Upregulated
## GO:0098687 37 Upregulated
## GO:0022618 30 Upregulated
## hsa03040 37 Upregulated
## hsa03013 21 Upregulated
## hsa04144 26 Downregulated
## hsa03050 10 Upregulated
## hsa05014 28 Upregulated
# Create a combined bar plot for the top 15 GO and KEGG pathways
ggplot(top_combined, aes(x = reorder(Description, -p.adjust), y = -log10(p.adjust), fill = Regulation)) +
geom_bar(stat = "identity", position = "dodge") +
coord_flip() + # Flip the coordinates to make it horizontal
labs(title = "Top 15 GO Terms and KEGG Pathways - Upregulated and Downregulated",
x = "Pathway/GO Term",
y = "-log10 Adjusted p-value") +
scale_fill_manual(values = c("Upregulated" = "red", "Downregulated" = "blue")) +
theme_minimal(base_size = 14) +
theme(plot.title = element_text(hjust = 0.5, size = 16))

# Convert KEGG results to data frames
kegg_up_df <- as.data.frame(kegg_up)
kegg_down_df <- as.data.frame(kegg_down)
# Add a column to distinguish between upregulated and downregulated
kegg_up_df <- kegg_up_df %>% mutate(Regulation = "Upregulated")
kegg_down_df <- kegg_down_df %>% mutate(Regulation = "Downregulated")
# Combine KEGG results
combined_kegg <- bind_rows(kegg_up_df, kegg_down_df)
# Select the top 15 KEGG pathways based on adjusted p-value
top_kegg <- combined_kegg %>%
arrange(p.adjust) %>%
group_by(Regulation) %>%
slice_head(n = 15)
# Create a separate bar plot for KEGG pathways
ggplot(top_kegg, aes(x = reorder(Description, -p.adjust), y = -log10(p.adjust), fill = Regulation)) +
geom_bar(stat = "identity", position = "dodge") +
coord_flip() + # Flip the coordinates to make it horizontal
labs(title = "Top 15 KEGG Pathways - Upregulated and Downregulated",
x = "KEGG Pathway",
y = "-log10 Adjusted p-value") +
scale_fill_manual(values = c("Upregulated" = "red", "Downregulated" = "blue")) +
theme_minimal(base_size = 14) +
theme(plot.title = element_text(hjust = 0.5, size = 16))

library(ggplot2)
# Convert GO results to data frames
go_up_df <- as.data.frame(go_up)
go_down_df <- as.data.frame(go_down)
# Add a column to distinguish between upregulated and downregulated
go_up_df <- go_up_df %>% mutate(Regulation = "Upregulated")
go_down_df <- go_down_df %>% mutate(Regulation = "Downregulated")
# Combine GO results
combined_go <- bind_rows(go_up_df, go_down_df)
# Select the top 15 GO terms based on adjusted p-value
top_go <- combined_go %>%
arrange(p.adjust) %>%
group_by(Regulation) %>%
slice_head(n = 15)
# Create a separate bar plot for GO terms
ggplot(top_go, aes(x = reorder(Description, -p.adjust), y = -log10(p.adjust), fill = Regulation)) +
geom_bar(stat = "identity", position = "dodge") +
coord_flip() + # Flip the coordinates to make it horizontal
labs(title = "Top 15 GO Terms - Upregulated and Downregulated",
x = "GO Term",
y = "-log10 Adjusted p-value") +
scale_fill_manual(values = c("Upregulated" = "red", "Downregulated" = "blue")) +
theme_minimal(base_size = 14) +
theme(plot.title = element_text(hjust = 0.5, size = 16))
