This is covered in ch. 11 of the really useful book: 'Modern comparative phylogenetic methods and their application in evolutionary biology' edited by L. Garamszegi https://www.springer.com/us/book/9783662435496#aboutBook
Here is a link to the code where they show how to calculate lambda for an MCMCglmm model: