Mairi McAllan said the SNP would "do a bit of soul-searching" after it suffered a surprise defeat in South Lanarkshire.