> Glycosites <- read.csv("D:/SCLC组学/糖基化/Glycosites.csv")
> View(Glycosites)
> NGT <- read.csv("D:/SCLC组学/糖基化/NGT.csv")
> View(NGT)
> View(Glycosites)
> View(NGT)
> View(Glycosites)
> View(NGT)
> View(Glycosites)
> setwd("D:/SCLC组学/糖基化")
> library(tidyverse)
>
> library(psych)
>
> library(pheatmap)
>
> library(qvalue)
错误于library(qvalue): 不存在叫‘qvalue’这个名称的程序包
> BiocManager::install("qvalue")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
Bioconductor version 3.21 (BiocManager 1.30.25), R 4.5.0 (2025-04-11 ucrt)
Installing package(s) 'qvalue'
试开URL’https://bioconductor.org/packages/3.21/bioc/bin/windows/contrib/4.5/qvalue_2.40.0.zip'
Content type 'application/zip' length 2810649 bytes (2.7 MB)
downloaded 2.7 MB
程序包‘qvalue’打开成功,MD5和检查也通过
下载的二进制程序包在
C:\Users\lenovo\AppData\Local\Temp\RtmpIl7yPX\downloaded_packages里
Old packages: 'annotate', 'BiocManager', 'BiocParallel', 'commonmark', 'ComplexHeatmap',
'cowplot', 'curl', 'data.table', 'dendextend', 'Deriv', 'doBy', 'DropletUtils',
'edgeR', 'emmeans', 'evaluate', 'fitdistrplus', 'future', 'future.apply', 'ggforce',
'ggpubr', 'gh', 'h5mread', 'haven', 'httr2', 'KEGGREST', 'limma', 'maps', 'openssl',
'parallelly', 'patchwork', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'plotly',
'promises', 'purrr', 'Rcpp', 'RcppArmadillo', 'restfulr', 'rhdf5', 'rprojroot',
'RSQLite', 'S4Arrays', 'shiny', 'spatstat.explore', 'spatstat.geom', 'spatstat.random',
'spatstat.univar', 'spatstat.utils', 'statnet.common', 'tensor', 'tibble', 'utf8',
'waldo', 'xgboost', 'zip', 'lattice', 'mgcv'
Update all/some/none? [a/s/n]:
n
> library(qvalue)
>
> Glycosites <- Glycosites[, colnames(NGT)]
错误于`[.data.frame`(Glycosites, , colnames(NGT)): 选择了未定义的列
> Glycosites <- Glycosites[, colnames(NGT)]
错误于`[.data.frame`(Glycosites, , colnames(NGT)): 选择了未定义的列
> View(NGT)
> colnames(Glycosites)[1] <- "Gene.Name"
> Glycosites <- Glycosites[, colnames(NGT)]
>
> results <- data.frame(
+ Gene = rownames(NGT),
+ Rho = numeric(nrow(NGT)),
+ P_value = numeric(nrow(NGT)),
+ Q_value = numeric(nrow(NGT))
+ )
> for(i in 1:nrow(NGT)) {
+ gene <- rownames(NGT)[i]
+
+ # 仅当两个表中都存在该基因时才计算
+ if(gene %in% rownames(Glycosites)) {
+ cor_test <- cor.test(
+ x = NGT[gene, ],
+ y = Glycosites[gene, ],
+ method = "spearman",
+ exact = FALSE # 精确计算在大样本中较慢
+ )
+
+ results[i, "Rho"] <- cor_test$ estimate
+ results[i, "P_value"] <- cor_test$ p.value
+ }
+ }
错误于cor.test.default(x = NGT[gene, ], y = Glycosites[gene, ], method = "spearman", :
'x'必需是数值向量
> library(WGCNA)
错误于library(WGCNA): 不存在叫‘WGCNA’这个名称的程序包
> BiocManager::install("WGCNA")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
Bioconductor version 3.21 (BiocManager 1.30.25), R 4.5.0 (2025-04-11 ucrt)
Installing package(s) 'WGCNA'
还安装依赖关系‘htmlTable’, ‘dynamicTreeCut’, ‘Hmisc’, ‘preprocessCore’, ‘GO.db’
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/htmlTable_2.4.3.zip'
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/dynamicTreeCut_1.63-1.zip'
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/Hmisc_5.2-3.zip'
试开URL’https://bioconductor.org/packages/3.21/bioc/bin/windows/contrib/4.5/preprocessCore_1.70.0.zip'
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/WGCNA_1.73.zip'
download.packages(pkgs, destdir = tmpd, available = available, 里有警告:
下载程序包‘Hmisc’时出了问题
download.packages(pkgs, destdir = tmpd, available = available, 里有警告:
下载程序包‘WGCNA’时出了问题
程序包‘htmlTable’打开成功,MD5和检查也通过
程序包‘dynamicTreeCut’打开成功,MD5和检查也通过
程序包‘preprocessCore’打开成功,MD5和检查也通过
下载的二进制程序包在
C:\Users\lenovo\AppData\Local\Temp\RtmpIl7yPX\downloaded_packages里
安装源码包‘GO.db’
试开URL’https://bioconductor.org/packages/3.21/data/annotation/src/contrib/GO.db_3.21.0.tar.gz'
Content type 'application/x-gzip' length 25563907 bytes (24.4 MB)
downloaded 24.4 MB
* installing *source* package 'GO.db' ...
** this is package 'GO.db' version '3.21.0'
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (GO.db)
下载的程序包在
‘C:\Users\lenovo\AppData\Local\Temp\RtmpIl7yPX\downloaded_packages’里
Old packages: 'annotate', 'BiocManager', 'BiocParallel', 'commonmark', 'ComplexHeatmap',
'cowplot', 'curl', 'data.table', 'dendextend', 'Deriv', 'doBy', 'DropletUtils',
'edgeR', 'emmeans', 'evaluate', 'fitdistrplus', 'future', 'future.apply', 'ggforce',
'ggpubr', 'gh', 'h5mread', 'haven', 'httr2', 'KEGGREST', 'limma', 'maps', 'openssl',
'parallelly', 'patchwork', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'plotly',
'promises', 'purrr', 'Rcpp', 'RcppArmadillo', 'restfulr', 'rhdf5', 'rprojroot',
'RSQLite', 'S4Arrays', 'shiny', 'spatstat.explore', 'spatstat.geom', 'spatstat.random',
'spatstat.univar', 'spatstat.utils', 'statnet.common', 'tensor', 'tibble', 'utf8',
'waldo', 'xgboost', 'zip', 'lattice', 'mgcv'
Update all/some/none? [a/s/n]:
n
警告信息:
1: In download.file(urls, destfiles, "libcurl", mode = "wb", ...) :
URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/Hmisc_5.2-3.zip': status was 'Failure when receiving data from the peer'
2: In download.file(urls, destfiles, "libcurl", mode = "wb", ...) :
URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/WGCNA_1.73.zip': status was 'Failed sending data to the peer'
3: In download.file(urls, destfiles, "libcurl", mode = "wb", ...) :
some files were not downloaded
> library(WGCNA)
错误于library(WGCNA): 不存在叫‘WGCNA’这个名称的程序包
> BiocManager::install("WGCNA")
'getOption("repos")' replaces Bioconductor standard repositories, see
'help("repositories", package = "BiocManager")' for details.
Replacement repositories:
CRAN: https://mirrors.tuna.tsinghua.edu.cn/CRAN/
Bioconductor version 3.21 (BiocManager 1.30.25), R 4.5.0 (2025-04-11 ucrt)
Installing package(s) 'WGCNA'
还安装依赖关系‘Hmisc’
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/Hmisc_5.2-3.zip'
试开URL’https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.5/WGCNA_1.73.zip'
程序包‘Hmisc’打开成功,MD5和检查也通过
程序包‘WGCNA’打开成功,MD5和检查也通过
下载的二进制程序包在
C:\Users\lenovo\AppData\Local\Temp\RtmpIl7yPX\downloaded_packages里
Old packages: 'annotate', 'BiocManager', 'BiocParallel', 'commonmark', 'ComplexHeatmap',
'cowplot', 'curl', 'data.table', 'dendextend', 'Deriv', 'doBy', 'DropletUtils',
'edgeR', 'emmeans', 'evaluate', 'fitdistrplus', 'future', 'future.apply', 'ggforce',
'ggpubr', 'gh', 'h5mread', 'haven', 'httr2', 'KEGGREST', 'limma', 'maps', 'openssl',
'parallelly', 'patchwork', 'pheatmap', 'pillar', 'pkgbuild', 'pkgdown', 'plotly',
'promises', 'purrr', 'Rcpp', 'RcppArmadillo', 'restfulr', 'rhdf5', 'rprojroot',
'RSQLite', 'S4Arrays', 'shiny', 'spatstat.explore', 'spatstat.geom', 'spatstat.random',
'spatstat.univar', 'spatstat.utils', 'statnet.common', 'tensor', 'tibble', 'utf8',
'waldo', 'xgboost', 'zip', 'lattice', 'mgcv'
Update all/some/none? [a/s/n]:
n
> library(WGCNA)
载入需要的程序包:dynamicTreeCut
载入需要的程序包:fastcluster
载入程序包:‘fastcluster’
The following object is masked from ‘package:stats’:
hclust
载入程序包:‘WGCNA’
The following object is masked from ‘package:qvalue’:
qvalue
The following object is masked from ‘package:stats’:
cor
警告信息:
程序包‘WGCNA’是用R版本4.5.1 来建造的
>
> library(reshape2)
载入程序包:‘reshape2’
The following object is masked from ‘package:tidyr’:
smiths
>
> library(pheatmap)
>
> if (!all(colnames(NGT) == colnames(Glycosites))) {
+ # 调整代谢组数据的列顺序与蛋白质组相同
+ Glycosites <- Glycosites[, colnames(NGT)]
+ }
> rm(results)
> rm(gene)
> rm(i)
> NGT_t <- t(NGT)
> View(NGT_t)
> colnames(NGT_t) <- NGT[,1]
> NGT_t <- NGT_t[,-1]
> View(NGT)
> View(NGT_t)
> View(NGT)
> View(NGT)
> View(NGT_t)
> rm(NGT_t)
> NGT_t <- t(NGT)
>
> View(NGT_t)
> colnames(NGT_t) <- NGT_t[,1]
错误于dimnames(x) <- dn: 'dimnames'的长度[2]必需与陈列范围相等
> colnames(NGT_t) <- NGT_t[1,]
> NGT_t <- NGT_t[-1,]
>
> Glycosites <- t(Glycosites) # 代谢物
>
> colnames(Glycosites) <- Glycosites[1,]
> Glycosites <- Glycosites[-1,]
> cor_res <- corAndPvalue(NGT_t, Glycosites, method = "spearman", use = "pairwise.complete.obs")
错误于stats::cor(x, y, use, method): 'x'必需为数值
> class(Glycosites) # 应返回"numeric"或"integer"
[1] "matrix" "array"
>
> str(Glycosites)
chr [1:9, 1:385] " 71.24190827" "2.448226e+00" " 3.404418298" "6.343631e+00" NA ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:9] "B" "C" "D" "G" ...
..$ : chr [1:385] "CEACAM5_580" "CEACAM5_480" "IL4I1_134" "THBS2_1069" ...
> Glycosites <- as.numeric(as.character(Glycosites))
> Glycosites <- read.csv("D:/SCLC组学/糖基化/Glycosites.csv", row.names=1)
> View(Glycosites)
> View(Glycosites)
> View(NGT)
> rownames(NGT) <- NGT[,1]
> NGT <- NGT[,-1]
> common_samples <- intersect(colnames(NGT), colnames(Glycosites))
>
> prot_t <- t(NGT)
> View(prot_t)
> rm(NGT_t)
> metab_t <- t(Glycosites) # 代谢组数据转置
>
> corr_result <- Hmisc::rcorr(
+ as.matrix(prot_t),
+ as.matrix(metab_t),
+ type = "spearman" # Spearman相关性
+ )
警告信息:
In sqrt(npair - 2) : 产生了NaNs
> View(corr_result)
> rho_matrix <- corr_result$ r[1:ncol(prot_t), (ncol(prot_t)+1):ncol(corr_result$ r)]
>
> pval_matrix <- corr_result$ P[1:ncol(prot_t), (ncol(prot_t)+1):ncol(corr_result$ P)]
>
> cor_df <- melt(rho_matrix, varnames = c("Gene", "Glycosites"), value.name = "Rho")
>
> pval_df <- melt(pval_matrix, varnames = c("Gene", "Glycosites"), value.name = "P_value")
>
> result_table <- cor_df %>%
+ left_join(pval_df, by = c("Gene", "Glycosites")) %>%
+ mutate(
+ FDR = p.adjust(P_value, method = "BH"), # BH法校正多重检验
+ )
> )
错误: 意外的')'在" )"里
> result_table <- cor_df %>%
+ left_join(pval_df, by = c("Gene", "Glycosites")) %>%
+ mutate(
+ FDR = p.adjust(P_value, method = "BH"), # BH法校正多重检验
+ )
> View(result_table)
> write.csv(result_table, "Protein_Glycosites_Correlation.csv", row.names = FALSE)
>
> sig_cor <- result_table %>%
+ filter(FDR < 0.05)
> heatmap_data <- dcast(sig_cor, Gene ~ Metabolite, value.var = "Rho")
错误于FUN(X[[i]], ...): 找不到对象'Metabolite'
> heatmap_data <- dcast(sig_cor, Gene ~ Glycosites, value.var = "Rho")
> rownames(heatmap_data) <- heatmap_data$ Gene
>
> heatmap_data <- as.matrix(heatmap_data[, -1])
>
> heatmap(
+ heatmap_data,
+ color = colorRampPalette(c("blue", "white", "red"))(50),
+ clustering_method = "complete",
+ show_rownames = TRUE,
+ show_colnames = TRUE,
+ scale = "none",
+ main = "Protein-Metabolite Significant Correlations (FDR < 0.05)",
+ fontsize_row = 8,
+ fontsize_col = 8
+ )
错误于hclustfun(distfun(x)): 外接函数调用时不能有NA/NaN/Inf(arg10)
> pheatmap(
+ heatmap_data,
+ color = colorRampPalette(c("blue", "white", "red"))(50),
+ clustering_method = "complete",
+ show_rownames = TRUE,
+ show_colnames = TRUE,
+ scale = "none",
+ main = "Protein-Metabolite Significant Correlations (FDR < 0.05)",
+ fontsize_row = 8,
+ fontsize_col = 8
+ )
错误于hclust(d, method = method):
外接函数调用时不能有NA/NaN/Inf(arg10)