The study of how fungi interact with other organisms and their environment, and how they impact ecosystems.