I found some great advice what to do in another post:

When a girl confronts you about her feelings, the best course of action (from my experience) is to deflect her anger onto something else. Example:

My LTR was mad that I had "kicked her out of my car". What actually happened was that she went to bed at midnight, woke up at 5:30am, and was busy doing makeup and hair for a wedding for several people. We got to her place at around 9:30pm, fucked in my car, and around 11pm I told her to get out because I needed to go home. She slammed my car door shut and left in a huff. When she confronted me about it, I told her "You were mad, but you weren't mad at me. You were mad about x,y,z, and the wedding, but not at me. Despite this, you took it out on me. You can be mad, but you took it out on me despite me having nothing to do with it. Don't do that again." She apologized, we had sex, all was good

You validate her feelings, but invalidate her ability to take it out on you. You establish your boundaries and self-respect without losing frame

I was in a similar situation a few days ago but it didn't go like this. She admitted herself that none of what made her mad was my fault and I did nothing wrong. Still she did take out her feelings one me and telling her to stop didn't help. She got angry at any minor decision I made or thing I said, and the next day also admitted that she was taking it out on me and apologized. But shit's too late, I'm not putting up with another evening of nonsense because she can't sort out her feelings. She is also my roommate (Mistake I know) So I can't just leave her. Is there something good I could say when "You aren't mad at me but are taking it out on me" doesn't help? Something to add or another phrase in general?