Complex relationships between species niches and environmental heterogeneity affect species co-occurrence patterns in modelled and real communities