Have you asked her if she's sad because her friend didn't want to be a ballerina rather than how she feels about the ballet class itself?
I would probe that gently and if she tells you that it made her sad that her friend didn't want to dance, I would explain to her that everyone has something different that they love to do and her friend might want to do something else. It doesn't mean that they can't be friends and have fun doing other things together. Just because her friend didn't want to doesn't mean that she can't be a ballerina herself.
I think at this age (at least I've noticed it with my daughter who is 3) they equate friendship many times with liking/doing all the same things. (My daughter sees other girls like her doing or enjoying certain things and she wants to follow.) My daughter has a special buddy with whom she shares many interests, but they have had misunderstandings before during play that have caused some sad feelings that we've had to address because my daughter avoided getting into the same play situation again. I had been surprised that they were old enough for this kind of thing to happen, but there it was. After I talked to her about the problem and explained that her friend was still her friend, she was (they were) fine. She's also had situations where she suggested something to do with her friends and when they wanted to do something else, she cried.
Maybe whenever your daughter goes to that space now she is reminded of her friend not wanting to dance with her and that is what's making her sad? If I had a negative experience as a kid, I sometimes associated it with the place. For example, I had a bad experience with the swimming program at the YMCA when I was that age and my mother had a hard time getting me to go to any other classes at that building.
Not sure if any of that helps, but I would try that. You might also ask the teacher to give her a little extra praise when she does participate or ask her to introduce her to another little girl as a special dance friend. That way she feels a special connection over dance with someone else she sees regularly.
Good luck! They're so cute in leotards and ballet slippers!