  We devise a method to detect and estimate forces in a heterogeneous
environment based on experimentally recorded stochastic trajectories. In
particular, we focus on systems modeled by the heterogeneous overdamped
Langevin equation. Here, the observed drift includes a "spurious" force term
when the diffusivity varies in space. We show how Bayesian inference can be
leveraged to reliably infer forces by taking into account such spurious forces
of unknown amplitude as well as experimental sources of error. The method is
based on marginalizing the force posterior over all possible spurious force
contributions. The approach is combined with a Bayes factor statistical test
for the presence of forces. The performance of our method is investigated
analytically, numerically and tested on experimental data sets. The main
results are obtained in a closed form allowing for direct exploration of their
properties and fast computation. The method is incorporated into TRamWAy, an
open-source software platform for automated analysis of biomolecule
trajectories.
