The problem of WGCNA (RNA)
1
0
Entering edit mode
5.9 years ago
786180187 • 0

This is my first time to using R to run analysis, i just follow the tutorial R code and try to learning WGCNA . However, there is a problem that I cannot solve, and the relevant solutions cannot be found online,I am very anxious, I have not been able to solve this problem for several days. PLEASE HELP ME! THANK U VERY MUCH! the problem is when i try to run WGCNA "TOM plot", the error as follow, but i don't know why! if you are familiar with R and WGCNA!help me please. I really need your help and thanks you very very much.

if you need more detail about my data!please leave your email, i can send you everything about this analysis!

> load(net$TOMFiles[1], verbose=T)
Loading objects:
  TOM
> TOM <- as.matrix(TOM)
> TOM[1:4,1:4]
            1          2           3           4
1 0.000000000 0.17213194 0.008410333 0.138254829
2 0.172131935 0.00000000 0.012847520 0.071286006
3 0.008410333 0.01284752 0.000000000 0.006169962
4 0.138254829 0.07128601 0.006169962 0.000000000
> dissTOM = 1-TOM
> plotTOM = dissTOM^7
> diag(plotTOM) = NA
> moduleColors = labels2colors(moduleLabels)
> TOMplot(plotTOM, net$dendrograms, moduleColors, 
+         main = "Network heatmap plot, all genes")
Error in TOMplot(plotTOM, net$dendrograms, moduleColors, main = "Network heatmap plot, all genes") : 
  ERROR: number of color labels does not equal number of nodes in dissim.
      nNodes != dim(dissim)[[1]] 
> nSelect = 400
> set.seed(10)
> select = sample(nGenes, size = nSelect)
> selectTOM = dissTOM[select, select]
Error in dissTOM[select, select] : subscript out of bounds
RNA-Seq • 3.9k views
ADD COMMENT
0
Entering edit mode

Please confirm that you have followed the main tutorial exactly as it is written. If you have, then there should not appear any error. Looking at your TOM object, it seems to have no labels? Also, where do you even initialise the moduleLabels variable in your code?

If you want help, then please help us by providing the complete picture.

ADD REPLY
0
Entering edit mode

Dear kevin,i am so glad that you can replay me, i think i already followed the tutorial exactly, but because I don’t know R, I may have made errors during the analysis. I am so sorry to taking your time but i really need your help. The tutorial as follow:https://blog.csdn.net/qazplm12_3/article/details/80001327 and https://www.jianshu.com/p/1b88b9d1dfc3. The whole code is too long to upload. I will split it and upload! thanks your very much!

ADD REPLY
0
Entering edit mode
    > library(WGCNA)
Loading required package: dynamicTreeCut
Loading required package: fastcluster

Attaching package: ‘fastcluster’

The following object is masked from ‘package:stats’:

    hclust
    enter code here

Attaching package: ‘WGCNA’

The following object is masked from ‘package:stats’:

    cor

> library(reshape2)
> library(stringr)
> options(stringsAsFactors = FALSE)
> enableWGCNAThreads()
Allowing parallel execution with up to 7 working processes.
> exprMat <- "~/Desktop/WGCNA/brainFPKM.txt"
> 
> type = "signed"
> corType = "pearson"
> corFnc = ifelse(corType=="pearson", cor, bicor)
> robustY = ifelse(corType=="pearson",T,F)
> dataExpr <- read.table(exprMat, sep='\t', row.names=1, header=T, 
+                      quote="", comment="", check.names=F)
> dim(dataExpr)
[1] 102839      8
> m.mad <- apply(dataExpr,1,mad)
> dataExprVar <- dataExpr[which(m.mad > 
+                  max(quantile(m.mad, probs=seq(0, 1, 0.25))[2],0.01)),]
> dataExpr <- as.data.frame(t(dataExprVar))
> gsg = goodSamplesGenes(dataExpr, verbose = 3)
 Flagging genes and samples with too many missing values...
  ..step 1
