WGCNA error: "Error in cutreeDynamic"
0
0
Entering edit mode
4.2 years ago
giuseppe0525 ▴ 20

Hi,

An error occurred to me when I used the function recutBlockwiseTrees of WGCNA package. The error message is:

> blockwiseModules: cutreeDynamic returned the following error:
>         Error in cutreeDynamic(dendro = dendrograms[[blockNo]], deepSplit = deepSplit,  :    Argument dendro must have class hclust.

However, the class of dendro is indeed correct, as is shown:

> class(net$dendrograms[[1]])   
> [1] "hclust"

I used the following codes:

> net <- recutBlockwiseTrees(   datExprPFC,  
> good_Samplegenes$goodSamples, good_Samplegenes$goodGenes,   rep(1,
> times=ncol(datExprPFC)),   "total_blockwiseTOM-block.1.RData",  
> **net$dendrograms[[1]]**,   corType = "bicor",   networkType = "signed",  
> deepSplit = 4,   detectCutHeight = 0.99, minModuleSize = min(20,
> ncol(datExprPFC)/2 ),   maxCoreScatter = NULL, minGap = NULL,  
> maxAbsCoreScatter = NULL, minAbsGap = NULL,   minSplitHeight = NULL,
> minAbsSplitHeight = NULL,   useBranchEigennodeDissim = FALSE,  
> minBranchEigennodeDissim = mergeCutHeight,   pamStage = TRUE,
> pamRespectsDendro = TRUE,   minCoreKME = 0.5, minCoreKMESize =
> minModuleSize/3,   minKMEtoStay = 0.3,   reassignThreshold = 1e-6,  
> mergeCutHeight = 0.15, impute = TRUE,   trapErrors = FALSE,
> numericLabels = FALSE,   verbose = 0, indent = 0)

Previously, I ran these codes to create the associated objects, and there's nothing wrong.

    > net = blockwiseModules(
   >   datExprPFC, 
   >   loadTOM = FALSE,
   >   corType="bicor", 
   >   networkType="signed", power=12,
   >   maxBlockSize=50000, 
   >   minModuleSize=30, pamRespectsDendro=FALSE,
   >   mergeCutHeight=mergingThresh,
   >   numericLabels=TRUE,
   >   TOMType = "signed", saveTOMs=TRUE, 
    >   saveTOMFileBase="total_blockwiseTOM",
    >   nThreads = 8)

The R environment is 3.5.0 on x86_64-redhat-linux-gnu (64-bit).

Do you know what might cause the error? Thank you!

rna-seq wgcna software error R next-gen • 2.8k views
ADD COMMENT
0
Entering edit mode

How does your network actually appear prior to recutBlockwiseTrees?, i.e., plot the dendrogram

ADD REPLY
0
Entering edit mode

Thanks for your reply. That's a weird plot where the majority of the genes don't fall into any module, and that's why I want to re-cut the trees. The plot was build on a single-cell RNA-seq dataset containing around 2,000 cells. The input genes were transformed to TPM and log2(x+1) transformed.! The plot is linked here. enter image description here

ADD REPLY
0
Entering edit mode

That looks very 'atypical', which may indirectly be the cause of the error...

You may consider trying to do some pre-processing of the data before WGCNA, such as removing samples with a high number of NA values and / or those with many genes of low expression.

ADD REPLY
0
Entering edit mode

Unfortunately, it didn't work. I have filtered many samples with many low expressed genes and the dendrogram looks similar. Have you done WGCNA on single-cell RNA-seq data? Is there any difference that I should pay attention to? Maybe I missed something.

ADD REPLY
0
Entering edit mode

Okay, can you explain the processing that you performed prior to WGCNA? - normalisation,. transformation(s), et cetera? I have worked with scRNA-seq data, but never with WGCNA.

Generally, your data-points look 'too similar', which renders your clustering 'flat' and not amenable to a network analysis.

ADD REPLY
0
Entering edit mode

Sure. The data has been transformed to TPM. What I performed was: 1. filter samples with many genes with low expression; 2. log2(x+1) transformation; 3. quantile normalisation.

The codes I used were shown below:

> ## filter sample with too many low expressed genes 
> sample_filter <- function(ExprData=ExprData,
>                           filter.gene=3,
>                           filter.gene.level=3){   del_col=c()   for ( i in 1:ncol(ExprData) ){
>     if ( sum(ExprData[ ,i] >= filter.gene.level) < filter.gene)
>       del_col = c(i, del_col)   }   new_dat=ExprData[, -del_col]   return(new_dat) }
> 
> DatExp_filter2 <- sample_filter(ExprData = DatExp_filter,
>                                 filter.gene = nrow(DatPFC_filter)/8,
>                                 filter.gene.level = 1)
> ## log2 transform 
> DatExp_filter_lg<- log2(DatExp_filter2  + 1)
> 
> ## quantile normalisation 
> library(preprocessCore) 
> DatExp_filter_lg_qn <- DatExp_filter_lg 
> DatExp_filter_lg_qn  <- as.matrix(DatExp_filter_lg_qn ) 
> DatExp_filter_lg_qn <- normalize.quantiles(DatExp_filter_lg_qn )

Additionally, I tried removing the 'bad samples' while not doing log2 and quantile transformation, and the dendrogram shows that slightly more genes were clustered. However, the majority were labeled grey.

ADD REPLY
0
Entering edit mode

Hi, but it does not really make sense to quantile normalise after you have log-transformed the data. From where does ExprData derive?

ADD REPLY
0
Entering edit mode

I got ExprData here. I want to test whether WGCNA can be performed on sc-RNA-seq data.

ADD REPLY
0
Entering edit mode

Hi! Well, there lies the issue. That file already contains TPM, which is already normalised. For WGCNA, just use the logged TPM data. You do not have to perform quantile normalisation.

ADD REPLY
0
Entering edit mode

Thanks for suggestion. But unluckily, It didn't work. I skipped the quantile normalisation step and the cluster dendrogram looks similar. It seems it is the data issue.

ADD REPLY
0
Entering edit mode

You can try without logging, too. WGCNA is based on correlation, so, the data does not strictly have to be logged. Even the authors state this.

ADD REPLY
0
Entering edit mode

Yes, I did try and the plot was similar. Maybe I can try the variance Stabilizing Transformation included in DESeq2, which takes a lot of time.

ADD REPLY
0
Entering edit mode

Variance stabilisation should, actually, be quick. It is rlog that can take a long time.

As a final suggestion, perhaps you could convert the TPM data to Z-scores, and then try WGCNA. Not ideal at all, but TPM data is neither ideal starting off.

ADD REPLY
0
Entering edit mode

Thanks for your suggestion.

ADD REPLY
0
Entering edit mode

What happened to your analysis, giuseppe0525?

ADD REPLY
0
Entering edit mode

Having some issues, rodd?

ADD REPLY
0
Entering edit mode

Hi, have you fixed it? I met the same problem.

ADD REPLY

Login before adding your answer.

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