Graphical models for statistical inference and data assimilation