I'm sharing my entire code which I'm running and the last part is generating some errors which I am not able to understand. Any help and suggestion around the same will be highly appreciated.
library(GEOquery)
library(WGCNA)
options(stringsAsFactors = FALSE)
enableWGCNAThreads()
my_id <- "GSE4843"
gse <- getGEO(my_id)
gse <-gse[[1]]
df_old<-as.data.frame(gse)
matrix_old=t(df_old)
matrix_new<-head(matrix_old,-26)
matrix_new_t=t(matrix_new)
df<-as.data.frame(matrix_new_t)
num=as.numeric(unlist(df))
sampleTree = hclust(dist(df), method = "average")
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 = 135000, col = "red")
sft = pickSoftThreshold(df, powerVector = powers, verbose = 5)
sizeGrWindow(9, 5)
par(mfrow = c(1,2));
cex1 = 0.9;
plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
xlab="Soft Threshold (power)",ylab="Scale Free Topology Model Fit,signed R^2",type="n",
main = paste("Scale independence"));
text(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],
labels=powers,cex=cex1,col="red");
abline(h=0.90,col="red")
plot(sft$fitIndices[,1], sft$fitIndices[,5],
xlab="Soft Threshold (power)",ylab="Mean Connectivity", type="n",
main = paste("Mean connectivity"))
text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=cex1,col="red")
df2 <- data.matrix(df)
bwnet = blockwiseModules(df2, power = 6,
TOMType = "unsigned", minModuleSize = 30,
reassignThreshold = 0, mergeCutHeight = 0.25,
numericLabels = TRUE,
maxBlockSize = 2000,
saveTOMs = TRUE,
saveTOMFileBase = "tstTOM",
verbose = 3)
Calculating module eigengenes block-wise from all genes
Flagging genes and samples with too many missing values...
..step 1
....pre-clustering genes to determine blocks..
Projective K-means:
..k-means clustering..
..merging smaller clusters...
Block sizes:
gBlocks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2000 2000 2000 2000 2000 2000 2000 1999 1999 1999 1999 1998 1998 1997 1997 1996 1995 1984 1954 1937
21 22 23 24 25 26 27 28 29
1934 1931 1904 1879 1693 1494 1425 1282 1281
..Working on block 1 .
Error in blockwiseModules(df2, power = 6, TOMType = "unsigned", minModuleSize = 30, :
REAL() can only be applied to a 'numeric', not a 'integer'
Thank you so much Mike Smith !!!!!