I don't agree that the rape was unnecessary.
There are two plot devices in operation, rather than the one in the book. In the book, Theon being forced to sexually assault Jeyne Poole, who Sansa is standing in for, is what ultimately gets him to re-grow some nads.
If Sansa is also the stand in for Stoneheart, then she needs some skin in the game. She's one of the few Starks to have avoided personal violence and I would imagine this sets up for a culmination of Sansa stabbing the life out of Ramsay, and his clingy bit on the side (who he raped in the last episode), while not clouding your opinion of Sansa.