Many Scottish surnames begin with the Gaelic word Mac, son, e. g. MacInnes, MacAllister. In Gaelic, the form changes when referring to a female, to Nic.
Murdo MacRae is Murchadh MacRath, but Margaret MacRae is Mairead NicRath (compare Icelandic, Magnusson, Magnusdottir).