outTab=data.frame()
> for(i in gene1){
+ for(j in gene2){
+ x=as.numeric(data[i,])
+ y=as.numeric(data[j,])
+ corT=cor.test(x, y, method = 'spearman')
+ cor=corT$estimate
+ pvalue=corT$p.value
+ if((abs(cor)>corFilter) & (pvalue<pvalueFilter)){
+ outTab=rbind(outTab, cbind(Gene1=i, Gene2=j, cor, pvalue))
+ #绘制相关性图形
+ df1=as.data.frame(cbind(x,y))
+ p1=ggplot(df1, aes(x, y)) +
+ xlab(i)+ylab(j)+
+ geom_point()+ geom_smooth(method="lm",formula = y ~ x) + theme_bw()+
+ stat_cor(method = 'spearman', aes(x =x, y =y))
+ p2=ggMarginal(p1, type = "density", xparams = list(fill = "orange"),yparams = list(fill = "blue"))
+ #输出相关性图形
+ pdf(file=paste0(i, "_", j, ".pdf"),width=5,height=4.8)
+ print(p2)
+ dev.off()
+ }
+ }
+ }
Error in data[j, ] : subscript out of bounds