This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R software error

Hello everyone

I am doing network analyses by using WGCNA, I got error message when I am setting the soft threshold. Here is what I got.

I am following these commands:

> library(WGCNA)

disableWGCNAThreads()
> library(cluster)
> options(stringsAsFactors = FALSE)
> femData = read.csv("gene.csv")
> names(femData)
 [1] "gene_id"           "gene"              "locus"             "log2.fold_change."
 [5] "test_stat"         "p_value"           "q_value"           "AF"               
 [9] "AF.1"              "AF.2"              "AD"                "AD.1"             
[13] "AD.2"             
> dim(femData)
[1] 6765   13
> datExprFemale=as.data.frame(t(femData[, -c(1:7)]))
> names(datExprFemale)=femData$gene
> rownames(datExprFemale)=names(femData)[-c(1:7)]
> powers=c(1:10)
> sft=pickSoftThreshold(datExprFemale,powerVector=powers)
Error in summary(lm1)$coefficients[2, 1] : subscript out of bounds

In addition: Warning message:

executing %dopar% sequentially: no parallel backend registered

I tried to find similar questions in archive, but I could not.

Please I need help with this issue if anyone able to help.

Best

Shaima

r

@saj98 Can you please give an example of your data so we can reproduce your problem and try to solve it?

I am following these commands:

> library(WGCNA)

disableWGCNAThreads()
> library(cluster)
> options(stringsAsFactors = FALSE)
> femData = read.csv("gene.csv")
> names(femData)
 [1] "gene_id"           "gene"              "locus"             "log2.fold_change."
 [5] "test_stat"         "p_value"           "q_value"           "AF"               
 [9] "AF.1"              "AF.2"              "AD"                "AD.1"             
[13] "AD.2"             
> dim(femData)
[1] 6765   13
> datExprFemale=as.data.frame(t(femData[, -c(1:7)]))
> names(datExprFemale)=femData$gene
> rownames(datExprFemale)=names(femData)[-c(1:7)]
> powers=c(1:10)
> sft=pickSoftThreshold(datExprFemale,powerVector=powers)
Error in summary(lm1)$coefficients[2, 1] : subscript out of bounds

For the warning message:

Have you tried the allowWGCNAThreads() function?

Yes I did, but I got the same error.

Are you trying to perform WGCNA analysis with 6 samples?

Yes I am doing six samples.

1 answer

The error means you're trying to access an element outside the array; this usually means one your indices is greater than the last available index of the array.

As for the warning, check the doParallel docs: "Remember: unless registerDoMC is called, foreach will not run in parallel. Simply loading the doParallel package is not enough."

Hello Jean Thanks for answering me, I appreciate your time. Can you give me more details about Do parallel, I tried to use but I had same issue. Best

It's all in the docs I linked to above. Basically, all you need is

library(doParallel);
registerDoParallel(cores= x);

where x is the number of cores/workers you want to use. Note that this is only worthwhile for relatively lengthy computations as creating parallel workers is expensive and can take longer than running a fast bit of code.

Log in to answer this question.