Morphology-dependent resonances in inhomogeneous spheres: comparison of the layered T-matrix method and the time-independent perturbation method