REAL() can only be applied to a 'numeric', not a 'integer'
1
0
Entering edit mode
@048777e0
Last seen 22 months ago
India

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'
#WGCNA #tom #integer #REAL #numeric • 2.5k views
ADD COMMENT
0
Entering edit mode
Mike Smith ★ 6.5k
@mike-smith
Last seen 2 hours ago
EMBL Heidelberg

I don't really follow all the pre-processing you're doing to your expression matrix, but I'm pretty sure you're not getting the output you expect after the df2 <- data.matrix(df) step. Take a look at the contents of df compared to df2, it doesn't look right at all:

## only do this on a small subset for this example as it takes a really long time on the full data
> df2 <- data.matrix( df[1:10,1:10] )
> df[1:5,1:5]
          X1007_s_at X1053_at X117_at X121_at X1255_g_at
GSM109050      781.9    715.6   134.7   548.1      16.23
GSM109051     2176.0    649.6   124.8   544.4      16.97
GSM109052     1071.0    242.3   476.8   589.4      13.31
GSM109053      927.9    831.3   176.1   474.3      15.70
GSM109054      371.0    493.5   177.4   425.5      13.26
> df2[1:5,1:5]
          X1007_s_at X1053_at X117_at X121_at X1255_g_at
GSM109050          4        7       4       7          9
GSM109051         10        5       1       6         10
GSM109052          8        1      10       9          4
GSM109053          6        8       8       2          8
GSM109054          3        2       9       1          3

Looking at ?data.matrix it's expecting "a data frame whose components are logical vectors, factors or numeric vectors", but you have a data.frame of characters. Presumably there's some weird type conversion going on here. It looks like each column is now the order of the values.

Is there a reason you're not using exprs(gse) to extract the matrix of expression values? That will stop you needing to remove the final 26 lines i.e.

> dim(exprs(gse))
[1] 54675    45

You can then feed that straight into blockwiseModules() with something like blockwiseModules( exprs(gse), ...)

ADD COMMENT
0
Entering edit mode

Thank you so much Mike Smith !!!!!

ADD REPLY

Login before adding your answer.

Traffic: 768 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6