The number ranking appears to relate solely to your performance during a rhythm section. If you play through a level with nothing but perfects for the dance sequences you will recieve an A+ every time regardless of score. However the statistics the game saves for a level are based on the highest score you've been able to achieve, regardless of rank, so if you get a massive score with only a rank of A because you missed a few button prompts, then that run will be the one recorded. If you want to lock in an A+ for the level you need to beat your current best score with a run that doesn't miss a single beat for it to overwrite. The best strategy is to instantly retry a level the second you miss a prompt so as not to corner yourself with an unbeatable highscore while trying to increase your rankings.