问题如下:
下载TCGA肿瘤样本,但该数据中无正常组织,合并GETx数据进行免疫lncRNA提取,代码部分如下:
rm(list = ls())
library(limma)
corFilter=0.4
pvalueFilter=0.001
setwd("C:\\Users\\CXH\\Desktop\\120irlncRNA\\09.irRNA")
#读取lncRNA,并对数据进行处理
rt = read.table("lncRNA.txt", header=T, sep="\t", check.names=F)
rt=as.matrix(rt)
rownames(rt)=rt[,1]
exp=rt[,2:ncol(rt)]
dimnames=list(rownames(exp),colnames(exp))
data=matrix(as.numeric(as.matrix(exp)),nrow=nrow(exp),dimnames=dimnames)
data=avereps(data)
data=data[rowMeans(data)>0.5,]
#删掉正常样品
group=sapply(strsplit(colnames(data),"\\-"),"[",4)
class(group)
list(group)
group=sapply(strsplit(group,""), "[", 1)
group=gsub("2","1",group)
lncRNA=data[,group==0]
#读取免疫基因表达文件,并对数据进行处理
rt = read.table("immGeneExp.txt", header=T, sep="\t", check.names=F)
rt=as.matrix(rt)
rownames(rt)=rt[,1]
exp=rt[,2:ncol(rt)]
dimnames=list(rownames(exp),colnames(exp))
immuneGene=matrix(as.numeric(as.matrix(exp)),nrow=nrow(exp),dimnames=dimnames)
immuneGene=avereps(immuneGene)
immuneGene=immuneGene[rowMeans(immuneGene)>0.5,]
#删掉正常样品
group=sapply(strsplit(colnames(immuneGene),"\\-"),"[",4)
group=sapply(strsplit(group,""),"[",1)
group=gsub("2","1",group)
immuneGene=immuneGene[,group==0]
#相关性检验
outTab=data.frame()
for(i in row.names(lncRNA)){
if(sd(lncRNA[i,])>0.5){
for(j in row.names(immuneGene)){
x=as.numeric(lncRNA[i,])
y=as.numeric(immuneGene[j,])
corT=cor.test(x,y)
cor=corT$estimate
pvalue=corT$p.value
if((cor>corFilter) & (pvalue<pvalueFilter)){
outTab=rbind(outTab,cbind(immuneGene=j,lncRNA=i,cor,pvalue,Regulation="postive"))
}
if((cor< -corFilter) & (pvalue<pvalueFilter)){
outTab=rbind(outTab,cbind(immuneGene=j,lncRNA=i,cor,pvalue,Regulation="negative"))
}
}
}
}
但是运行相关性检验后,结果:Error in if ((cor > corFilter) & (pvalue < pvalueFilter)) { :
需要TRUE/FALSE值的地方不可以用缺少值
此外: Warning message:
In cor(x, y) : 标准差为零
反复排查,初步考虑删掉正常样品部分的代码需要修改,但怎么尝试都不行,请大神指点:
#删掉正常样品
group=sapply(strsplit(colnames(immuneGene),"\\-"),"[",4)
group=sapply(strsplit(group,""),"[",1)
group=gsub("2","1",group)
immuneGene=immuneGene[,group==0]
因为TCGA命名规律:TCGA-20-0987-01A
而GETx命名规律:GTEX-PWCY-1326-SM-48TCU
还请大神们不惜赐教,谢谢!谢谢!