Hi my DD was the same in year 4 and it was awful, I do feel for you. Got quieter and sometimes stroppy and then one night it all came out. Very similar situation by the sounds of it. DD was playing with much younger kids, if at all and joined any lunchtime club to avoid the playground.
Turned out that the groups of girls were well established and she felt she couldn't join in. When she did manage it, she said the games they played were not wanted to play so she wandered off and was alone.
I explained, very tentatively, that not all the games will be exactly what she wants but it was important to join in and play and be with the group. This so when they get bigger and the games change she will be part of it and will have made the friendships.
It took some time but now, year 5 she is happy, popular and a completely different girl from 18 months ago.
I am not suggesting your DD joins in with the girls she doesn't actually like but perhaps sticking with a group and staying and joining in, even if the games are not to her liking, may pay off...
It's not easy and wasn't for my DD, took months.
Also sent her to a drama summer school, just a week. As mentioned above, fantastic for confidence building and really helped.