Neural circuit analysis relies on having molecular markers for specific cell types. However, for a cell type identified only by its circuit function, the process of identifying markers remains laborious. We developed physiological optical tagging sequencing (PhOTseq), a technique for tagging and expression profiling of cells on the basis of their functional properties. PhOTseq was capable of selecting rare cell types and enriching them by nearly 100-fold. We applied PhOTseq to the challenge of mapping receptor-ligand pairings among pheromone-sensing neurons in mice. Together with in vivo ectopic expression of vomeronasal chemoreceptors, PhOTseq identified the complete combinatorial receptor code for a specific set of ligands.