The game being setup to have Ellie being in need of die to have the cure doesn't really make that well written. It was something forced. Just as Deus Ex Machina situations on entertainment may have been planned that way, but that doesn't make they not Deus Ex Machina.
Cancer is very much brain invasive, and effectivelly takes parts of the brain off, still a neurocirurgion can extract part of the brain without killing the patient. Ellie is imune and the fungus didn't really develop so it is likely small and funghi certainly can be taken small portion and still would be working enough to do the research.
And you do not need the part that is infected first to see how antibodies react,they could test with some drained blood first or on a safer part of her body.