The impact of recent measurements of heavy-flavour production in deep inelastic $ep$ scattering and in $pp$ collisions on parton distribution functions is studied in a QCD analysis in the fixed-flavour number scheme at next-to-leading order. Differential cross sections of charm- and beauty-hadron production measured by LHCb are used together with inclusive and heavy-flavour production cross sections in deep inelastic scattering at HERA. The heavy-flavour data of the LHCb experiment impose additional constraints on the gluon and the sea-quark distributions at low partonic fractions $x$ of the proton momentum, down to $x sim 5 times 10^{-6}$. This kinematic range is currently not covered by other experimental data in perturbative QCD fits.