Skip to content

cutreeHybrid fails when pamRespectsDendro=True with ValueError: operands could not be broadcast together with shapes #149

@potulabe

Description

@potulabe

Running this code:

net_post.findModules(
    kwargs_function={
        'cutreeHybrid': {
            'deepSplit': 3,
            'pamRespectsDendro': True,
        },
        "pickSoftThreshold": {
            "blockSize": 5000
        },
    }
)

results in:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[38], line 3
      1 net_post.MEDissThres = 0.01
----> 3 net_post.findModules(
      4     kwargs_function={
      5         'cutreeHybrid': {
      6             'deepSplit': 3,
      7             'pamRespectsDendro': True,
      8             # "cutHeight": 0.998,
      9             # "pamStage": False,
     10         },
     11         "pickSoftThreshold": {
     12             "blockSize": 5000
     13         },
     14     },
     15     # skip_steps=["pickSoftThreshold", "adjacency", "TOMsimilarity", "linkage", "cutreeHybrid"],
     16     force_power=7
     17 )

File ~/.conda/envs/rnaseq/lib/python3.13/site-packages/PyWGCNA/wgcna.py:367, in WGCNA.findModules(self, kwargs_function, skip_steps, force_power)
    364 dissTOM = 1 - self.TOM
    365 dissTOM = dissTOM.round(decimals=8)
--> 367 dynamicMods = WGCNA.cutreeHybrid(dendro=self.geneTree, distM=dissTOM, minClusterSize=self.minModuleSize,
    368                              **kwargs)
    371 # Convert numeric labels into colors
    372 kwargs = dict()

File ~/.conda/envs/rnaseq/lib/python3.13/site-packages/PyWGCNA/wgcna.py:1821, in WGCNA.cutreeHybrid(dendro, distM, cutHeight, minClusterSize, deepSplit, maxCoreScatter, minGap, maxAbsCoreScatter, minAbsGap, minSplitHeight, minAbsSplitHeight, externalBranchSplitFnc, nExternalSplits, minExternalSplit, externalSplitOptions, externalSplitFncNeedsDistance, assumeSimpleExternalSpecification, pamStage, pamRespectsDendro, useMedoids, maxPamDist, respectSmallClusters)
   1819 basicOnBranch = branch_basicClusters[onBr[0] - 1]
   1820 labelsOnBranch = branchLabels[basicOnBranch - 1]
-> 1821 useObjects = ColorsX in np.unique(labelsOnBranch)
   1822 DistSClustClust = distM.iloc[InCluster, useObjects]
   1823 MeanDist = DistSClustClust.mean(axis=0)

ValueError: operands could not be broadcast together with shapes (2,) (21902,)`

whereas running the same code with pamRespectsDendro=False works fine. What can be the problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions