http://www.tsa.gov/travel/frequently-asked-questions
Transgender persons should use the name and gender that appears on their government-issued ID when making flight reservations and at the security checkpoint. You may ask that carry-on bags be screened in private if a bag must be opened by a TSA officer to resolve an alarm. Screening can be conducted in a private screening area with a witness or companion. You may request private screening or to speak with a supervisor at any time during the screening process.
If the TSA screeners based the screening on appearance seems these screeners may have been in violation of TSA policy.