> if (!gsg$allOK){
+   # Optionally, print the gene and sample names that were removed:
+   if (sum(!gsg$goodGenes)>0) 
+     printFlush(paste("Removing genes:", 
+                      paste(names(dataExpr)[!gsg$goodGenes], collapse = ",")));
+   if (sum(!gsg$goodSamples)>0) 
+     printFlush(paste("Removing samples:", 
+                      paste(rownames(dataExpr)[!gsg$goodSamples], collapse = ",")));
+   # Remove the offending genes and samples from the data:
+   dataExpr = dataExpr[gsg$goodSamples, gsg$goodGenes]
+ }
> nGenes = ncol(dataExpr)
> nSamples = nrow(dataExpr)
> dim(dataExpr)
[1]     8 77110
> head(dataExpr)[,1:8]
     TRINITY_DN0_c0_g1 TRINITY_DN0_c0_g2 TRINITY_DN0_c1_g1
RQ_1             16.07              3.04              3.23
RQ_2             18.68              2.78              2.98
RQ_3             29.71              6.88              6.05
RQ_4              9.83              2.04              0.79
RQ_5             20.06              5.61              2.89
XJ_1             10.10              1.13              2.95
     TRINITY_DN0_c2_g1 TRINITY_DN0_c3_g1 TRINITY_DN0_c6_g3
RQ_1              8.19              9.25              1.61
RQ_2              8.88              8.71              2.23
RQ_3             14.69              6.01              1.95
RQ_4              5.03              5.85              0.32
RQ_5             10.16              6.70              1.77
XJ_1              1.36              5.25              2.54
     TRINITY_DN0_c8_g1 TRINITY_DN100017_c0_g3
RQ_1             11.27                   2.79
RQ_2             11.58                   3.56
RQ_3             10.26                   3.40
RQ_4             14.25                   2.27
RQ_5             14.68                   4.64
XJ_1              3.10                   1.30
> sampleTree = hclust(dist(dataExpr), method = "average")
> plot(sampleTree, main = "Sample clustering to detect outliers", sub="", xlab="")
> powers = c(c(1:10), seq(from = 12, to=30, by=2))
> sft = pickSoftThreshold(dataExpr, powerVector=powers, 
+                         networkType=type, verbose=5)
pickSoftThreshold: will use block size 580.
 pickSoftThreshold: calculating connectivity for given powers...
   ..working on genes 1 through 580 of 77110
   ..working on genes 581 through 1160 of 77110
   ..working on genes 1161 through 1740 of 77110
   ..working on genes 1741 through 2320 of 77110
   ..working on genes 2321 through 2900 of 77110
   ..working on genes 2901 through 3480 of 77110
   ..working on genes 3481 through 4060 of 77110
   ..working on genes 4061 through 4640 of 77110
   ..working on genes 4641 through 5220 of 77110
   ..working on genes 5221 through 5800 of 77110
   ..working on genes 5801 through 6380 of 77110
