Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的论文库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
How to conduct Enrichment Analysis with TCGA-BRCA RNA-seq (FPKM)?
bioinformatics
生物信息学
bioinformatics生物信息学
Judy Lin
发布于 2023-12-21
推荐镜像 :bio-r-notebook:v4
推荐机型 :c2_m8_cpu
赞 3
ults(v1)
our)(v1)

Bioinformatic Practices: How to conduct Enrichment Analysis with TCGA-BRCA RNA-seq (FPKM)?

Tissue:

Processed TCGA-BRCA RNAseq data in FPKM (2 excel files) have been given (normal and primary tumour; brca-rsem-fpkm-tcga.xlsx and brca-rsem-fpkm-tcga-t.xlsx, respectively). How to perform analysis to find out the the most enriched and downregulated genes and gene sets in primary breast tumours?

©️ Copyright 2023 @ Authors
Author: Mujie Lin 📨
日期:2023-12-19
共享协议:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。
快速开始:点击上方的 开始连接 按钮,选择 bio-r-notebook:v4镜像 和任意内存大于4G的机型即可开始。

1 Analysis Differential Expression Genes by Wilcoxon Test

代码
文本

The two most popular methods in statistical approaches and software for RNA-seq data analysis are DESeq2 and edgeR. Both are built on the core assumption that sequencing data follow a negative binomial distribution, and they apply their own logic to normalize the raw read counts. If samples lack replicates, the negative binomial distribution may be noisy, in which case one might consider DEGseq based on the Poisson distribution. However, an underlying assumption that must be accepted for software like DESeq2 and edgeR to function properly is that there are no absolute differences between two groups of samples, or in other words, the expression of the vast majority of genes is the same across both groups.

A recent study[1] has indicated that once the analysis scales to large cohorts in population-level RNA-seq studies, with sample sizes ranging from several dozen to hundreds or thousands, the assumption of no differential gene expression across the majority of genes no longer holds. In population-level studies that have a larger sample size (at least several dozen), parameter assumptions often become unnecessary. Furthermore, with a larger number of samples, outliers are more likely to occur, violating assumptions and leading to unstable p-values, which in turn can invalidate the false discovery rate (FDR).

To explore how sample size affects the performance of six analytical methods, researchers conducted subsampling on each dataset, resulting in datasets with sample sizes ranging from 2 to 100. From the results shown above, it is evident that at a 1% FDR threshold, as long as the sample size per condition exceeds eight, the Wilcoxon rank-sum test performs comparably or better than the three parametric methods (DESeq2, edgeR, and limma-voom) and other non-parametric methods.

Therefore, the Wilcoxon rank-sum test should be employed for differential expression analysis in this case.

代码
文本
[1]
rm(list = ls())
setwd("/data/scRNAseq_GSEA/")
代码
文本
[2]
library(readxl)
library(dplyr)
library(tidyr)
library(openxlsx)
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


Loading required package: limma

代码
文本
[3]
fpkm_normal <- read.xlsx("brca-rsem-fpkm-tcga.xlsx",rowNames = F,colNames = T)
代码
文本
[4]
fpkm_tumor <- read.xlsx("brca-rsem-fpkm-tcga-t.xlsx",rowNames = F,colNames = T)
代码
文本

Unlike DESeq2, edgeR, and limma, as a non-regression-based method, the Wilcoxon rank-sum test cannot adjust for various potential confounding factors, such as differences in sequencing depth. Therefore, to utilize the Wilcoxon rank-sum test, RNA-seq samples should first be normalized to eliminate batch effects before analysis. Given that the provided type of scRNAseq is in FPKM format, which stands for fragments per kilobase of exon per million fragments mapped, FPKM cannot be used directly for differential expression analysis and should first be converted into another form. Here, we choose to transform it into TPM (Transcripts Per Million) because we will use the Wilcoxon Test to conduct a differential expression analysis.

Therefore, I have constructed a function that converts the expression matrix from FPKM to TPM.

