First, be aware that the "Reaper IFF" mission triggers a cascade to the final mission. For the 'best' result (no casualties, fully rescued crew), you will have to play in a precise sequence after Reaper IFF, so do all your mining and buy all your upgrades before starting that one. You'll also want some spare resources to research the last few things you get; I'm not sure if time taken mining affects the countdown, so do your mining first. I went into Reaper IFF with 50,000 of the #2 and #3 minerals, which was enough. If you happen to notice the exact amount you need for your final research items, post it below and I'll incorporate it here.
During Reaper IFF, you will get Legion, and you trigger either a 1- or 2-mission countdown until your crew is kidnapped. If you're going to use Legion, you need to wake him up and talk to him immediately to get his 'loyalty' mission. Also make sure to get his sniper rifle upgrade research; it's wickedly powerful. Run his mission, and do all the research you've recovered; that takes no game time.
You will then be forced to exit the ship the next time you visit the galactic map. Your crew will be kidnapped. During the subsequent conversation, tell Miranda and Jacob that you're going after the crew, and do so..... go straight to the Omega 4 relay and start the final assault. If you don't do this immediately, your crew will die. You may not even be able to visit planets; I haven't tried.
During the long, unskippable cutscenes, you will either lose team members or not, depending on whether you bought the three upgrades to armor, shields, and weapons. Each missing upgrade kills someone.... I don't know if it's random. You also have to fight a drone in the cargo hold twice; this is pretty straightforward. It's big and tough, but don't worry about using up heavy weapon ammo, because it will be restored when you land on the base. Blast away freely. Eventually, you will crash at the Collector base.
Now you have to choose someone to go on the suicide vent mission, and someone to lead the other team. I don't know if loyalty matters for these two characters. I do know, for sure, that the choice you make for the other leader is critical. I chose Samara because I liked her and she seemed steady, and that kept getting my vent person killed. You need someone with experience with leading troops in combat; Garrus worked well for me. Miranda will probably work. Samara, even loyal, is a bad choice. Rumor claims that only Legion and Tali are good choices for the vent; it's possible that others may work if your other squad leader is good. I used Tali, because Legion kicks so much ass in combat against Collectors.
Choose your team for the first section. I was playing a soldier, and I found that the combination of taking the Barrier power as the research bonus, at full strength, and combining it with Thane's Shredder ammo upgraded to squad level, combined with the various assault rifle upgrades, made the Collectors in this section extremely easy. One quick burst to the head and they die. I also used Legion, and we cut through those fights like those guys weren't even there. Pop Barrier when you need it, headshot the grunts with your assault rifle, and race Legion to the kill on the possessed guys. His researched sniper rifle is incredibly deadly. (you can get it too at midgame, it's one of the three choices for your special weapon on the Collector ship, and I found it to be absolutely devastating when sniper rifle damage and headshot bonuses are researched. With that research, it's better than heavy weapons most of the time.)
You have to flip a bunch of switches here, but I don't think speed matters very much, as long as you don't miss any. I was rushing rushing rushing because I thought my lack of speed was killing my vent squaddie, but I don't think it actually matters, as long as you release each switch before they die. They seem to be fully restored for the next switch, and again when you get all the way through.
After throwing the last switch, you go to a cutscene. Here, your vent tech is desperately trying to close the door. If you chose a bad leader for the other squad, your vent person will have his or her head in the door when a missile comes in, and will instantly die. A smart squad leader (possibly loyal, not sure) will have his team focus fire on the door, protecting your tech.
Now you find your crew; if you went right away, they will be alive. If you didn't go immediately after the kidnap, you get to watch Yeoman Chambers die, and all you save is the doctor. She's... not happy with you if that happens. If you send the crew back alone, they'll die; you need to detach someone to go with them. Mordin is a good choice here; he's apparently somewhat susceptible to getting killed later on. I don't think loyalty matters here; as long as they have an escort, I believe the crew (or just the doctor, if you were slow) will live no matter what.
Now you split again into two squads, once again choosing a second leader. I believe that loyalty and skill are both required here for them to survive. Samara, even loyal, dies. Miranda, fully loyal, lives.
You also choose a biotic to protect you from Seeker swarms. I chose Thane on my first playthrough, and lost Jack because he wasn't strong enough, and flagged by the end. On the second playthrough, choosing Samara saved everyone; she's strong enough to do a final large burst that drives away the seekers and saves your squad. Jack can apparently also do it. Miranda is confirmed as not working. I don't know if loyalty matters for the biotic; I believe it does matter for the squad leader.
You can tell, by the way, whether you've chosen good squad leaders, because if you choose badly, you'll keep getting 'we're in trouble!' radio messages; if you choose well, the radio messages will be encouraging.
In the third section, don't choose the 'we have to hurry' option... if you do, you'll lose people. Have everyone hold the door, and pick your final team. I believe these final two MUST be loyal or they will die. I again went with Legion and Thane; that combination is freaking devastating against Collectors. I did the full Paragon-style speech; I don't know if it matters, but I figured extra morale couldn't hurt. I don't know if loyalty matters back there, as my team was all loyal, and they all lived.
Fight your way to the platform, kill the tubes, make your decision on whether to keep or blow up the base. Me, I blew it up; there's no way I'd let the Illusive Man anywhere near it. But do whatever you like, it doesn't matter for outcomes in this game.
Once you decide and set the charges/radiation pulse, the Reaper shows back up. Kill him. On my first playthrough, I had gotten enough upgrades to get 200% on the M920 Cain device; two shots of that killed the Reaper in about ten seconds. On my second playthrough, I apparently missed something, because I had only 175% -- I could only fire once, which is about 50% damage. Peppering his eyes with the assault rifle did the rest. He moves so fast he's hard to snipe.
From there, it's all cutscenes. You will recover your two squadmates from the wreckage; I believe their loyalty determines life or death.
Interestingly, the only way to die yourself (other than in combat, the usual way) is to get everyone killed.... if absolutely everyone but you is dead, Joker alone isn't strong enough to pull you into the ship when you jump, and you die too.