当似乎没有出现时我错误地说我有NA / NaN / Inf值。 hclustfun(distc)出错:外部函数调用中的NA / NaN / Inf(arg 11)

问题描述 投票:1回答:1

我有一个看起来像这样的文件:

Taxa,D0,D1,...
1,0,10,...
20,0,0,...
...

该文件可在此处获取:https://www.dropbox.com/s/lvtxztz3kypnxre/Taxa_Conf.csv?dl=0

当我运行脚本时

$CONCOCT/scripts/ConfPlot.R -c Taxa_Conf.csv -o Taxa_Conf.pdf

我收到以下错误:

Error in hclustfun(distc) : NA/NaN/Inf in foreign function call (arg 11)
Calls: heatmap.2 -> hclustfun
Execution halted

ConfPlot.R的样子

#!/usr/bin/Rscript

#load libraries
library(gplots)
library(getopt)

spec = matrix(c('verbose','v',0,"logical",'help','h',0,"logical",'confile','c',1,"character",'ofile','o',1,"character"),byrow=TRUE,ncol=4)

opt=getopt(spec)

if( !is.null(opt$help)) {
cat(getopt(spec, usage=TRUE)); 
q(status=1);
}

confFile <- opt$confile

Conf <- read.csv(confFile,header=TRUE,row.names=1)
Conf.t <- t(Conf)
ConfP <- Conf.t/rowSums(Conf.t)

crp <- colorRampPalette(c("blue","red","orange","yellow"))(100)

pdf(opt$ofile)

heatmap.2 (as.matrix(t(ConfP)),col=crp,trace="none",dendrogram="none",Rowv=FALSE,lwid = c(1.25,4.5),lhei = c(1.25,4.5),cexRow=0.5)

dev.off()

读完Error while creating heatmaps - NA/NaN/Inf in foreign function call (arg 11)之后,我试过了

> a=read.csv("/home/mathed/Simulation/custom_desman/1/Strains/Simulation/Metabat/Taxa_Conf.csv",header=TRUE,row.names=1)
> any(is.na(a))
[1] FALSE

似乎没有NA值。 ConfPlot.R适用于我的其他文件。问题是什么??似乎没有任何na,nan或inf值。先感谢您

r nan na gplots
1个回答
1
投票

检查此行:

ConfP <- Conf.t/rowSums(Conf.t)

它必须基本上评估为除以零:

> 0/0
[1] NaN

> 1/0
[1] Inf
© www.soinside.com 2019 - 2024. All rights reserved.