Manifold learning in metric spaces