A lineage tree-based hidden Markov model quantifies cellular heterogeneity and plasticity