Microscopic derivation of spin-transfer torque in ferromagnets