Relative influence of resident species and environmental variation on community assembly