I have a file that looks like this :
Taxa,D0,D1,...
1,0,10,...
20,0,0,...
...
The file is available here : https://www.dropbox.com/s/lvtxztz3kypnxre/Taxa_Conf.csv?dl=0
When I run a script by
$CONCOCT/scripts/ConfPlot.R -c Taxa_Conf.csv -o Taxa_Conf.pdf
I get the following error :
Error in hclustfun(distc) : NA/NaN/Inf in foreign function call (arg 11)
Calls: heatmap.2 -> hclustfun
Execution halted
where ConfPlot.R looks like
#!/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()
After reading Error while creating heatmaps - NA/NaN/Inf in foreign function call (arg 11), I tried
> 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
There seems to be no NA value. ConfPlot.R works for my other files. What is the problem?? There does not seem to be any na, nan, or inf value. Thank you in advance
Check this row:
ConfP <- Conf.t/rowSums(Conf.t)
It must be evaluating essentially to division by zero:
> 0/0
[1] NaN
> 1/0
[1] Inf