Flatulence is simply undigested, partially digested food. I find cooked food causes more gas than fresh and poor food combining, mixing foods that don't digest well together, also gives me problems. Put a piece of kombu seaweed in your beans while they're cooking. That's supposed to eliminate the flatulence that goes with eating beans.
My husband's vegetarian for 6 years, and he claims vegetarianism caused him more gas problems. We make jokes and laugh about it, oh, and he complains!