WGCNA error during network construction
0
0
Entering edit mode
gitanjali • 0
@8d19db25
Last seen 3 months ago
United States

I am performing WGCNA analysis on my RNAseq dataset for the first time and getting this error message:

        > net = blockwiseModules(expression, power = 6,
    +                        TOMType = "unsigned", minModuleSize = 30,
    +                        reassignThreshold = 0, mergeCutHeight = 0.25,
    +                        numericLabels = TRUE, pamRespectsDendro = FALSE,
    +                        saveTOMs = TRUE,
    +                        saveTOMFileBase = "SW_TOM", 
    +                        verbose = 3)
     Calculating module eigengenes block-wise from all genes
       Flagging genes and samples with too many missing values...
        ..step 1
      ..Excluding 722 genes from the calculation due to too many missing samples or zero variance.
        ..step 2
     ....pre-clustering genes to determine blocks..
       Projective K-means:
       ..k-means clustering..
       ..merging smaller clusters...
    Block sizes:
    gBlocks
       1    2    3    4    5 
    4999 4998 4945 4424 4306 
     ..Working on block 1 .
    Error in blockwiseModules(expression, power = 6, TOMType = "unsigned",  : 
      REAL() can only be applied to a 'numeric', not a 'integer'

`

The code I used is given below. How do I solve this error?


    library(WGCNA)
#Setting string not as factor
options(stringsAsFactors = FALSE)
#Enable multithread
enableWGCNAThreads()
#Reading the raw data (rows are the sample and columns the genes)
SWexpressiondata = read.csv("edgeR_normalized.csv")

#Create a new format expression data - remove gene name column
expression = as.data.frame(expressiondata[, -c(1)]) 
expression = t(expression)

#Column 1 -  gene names
colnames(expression) = expressiondata$genes
rownames(expression) = names(expressiondata)[-c(1)]

#Group data in a dendogram to check outliers
sampleTree = hclust(dist(expression), method = "average")
dev.off()
sizeGrWindow(12,9)
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)


# Choose a set of soft-thresholding powers
powers = c(c(1:10), seq(from = 12, to = 20, by = 2))
# Call the network topology analysis function
sft = pickSoftThreshold(expression,             # <= Input data
  #blockSize = 30,
  powerVector = powers,
  verbose = 5)
# Plot the results:
sizeGrWindow(9, 5)
par(mfrow = c(1,2));
cex1 = 0.9;

# Scale-free topology fit index as a function of the soft-thresholding power
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")

# this line corresponds to using an R^2 cut-off of h
abline(h = 0.90, col = "red")
# Mean connectivity as a function of the soft-thresholding power
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")
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices utils     datasets  methods  
[9] base     

other attached packages:
 [1] magrittr_2.0.1         edgeR_3.28.1           limma_3.42.2          
 [4] WGCNA_1.70-3           fastcluster_1.2.3      dynamicTreeCut_1.63-1 
 [7] ggplot2_3.3.5          org.Mm.eg.db_3.10.0    AnnotationDbi_1.48.0  
[10] IRanges_2.20.2         S4Vectors_0.24.4       Biobase_2.46.0        
[13] BiocGenerics_0.32.0    DOSE_3.12.0            clusterProfiler_3.14.3
[16] dplyr_1.0.7           

loaded via a namespace (and not attached):
  [1] fgsea_1.12.0          colorspace_2.0-2      ellipsis_0.3.2       
  [4] ggridges_0.5.3        qvalue_2.18.0         htmlTable_2.2.1      
  [7] base64enc_0.1-3       rstudioapi_0.13       farver_2.1.0         
 [10] urltools_1.7.3        graphlayouts_0.7.1    ggrepel_0.9.1        
 [13] bit64_4.0.5           fansi_0.5.0           xml2_1.3.2           
 [16] codetools_0.2-18      splines_3.6.3         doParallel_1.0.16    
 [19] impute_1.60.0         cachem_1.0.5          GOSemSim_2.12.1      
 [22] knitr_1.33            polyclip_1.10-0       Formula_1.2-4        
 [25] jsonlite_1.7.2        cluster_2.1.2         GO.db_3.10.0         
 [28] png_0.1-7             ggforce_0.3.3         BiocManager_1.30.16  
 [31] compiler_3.6.3        httr_1.4.2            backports_1.2.1      
 [34] rvcheck_0.1.8         assertthat_0.2.1      Matrix_1.3-4         
 [37] fastmap_1.1.0         tweenr_1.0.2          htmltools_0.5.1.1    
 [40] prettyunits_1.1.1     tools_3.6.3           igraph_1.2.6         
 [43] gtable_0.3.0          glue_1.4.2            reshape2_1.4.4       
 [46] DO.db_2.9             fastmatch_1.1-0       Rcpp_1.0.7           
 [49] enrichplot_1.6.1      vctrs_0.3.8           preprocessCore_1.48.0
 [52] iterators_1.0.13      ggraph_2.0.5          xfun_0.24            
 [55] stringr_1.4.0         lifecycle_1.0.0       europepmc_0.4        
 [58] MASS_7.3-54           scales_1.1.1          tidygraph_1.2.0      
 [61] hms_1.1.0             RColorBrewer_1.1-2    memoise_2.0.0        
 [64] gridExtra_2.3         triebeard_0.3.0       rpart_4.1-15         
 [67] latticeExtra_0.6-29   stringi_1.7.2         RSQLite_2.2.7        
 [70] foreach_1.5.1         checkmate_2.0.0       BiocParallel_1.20.1  
 [73] rlang_0.4.11          pkgconfig_2.0.3       matrixStats_0.59.0   
 [76] lattice_0.20-41       purrr_0.3.4           htmlwidgets_1.5.3    
 [79] labeling_0.4.2        cowplot_1.1.1         bit_4.0.4            
 [82] tidyselect_1.1.1      plyr_1.8.6            R6_2.5.0             
 [85] generics_0.1.0        Hmisc_4.5-0           DBI_1.1.1            
 [88] pillar_1.6.1          foreign_0.8-75        withr_2.4.2          
 [91] survival_3.2-11       nnet_7.3-16           tibble_3.1.2         
 [94] crayon_1.4.1          utf8_1.2.1            viridis_0.6.1        
 [97] jpeg_0.1-8.1          progress_1.2.2        locfit_1.5-9.4       
[100] grid_3.6.3            data.table_1.14.2     blob_1.2.1           
[103] digest_0.6.27         tidyr_1.1.3           gridGraphics_0.5-1   
[106] munsell_0.5.0         viridisLite_0.4.0     ggplotify_0.0.7
WGCNA Network R • 108 views
ADD COMMENT

Login before adding your answer.

Traffic: 193 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