We obtain Gaussian estimates for the kernels of the semigroups generated by a class of subelliptic operators $H$ acting on $L_p(\boldsymbol R^k)$. The class includes anharmonic oscillators and Schrödinger operators with external magnetic fields. The estimates imply an $H_\infty$-functional calculus for the operator $H$ on $L_p$ with $p \in \langle 1,\infty\rangle$ and in many cases the spectral $p$-independence. Moreover, we show for a subclass of operators satisfying a homogeneity property that the Riesz transforms of all orders are bounded.