A Bayesian latent variable approach to functional principal components analysis with binary and count data