First, do all the loyalty missions. The game pretty much hammers this into you at every turn so... take the hint.
Second, don't acquire the Reaper IFF until you have done pretty much everything you possibly can.
Third, upgrade the ship with the Armor (Jacob), Shields (Tali), and Thanix Cannons (Garrus).
Forth, don't assign people to jobs at random. Again, the game will beat it into so pay attention.
Tubes: It pretty much tells you, TECH EXPERT YOU DUMB FUCK! So guess what, you send Jacob and he dies. Duh. Tali or Legion.
Team Leaders: Leadership. If you put Zaeed in charge (The guy who's every story is about how he got EVERYONE BUT HIMSELF killed on every mission) the obvious happens. Put leaders like Miranda, Garrus, or Jacob in charge.
Biotic: Again, powerful biotic. Who are the most powerful biotics on the ship? The ones the game tells you are. Jack or Samara.
Crew Escort: This one isn't as obvious but to be safe send Mordin. He's the least capable of holding the line. However if you want to take Mordin to the Reaper baby then send Tali, or Kasumi. However if you are leaving Grunt, Zaeed, and Garrus to hold the line and they are loyal you aren't likely to lose anyone.
Reaper Baby: Two people who are loyal and not good line holders.
You do all that and you'll likely save everyone. In fact its far far harder to actually lose everyone like the game tries and tells you is the most likely outcome.
Oh, and when it comes to your general Cerberus crew you should head for the Omega relay ASAP. In my experience the game will let you finish up however many loyalty missions you have remaining but there's no guarantee. My usual pattern is to finish everything but Tali and Legion's loyalty missions. I hit the Reaper IFF and pick up Legion. I activate him. I hit Tali's loyalty mission then Legions, then the Collectors attack. I immediately go to the Omega 4 relay. Never lost the crew.