Study of W boson production in association with beauty and charm