hahahueg 2023-02-28 21:39 采纳率: 87.5%
浏览 61
已结题

核心基因药物敏感性分析

药物敏感性分析,中途出现的警告不知道要不要处理,最后报错显示要加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
  • 写回答

2条回答 默认 最新

  • Bioinfo Guy R语言领域新星创作者 2023-03-01 09:30
    关注

    主要报错是这一段,分别检查一下corT,corT$p.value,pvalue有无缺失值,有的话强制is.na运行

    corT=cor.test(x,y,method="pearson")
    cor=corT$estimate
    pvalue=corT$p.value
    if(!is.na(pvalue) && pvalue<0.05){
       outVector=cbind(Gene,Drug,cor,pvalue)
       outTab=rbind(outTab,outVector)
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 3月9日
  • 已采纳回答 3月1日
  • 创建了问题 2月28日

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端