Sadly, it is true that women generally have to be more cautious than men about where they go and what they do. Further, transpeople generally have to be more cautious than cispeople.
My 7 personal rules of thumb regarding dealing with trouble:
1) Always be aware of your surroundings. Trouble can often be avoided by just crossing the street, waiting 5 more minutes in the Starbucks until "creepydude" drives away, or even just buying a new drink when your old one has left your sight at the bar/party.
2) Use common sense in planning activities. If a certain part of town you need/want to visit has a bad reputation, don't go alone and don't go after dark. Park your car in a well-lit part of the parking lot. etc.
3) If you are confronted, try leaving and/or talking your way out of it. The best way to win a fight is to defuse it before it can even start. Your pride is never worth a possible beating...or worse.
4) If a conflict seems imminent and you don't think you can get away on your own, make noise...lots of it. A good shout for help can often end a conflict. If it doesn't, it may still bring valuable assistance. Also, try to memorize everything you can about your potential opponents; especially thinks like tattoos, unusual voices, scars, t-shirt designs, unusual bling, names, license plates, customized car styles, and anything else that might help identify them later. Don't wait for the fight to start, notice as much as you can BEFORE the panic sets in fully, and keep trying to notice things until the situation is resolved/concluded.
5) If you have to fight, don't play fair. Ever! Fight to win. Fight with everything you've got. Use every "dirty trick" you can think of. Go for the eyes, ears, solar plexus, "junk", and anything else that will be painful or cause damage. Fair play is for the gym, not the street. Knowing the practical use of one or more martial arts can help, but be prepared to practice regularly and often. As soon as you see a chance to escape, take it!
6) If you want to carry a weapon, whether a gun or something else, make sure you can use it properly, without hesitation, and without remorse. Do not carry a gun unless you know you have it in you to end a hostile person's life in a very loud and messy way. Any weapon you cannot use effectively WILL be taken from you and used against you.
7) Assuming you either escape or survive whatever your attacker did to you, get to safety and call the police RIGHT NOW! Remember that no matter what happened, you are not to blame in this. You did not ask to be attacked. You need to tell the authorities right away, and you will very likely need to talk about it later with a therapist/counselor or a trusted friend or family member. Do not try to hide away and keep it to yourself no matter how embarrassing the situation was. If it is bothering you, solitude and isolation are not your friends.
Your mileage may vary, but it's what I live by.