Using state-space models to infer the dynamics of gene expression driven by external and internal regulatory networks