代码
文本
[8]
# Function to convert FPKM to TPM
fpkm_to_tpm <- function(fpkm) {
# Obtain the gene_symbol column to merge back later
gene_symbol <- fpkm[, 1]
# Calculate the sum of FPKM values for normalization
sum_fpkm <- colSums(fpkm[, -1])
# Convert FPKM to TPM
tpm <- sweep(fpkm[, -1], 2, sum_fpkm, "/") * 1e6
# Return a data frame with gene symbols and TPM values
return(data.frame(gene_symbol, tpm))
}
代码
文本
[9]
# Convert FPKM to TPM
tpm_normal <- fpkm_to_tpm(fpkm_normal)
tpm_tumor <- fpkm_to_tpm(fpkm_tumor)
代码
文本
[10]
# Perform differential expression analysis using Wilcoxon rank-sum test
results <- data.frame(
gene_symbol = tpm_normal$gene_symbol,
Log2FoldChange = numeric(nrow(tpm_normal)),
AveExpr = numeric(nrow(tpm_normal)),
t = numeric(nrow(tpm_normal)), # Wilcoxon doesn't provide a 't' statistic
pvalue = numeric(nrow(tpm_normal)),
padj = numeric(nrow(tpm_normal)),
B = numeric(nrow(tpm_normal))
)
代码
文本
[15]
# Loop over each gene to perform the tests
for (i in 1:nrow(tpm_normal)) {
normal_values <- unlist(tpm_normal[i, -1, drop = TRUE])
tumor_values <- unlist(tpm_tumor[i, -1, drop = TRUE])
# Proceed only if both vectors are numeric and non-empty
if (is.numeric(normal_values) && is.numeric(tumor_values) && length(normal_values) > 0 && length(tumor_values) > 0) {
test_result <- wilcox.test(normal_values, tumor_values, exact = FALSE)
results$Log2FoldChange[i] <- log2(mean(tumor_values) + 1) - log2(mean(normal_values) + 1)
results$AveExpr[i] <- (mean(tumor_values) + mean(normal_values)) / 2
results$pvalue[i] <- test_result$p.value
} else {
# Assign NA to the results if the data is not numeric or is empty
results$Log2FoldChange[i] <- NA
results$AveExpr[i] <- NA
results$pvalue[i] <- NA
}
}
代码
文本
[16]
results$padj <- p.adjust(results$pvalue, method = "BH")
代码
文本

Thus, we will obtain a table listing the results of the differential expression analysis.

代码
文本
[17]
write.xlsx(results, "differential_expression_results.xlsx")
代码
文本

2 Enrichment Analysis and Visualization

Next, let's conduct enrichment analysis, including GO, KEGG, and GSEA analysis.

代码
文本
[3]
library(openxlsx)#读取.xlsx文件
library(ggplot2)#柱状图和点状图
library(stringr)#基因ID转换
library(enrichplot)#GO,KEGG,GSEA
library(clusterProfiler)#GO,KEGG,GSEA
library(GOplot)#弦图,弦表图,系统聚类图
library(DOSE)
library(ggnewscale)
library(topGO)#绘制通路网络图
library(circlize)#绘制富集分析圈图
library(ComplexHeatmap)#绘制图例
Loading required package: BiocGenerics


Attaching package: ‘BiocGenerics’


The following object is masked from ‘package:gridExtra’:

    combine


The following objects are masked from ‘package:stats’:

    IQR, mad, sd, var, xtabs


The following objects are masked from ‘package:base’:

    Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
    as.data.frame, basename, cbind, colnames, dirname, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin,
    pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table,
    tapply, union, unique, unsplit, which.max, which.min


Loading required package: graph


Attaching package: ‘graph’


The following object is masked from ‘package:stringr’:

    boundary


Loading required package: Biobase

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.


Loading required package: GO.db

Loading required package: AnnotationDbi

Loading required package: stats4

Loading required package: IRanges

Loading required package: S4Vectors


Attaching package: ‘S4Vectors’


The following object is masked from ‘package:clusterProfiler’:

    rename


The following object is masked from ‘package:utils’:

    findMatches


The following objects are masked from ‘package:base’:

    I, expand.grid, unname



Attaching package: ‘IRanges’


The following object is masked from ‘package:clusterProfiler’:

    slice



Attaching package: ‘AnnotationDbi’


The following object is masked from ‘package:clusterProfiler’:

    select


Loading required package: SparseM


Attaching package: ‘SparseM’


The following object is masked from ‘package:base’:

    backsolve



