the engine mounts on the 06 YZ and 07 WR are the same I have one of each sitting in my garage. The only difference is that the WR has mounts for the regulator on the side. And a WR vin
and the subframe mount on the left side of the bike is different other than that they are the same.... I too my 07 WR frame and welded a tab for my YZ subframe and hooked it right up. the tank seat and radiators all slide right on. the shock mount and linkage hookup's are the same too.... The main question is how many modifications will need to be made to make your 04 engine mount in. You'll have to fab engine mounts if you feel like your capable of doing that. Then yes it will work.
I'm sure the engine will fit then you'll have to choose your set up after that Good luck.
pssss (I do know that an old 465 2t will fit in the newer chassis
) sshhh don't tell any one.