ADD REPLY
0
Entering edit mode
       ..working on genes 6381 through 6960 of 77110
   ..working on genes 6961 through 7540 of 77110
   ..working on genes 7541 through 8120 of 77110
   ..working on genes 8121 through 8700 of 77110
   ..working on genes 8701 through 9280 of 77110
   ..working on genes 9281 through 9860 of 77110
   ..working on genes 9861 through 10440 of 77110
   ..working on genes 10441 through 11020 of 77110
   ..working on genes 11021 through 11600 of 77110
   ..working on genes 11601 through 12180 of 77110
   ..working on genes 12181 through 12760 of 77110
   ..working on genes 12761 through 13340 of 77110
   ..working on genes 13341 through 13920 of 77110
   ..working on genes 13921 through 14500 of 77110
   ..working on genes 14501 through 15080 of 77110
   ..working on genes 15081 through 15660 of 77110
   ..working on genes 15661 through 16240 of 77110
   ..working on genes 16241 through 16820 of 77110
   ..working on genes 16821 through 17400 of 77110
   ..working on genes 17401 through 17980 of 77110
   ..working on genes 17981 through 18560 of 77110
   ..working on genes 18561 through 19140 of 77110
   ..working on genes 19141 through 19720 of 77110
   ..working on genes 19721 through 20300 of 77110
   ..working on genes 20301 through 20880 of 77110
   ..working on genes 20881 through 21460 of 77110
   ..working on genes 21461 through 22040 of 77110
   ..working on genes 22041 through 22620 of 77110
   ..working on genes 22621 through 23200 of 77110
   ..working on genes 23201 through 23780 of 77110
   ..working on genes 23781 through 24360 of 77110
   ..working on genes 24361 through 24940 of 77110
   ..working on genes 24941 through 25520 of 77110
   ..working on genes 25521 through 26100 of 77110
   ..working on genes 26101 through 26680 of 77110
   ..working on genes 26681 through 27260 of 77110
   ..working on genes 27261 through 27840 of 77110
   ..working on genes 27841 through 28420 of 77110
   ..working on genes 28421 through 29000 of 77110
   ..working on genes 29001 through 29580 of 77110
   ..working on genes 29581 through 30160 of 77110
   ..working on genes 30161 through 30740 of 77110
   ..working on genes 30741 through 31320 of 77110
   ..working on genes 31321 through 31900 of 77110
   ..working on genes 31901 through 32480 of 77110
   ..working on genes 32481 through 33060 of 77110
   ..working on genes 33061 through 33640 of 77110
   ..working on genes 33641 through 34220 of 77110
   ..working on genes 34221 through 34800 of 77110
   ..working on genes 34801 through 35380 of 77110
   ..working on genes 35381 through 35960 of 77110
   ..working on genes 35961 through 36540 of 77110
   ..working on genes 36541 through 37120 of 77110
   ..working on genes 37121 through 37700 of 77110
   ..working on genes 37701 through 38280 of 77110
   ..working on genes 38281 through 38860 of 77110
   ..working on genes 38861 through 39440 of 77110
   ..working on genes 39441 through 40020 of 77110
   ..working on genes 40021 through 40600 of 77110
   ..working on genes 40601 through 41180 of 77110
   ..working on genes 41181 through 41760 of 77110
   ..working on genes 41761 through 42340 of 77110
   ..working on genes 42341 through 42920 of 77110
   ..working on genes 42921 through 43500 of 77110
   ..working on genes 43501 through 44080 of 77110
   ..working on genes 44081 through 44660 of 77110
   ..working on genes 44661 through 45240 of 77110
   ..working on genes 45241 through 45820 of 77110
   ..working on genes 45821 through 46400 of 77110
   ..working on genes 46401 through 46980 of 77110
   ..working on genes 46981 through 47560 of 77110
   ..working on genes 47561 through 48140 of 77110
   ..working on genes 48141 through 48720 of 77110
   ..working on genes 48721 through 49300 of 77110
   ..working on genes 49301 through 49880 of 77110
   ..working on genes 49881 through 50460 of 77110
   ..working on genes 50461 through 51040 of 77110
   ..working on genes 51041 through 51620 of 77110
   ..working on genes 51621 through 52200 of 77110
   ..working on genes 52201 through 52780 of 77110
   ..working on genes 52781 through 53360 of 77110
   ..working on genes 53361 through 53940 of 77110
   ..working on genes 53941 through 54520 of 77110
   ..working on genes 54521 through 55100 of 77110
   ..working on genes 55101 through 55680 of 77110
   ..working on genes 55681 through 56260 of 77110
   ..working on genes 56261 through 56840 of 77110
   ..working on genes 56841 through 57420 of 77110
ADD REPLY
2
Entering edit mode
5.9 years ago

Oh, you may want to follow the 'official' tutorial, written by the developer of WGCNA: https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/

ADD COMMENT
0
Entering edit mode

Dear Kevin, thanks you very much to give me this tutorial,and i followed this tutorial to run my data and show error

    femaleSamples = rownames(datExpr);
> traitRows = match(femaleSamples, allTraits$Mice)
> datTraits = allTraits[traitRows, -1]
> rownames(datTraits) = allTraits[traitRows, 1]
> collectGarbage()
> sampleTree2 = hclust(dist(datExpr), method = "average")
Error in hclust(dist(datExpr), method = "average") : 
  N must be at least 2.
ADD REPLY
0
Entering edit mode

this is because of my traits? my traits as follow

sample  control test    eyes    horn
RQ_1    1   0   1   0
RQ_2    1   0   1   0
RQ_3    1   0   1   0
RQ_4    1   0   1   0
RQ_5    1   0   1   0
XJ_1    0   1   0   1
XJ_2    0   1   0   1
XJ_3    0   1   0   1
ADD REPLY
0
Entering edit mode

Hey, oh, I mean to complete the tutorial, first using the data provided by the authors. Then, you will understand better the format of the data required for each step.

ADD REPLY
0
Entering edit mode

dear kevin, thanks for your help,accordingly,i already using the data provided by the authors and everything all right. But when i change to my own data, error aways be there! and i am so sad.

ADD REPLY
0
Entering edit mode

Please check what are the differences between your data and the data used by the authors. You should also check formatting of objects via str()

ADD REPLY

Login before adding your answer.

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