groupGOTerms: 	GOBPTerm, GOMFTerm, GOCCTerm environments built.


Attaching package: ‘topGO’


The following object is masked from ‘package:IRanges’:

    members


========================================
circlize version 0.4.15
CRAN page: https://cran.r-project.org/package=circlize
Github page: https://github.com/jokergoo/circlize
Documentation: https://jokergoo.github.io/circlize_book/book/

If you use it in published research, please cite:
Gu, Z. circlize implements and enhances circular visualization
  in R. Bioinformatics 2014.

This message can be suppressed by:
  suppressPackageStartupMessages(library(circlize))
========================================



Attaching package: ‘circlize’


The following object is masked from ‘package:graph’:

    degree


Loading required package: grid


Attaching package: ‘grid’


The following object is masked from ‘package:topGO’:

    depth


========================================
ComplexHeatmap version 2.16.0
Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
Github page: https://github.com/jokergoo/ComplexHeatmap
Documentation: http://jokergoo.github.io/ComplexHeatmap-reference

If you use it in published research, please cite either one:
- Gu, Z. Complex Heatmap Visualization. iMeta 2022.
- Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional 
    genomic data. Bioinformatics 2016.


The new InteractiveComplexHeatmap package can directly export static 
complex heatmaps into an interactive Shiny app with zero effort. Have a try!

This message can be suppressed by:
  suppressPackageStartupMessages(library(ComplexHeatmap))
========================================


代码
文本

Load in the differential expression data.

代码
文本
[4]
info <- read.xlsx( "differential_results.xlsx", rowNames = F,colNames = T)
代码
文本

First, we need to specify the species databases for enrichment analysis: the species database for GO analysis is 'org.Hs.eg.db', and for KEGG analysis, it is 'hsa'.

代码
文本
[5]
GO_database <- 'org.Hs.eg.db'
KEGG_database <- 'hsa'
代码
文本
[6]
gene <- bitr(info$gene_symbol,fromType = 'SYMBOL',toType = 'ENTREZID',OrgDb = GO_database)
'select()' returned 1:many mapping between keys and columns

