Disclosed are methods for trapping and barcoding discrete biological units in a hydrogel. Also disclosed are methods for analyzing gene expression, genotype, haplotype or epigenome in discrete biological units, as well as kits for implementing the methods of the present disclosure.