What causes yellow mucus to occur in stool, accompanied by lots of gas, and slight mushy but in balls?

Good possibilities. Mucus discharge occurs in up to 50% of patients with irritable bowel syndrome, with or without pain. Mucus may also be produced in response to partial obstruction, chronic constipation, rectal dysfunction, infection, & even from secretory villous tumors of the rectum. Stool studies & exam should help to at least start addressing some of these possibilities.