Entering edit mode
Hi everyone:
I want to conduct WGCNA on paired samples. I first filter out the genes that have no expression in both samples, then calculate the correlation using Spearman method and assign 0 to NA value in the correlation matrix.
count<-0
for(i in 1:nrow(NN_expr)){
if(sum(NN_expr[i,])+sum(PP_expr[i,])==0){
count<-c(count,i)
}
}
count<-count[-1]
non_zero_NN<-NN_expr[-count,]
non_zero_PP<-PP_expr[-count,]
non_zero_NN<-t(as.matrix(non_zero_NN))
non_zero_PP<-t(as.matrix(non_zero_PP))
NN_cor<-cor(non_zero_NN,method = "spearman")
PP_cor<-cor(non_zero_PP,method = "spearman")
NN_cor[is.na(NN_cor)]<-0.00
PP_cor[is.na(PP_cor)]<-0.00
However, when I use the curated correlation matrix as the input of the function pickSoftThreshold.fromSimilarity, it has the error:
# choose a set of soft-threshold powers
powers=c(c(1:10),seq(from= 12 ,to = 20,by = 2))
#calculate soft-threshold
sft<-pickSoftThreshold.fromSimilarity(NN_cor,RsquaredCut=0.85,powerVector=powers, removeFirst=FALSE,nBreaks=10,blockSize=1000,moreNetworkConcepts=FALSE,verbose=0,indent=0)
Error in { : task 1 failed - "non-numeric matrix extent"
Calls: pickSoftThreshold.fromSimilarity -> pickSoftThreshold -> %dopar% -> <Anonymous>
Execution halted
Does anyone have any idea how to solve this problem? Thank you so much!