Hi everyone, I'm trying to use WGCNA but I keep getting this error:
Error in numbers2colors(traitData, signed = FALSE) :
'x' must be numeric. For a factor, please use as.numeric(x) in the call.
Here is my code:
library(WGCNA)
allowWGCNAThreads()
options(stringsasfactors = FALSE)
datCompds0=read.csv("IntSigSQRT2.csv")
dim(datCompds0)
names(datCompds0)
traitData = read.csv("PARAM.csv");
dim(traitData)
names(traitData)
library(flashClust)
sampleTree = flashClust(dist(datCompds0), method = "average");
sizeGrWindow(8,5)
par(cex = 0.6);
par(mar = c(0,4,2,0))
plot(sampleTree, main = "Sample clustering to detect outliers", sub="", xlab="", cex.lab = 1.5, cex.axis = 1.5, cex.main = 2)
abline(h = 20, col = "red");
sampleTree2 = flashClust(dist(datCompds0), method = "average")
traitColors = numbers2colors(traitData, signed = FALSE);
I've tried adding as.numeric(x) into the last line but to be honest, I'm not entirely sure how to do this properly! This is some output showing my data:
dim(datCompds0)
[1] 18 26
names(datCompds0)
[1] "Sample" "C01" "C02" "C03" "C04" "C05" "C06" "C07" "C08" "C09" "C10"
[12] "C11" "C12" "C13" "C14" "C15" "C16" "C17" "C18" "C19" "C20" "C21"
[23] "C22" "C23" "C24" "C25"
traitData = read.csv("PARAM.csv");
dim(traitData)
[1] 18 2
names(traitData)
[1] "Sample" "Treatment"
Any help would be greatly appreciated