Gene genealogies for detecting rare and common variants