Transition between extended and localized states in a one-dimensional incommensurate optical lattice