Dear Adrien and Ted, thank you for your suggestions. For now I do not care about elegance and the simple solution worked perfectly enough for me: I "cbinded" a group-vector to my environmental data and plotted the oridiellipse accordingly:
points(fig.nms.its1, "sites", pch=19, col="green", select=env.its1$group==1) with(env.its1, ordiellipse(fig.nms.its1, env.its1$group, kind="se",label=T, conf=0.95, col="green", show.groups=1)) with(env.its1, ordihull(fig.nms.its1$site, group, col="green", lty=2, show.groups=1)) Thanks also for the second answer! With best wishes Martin > From: "Donn, Ted" <[email protected]> > Subject: RE: [R-sig-eco] ordiellipse with more than one environmental factor?? > Date: 21 May 2014 01:05:48 CEST > To: Martin Unterseher <[email protected]> > > Dr. Unterseher, > Although this is not very elegant, I generally add a column that identifies > my groups and then use that to select the group for the hull or ellipse that > I want to plot. You can place that column in a separate variable (array) or > add it to the environmental variable matrix. > Regards, > Ted > > Theodore E. Donn, Jr, PhD | Principal Ecologist (E.S.A. Certified) > Direct: 925.280-7419 | Main: 925.280.7411 | Fax: 925.283.0780 > [email protected] > > Tetra Tech | Research and Development > 3746 Mt. Diablo Blvd., Suite 300 | Lafayette, CA 94549| www.tetratech.com > > PLEASE NOTE: This message, including any attachments, may include > privileged, confidential and/or inside information. Any distribution or use > of this communication by anyone other than the intended recipient is strictly > prohibited and may be unlawful. If you are not the intended recipient, please > notify the sender by replying to this message and then delete it from your > system. > > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Martin Unterseher > Sent: Tuesday, May 20, 2014 2:54 PM > To: [email protected] > Subject: [R-sig-eco] ordiellipse with more than one environmental factor?? > > Dear all, > > I have a species (phyllosphere microfungi)-sample matrix "spec.its1.s" and an > environmental matrix "env.its1" with several parameters, such as setting > ("phytometer" and "natural"), elevation ("valley", "mountain" and "top") or > substrate ("living" and "dead" [leaves]). > > My species matrix therefore contains samples with different environmental > combinations, e.g. phytometer-valley-living, phytometer-mountain-living, etc. > Instead of extracting several subsets and calculating metaMDS independently > for every subset, I seek a solution to manage all data simultaneously. > > Whereas I know how to plot subsets of samples with points(...) in different > colours, I have no idea about how to do this with ordiellipse, ordihull, > ordiclust, etc. Of course, I did my best to search the www for a solution. > > Here are my commands: > > nms.its1<-metaMDS(spec.its1.s, autotransform=F, distance="bray") > > fig.nms.its1<-ordiplot(nms.its1, type="none", main="Phyllosphere community - > relative abundances") points(fig.nms.its1, "species", pch=20, col="blue", > cex=0.25) points(fig.nms.its1, "sites", pch=19, col="green", > select=env.its1$elevation=="valley" & env.its1$setting=="phytometer" & > env.its1$substrate=="living") points(fig.nms.its1, "sites", pch=19, > col="darkgreen", select=env.its1$elevation=="mountain" & > env.its1$setting=="phytometer" & env.its1$substrate=="living") > points(fig.nms.its1, "sites", pch=19, col="orange", > select=env.its1$elevation=="valley" & env.its1$setting=="natural" & > env.its1$substrate=="living") points(fig.nms.its1, "sites", pch=19, > col="red", select=env.its1$elevation=="mountain" & > env.its1$setting=="natural" & env.its1$substrate=="living") > points(fig.nms.its1, "sites", pch=19, col="violet", > select=env.its1$elevation=="top" & env.its1$setting=="natural" & > env.its1$substrate=="living") > > And then I got stuck: How can I draw a ordihull, ordiellipse for the green, > orange, violet, etc. groups? > > Next I want to apply e.g. "anosim" to check for significant community > compositions. For instance, I want to compare the phytometer-VALLEY-living > community with the phytometer-MOUNTAIN-living community with the (null) > hypothesis that both communities do not overlap. > > This brings me to the next question: How can I extract subsets of my > species-sample matrix by using information from the environmental data: e.g. > "extract only those samples (and species) from the species-sample dataframe, > that have the combination setting=phytometer, elevation=valley, and > substrate=living, etc.. > > I hope that someone out there can help me though I do not provide some of the > data at the moment. > > > Best wishes > Martin > __________ > > Dr. Martin Unterseher > Ernst-Moritz-Arndt University > Institute of Botany and Landscape Ecology Dept. of Systematic Botany > Soldmannstr. 15 > D-17487 Greifswald > > http://www.botanik.uni-greifswald.de/100.html > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-ecology mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > > Begin forwarded message: > From: Adrien Vetterli <[email protected]> > Subject: Re: [R-sig-eco] ordiellipse with more than one environmental factor?? > Date: 21 May 2014 08:20:25 CEST > To: Martin Unterseher <[email protected]> > > Hello Martin , > > for your first question, you should definitely give ggplot2 a go: > > http://stackoverflow.com/questions/13794419/plotting-ordiellipse-function-from-vegan-package-onto-nmds-plot-created-in-ggplo > > It's easy to learn how to deal with facets in ggplot2 and if I understood > correctly, that's the way you want to go about plotting your subsets nmds > plots with ordiellipse. > > http://docs.ggplot2.org/0.9.3.1/facet_grid.html > > As for the last question, you can either use the function "subset", or subset > directly like this: > > yourdataframe[yourdataframe$yourcolumn=='yourmatch',] > > StackOverflow is a wonderful resource fall all these questions, they should > pop up on Google search. > > a. > [[alternative HTML version deleted]] _______________________________________________ R-sig-ecology mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
