Commit f96cd20c by Eric Coissac

Initial commit...

parents
.Rproj.user
.Rhistory
.RData
.Ruserdata
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: ISO-8859-1
RnwWeave: knitr
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
---
title: "Untitled"
author: "Aurlie & Eric"
date: "27/03/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(ade4)
library(vegan)
```
```{r}
euk = read.csv("australia.euk.reads.plot.csv",head=TRUE,row.names = 1)
bac = read.csv("australia.bac.reads.plot.csv",head=TRUE,row.names = 1)
env = read.csv("biogegraphy_and_environment.csv",head=TRUE,row.names = 1)
```
```{r}
env=env[,lapply(env,class)=="numeric"]
euk=euk[rownames(env),]
bac=bac[rownames(env),]
```
```{r}
env = sweep(env,MARGIN = 2,colMeans(env),'-')
env = sweep(env,MARGIN = 2,apply(env,2,sd),'/')
```
```{r eval=FALSE, include=FALSE}
euk=sqrt(euk)
euk = sweep(euk,MARGIN = 2,colMeans(euk),'-')
euk = sweep(euk,MARGIN = 2,apply(euk,2,sd),'/')
```
```{r eval=FALSE, include=FALSE}
bac=sqrt(bac)
bac = sweep(bac,MARGIN = 2,colMeans(bac),'-')
bac = sweep(bac,MARGIN = 2,apply(bac,2,sd),'/')
```
```{r}
euk.dist=quasieuclid(vegdist(euk,method = "jaccard"))
euk.pco =dudi.pco(euk.dist,full = TRUE)
euk.pco.li = euk.pco$li
dim(euk.pco.li)
plot(euk.pco.li[,1:2],cex=0)
text(euk.pco.li[,1:2],labels = rownames(euk.pco.li),cex=0.6)
```
```{r}
bac.dist=quasieuclid(vegdist(bac,method = "jaccard"))
bac.pco =dudi.pco(bac.dist,full = TRUE)
bac.pco.li = bac.pco$li
dim(bac.pco.li)
plot(bac.pco.li[,1:2],cex=0)
text(bac.pco.li[,1:2],labels = rownames(bac.pco.li),cex=0.6)
```
```{r}
euk.sct = sum(euk.pco.li**2)
bac.sct = sum(bac.pco.li**2)
```
```{r}
x = procrustes(euk.pco.li,bac.pco.li,scale = TRUE)
```
```{r}
y = procrustes(bac.pco.li,euk.pco.li,scale = TRUE)
```
```{r}
SCR.E.B = sum((euk.pco.li-x$Yrot)^2)
SCT.E = sum((euk.pco.li- colMeans(euk.pco.li))^2)
SCR.E.B/SCT.E
```
```{r}
SCR.B.E = sum((bac.pco.li-y$Yrot)^2)
SCT.B = sum((bac.pco.li- colMeans(bac.pco.li))^2)
SCR.B.E/SCT.B
```
```{r}
x = procrustes(sweep(euk.pco.li,2,colMeans(euk.pco.li),"-"),
sweep(bac.pco.li,2,colMeans(bac.pco.li),"-"),scale = TRUE)
y = procrustes(sweep(bac.pco.li,2,colMeans(bac.pco.li),"-"),
sweep(euk.pco.li,2,colMeans(euk.pco.li),"-"),scale = TRUE)
x$scale
1/y$scale
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment