The initial red flags for any HMRC investigation are typically picked up by their super computer 'Connect', which is a military grade machine built by BAE Systems and with the power to assess a wide range of data. If it finds an inconsistency it may trigger a human to start looking deeper. If this closer look suggestions a formal investigation is required you will receive a letter from HMRC explaining that, and the process they will follow.