We report on HistoMosaic, a novel technique for genetic analysis of formalin-fixed, paraffin-embedded tissue slices. It combines microfluidic compartmentalization, in situ allele-specific PCR, and fluorescence microscopy. The experimental proof of principle was achieved by in situ detection of KRAS G12V mutation in colorectal cancer tissues and is presented herein. HistoMosaic offers the ability to detect mutations over the entire tissue slide simultaneously, rapidly, economically, and without selection bias, while coregistering the genetic information with the preserved morphological information. Thus, HistoMosaic has wide applicability in basic science as a tool to map genetic heterogeneity. It is also a platform to build companion diagnostics for targeted therapies in oncology, to help ensure that the right drug is given to the right patient, thereby saving healthcare resources and improving patient outcomes.