药物敏感性分析,中途出现的警告不知道要不要处理,最后报错显示要加true/flase不知道加在哪
library(impute)
> library(limma)
> library(ggplot2)
> library(ggpubr)
> drugFile="drug.txt" #ҩ???????ļ?
> expFile="geneExp.txt" #?????????ļ?
> geneFile="gene.txt" #?????б??ļ?
> corPlotNum=16 #??ʾͼƬ??Ŀ
> setwd("/Users/apple/Desktop/GSVA/drug sensitivity analysis") #???ù???Ŀ¼
> #??ȡҩ???????ļ?
> rt=read.table(drugFile,sep="\t",header=T,check.names=F)
Warning messages:
1: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
EOF within quoted string
2: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
number of items read is not a multiple of the number of columns
> View(rt)
> rt=as.matrix(rt)
> rownames(rt)=rt[,1]
> drug=rt[,2:ncol(rt)]
> dimnames=list(rownames(drug),colnames(drug))
> data=matrix(as.numeric(as.matrix(drug)),nrow=nrow(drug),dimnames=dimnames)
Warning message:
In matrix(as.numeric(as.matrix(drug)), nrow = nrow(drug), dimnames = dimnames) :
NAs introduced by coercion
> #??ҩ?????ݲ?ȱ
> mat=impute.knn(data)
Warning message:
In knnimp(x, k, maxmiss = rowmax, maxp = maxp) :
1 rows with more than 50 % entries missing;
mean imputation used for these rows
> drug=mat$data
> drug=avereps(drug)
> #??ȡ?????????ļ?,?????????ļ?????
> rt=read.table(expFile,sep="\t",header=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)
> exp=avereps(data)
> #??ȡ?ض?????????
> gene=read.table(geneFile,sep="\t",header=F,check.names=F)
Warning message:
In read.table(geneFile, sep = "\t", header = F, check.names = F) :
incomplete final line found by readTableHeader on 'gene.txt'
> genelist=as.vector(gene[,1])
> genelist=gsub(" ","",genelist)
> genelist=intersect(genelist,row.names(exp))
> exp=exp[genelist,]
> #?Ի???ѭ??
> outTab=data.frame()
> for(Gene in row.names(exp)){
+ x=as.numeric(exp[Gene,])
+ #??ҩ??ѭ??
+ for(Drug in row.names(drug)){
+ y=as.numeric(drug[Drug,])
+ corT=cor.test(x,y,method="pearson")
+ cor=corT$estimate
+ pvalue=corT$p.value
+ if(pvalue<0.05){
+ outVector=cbind(Gene,Drug,cor,pvalue)
+ outTab=rbind(outTab,outVector)
+ }
+ }
+ }
Error in if (pvalue < 0.05) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In cor(x, y) : the standard deviation is zero