# Apply Shannon-Weiner index to evaluate single-cell sample balance?

I would like to identify single-cell clusters where each sample is evenly represented in it. Is it OK to calculate the Shannon-Weiner index from the sample counting data of each cluster? I am worrying that the entire population of each sample is not balanced, therefore I plan to normalize within-cluster counts with total cell number in each cluster.

My naive idea is summarized in these formulas:

$$E_{i} = \frac{\sum_{j=1}^{N_{sample\,}}P_{i,j}\log_2{P_{i,j}}}{E_{max}}$$

where,

$$P_{i,j} = \frac{C_{i,j}}{\sum_{i=1}^{N_{cluster}}} + pseudo\_count$$

$$C_{i,j}$$ is the count of sample $$j$$ in cluster $$i$$.

• What is the purpose of the pseudocount? Jul 12 '21 at 18:54
• Pseudocount aside, you are proposing to estimate a rescaled Shannon entropy onto $[0,1]$ of each cluster. That is fine if that is what you want to know. Jul 12 '21 at 18:58
• @Galen Log2P_ij undefined if C_ij equals to zero. That is the cluster does not have any instances of the sample. Are there other approaches to avoid this?
– J.G
Jul 13 '21 at 14:09
• That's quite understandable, however by convention we take the right-limiting value $H(0) \triangleq \lim_{p \rightarrow 0^+} p \log_2(p) = 0$. Jul 13 '21 at 14:21