library(TCGAbiolinks)
# 读取之前保存的数据
dataPrep <- readRDS("dataprep.rds")
dataPrep <- TCGAanalyze_Preprocessing(object = dataPrep,
cor.cut = 0.6)Number of outliers: 0
本笔记的目的在于对下载好的 TCGA 乳腺癌数据集进行指控以及差异分析(肿瘤 vs 正常)。
TCGAanalyze_Preprocessing()对数据进行预处理:使用 spearman 相关系数去除数据中的异常值:
library(TCGAbiolinks)
# 读取之前保存的数据
dataPrep <- readRDS("dataprep.rds")
dataPrep <- TCGAanalyze_Preprocessing(object = dataPrep,
cor.cut = 0.6)Number of outliers: 0
导出:
write.csv(dataPrep,file = "TCGA_BRCA.csv",quote = FALSE)TCGAanalyze_Preprocessing()中的参数:
| 参数 | 用法 |
|---|---|
| object | 来自TCGAprepare的结果 |
| cor.cut | 设置阈值,根据样本中各个样本之间的spearman相关系数进行过滤。默认为0 |
| filename | 设置生成图片文件的名称,默认为PreprocessingOutput.png |
| width | 生成图片的宽度 |
| height | 生成图片的高度 |
| datatype | 描述RangedSummarizedExperiment 数据类型的字符串 |
进行表达矩阵标准化和过滤,得到用于差异分析的表达矩阵:
TCGAanalyze_Normalization()使用EDASeq软件包标准化 mRNA 转录本和 miRNA。 TCGAanalyze_Normalization()执行EDASeq包中的如下功能:
EDASeq::newSeqExpressionSet
EDASeq::withinLaneNormalization
EDASeq::betweenLaneNormalization
EDASeq::counts
在此之前需要先安装EDASeq软件包:
BiocManager::install("EDASeq")dataNorm <- TCGAanalyze_Normalization(
tabDF = dataPrep,
geneInfo = geneInfoHT
)I Need about 887 seconds for this Complete Normalization Upper Quantile [Processing 80k elements /s]
Step 1 of 4: newSeqExpressionSet ...
Step 2 of 4: withinLaneNormalization ...
Step 3 of 4: betweenLaneNormalization ...
Step 4 of 4: exprs ...
基因百分位筛选:
dataFilt <- TCGAanalyze_Filtering(
tabDF = dataNorm,
method = "quantile",
qnt.cut = 0.25
)提取癌组织及正常组织:
# selection of normal samples "NT"
samplesNT <- TCGAquery_SampleTypes(
barcode = colnames(dataFilt),
typesample = c("NT")
)
# selection of tumor samples "TP"
samplesTP <- TCGAquery_SampleTypes(
barcode = colnames(dataFilt),
typesample = c("TP")
)TCGAanalyze_DEA函数使用以下 R 函数执行差异分析:
edgeR::DGEList 将计数矩阵转换为edgeR对象。edgeR::estimateCommonDisp 每个基因被分配相同的离散度估计。edgeR::exactTest 对两组之间的差异表达进行成对检验。edgeR::topTags 获取exactTest()的输出,使用 FDR 校正调整原始 p 值,并返回前几个差异表达基因。在此之前需要先安装edgeR软件包:
BiocManager::install("edgeR")这个函数接受如下参数:
mat1 第一组的矩阵(在本例中,第一组是正常样本)
mat2 第二组的矩阵(在本例中,第二组是肿瘤样本)
Cond1type 第一组的标签
Cond2type 第二组的标签
# Diff.expr.analysis (DEA)
dataDEGs <- TCGAanalyze_DEA(
mat1 = dataFilt[,samplesNT],
mat2 = dataFilt[,samplesTP],
Cond1type = "Normal",
Cond2type = "Tumor",
fdr.cut = 0.01 ,
logFC.cut = 1,
method = "glmLRT"
)Batch correction skipped since no factors provided
----------------------- DEA -------------------------------
o 113 samples in Cond1type Normal
o 1111 samples in Cond2type Tumor
o 26540 features as miRNA or genes
This may take some minutes...
----------------------- END DEA -------------------------------
# DEGs table with expression values in normal and tumor samples
# 输出结果
dataDEGsFiltLevel <- TCGAanalyze_LevelTab(
FC_FDR_table_mRNA = dataDEGs,
typeCond1 = "Tumor",
typeCond2 = "Normal",
TableCond1 = dataFilt[,samplesTP],
TableCond2 = dataFilt[,samplesNT]
)看看输出的结果:
head(dataDEGs) logFC logCPM LR PValue FDR
ENSG00000000005 -3.459760 1.345418 352.86249 1.008787e-78 2.754444e-77
ENSG00000000460 1.295790 3.652530 217.64219 2.955933e-49 4.062685e-48
ENSG00000000971 -1.347594 5.925204 232.26403 1.912521e-52 2.867701e-51
ENSG00000001617 1.121932 6.776507 145.12346 2.018223e-33 1.662950e-32
ENSG00000002079 1.054519 -1.570113 39.04656 4.138172e-10 1.038947e-09
ENSG00000002726 3.418085 1.968093 122.54263 1.756018e-28 1.181062e-27
gene_name gene_type
ENSG00000000005 TNMD protein_coding
ENSG00000000460 C1orf112 protein_coding
ENSG00000000971 CFH protein_coding
ENSG00000001617 SEMA3F protein_coding
ENSG00000002079 MYH16 transcribed_unitary_pseudogene
ENSG00000002726 AOC1 protein_coding
head(dataDEGsFiltLevel) mRNA logFC FDR Delta Tumor
ENSG00000108821 ENSG00000108821 2.250877 6.552169e-48 929155.8 412797.3
ENSG00000115414 ENSG00000115414 2.927516 2.736040e-78 912481.3 311691.3
ENSG00000153002 ENSG00000153002 4.652968 2.759898e-16 502990.8 108101.1
ENSG00000164692 ENSG00000164692 1.602106 3.985857e-29 500681.0 312514.2
ENSG00000211896 ENSG00000211896 3.063492 1.424533e-22 499798.5 163146.7
ENSG00000168542 ENSG00000168542 1.426295 5.324314e-23 404047.3 283284.5
Normal start end
ENSG00000108821 84650.053 50184101 50201632
ENSG00000115414 39882.327 215360440 215436073
ENSG00000153002 3887.947 148791102 148860187
ENSG00000164692 102432.071 94394895 94431227
ENSG00000211896 19985.912 105736343 105743071
ENSG00000168542 104408.619 188974373 189012746
保存:
write.csv(dataDEGs, "BRCA_dataDEGs.csv")
write.csv(dataDEGsFiltLevel, "BRCA_dataDEGsFiltLevel.csv")devtools::session_info()─ Session info ───────────────────────────────────────────────────────────────
setting value
version R version 4.3.1 (2023-06-16 ucrt)
os Windows 11 x64 (build 22621)
system x86_64, mingw32
ui RTerm
language (EN)
collate Chinese (Simplified)_China.utf8
ctype Chinese (Simplified)_China.utf8
tz Asia/Hong_Kong
date 2023-11-04
pandoc 3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
─ Packages ───────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 4.3.0)
AnnotationDbi 1.62.2 2023-07-02 [1] Bioconductor
aroma.light 3.30.0 2023-04-25 [1] Bioconductor
Biobase 2.60.0 2023-04-25 [1] Bioconductor
BiocFileCache 2.8.0 2023-04-25 [1] Bioconductor
BiocGenerics 0.46.0 2023-04-25 [1] Bioconductor
BiocIO 1.10.0 2023-04-25 [1] Bioconductor
BiocParallel 1.34.2 2023-05-22 [1] Bioconductor
biomaRt 2.56.1 2023-06-11 [1] Bioconductor
Biostrings 2.68.1 2023-05-16 [1] Bioconductor
bit 4.0.5 2022-11-15 [1] CRAN (R 4.3.1)
bit64 4.0.5 2020-08-30 [1] CRAN (R 4.3.1)
bitops 1.0-7 2021-04-24 [1] CRAN (R 4.3.0)
blob 1.2.4 2023-03-17 [1] CRAN (R 4.3.1)
cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.1)
callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.1)
cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.1)
codetools 0.2-19 2023-02-01 [2] CRAN (R 4.3.1)
colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.1)
crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.1)
curl 5.0.1 2023-06-07 [1] CRAN (R 4.3.1)
data.table 1.14.8 2023-02-17 [1] CRAN (R 4.3.1)
DBI 1.1.3 2022-06-18 [1] CRAN (R 4.3.1)
dbplyr 2.3.3 2023-07-07 [1] CRAN (R 4.3.1)
DelayedArray 0.26.7 2023-07-28 [1] Bioconductor
deldir 1.0-9 2023-05-17 [1] CRAN (R 4.3.0)
devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.1)
digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.1)
downloader 0.4 2015-07-09 [1] CRAN (R 4.3.2)
dplyr 1.1.2 2023-04-20 [1] CRAN (R 4.3.1)
EDASeq 2.34.0 2023-04-25 [1] Bioconductor
edgeR 3.42.4 2023-06-01 [1] Bioconductor
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.1)
evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.1)
fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.1)
fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.1)
filelock 1.0.2 2018-10-05 [1] CRAN (R 4.3.1)
fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1)
generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.1)
GenomeInfoDb 1.36.4 2023-10-02 [1] Bioconductor
GenomeInfoDbData 1.2.10 2023-10-18 [1] Bioconductor
GenomicAlignments 1.36.0 2023-04-25 [1] Bioconductor
GenomicFeatures 1.52.2 2023-08-25 [1] Bioconductor
GenomicRanges 1.52.1 2023-10-08 [1] Bioconductor
ggplot2 3.4.2 2023-04-03 [1] CRAN (R 4.3.1)
glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.1)
gtable 0.3.3 2023-03-21 [1] CRAN (R 4.3.1)
hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.1)
htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.1)
htmlwidgets 1.6.2 2023-03-17 [1] CRAN (R 4.3.1)
httpuv 1.6.11 2023-05-11 [1] CRAN (R 4.3.1)
httr 1.4.6 2023-05-08 [1] CRAN (R 4.3.1)
hwriter 1.3.2.1 2022-04-08 [1] CRAN (R 4.3.1)
interp 1.1-4 2023-03-31 [1] CRAN (R 4.3.2)
IRanges 2.34.1 2023-06-22 [1] Bioconductor
jpeg 0.1-10 2022-11-29 [1] CRAN (R 4.3.1)
jsonlite 1.8.7 2023-06-29 [1] CRAN (R 4.3.1)
KEGGREST 1.40.1 2023-09-29 [1] Bioconductor
knitr 1.43 2023-05-25 [1] CRAN (R 4.3.1)
later 1.3.1 2023-05-02 [1] CRAN (R 4.3.1)
lattice 0.21-8 2023-04-05 [2] CRAN (R 4.3.1)
latticeExtra 0.6-30 2022-07-04 [1] CRAN (R 4.3.2)
lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.1)
limma 3.56.2 2023-06-04 [1] Bioconductor
locfit 1.5-9.8 2023-06-11 [1] CRAN (R 4.3.2)
magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.1)
Matrix 1.5-4.1 2023-05-18 [2] CRAN (R 4.3.1)
MatrixGenerics 1.12.3 2023-07-30 [1] Bioconductor
matrixStats 1.0.0 2023-06-02 [1] CRAN (R 4.3.1)
memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.1)
mime 0.12 2021-09-28 [1] CRAN (R 4.3.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.3.1)
pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.1)
pkgbuild 1.4.2 2023-06-26 [1] CRAN (R 4.3.1)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.1)
pkgload 1.3.2.1 2023-07-08 [1] CRAN (R 4.3.1)
plyr 1.8.8 2022-11-11 [1] CRAN (R 4.3.1)
png 0.1-8 2022-11-29 [1] CRAN (R 4.3.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.3.1)
processx 3.8.2 2023-06-30 [1] CRAN (R 4.3.1)
profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.1)
progress 1.2.2 2019-05-16 [1] CRAN (R 4.3.1)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.3.1)
ps 1.7.5 2023-04-18 [1] CRAN (R 4.3.1)
purrr 1.0.1 2023-01-10 [1] CRAN (R 4.3.1)
R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0)
R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.3.0)
R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.3.1)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.1)
rappdirs 0.3.3 2021-01-31 [1] CRAN (R 4.3.1)
RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.3.0)
Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.3.1)
RCurl 1.98-1.12 2023-03-27 [1] CRAN (R 4.3.1)
readr 2.1.4 2023-02-10 [1] CRAN (R 4.3.1)
remotes 2.4.2.1 2023-07-18 [1] CRAN (R 4.3.1)
restfulr 0.0.15 2022-06-16 [1] CRAN (R 4.3.2)
rjson 0.2.21 2022-01-09 [1] CRAN (R 4.3.1)
rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.1)
rmarkdown 2.23 2023-07-01 [1] CRAN (R 4.3.1)
Rsamtools 2.16.0 2023-04-25 [1] Bioconductor
RSQLite 2.3.1 2023-04-03 [1] CRAN (R 4.3.1)
rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.1)
rtracklayer 1.60.1 2023-08-15 [1] Bioconductor
rvest 1.0.3 2022-08-19 [1] CRAN (R 4.3.1)
S4Arrays 1.0.6 2023-08-30 [1] Bioconductor
S4Vectors 0.38.2 2023-09-22 [1] Bioconductor
scales 1.2.1 2022-08-20 [1] CRAN (R 4.3.1)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.1)
shiny 1.7.4.1 2023-07-06 [1] CRAN (R 4.3.1)
ShortRead 1.58.0 2023-04-25 [1] Bioconductor
stringi 1.7.12 2023-01-11 [1] CRAN (R 4.3.0)
stringr 1.5.0 2022-12-02 [1] CRAN (R 4.3.1)
SummarizedExperiment 1.30.2 2023-06-06 [1] Bioconductor
TCGAbiolinks * 2.28.4 2023-10-05 [1] Bioconductor
TCGAbiolinksGUI.data 1.20.0 2023-04-27 [1] Bioconductor
tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.1)
tidyr 1.3.0 2023-01-24 [1] CRAN (R 4.3.1)
tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.3.1)
tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.3.1)
urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.1)
usethis 2.2.2 2023-07-06 [1] CRAN (R 4.3.1)
utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.1)
vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.1)
xfun 0.39 2023-04-20 [1] CRAN (R 4.3.1)
XML 3.99-0.14 2023-03-19 [1] CRAN (R 4.3.1)
xml2 1.3.5 2023-07-06 [1] CRAN (R 4.3.1)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.1)
XVector 0.40.0 2023-04-25 [1] Bioconductor
yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0)
zlibbioc 1.46.0 2023-04-25 [1] Bioconductor
[1] C:/Users/Han Wang/AppData/Local/R/win-library/4.3
[2] C:/Program Files/R/R-4.3.1/library
──────────────────────────────────────────────────────────────────────────────