I have to compare two different lists of biomolecular annotations, and to find out their correlation degree. To do this, I have implemented a function computing the Spearman's rank correlation coefficient between two lists and a function computing the Kendall tau distance between two lists.
In my implementation, I have managed the case of having two lists of different dimensions and/or containing different elements, by this way: I take the elements of ListA that are missing in ListB and I insert them at the end of ListB; then I take the elements of ListB that are missing in ListA and I insert them at the end of ListA.
I thought this was a good way to proceed, but actually I discovered that it worked out only if the lists have similar dimensions (maximum difference: ~20%). Especially, if the two lists have very different dimensions, this approach give wrong results.
For example, I computed the two correlation metrics when ListA had dimension 4 and ListB had dimension 816. Obviously, these lists have little in common, but the Kendall and Spearman methods I implemented stated wrongly that they had a "high correlation". This happened because the 812 elements of ListB missing in ListA were inserted in ListA.
So the question is: how to manage correctly lists of different dimensions in computing Kendall and Spearman correlation coefficients?
How to manage the missing elements?