The issue here is uncertainty about ones own gender - am I male or female? A common issue for the sole survivors of a dizygotic opposite sex pair pf twins.
The first book: "The Bone Doll's Twin"
Plot summery: "In order for Skala to live in peace and prosperity, a Queen must sit on the throne.
The Bone Doll's Twin begins with an unusual and intriguing premise: in order to fulfill a prophecy and protect the rightful female heir to the throne of Skala, an outlawed witch and two wizards - Iya and her apprentice Arkoniel, attend a royal birthing of twins. These twins are born to Ariani, the sister of the Usurper King. This king has taken what, by the God's wishes, is a matriarchal throne; in the process eliminating every possible female contender to his reign, even secretly murdering his own female kin.
The twins born to his sister Ariani are a boy and a girl, and to protect as well as disguise the new princess, Iya and Arkoniel assist the witch Lhel in killing the son at birth, then cast a spell that binds the newborn princess' physical appearance to that of her dead brother; a bodily glamour achieved by the stitching of skin that causes the sister to assimilate the brother's body, and vice versa. But there is one thing - the brother has to be killed before he draws his first breath - so that his soul would not enter his body.
However, the plan goes all wrong. When the King comes to visit his sister, Lhel is startled from her concentration. The brother's soul is accidentally allowed to enter his body, and the mother, who is not a party to the plot, hears the cry of her infant son just before he is smothered to death. While the physical switch of identities works to deceive the king, the infants' mother is, on some level, aware of the deception and the unnatural death of her son; an awareness that leads to madness and a hostility towards her surviving child. Worse, the vengeful spirit of the murdered sibling comes to haunt not only the perpetrators of the crime, but in particular his unknowing sister, who, as she matures, remains totally unaware of her true gender and identity; knowing herself as the boy (Prince) Tobin.
Conflicts begin to emerge between the kingdom of Skala and an ancient foe, intrigues simmer at court, and a looming struggle begins to emerge between mages who support the new rule of the king and those who wish a return to the older reign of queens."Worth reading to see what she makes of these issues.
See more here
There is a full list of books, movies etc that consider the lost twin issue:
See the full list here and see if you have some more ideas