Hi
I noticed that sometimes your mcc calculation gives NaN. This is probably because the denominators is becoming zero. Here is some code that corrects for this:
https://stackoverflow.com/questions/16332461/which-method-is-best-for-computing-the-matthews-correlation-coefficient-mcc-va/20549450