I am trying to generate a TOM matrix using WGCNA package but the output shows value 0 instead of 1 when the index is calculated for a gene with respect itself. I do not know what is wrong because I am using the function blockwiseModules, that in theory, generates uses similarity by default.
1 answer
The topological overlap matrix in the WGCNA package represents similarity values between genes, which range from zero to one. The diagonal elements must equal one because each gene has perfect topological overlap with itself. If you observe zeros on the diagonal, you are examining the dissimilarity topological overlap matrix instead of the similarity topological overlap matrix. The blockwiseModules function computes the similarity topological overlap matrix by default when the parameter TOMType is set to "unsigned" or "signed", but subsequent steps or outputs may involve the dissimilarity version for clustering purposes, where dissimilarity equals one minus similarity, resulting in diagonal zeros.
To verify and correct this:
- Inspect the object returned by blockwiseModules and confirm whether you are accessing the similarity topological overlap matrix or a derived dissimilarity matrix.
- If saveTOMs is set to TRUE in blockwiseModules, load the saved RData files and check the diagonal of the TOM object directly using diag(TOM).
- If the values are zeros, compute the similarity topological overlap matrix as TOM_similarity <- 1 - dissTOM, where dissTOM is your current matrix.
- Alternatively, use the TOMsimilarity function on your adjacency matrix to generate the similarity topological overlap matrix explicitly, ensuring the adjacency matrix diagonal is set to one beforehand with diag(adjacency) <- 1.
Kevin
Log in to answer this question.