Rank is not directly related to score as one might initially think. I have gotten Rank B scores higher than my Rank A scores. So if it isn't score that determines rank, what is it?
Score is determined based on how many notes you hit and how well you hit them. Rank is determined only by how well you hit them. S ranks also require you don't miss anything; if you miss but still meet the requirements for an S, you'll only get an A. Since the number of notes varies by song, that means score and rank can be very different between them. As a degenerate case, consider a one-note song. The maximum score would be 300 points, but if you got that, you'd expect an S rank.
(I don't remember if these numbers are rounded up or down.)