Some corrections on the lecture

This commit is contained in:
2019-11-03 13:12:58 -05:00
parent cf80ff9f6a
commit 050956c01b
7 changed files with 246 additions and 104 deletions

View File

@@ -7,5 +7,6 @@ export(H_spectrum)
export(exp_q)
export(log_q)
export(mode)
export(norm)
export(tag_bad_pcr)
importFrom(Rdpack,reprompt)

16
R/norme.R Normal file
View File

@@ -0,0 +1,16 @@
#' @export
norm <- function(data,l=2) {
no <- function(x,y) sum(abs(data[x,]-data[y,])^l)^(1/l)
n = nrow(data)
d = matrix(0,nrow = n,ncol = n)
for (i in 1:n)
for (j in i:n) {
d[i,j] <- no(i,j)
d[j,i] <- d[i,j]
}
rownames(d) = rownames(data)
colnames(d) = rownames(data)
as.dist(d)
}

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 408 KiB

139
index.Rmd
View File

@@ -28,6 +28,7 @@ opts_chunk$set(echo = FALSE,
# Summary
- The MetabarSchool Package
- What do the reading numbers per PCR mean?
- Rarefaction vs. relative frequencies
- alpha diversity metrics
@@ -35,6 +36,28 @@ opts_chunk$set(echo = FALSE,
- multidimentionnal analysis
- comparison between datasets
# The MetabarSchool Package
## Instaling the package
You need the *devtools* package
```{r eval=FALSE, echo=TRUE}
install.packages("devtools",dependencies = TRUE)
```
Then you can install *MetabarSchool*
```{r eval=FALSE, echo=TRUE}
devtools::install_git("https://git.metabarcoding.org/MetabarcodingSchool/biodiversity-metrics.git")
```
You will also need the *vegan* package
```{r eval=FALSE, echo=TRUE}
install.packages("vegan",dependencies = TRUE)
```
# The dataset
## The mock community {.flexbox .vcenter .smaller}
@@ -68,6 +91,8 @@ data("positive.samples")
## Loading data
```{r echo=TRUE}
library(MetabarSchool)
data("positive.count")
data("positive.samples")
data("positive.motus")
@@ -94,6 +119,8 @@ positive.count[1:5,1:5]
## Loading data
```{r echo=TRUE}
library(MetabarSchool)
data("positive.count")
data("positive.samples")
data("positive.motus")
@@ -119,6 +146,8 @@ head(positive.samples,n=3)
## Loading data
```{r echo=TRUE}
library(MetabarSchool)
data("positive.count")
data("positive.samples")
data("positive.motus")
@@ -169,7 +198,7 @@ positive.motus = positive.motus[are.not.singleton,]
$`r nrow(positive.count)` \; PCRs \; \times \; `r ncol(positive.count)` \; MOTUs$
matrix
## Not all the PCR have the number of reads {.flexbox .vcenter}
## Not all the PCR have the same number of reads {.flexbox .vcenter}
Despite all standardization efforts
@@ -240,13 +269,19 @@ positive.count.rarefied = rrarefy(positive.count,2000)
## Rarefying read count (2) {.flexbox .vcenter}
```{r fig.height=3}
```{r fig.height=4}
par(mfrow=c(1,2),bg=NA)
hist(log10(colSums(positive.count)+1),
main = "Not rarefied",
xlim = c(0,6),
ylim = c(0,2300),
breaks = 30,
xlab = TeX("$\\log_{10}(reads per MOTUs)$"))
hist(log10(colSums(positive.count.rarefied)+1),
main = "Rarefied data",
xlim = c(0,6),
ylim = c(0,2300),
breaks = 30,
xlab = TeX("$\\log_{10}(reads per MOTUs)$"))
```
@@ -325,11 +360,11 @@ knitr::include_graphics("figures/diversity.svg")
@Whittaker:10:00
<br><br><br><br>
- $\alpha-diversity$ : Mean diversity per site ($species/site$)
- $\alpha\text{-diversity}$ : Mean diversity per site ($species/site$)
- $\gamma-diversity$ : Regional biodiversity ($species/region$)
- $\gamma\text{-diversity}$ : Regional biodiversity ($species/region$)
- $\beta-diversity$ : $\beta = \frac{\gamma}{\alpha}$ ($site$)
- $\beta\text{-diversity}$ : $\beta = \frac{\gamma}{\alpha}$ ($sites/region$)
</div>
@@ -410,25 +445,19 @@ kable(data.frame(`Gini-Simpson`=GS),
kable_styling(position = "center")
```
## Shanon entropy {.smaller}
## Shannon entropy {.smaller}
<div style="float: left; width: 65%;">
Shanon entropy is based on information theory.
Shannon entropy is based on information theory:
Let $X$ be a uniformly distributed random variable with values in $A$
<center>
$H^{\prime }=-\sum _{i=1}^{S}p_{i}\log p_{i}$
</center>
$$
H(X) = \log|A|
$$
<br>
</div>
<div style="float: right; width: 35%;">
if $A$ is a community where every species are equally represented then
$$
H^{\prime }=-\sum _{i=1}^{S}p_{i}\log p_{i}
H(A) = \log|A|
$$
<br>
</div>
<center>
```{r out.width = "400px"}
@@ -441,7 +470,7 @@ H = - rowSums(environments * log(environments),na.rm = TRUE)
```
```{r}
kable(data.frame(`Shanon index`=H),
kable(data.frame(`Shannon index`=H),
format="html",
align = 'rr') %>%
kable_styling(position = "center")
@@ -452,12 +481,12 @@ kable(data.frame(`Shanon index`=H),
<div style="float: left; width: 50%;">
As :
$$
H(X) = \log|A| \;\Rightarrow\; ^1D = e^{H(X)}
H(A) = \log|A| \;\Rightarrow\; ^1D = e^{H(A)}
$$
<br>
</div>
<div style="float: right; width: 50%;">
where $^1D$ is the theoretical number of species in a evenly distributed community that would have the same Shanon's entropy than ours.
where $^1D$ is the theoretical number of species in a evenly distributed community that would have the same Shannon's entropy than ours.
</div>
<center>
@@ -548,10 +577,10 @@ exp_q = function(x,q=1) {
}
```
## Generalised Shanon entropy
## Generalised Shannon entropy
$$
^qH = - \sum_{i=1}^S pi \times ^q\log pi
^qH = - \sum_{i=1}^S p_i \; ^q\log p_i
$$
```{r echo=TRUE, eval=FALSE}
@@ -616,7 +645,7 @@ abline(v=c(0,1,2),lty=2,col=4:6)
- $^0H(X) = S - 1$ : the richness minus one.
- $^1H(X) = H^{\prime}$ : the Shanon's entropy.
- $^1H(X) = H^{\prime}$ : the Shannon's entropy.
- $^2H(X) = 1 - \lambda$ : Gini-Simpson's index.
@@ -1074,15 +1103,15 @@ BC_{jk}=\frac{\sum _{i=1}^{p}(N_{ij} - min(N_{ij},N_{ik}) + (N_{ik} - min(N_{ij}
$$
$$
BC_{jk}=\frac{\sum _{i=1}^{p}]N_{ij} - N_{ik}|}{\sum _{i=1}^{p}N_{ij}+\sum _{i=1}^{p}N_{ik}}
BC_{jk}=\frac{\sum _{i=1}^{p}|N_{ij} - N_{ik}|}{\sum _{i=1}^{p}N_{ij}+\sum _{i=1}^{p}N_{ik}}
$$
$$
BC_{jk}=\frac{\sum _{i=1}^{p}]N_{ij} - N_{ik}|}{1+1}
BC_{jk}=\frac{\sum _{i=1}^{p}|N_{ij} - N_{ik}|}{1+1}
$$
$$
BC_{jk}=\frac{1}{2}\sum _{i=1}^{p}]N_{ij} - N_{ik}|
BC_{jk}=\frac{1}{2}\sum _{i=1}^{p}|N_{ij} - N_{ik}|
$$
## Principale coordinate analysis (1) {.flexbox .vcenter}
@@ -1109,7 +1138,7 @@ plot(guiana.bc.pcoa$points[,1:2],
xlab="Axis 1",
ylab="Axis 2",
main = "Bray Curtis on Rel. Freqs")
plot(guiana.euc.pcoa$points[,1:2],
plot(guiana.euc.pcoa$points[,1],-guiana.euc.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
@@ -1123,7 +1152,7 @@ plot(guiana.jac.1.pcoa$points[,1:2],
xlab="Axis 1",
ylab="Axis 2",
main = "Jaccard on presence (0.1%)")
plot(guiana.jac.10.pcoa$points[,1:2],
plot(-guiana.jac.10.pcoa$points[,1],guiana.jac.10.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
@@ -1162,6 +1191,58 @@ plot(0,type='n',axes=FALSE,ann=FALSE)
legend("topleft",legend = levels(samples.type),fill = 1:4,cex=1.2)
```
<!---
## Computation of norms
```{r guiana_norm, echo=TRUE}
guiana.n1.dist = norm(guiana.relfreq.final,l=1)
guiana.n2.dist = norm(guiana.relfreq.final^(1/2),l=2)
guiana.n3.dist = norm(guiana.relfreq.final^(1/3),l=3)
guiana.n4.dist = norm(guiana.relfreq.final^(1/100),l=100)
```
## pCoA on norms
```{r dependson="guiana_norm"}
guiana.n1.pcoa = cmdscale(guiana.n1.dist,k=3,eig = TRUE)
guiana.n2.pcoa = cmdscale(guiana.n2.dist,k=3,eig = TRUE)
guiana.n3.pcoa = cmdscale(guiana.n3.dist,k=3,eig = TRUE)
guiana.n4.pcoa = cmdscale(guiana.n4.dist,k=3,eig = TRUE)
```
```{r}
par(mfrow=c(2,3),bg=NA)
plot(guiana.n1.pcoa$points[,1],guiana.n1.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
ylab="Axis 2",
main = "Norm 1 on Hellinger")
plot(guiana.n2.pcoa$points[,1],-guiana.n2.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
ylab="Axis 2",
main = "Norm 2 on Hellinger")
plot(0,type='n',axes=FALSE,ann=FALSE)
legend("topleft",legend = levels(samples.type),fill = 1:4,cex=1.2)
plot(-guiana.n3.pcoa$points[,1],-guiana.n3.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
ylab="Axis 2",
main = "Norm 3 on Hellinger")
plot(-guiana.n4.pcoa$points[,1],-guiana.n4.pcoa$points[,2],
col = samples.type,
asp = 1,
xlab="Axis 1",
ylab="Axis 2",
main = "Norm 4 on Hellinger")
```
--->
## Comparing diversity of the environments
```{r}

View File

@@ -4,7 +4,6 @@
<title>Biodiversity metrics and metabarcoding</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="generator" content="pandoc" />
@@ -82,6 +81,10 @@
transition: opacity 0.6s ease-in 0.4s;
opacity: 0;
}
/* https://github.com/ropensci/plotly/pull/524#issuecomment-468142578 */
slide:not(.current) .plotly.html-widget{
display: block;
}
</style>
@@ -106,14 +109,31 @@
<slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>Summary</h2></hgroup><article id="summary" class="smaller ">
<ul>
<li>The MetabarSchool Package</li>
<li>What do the reading numbers per PCR mean?</li>
<li>Rarefaction vs. relative frequencies</li>
<li>Rarefaction vs. relative frequencies</li>
<li>alpha diversity metrics</li>
<li>beta diversity metrics</li>
<li>multidimentionnal analysis</li>
<li>comparison between datasets</li>
</ul>
</article></slide><slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>The MetabarSchool Package</h2></hgroup><article id="the-metabarschool-package" class="smaller ">
</article></slide><slide class=""><hgroup><h2>Instaling the package</h2></hgroup><article id="instaling-the-package" class="smaller ">
<p>You need the <em>devtools</em> package</p>
<pre class = 'prettyprint lang-r'>install.packages(&quot;devtools&quot;,dependencies = TRUE)</pre>
<p>Then you can install <em>MetabarSchool</em></p>
<pre class = 'prettyprint lang-r'>devtools::install_git(&quot;https://git.metabarcoding.org/MetabarcodingSchool/biodiversity-metrics.git&quot;)</pre>
<p>You will also need the <em>vegan</em> package</p>
<pre class = 'prettyprint lang-r'>install.packages(&quot;vegan&quot;,dependencies = TRUE)</pre>
</article></slide><slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>The dataset</h2></hgroup><article id="the-dataset" class="smaller ">
</article></slide><slide class=""><hgroup><h2>The mock community</h2></hgroup><article id="the-mock-community" class="smaller flexbox vcenter smaller">
@@ -609,14 +629,19 @@ Lotus corniculatus
</article></slide><slide class=""><hgroup><h2>The experiment</h2></hgroup><article id="the-experiment" class="smaller flexbox vcenter">
<ul>
<li><p>192 PCR of the mock community using SPER02 trnL-P6-Loop primers</p></li>
<li><p>192 PCR of the mock community using SPER02 trnL-P6-Loop primers</p>
<ul>
<li><p>6 dilutions of the mock community: 1/1, 1/2, 1/4, 1/8, 1/16, 1/32</p></li>
<li><p>32 repeats per dilution</p></li>
</ul></li>
</ul>
</article></slide><slide class=""><hgroup><h2>Loading data</h2></hgroup><article id="loading-data" class="smaller ">
<pre class = 'prettyprint lang-r'>data(&quot;positive.count&quot;)
<pre class = 'prettyprint lang-r'>library(MetabarSchool)
data(&quot;positive.count&quot;)
data(&quot;positive.samples&quot;)
data(&quot;positive.motus&quot;)</pre>
@@ -880,7 +905,9 @@ sample.TM_POS_d16_2_a_A1
</article></slide><slide class=""><hgroup><h2>Loading data</h2></hgroup><article id="loading-data-1" class="smaller ">
<pre class = 'prettyprint lang-r'>data(&quot;positive.count&quot;)
<pre class = 'prettyprint lang-r'>library(MetabarSchool)
data(&quot;positive.count&quot;)
data(&quot;positive.samples&quot;)
data(&quot;positive.motus&quot;)</pre>
@@ -992,7 +1019,9 @@ sample.TM_POS_d16_1_b_A2
</article></slide><slide class=""><hgroup><h2>Loading data</h2></hgroup><article id="loading-data-2" class="smaller ">
<pre class = 'prettyprint lang-r'>data(&quot;positive.count&quot;)
<pre class = 'prettyprint lang-r'>library(MetabarSchool)
data(&quot;positive.count&quot;)
data(&quot;positive.samples&quot;)
data(&quot;positive.motus&quot;)</pre>
@@ -1212,11 +1241,11 @@ positive.motus = positive.motus[are.not.singleton,]</pre>
<li><code>positive.count</code> is now a \(192 \; PCRs \; \times \; 5579 \; MOTUs\) matrix</li>
</ul>
</article></slide><slide class=""><hgroup><h2>Not all the PCR have the number of reads</h2></hgroup><article id="not-all-the-pcr-have-the-number-of-reads" class="smaller flexbox vcenter">
</article></slide><slide class=""><hgroup><h2>Not all the PCR have the same number of reads</h2></hgroup><article id="not-all-the-pcr-have-the-same-number-of-reads" class="smaller flexbox vcenter">
<p>Despite all standardization efforts</p>
<p><img src="index_files/figure-html/unnamed-chunk-15-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-18-1.png" width="720" /></p>
<div class="green">
<p>Is it related to the amount of DNA in the extract ?</p></div>
@@ -1227,7 +1256,7 @@ positive.motus = positive.motus[are.not.singleton,]</pre>
boxplot(rowSums(positive.count) ~ positive.samples$dilution,log=&quot;y&quot;)
abline(h = median(rowSums(positive.count)),lw=2,col=&quot;red&quot;,lty=2)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-16-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-19-1.png" width="720" /></p>
<div class="red2">
<center>
@@ -1268,7 +1297,7 @@ Only 7.4% of the PCR read count variation is explain by dilution
</article></slide><slide class=""><hgroup><h2>Rarefying read count (2)</h2></hgroup><article id="rarefying-read-count-2" class="smaller flexbox vcenter">
<p><img src="index_files/figure-html/unnamed-chunk-21-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-24-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Rarefying read count (3)</h2></hgroup><article id="rarefying-read-count-3" class="smaller flexbox vcenter">
@@ -1284,16 +1313,16 @@ are.still.present[1:5]</pre>
<pre >## are.still.present
## FALSE TRUE
## 1942 3637</pre>
## 1886 3693</pre>
</article></slide><slide class=""><hgroup><h2>Rarefying read count (4)</h2></hgroup><article id="rarefying-read-count-4" class="smaller flexbox vcenter">
<pre class = 'prettyprint lang-r'>par(bg=NA)
boxplot(colSums(positive.count) ~ are.still.present, log=&quot;y&quot;)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-24-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-27-1.png" width="720" /></p>
<p>The MOTUs removed by rarefaction were at most occurring 21 times</p>
<p>The MOTUs removed by rarefaction were at most occurring 13 times</p>
<p>The MOTUs kept by rarefaction were at least occurring 2 times</p>
@@ -1306,7 +1335,7 @@ positive.motus.rare = positive.motus[are.still.present,]</pre>
<center>
positive.motus.rare is now a \(192 \; PCRs \; \times \; 3637 \; MOTUs\)
positive.motus.rare is now a \(192 \; PCRs \; \times \; 3693 \; MOTUs\)
</center>
@@ -1340,9 +1369,9 @@ positive.motus.rare is now a \(192 \; PCRs \; \times \; 3637 \; MOTUs\)
<p><br><br> <span class="cite">Whittaker (2010)</span> <br><br><br><br></p>
<ul>
<li><p>\(\alpha-diversity\) : Mean diversity per site (\(species/site\))</p></li>
<li><p>\(\gamma-diversity\) : Regional biodiversity (\(species/region\))</p></li>
<li><p>\(\beta-diversity\) : \(\beta = \frac{\gamma}{\alpha}\) (\(site\))</p></li>
<li><p>\(\alpha\text{-diversity}\) : Mean diversity per site (\(species/site\))</p></li>
<li><p>\(\gamma\text{-diversity}\) : Regional biodiversity (\(species/region\))</p></li>
<li><p>\(\beta\text{-diversity}\) : \(\beta = \frac{\gamma}{\alpha}\) (\(sites/region\))</p></li>
</ul></div>
</article></slide><slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>\(\alpha\)-diversity</h2></hgroup><article id="alpha-diversity" class="smaller ">
@@ -1583,10 +1612,10 @@ Environment.2
</table>
</article></slide><slide class=""><hgroup><h2>Gini-Simpson&#39;s index</h2></hgroup><article id="gini-simpsons-index" class="smaller smaller">
</article></slide><slide class=""><hgroup><h2>Gini-Simpsons index</h2></hgroup><article id="gini-simpsons-index" class="smaller smaller">
<div style="float: left; width: 60%;">
<p>The Simpson&#39;s index is the probability of having the same species twice when you randomly select two specimens. <br> <br></p></div>
<p>The Simpsons index is the probability of having the same species twice when you randomly select two specimens. <br> <br></p></div>
<div style="float: right; width: 40%;">
<p>\[
@@ -1597,7 +1626,7 @@ Environment.2
<p>\(\lambda\) decrease when complexity of your ecosystem increase.</p>
<p>Gini-Simpson&#39;s index defined as \(1-\lambda\) increase with diversity</p>
<p>Gini-Simpsons index defined as \(1-\lambda\) increase with diversity</p>
<p><img src="figures/alpha_diversity.svg" width="250px" /></p>
@@ -1663,24 +1692,20 @@ Environment.2
</table>
</article></slide><slide class=""><hgroup><h2>Shanon entropy</h2></hgroup><article id="shanon-entropy" class="smaller smaller">
</article></slide><slide class=""><hgroup><h2>Shannon entropy</h2></hgroup><article id="shannon-entropy" class="smaller smaller">
<div style="float: left; width: 65%;">
<p>Shanon entropy is based on information theory.</p>
<p>Shannon entropy is based on information theory:</p>
<p>Let \(X\) be a uniformly distributed random variable with values in \(A\)</p>
<center>
<p>\[
H(X) = \log|A|
\(H^{\prime }=-\sum _{i=1}^{S}p_{i}\log p_{i}\)
</center>
<p>if \(A\) is a community where every species are equally represented then \[
H(A) = \log|A|
\]</p>
<p><br></p></div>
<div style="float: right; width: 35%;">
<p>\[
H^{\prime }=-\sum _{i=1}^{S}p_{i}\log p_{i}
\] <br></p></div>
<center>
<img src="figures/alpha_diversity.svg" width="400px" />
@@ -1701,7 +1726,7 @@ H^{\prime }=-\sum _{i=1}^{S}p_{i}\log p_{i}
<th style="text-align:right;">
Shanon.index
Shannon.index
</th>
@@ -1747,15 +1772,15 @@ Environment.2
</table>
</article></slide><slide class=""><hgroup><h2>Hill&#39;s number</h2></hgroup><article id="hills-number" class="smaller smaller">
</article></slide><slide class=""><hgroup><h2>Hills number</h2></hgroup><article id="hills-number" class="smaller smaller">
<div style="float: left; width: 50%;">
<p>As : \[
H(X) = \log|A| \;\Rightarrow\; ^1D = e^{H(X)}
H(A) = \log|A| \;\Rightarrow\; ^1D = e^{H(A)}
\] <br></p></div>
<div style="float: right; width: 50%;">
<p>where \(^1D\) is the theoretical number of species in a evenly distributed community that would have the same Shanon&#39;s entropy than ours.</p></div>
<p>where \(^1D\) is the theoretical number of species in a evenly distributed community that would have the same Shannons entropy than ours.</p></div>
<center>
@@ -1851,7 +1876,7 @@ Environment.2
</article></slide><slide class=""><hgroup><h2>Impact of \(q\) on the <code>log_q</code> function</h2></hgroup><article id="impact-of-q-on-the-log_q-function" class="smaller ">
<p><img src="index_files/figure-html/unnamed-chunk-45-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-48-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>And its inverse function</h2></hgroup><article id="and-its-inverse-function" class="smaller flexbox vcenter">
@@ -1871,17 +1896,17 @@ Environment.2
(1 + (1-q)*x)^(1/(1-q))
}</pre>
</article></slide><slide class=""><hgroup><h2>Generalised Shanon entropy</h2></hgroup><article id="generalised-shanon-entropy" class="smaller ">
</article></slide><slide class=""><hgroup><h2>Generalised Shannon entropy</h2></hgroup><article id="generalised-shannon-entropy" class="smaller ">
<p>\[
^qH = - \sum_{i=1}^S pi \times ^q\log pi
^qH = - \sum_{i=1}^S p_i \; ^q\log p_i
\]</p>
<pre class = 'prettyprint lang-r'>H_q = function(x,q=1) {
sum(x * log_q(1/x,q),na.rm = TRUE)
}</pre>
<p>and generalized the previously presented Hill&#39;s number</p>
<p>and generalized the previously presented Hills number</p>
<p>\[
^qD=^qe^{^qH}
@@ -1908,22 +1933,22 @@ qs = seq(from=0,to=3,by=0.1)
environments.hq = apply(environments,MARGIN = 1,H_spectrum,q=qs)
environments.dq = apply(environments,MARGIN = 1,D_spectrum,q=qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-52-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-55-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Generalized entropy \(vs\) \(\alpha\)-diversity indices</h2></hgroup><article id="generalized-entropy-vs-alpha-diversity-indices" class="smaller ">
<ul>
<li><p>\(^0H(X) = S - 1\) : the richness minus one.</p></li>
<li><p>\(^1H(X) = H^{\prime}\) : the Shanon&#39;s entropy.</p></li>
<li><p>\(^2H(X) = 1 - \lambda\) : Gini-Simpson&#39;s index.</p></li>
<li><p>\(^1H(X) = H^{\prime}\) : the Shannons entropy.</p></li>
<li><p>\(^2H(X) = 1 - \lambda\) : Gini-Simpsons index.</p></li>
</ul>
<h3>When computing the exponential of entropy : Hill&#39;s number</h3>
<h3>When computing the exponential of entropy : Hills number</h3>
<ul>
<li><p>\(^0D(X) = S\) : The richness.</p></li>
<li><p>\(^1D(X) = e^{H^{\prime}}\) : The number of species in an even community having the same \(H^{\prime}\).</p></li>
<li><p>\(^2D(X) = 1 / \lambda\) : The number of species in an even community having the same Gini-Simpson&#39;s index.</p></li>
<li><p>\(^2D(X) = 1 / \lambda\) : The number of species in an even community having the same Gini-Simpsons index.</p></li>
</ul>
<br>
@@ -1941,7 +1966,7 @@ environments.dq = apply(environments,MARGIN = 1,D_spectrum,q=qs)</pre>
<pre class = 'prettyprint lang-r'>H.mock = H_spectrum(plants.16$dilution,qs)
D.mock = D_spectrum(plants.16$dilution,qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-54-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-57-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Biodiversity spectrum and metabarcoding (1)</h2></hgroup><article id="biodiversity-spectrum-and-metabarcoding-1" class="smaller smaller">
@@ -1950,11 +1975,11 @@ D.mock = D_spectrum(plants.16$dilution,qs)</pre>
FUN = H_spectrum,
q=qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-56-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-59-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Biodiversity spectrum and metabarcoding (2)</h2></hgroup><article id="biodiversity-spectrum-and-metabarcoding-2" class="smaller flexbox vcenter smaller">
<p><img src="index_files/figure-html/unnamed-chunk-57-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-60-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Biodiversity spectrum and metabarcoding (3)</h2></hgroup><article id="biodiversity-spectrum-and-metabarcoding-3" class="smaller smaller">
@@ -1963,7 +1988,7 @@ D.mock = D_spectrum(plants.16$dilution,qs)</pre>
FUN = D_spectrum,
q=qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-59-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-62-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Impact of data cleaning on \(\alpha\)-diversity (1)</h2></hgroup><article id="impact-of-data-cleaning-on-alpha-diversity-1" class="smaller ">
@@ -1999,7 +2024,7 @@ positive.clean.H = apply(positive.clean.count.relfreq,
FUN = H_spectrum,
q=qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-62-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-65-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Impact of data cleaning on \(\alpha\)-diversity (3)</h2></hgroup><article id="impact-of-data-cleaning-on-alpha-diversity-3" class="smaller ">
@@ -2008,7 +2033,7 @@ positive.clean.H = apply(positive.clean.count.relfreq,
FUN = D_spectrum,
q=qs)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-64-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-67-1.png" width="720" /></p>
</article></slide><slide class="segue dark nobackground level1"><hgroup class = 'auto-fadein'><h2>\(\beta\)-diversity</h2></hgroup><article id="beta-diversity" class="smaller ">
@@ -2102,7 +2127,7 @@ d_c =&amp; \max\limits_{1\leqslant i \leqslant n}\left|a_i - b_i\right| \\
\end{align}
\]</p>
</article></slide><slide class=""><hgroup><h2>For the fun&#8230; ;-)</h2></hgroup><article id="for-the-fun...--" class="smaller flexbox vcenter">
</article></slide><slide class=""><hgroup><h2>For the fun ;-)</h2></hgroup><article id="for-the-fun--" class="smaller flexbox vcenter">
<p>You can generalize those distances as a norm of order \(k\)</p>
@@ -2140,7 +2165,7 @@ d(x,z)\leq \max(d(x,y),d(y,z))
<li>A metric induce a metric space</li>
<li>In a metric space rotations are isometries</li>
<li>This means that rotations are not changing distances between objects</li>
<li>Multidimensional scaling (PCA, PCoA, CoA&#8230;) are rotations</li>
<li>Multidimensional scaling (PCA, PCoA, CoA) are rotations</li>
</ul>
</article></slide><slide class=""><hgroup><h2>The data set</h2></hgroup><article id="the-data-set" class="smaller flexbox vcenter">
@@ -2167,7 +2192,7 @@ data(&quot;guiana.samples&quot;)</pre>
<pre class = 'prettyprint lang-r'>s = tag_bad_pcr(guiana.samples$sample,guiana.count)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-69-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-72-1.png" width="720" /></p>
<pre class = 'prettyprint lang-r'>guiana.count.clean = guiana.count[s$keep,]
guiana.samples.clean = guiana.samples[s$keep,]</pre>
@@ -2182,7 +2207,7 @@ guiana.samples.clean = guiana.samples[s$keep,]</pre>
<pre class = 'prettyprint lang-r'>s = tag_bad_pcr(guiana.samples.clean$sample,guiana.count.clean)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-71-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-74-1.png" width="720" /></p>
<pre class = 'prettyprint lang-r'>guiana.count.clean = guiana.count.clean[s$keep,]
guiana.samples.clean = guiana.samples.clean[s$keep,]</pre>
@@ -2197,7 +2222,7 @@ guiana.samples.clean = guiana.samples.clean[s$keep,]</pre>
<pre class = 'prettyprint lang-r'>s = tag_bad_pcr(guiana.samples.clean$sample,guiana.count.clean)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-73-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-76-1.png" width="720" /></p>
<pre class = 'prettyprint lang-r'>guiana.count.clean = guiana.count.clean[s$keep,]
guiana.samples.clean = guiana.samples.clean[s$keep,]</pre>
@@ -2264,7 +2289,7 @@ xy = xy[,1:2]
xy.hellinger = decostand(xy,method = &quot;hellinger&quot;)</pre>
<div style="float: left; width: 50%;">
<p><img src="index_files/figure-html/unnamed-chunk-80-1.png" width="384" /></p></div>
<p><img src="index_files/figure-html/unnamed-chunk-83-1.png" width="384" /></p></div>
<div style="float: right; width: 50%;">
<p><img src="figures/euclidean_hellinger.svg" width="400px" /></p></div>
@@ -2284,15 +2309,15 @@ BC_{jk}=\frac{\sum _{i=1}^{p}(N_{ij} - min(N_{ij},N_{ik}) + (N_{ik} - min(N_{ij}
\]</p>
<p>\[
BC_{jk}=\frac{\sum _{i=1}^{p}]N_{ij} - N_{ik}|}{\sum _{i=1}^{p}N_{ij}+\sum _{i=1}^{p}N_{ik}}
BC_{jk}=\frac{\sum _{i=1}^{p}|N_{ij} - N_{ik}|}{\sum _{i=1}^{p}N_{ij}+\sum _{i=1}^{p}N_{ik}}
\]</p>
<p>\[
BC_{jk}=\frac{\sum _{i=1}^{p}]N_{ij} - N_{ik}|}{1+1}
BC_{jk}=\frac{\sum _{i=1}^{p}|N_{ij} - N_{ik}|}{1+1}
\]</p>
<p>\[
BC_{jk}=\frac{1}{2}\sum _{i=1}^{p}]N_{ij} - N_{ik}|
BC_{jk}=\frac{1}{2}\sum _{i=1}^{p}|N_{ij} - N_{ik}|
\]</p>
</article></slide><slide class=""><hgroup><h2>Principale coordinate analysis (1)</h2></hgroup><article id="principale-coordinate-analysis-1" class="smaller flexbox vcenter">
@@ -2305,17 +2330,36 @@ guiana.jac.50.pcoa = cmdscale(guiana.jac.50.dist,k=3,eig = TRUE)</pre>
</article></slide><slide class=""><hgroup><h2>Principale coordinate analysis (2)</h2></hgroup><article id="principale-coordinate-analysis-2" class="smaller ">
<p><img src="index_files/figure-html/unnamed-chunk-83-1.png" width="720" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-86-1.png" width="720" /></p>
</article></slide><slide class=""><hgroup><h2>Principale composante analysis</h2></hgroup><article id="principale-composante-analysis" class="smaller flexbox vcenter">
<pre class = 'prettyprint lang-r'>guiana.hellinger.pca = prcomp(guiana.hellinger.final,center = TRUE, scale. = FALSE)</pre>
<p><img src="index_files/figure-html/unnamed-chunk-85-1.png" width="1152" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-88-1.png" width="1152" /></p>
<!---
## Computation of norms
```r
guiana.n1.dist = norm(guiana.relfreq.final,l=1)
guiana.n2.dist = norm(guiana.relfreq.final^(1/2),l=2)
guiana.n3.dist = norm(guiana.relfreq.final^(1/3),l=3)
guiana.n4.dist = norm(guiana.relfreq.final^(1/100),l=100)
```
## pCoA on norms
<img src="index_files/figure-html/unnamed-chunk-90-1.png" width="720" />
--->
</article></slide><slide class=""><hgroup><h2>Comparing diversity of the environments</h2></hgroup><article id="comparing-diversity-of-the-environments" class="smaller ">
<p><img src="index_files/figure-html/unnamed-chunk-87-1.png" width="864" /></p>
<p><img src="index_files/figure-html/unnamed-chunk-92-1.png" width="864" /></p>
</article></slide><slide class=""><hgroup><h2>Bibliography</h2></hgroup><article id="bibliography" class="smaller unnumbered">