Ranks don't tend to be as important as in MTW. Aside from phalanx units, I don't recall there being any noticable rank bonuses or penalties.

Hoplites should ideally be in 3 ranks minimum (I recommend 5, 6-7 if the hoplite is a low level and the enemy has lots of strong cavalry ), and Pikes should be 4-5 ranks minimum, with another couple extra for reserves/absorbing enemy charge.

I typically use 4 ranks for Legionary/Pilum units, and 4 for most other units to be honest, except archers and skirmishers which I use less and spread them out. I don't think there are accuracy penalties for having deep ranks for missile troops in RTW though.

Ranks should really just be set to match whatever the enemy has to throw at you. If you're worried about cavalry, use more ranks; if you have better infantry, you can use less ranks and use a wider line and hope any excess units automatically start to flank and wrap around the opposing unit. As there are no penalties for having numerous units occuping the same space, you can just mass-attack the enemy in one big cluster anyway, thus removing the need for rank bonuses.

I find cavalry and chariots are often better with several ranks for a frontal charge, although if you are charging the rear of a unit, having a wider front rank instead of lots of narrow ranks means you'll probably kill a lot more troops when the cavalry smashes into the back of the enemy unit. That applies to most of the other units too really. There's no great science to ranks in RTW. I'd add that more ranks tend to be for more defensive reasons (withstanding attacks), and less for more offensive manoeuvres.