数据

转录组数据要与代谢组数据一一对应在这里插入图片描述
在这里插入图片描述
导入Rstudio

dx <- read.csv("dx.csv",header = T,row.names = 1)
gene <- read.csv("gene.csv",header = T,row.names = 1)

转换数据类型

gene1 <- as.matrix(gene)
dx1 <- as.matrix(dx)

就某个基因与代谢物进行相关性分析

cor(dx1[(row.names='4-Pentenoic acid'),],gene1[(row.names='A2ML1'),])
[1] 0.2306677

进行全部代谢物与基因相关性分析
行列转置

gene2 <- t(gene1)
dx2 <- t(dx1)

皮尔逊相关

library(WGCNA)
metaGeneCor.r <- cor(gene2, dx2, method="pearson")
write.csv(metaGeneCor.r,file="GeneCorMeta.csv")

p值

nmeta=ncol(dx) #nmeta为样本数量
metaGeneCor.p <- corPvalueStudent(metaGeneCor.r, nmeta)
write.csv(metaGeneCor.p,file = "MetaCorGene.p.csv") 

热图

library(pheatmap)
pheatmap(metaGeneCor.r,show_rownames = F,show_colnames = F)

想调出少量的数据
在这里插入图片描述

c <-c('RGN','GPI','ALDOA','PFKM','LOC106841113','LOC106828083','PGM1','FBP1','PGM2')
write.table(metaGeneCor.r[row.names=c,colnames="Sedoheptulose 7-phosphate"],file="1.txt",quote=F,col.name=F,row.names=F)

参考:https://blog.csdn.net/ziixiaoshenwang/article/details/115532419?spm=1001.2014.3001.5502

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