Warning message in bitr(info$gene_symbol, fromType = "SYMBOL", toType = "ENTREZID", :
“11.39% of input gene IDs are fail to map...”
代码
文本
[7]
GO<-enrichGO( gene$ENTREZID,#GO富集分析
OrgDb = GO_database,
keyType = "ENTREZID",
ont = "ALL",#(ont为ALL因此包括 Biological Process,Cellular Component,Mollecular Function三部分)
pvalueCutoff = 0.05,#设定p值阈值
qvalueCutoff = 0.05,#设定q值阈值
readable = T)
代码
文本
[8]
KEGG<-enrichKEGG(gene$ENTREZID,#KEGG富集分析
organism = KEGG_database,
pvalueCutoff = 0.05,
qvalueCutoff = 0.05)
Reading KEGG annotation online: "https://rest.kegg.jp/link/hsa/pathway"...

Reading KEGG annotation online: "https://rest.kegg.jp/list/pathway/hsa"...

代码
文本
[9]
names(info) <- c('SYMBOL','Log2FoldChange','pvalue','padj')
info_merge <- merge(info,gene,by='SYMBOL')#合并转换后的基因ID和Log2FoldChange
GSEA_input <- info_merge$Log2FoldChange
names(GSEA_input) = info_merge$ENTREZID
GSEA_input = sort(GSEA_input, decreasing = TRUE)
Warning message in merge.data.frame(info, gene, by = "SYMBOL"):
“column names ‘NA’, ‘NA’ are duplicated in the result”
代码
文本
[10]
GSEA_KEGG <- gseKEGG(GSEA_input, organism = KEGG_database, pvalueCutoff = 0.05)
preparing geneSet collections...

GSEA analysis...

Warning message in preparePathwaysAndStats(pathways, stats, minSize, maxSize, gseaParam, :
“There are ties in the preranked stats (0.09% of the list).
The order of those tied genes will be arbitrary, which may produce unexpected results.”
Warning message in fgseaMultilevel(pathways = pathways, stats = stats, minSize = minSize, :
“For some pathways, in reality P-values are less than 1e-10. You can set the `eps` argument to zero for better estimation.”
leading edge analysis...

done...

代码
文本
[11]
GSEA_KEGG
#
# Gene Set Enrichment Analysis
#
#...@organism 	 hsa 
#...@setType 	 KEGG 
#...@keytype 	 kegg 
#...@geneList 	 Named num [1:17493] 7.68 6.52 5.99 5.81 5.78 ...
 - attr(*, "names")= chr [1:17493] "1300" "1469" "4320" "1301" ...
#...nPerm 	 
#...pvalues adjusted by 'BH' with cutoff <0.05 
#...49 enriched terms found
'data.frame':	49 obs. of  11 variables:
 $ ID             : chr  "hsa04110" "hsa00982" "hsa04152" "hsa04923" ...
 $ Description    : chr  "Cell cycle" "Drug metabolism - cytochrome P450" "AMPK signaling pathway" "Regulation of lipolysis in adipocytes" ...
 $ setSize        : int  154 68 120 54 74 49 42 73 68 65 ...
 $ enrichmentScore: num  0.603 -0.684 -0.566 -0.685 -0.642 ...
 $ NES            : num  2.42 -2.22 -1.98 -2.13 -2.11 ...
 $ pvalue         : num  1.00e-10 2.74e-08 2.40e-07 3.85e-07 4.40e-07 ...
 $ p.adjust       : num  3.38e-08 4.64e-06 2.71e-05 2.98e-05 2.98e-05 ...
 $ qvalue         : num  2.34e-08 3.20e-06 1.87e-05 2.06e-05 2.06e-05 ...
 $ rank           : num  1298 3057 1227 1253 1640 ...
 $ leading_edge   : chr  "tags=27%, list=7%, signal=25%" "tags=46%, list=17%, signal=38%" "tags=19%, list=7%, signal=18%" "tags=54%, list=7%, signal=50%" ...
 $ core_enrichment: chr  "9088/995/5347/991/699/9133/10403/9212/113130/701/9232/8318/890/9700/983/7272/990/9134/157570/1870/81620/1869/89"| __truncated__ "2941/2330/2329/2952/27306/2328/131/1577/128/130/54577/7363/2950/2326/4257/7364/1576/1548/54490/2946/10720/4129/"| __truncated__ "81617/5519/5521/10891/8660/5209/2308/5295/9586/2998/3479/5207/3953/5468/32/148/6517/3991/948/5105/1149/9370/3952" "7253/5290/51099/134/114/112/109/155/3667/10000/4886/57104/8660/5733/5295/196883/153/11343/111/2770/5743/5140/15"| __truncated__ ...
#...Citation
 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 
代码
文本
[25]
barplot(GO, width=0.5, space=0.4, angle = 90, hjust = 1, size = rel(0.1), split="ONTOLOGY")+facet_grid(ONTOLOGY~., scale="free")
代码
文本

The GO terms are grouped into different biological processes, including gland development, small GTPase mediated signal transduction, embryonic organ development, mononuclear cell differentiation, and others. The presence of these terms suggests these biological processes are potentially involved in the differences between normal and tumor samples in breast cancer. For instance, GO terms such as "gland development" and "embryonic organ development" with a high number of counts and very low p-values (dark red bars) suggest that these processes are highly relevant in the context of the tumor's biology and are significantly different compared to normal samples.

Similarly, terms like "DNA-binding transcription factor activity" and "RNA polymerase II-specific DNA-binding transcription factor binding" have a high count, which implies a significant change in gene expression related to transcription regulation between normal and tumor tissues. The blue bar at the bottom represents "GTPase regulator activity," which has a substantial number of genes involved but with a less significant p-value (as indicated by the lighter shade of red).

代码
文本
[26]
pdf(file=paste0("1.", "GO_柱状图.pdf"),height=12,width=10)
barplot(GO, split="ONTOLOGY")+facet_grid(ONTOLOGY~., scale="free")#柱状图
dev.off()
png: 2
代码
文本
[32]
barplot(KEGG,showCategory = 40,title = 'KEGG Pathway')
代码
文本

Due to this chart, the PI3K-Akt signaling pathway has the highest count of differentially expressed genes, suggesting that this pathway plays a significant role in the molecular events of BRCA tumor development or progression.

Pathways such as MAPK signaling, Cytokine-cytokine receptor interaction, and Calcium signaling also have high counts, underscoring their potential involvement in breast cancer pathophysiology. The Breast cancer pathway itself is highlighted, which is expected since the dataset specifically concerns breast cancer.

The color coding shows that pathways related to cancer, immune response, and cell signaling (such as Hepatocellular carcinoma, Human T-cell leukemia virus 1 infection, and Chemokine signaling pathway) are highly significant, as indicated by the deeper red colors.

Interestingly, pathways like Neuroactive ligand-receptor interaction and the Neurotrophin signaling pathway are also represented, which could suggest a role for these neuro-related pathways in breast cancer, a connection that has been explored in recent research.

The presence of non-cancer-specific pathways (such as Salmonella infection or AMPK signaling pathway) may reflect broader cellular processes affected by cancer or might be incidental findings due to the wide-ranging impact of the disease on cellular metabolism.

代码
文本
[28]
pdf(file=paste0("1.", "KEGG_柱状图.pdf"),height=12,width=10)
barplot(KEGG,showCategory = 40,title = 'KEGG Pathway')
dev.off()
png: 2
代码
文本
[29]
dotplot(GO, split="ONTOLOGY")+facet_grid(ONTOLOGY~., scale="free")
代码
文本

Processes like "small GTPase mediated signal transduction" and "mononuclear cell differentiation" have a relatively high Gene Ratio and a significant number of genes involved (larger red dots), indicating these are likely important processes in the tumor samples.

"Gland development" and "embryonic organ development" also show significant enrichment, which is expected in the context of breast cancer, as these processes are related to tissue and organ formation, and their dysregulation might play a role in tumorigenesis.

Some terms like "DNA-binding transcription factor activity" and "actin binding" appear less significant (indicated by blue dots) and involve fewer genes (smaller dots), which may suggest a lesser role in the specific aspects of breast cancer pathology being studied.

Overall, the dot plot visualizes which biological processes are most significantly associated with the genes that are differentially expressed between normal and breast cancer tumor samples.

代码
文本
[30]
pdf(file=paste0("2.", "GO_点状图.pdf"),height=14,width=10)
dotplot(GO, split="ONTOLOGY")+facet_grid(ONTOLOGY~., scale="free")#点状图
dev.off()
png: 2
代码
文本
[31]
dotplot(KEGG)
代码
文本

Due to this dotplot, the Neuroactive ligand-receptor interaction and PI3K-Akt signaling pathway appear to be the most significantly enriched pathways, as indicated by their position towards the top of the plot and their red color.

MAPK signaling and Cytokine-cytokine receptor interaction pathways also show significant enrichment, suggesting these signaling pathways are potentially involved in the pathophysiology of breast cancer.

The presence of pathways such as Human papillomavirus infection may reflect underlying processes related to viral mechanisms that could be implicated in cancer or might be associated with the wider effects of tumor biology on cellular function.

The Calcium signaling pathway and cAMP signaling pathway are less significantly enriched but still noteworthy, as indicated by their purple and blue colors.

The size of the dots, particularly for pathways like Neuroactive ligand-receptor interaction and PI3K-Akt signaling, suggests a substantial number of genes are involved, highlighting the importance of these pathways in the context of BRCA tumor biology.

代码
文本

Now, let's discover the correlation between GO pathways.

代码
文本
[33]
GO2 <- pairwise_termsim(GO)
enrichplot::emapplot(GO2,showCategory = 50, color = "p.adjust", layout = "kk")
Warning message in emapplot.enrichResult(x, showCategory = showCategory, ...):
“Use 'layout.params = list(layout = your_value)' instead of 'layout'.
 The layout parameter will be removed in the next version.”
代码
文本

The network plot visualizes the relationships and overlap between different GO biological process categories. Each node (circle) represents a GO term, and the size of the node reflects the number of genes associated with that term—larger nodes indicate more genes are involved. The color of the nodes corresponds to the adjusted p-value (p.adjust) of the enrichment, with the gradient from blue to red indicating less to more significant terms, respectively.

Central nodes, like "small GTPase mediated signal transduction" and "cell junction assembly," suggest they are pivotal biological processes with a larger number of genes involved, making them potentially crucial in the context of the pathology of breast cancer. Highly connected nodes indicate GO terms that share a significant number of genes, suggesting related or overlapping biological functions.

Red nodes, such as "response to metal ion" and "synapse organization," are among the most significantly enriched processes, which might be particularly relevant to the pathophysiology of breast cancer.

Peripheral nodes with fewer connections and smaller size may represent more specific processes that are altered between normal and tumor samples but are not as broadly represented across the differentially expressed genes.

The plot provides a comprehensive overview of the biological processes that are most impacted in breast cancer tumor tissue compared to normal breast tissue.

Furthermore, we can make a directed acyclic graph (DAG) representing a hierarchy of Biological Process (BP) Gene Ontology (GO) terms derived from a GO enrichment analysis.

代码
文本
[34]
pdf(file=paste0("3.", "GO_通路间关联网络图.pdf"),height=9,width=10)
enrichplot::emapplot(GO2,showCategory = 50, color = "p.adjust", layout = "kk")#通路间关联网络图
dev.off()
Warning message in emapplot.enrichResult(x, showCategory = showCategory, ...):
“Use 'layout.params = list(layout = your_value)' instead of 'layout'.
 The layout parameter will be removed in the next version.”
png: 2
代码
文本

And let's discover the correlation between KEGG pathways.

代码
文本
[36]
KEGG2 <- pairwise_termsim(KEGG)
enrichplot::emapplot(KEGG2,showCategory =50, color = "p.adjust", layout = "kk")
Warning message in emapplot.enrichResult(x, showCategory = showCategory, ...):
“Use 'layout.params = list(layout = your_value)' instead of 'layout'.
 The layout parameter will be removed in the next version.”
Warning message:
“ggrepel: 17 unlabeled data points (too many overlaps). Consider increasing max.overlaps”
代码
文本

Central and larger nodes like those representing the Cell cycle and MAPK signaling pathway are significant and involve a high number of genes, suggesting these pathways play a central role in the biology of breast cancer presented in the data. Pathways such as Estrogen signaling, PI3K-Akt signaling, and Insulin signaling are also highlighted. These signaling pathways are known to be crucial in breast cancer development and progression, affecting cell growth, metabolism, and survival.

The presence of infection-related pathways like Human papillomavirus infection, Salmonella infection, and notably Coronavirus disease – COVID-19 in the context of breast cancer analysis might reflect the impact of these infections on cellular processes or could be due to the interplay between infectious agents and cancer pathways.

Peripheral nodes such as Peroxisome, Endocytosis, and Lysosome might indicate ancillary pathways that are less central but still impacted by the differential gene expression between normal and tumor samples.

The network layout with densely interconnected nodes in the center and less connected nodes on the periphery helps identify the core biological processes and secondary pathways that may contribute to the phenotype observed.

代码
文本
[37]
pdf(file=paste0("3.", "KEGG_通路间关联网络图.pdf"),height=9,width=10)
enrichplot::emapplot(KEGG2,showCategory =50, color = "p.adjust", layout = "kk")
dev.off()
Warning message in emapplot.enrichResult(x, showCategory = showCategory, ...):
“Use 'layout.params = list(layout = your_value)' instead of 'layout'.
 The layout parameter will be removed in the next version.”
png: 2
代码
文本
[38]
GO_BP<-enrichGO( gene$ENTREZID,
OrgDb = GO_database,
keyType = "ENTREZID",
ont = "BP",
pvalueCutoff = 0.05,
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
minGSSize = 10,
maxGSSize = 500,
readable = T)
代码
文本
[41]
plotGOgraph(GO_BP)
groupGOTerms: 	GOBPTerm, GOMFTerm, GOCCTerm environments built.


Building most specific GOs .....

	( 15741 GO terms found. )


Build GO DAG topology ..........

	( 15741 GO terms and 35553 relations. )


Annotating nodes ...............

	( 18614 genes annotated to the GO terms. )

Loading required package: Rgraphviz


Attaching package: ‘Rgraphviz’


The following objects are masked from ‘package:IRanges’:

    from, to


The following objects are masked from ‘package:S4Vectors’:

    from, to


$dag
A graphNEL graph with directed edges
Number of Nodes = 51 
Number of Edges = 72 

$complete.dag
[1] "A graph with 51 nodes."
代码
文本

The central node colored in red, "GO:0042127 - regulation of cell proliferation", is a critical biological process often implicated in cancer, indicating that regulation of cell proliferation is significantly affected in BRCA tumor samples.

The nodes in orange may represent processes that are important but have a slightly lower significance level compared to the red node. They include processes such as "GO:0051270 - regulation of cell motion" and "GO:0030334 - regulation of cell migration", which are also relevant to cancer progression as they involve the movement and spread of cells.

Yellow nodes, such as "GO:0007155 - cell adhesion", could be indicative of processes that are important in the context of the pathology, like the adhesion of cancer cells within the tumor microenvironment or to distant tissues during metastasis.

代码
文本
[43]
pdf(file=paste0("4.", "GO-BP功能网络图.pdf"),height=9,width=10)
plotGOgraph(GO_BP)#GO-BP功能网络图
dev.off()
groupGOTerms: 	GOBPTerm, GOMFTerm, GOCCTerm environments built.


Building most specific GOs .....

	( 15741 GO terms found. )


Build GO DAG topology ..........

	( 15741 GO terms and 35553 relations. )


Annotating nodes ...............

	( 18614 genes annotated to the GO terms. )

$dag
A graphNEL graph with directed edges
Number of Nodes = 51 
Number of Edges = 72 

$complete.dag
[1] "A graph with 51 nodes."
png: 2
代码
文本
[44]
GO_CC<-enrichGO( gene$ENTREZID,#GO富集分析CC模块
OrgDb = GO_database,
keyType = "ENTREZID",
ont = "CC",
pvalueCutoff = 0.05,
pAdjustMethod = "BH",
qvalueCutoff = 0.05,
minGSSize = 10,
maxGSSize = 500,
readable = T)
代码
文本
[45]
plotGOgraph(GO_CC)
groupGOTerms: 	GOBPTerm, GOMFTerm, GOCCTerm environments built.


Building most specific GOs .....

	( 1919 GO terms found. )


Build GO DAG topology ..........

	( 1919 GO terms and 3154 relations. )


Annotating nodes ...............

	( 19518 genes annotated to the GO terms. )

$dag
A graphNEL graph with directed edges
Number of Nodes = 38 
Number of Edges = 54 

$complete.dag
[1] "A graph with 38 nodes."
代码
文本
[46]
pdf(file=paste0("4.", "GO-CC功能网络图.pdf"),height=9,width=10)
plotGOgraph(GO_CC)#GO-CC功能网络图
dev.off()
groupGOTerms: 	GOBPTerm, GOMFTerm, GOCCTerm environments built.


Building most specific GOs .....

	( 1919 GO terms found. )


Build GO DAG topology ..........

	( 1919 GO terms and 3154 relations. )


Annotating nodes ...............

	( 19518 genes annotated to the GO terms. )

$dag
A graphNEL graph with directed edges
Number of Nodes = 38 
Number of Edges = 54 

$complete.dag
[1] "A graph with 38 nodes."
png: 2
代码
文本
[47]
genedata<-data.frame(ID=info$gene_symbol,logFC=info$log2FoldChange)
代码
文本
[48]
write.table(GO$ONTOLOGY, file = "GO_ONTOLOGYs.txt",
append = FALSE, quote = TRUE, sep = " ",
eol = "\n", na = "NA", dec = ".", row.names = TRUE,
col.names = TRUE, qmethod = c("escape", "double"),
fileEncoding = "")
代码
文本
[49]
ridgeplot(GSEA_KEGG)
Picking joint bandwidth of 0.424

代码
文本
[50]
pdf(file=paste0("5.", "GSEA ridgeplot.pdf"),height=12,width=10)
ridgeplot(GSEA_KEGG)
dev.off()
Picking joint bandwidth of 0.424

png: 2
代码
文本
[66]
gseaplot2(GSEA_KEGG,1,title = 'Enrichment Plot: Cell cycle')
代码
文本
[51]
pdf(file=paste0("5.", "GSEA gseaplot.pdf"),height=9,width=10)
gseaplot2(GSEA_KEGG,1)
dev.off()
png: 2
代码
文本
[53]
gseaplot2(GSEA_KEGG,1:30)
代码
文本
[52]
pdf(file=paste0("5.", "GSEA gseaplot2.pdf"),height=9,width=10)
gseaplot2(GSEA_KEGG,1:30)
dev.off()
png: 2
代码
文本
[67]
library(forcats)
代码
文本
[72]
library(ggstance)
Attaching package: ‘ggstance’


The following objects are masked from ‘package:ggplot2’:

    GeomErrorbarh, geom_errorbarh


代码
文本
[74]
dotplot(GSEA_KEGG,x='GeneRatio', showCategory =20)
代码
文本
[75]
dotplot(GSEA_KEGG,split='.sign')+facet_grid(~.sign)
代码
文本
[78]
y <- arrange(GSEA_KEGG, abs(NES)) %>% group_by(sign(NES))
Warning message:
“The `add` argument of `group_by()` is deprecated as of dplyr 1.0.0.
 Please use the `.add` argument instead.
 The deprecated feature was likely used in the dplyr package.
  Please report the issue at <https://github.com/tidyverse/dplyr/issues>.”
代码
文本
[87]

ggplot(y,aes(NES,fct_reorder(Description,NES),fill=qvalue),showCategory=20)+
geom_barh(stat='identity')+
scale_fill_continuous(low='red',high='blue')+
theme_minimal()+ylab(NULL)
代码
文本

The gradient from blue to red indicates increasing significance, with red being the most statistically significant (lowest q-value). Positive NES (to the right) indicates gene sets that are overrepresented at the top of the ranked list, suggesting a potential upregulation or activation in the condition being studied. And negative NES (to the left) indicates gene sets that are overrepresented at the bottom of the ranked list, suggesting potential downregulation or deactivation.

From this plot, we can infer which biological processes or pathways might be relevant in the condition or phenotype being studied. For example, gene sets related to "Antigen processing and presentation," "Nucleocytoplasmic transport", and "Motor proteins" show a positive NES, suggesting they might be more active. On the other hand, gene sets such as "ABC transporters" and "Insulin resistance" have a negative NES, indicating they might be less active or downregulated in the condition under study.

Pathways on the far right with positive NES values and red bars, such as Antigen processing and presentation and Nucleocytoplasmic transport, are significantly enriched in the tumor samples. This suggests these pathways are upregulated in the primary tumor samples compared to the normal samples and could be critical in the cancer’s biology.

The PI3K-Akt signaling pathway, often implicated in cancer, shows a moderate NES and a highly significant q-value. This pathway's role in cell survival, growth, and metabolism is well-documented in oncology, and its enrichment here supports its potential involvement in breast cancer tumorigenesis.

Pathways with negative NES values, depicted by blue bars, such as ABC transporters and Insulin resistance, are potentially downregulated in the tumor samples. These pathways might be less active in tumor cells or could be associated with the tumor microenvironment’s metabolic changes. The q-value color coding indicates that all the depicted pathways are significantly enriched, but those with the reddest bars, such as Nucleocytoplasmic transport and Antigen processing and presentation, are the most statistically significant.

代码
文本
[88]
pdf(file=paste0("5.", "GSEA barplot总.pdf"),height=9,width=10)
ggplot(y,aes(NES,fct_reorder(Description,NES),fill=qvalue),showCategory=20)+
geom_barh(stat='identity')+
scale_fill_continuous(low='red',high='blue')+
theme_minimal()+ylab(NULL)
dev.off()
png: 2
代码
文本

References:

[1] Li, Yumei, Xinzhou Ge, Fanglue Peng, Wei Li, and Jingyi Jessica Li. “Exaggerated False Positives by Popular Differential Expression Methods When Analyzing Human Population Samples.” Genome Biology 23, no. 1 (March 15, 2022): 79. https://doi.org/10.1186/s13059-022-02648-4.

代码
文本
bioinformatics
生物信息学
bioinformatics生物信息学
已赞3
推荐阅读
公开
transPlotR:优雅地绘制基因转录本结构
生物信息学中文基因组转录组
生物信息学中文基因组转录组
Judy Lin
发布于 2023-08-05
1 赞1 转存文件2 评论
公开
有参考基因组的Bulk RNA-Seq数据分析
生物信息学rnaseq
生物信息学rnaseq
Julia_Xiang
发布于 2023-07-17
5 赞7 转存文件4 评论