Interplay between thermal and electrical effects in phase-change memory