User Tools

Site Tools


en:pcoa_nmds_rscript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:pcoa_nmds_rscript [2019/02/06 01:06] (current)
David Zelený created
Line 1: Line 1:
 +<code rsplus>
 +# PCoA and NMDS ordiagrams using Vltava data (added categorical variable)
  
 +vltava.spe <- read.delim ('​https://​raw.githubusercontent.com/​zdealveindy/​anadat-r/​master/​data/​vltava-spe.txt',​ row.names = 1)
 +vltava.env <- read.delim ('​https://​raw.githubusercontent.com/​zdealveindy/​anadat-r/​master/​data/​vltava-env.txt'​)
 +
 +library (vegan)
 +
 +png ('​pcoa_nmds.png',​ width = 8, height = 4, units = '​in',​ res = 300, pointsize = 11)
 +par (mfrow = c(1,2))
 +pcoa <- capscale (log1p (vltava.spe) ~ 1, distance = '​bray',​ sqrt.dist = TRUE, scaling = 1)
 +plot (pcoa, main = 'PCoA (MDS)',​ type = '​n'​)
 +points (pcoa, display = '​si',​ col = vltava.env$GROUP,​ pch = vltava.env$GROUP)
 +text (pcoa, display = '​sp',​ col = "#​FF000080",​ cex = 0.6, scaling = 1, select = colSums (vltava.spe>​0)>​20)
 +legend ('​bottomleft',​ pch = 1:4, col = 1:4, legend = 1:4, title = '​GROUP',​ cex = 0.6)
 +
 +nmds <- metaMDS (log1p (vltava.spe),​ distance = '​bray',​ scaling = 1)
 +plot (nmds, main = '​NMDS',​ type = '​n',​ display = '​si'​)
 +points (nmds, display = '​si',​ col = vltava.env$GROUP,​ pch = vltava.env$GROUP)
 +text (nmds, display = '​sp',​ col = "#​FF000080",​ cex = 0.6, select = colSums (vltava.spe>​0)>​20)
 +dev.off ()
 +</​code>​
en/pcoa_nmds_rscript.txt · Last modified: 2019/02/06 01:06 by David Zelený