Current state

Adding text to dore application

More ddore data
This commit is contained in:
Louis Lacoste 2023-08-08 17:25:28 +02:00
parent bd6a12b8df
commit 070d2f0655
163 changed files with 1076 additions and 808 deletions

View file

@ -0,0 +1,157 @@
# Application to \cite{doreRelativeEffectsAnthropogenic2021} data
\label{sec:application-to-dorerelativeeffectsanthropogenic2021-data}
```{r, setup, include=FALSE, warning=FALSE}
knitr::opts_chunk$set(echo = FALSE, dpi = 300)
```
```{r}
# import fix
if (getwd() == "/home/polarolouis/Nextcloud/Documents/APT/CEI/Stage Recherche Mathématiques/Depuis PC Portable/Stage MIA 2023/rapport-MIA-2023") {
path_to_add <- "Rcodes/real_data/"
} else {
path_to_add <- ""
}
```
```{r require_lib, echo = FALSE, include=FALSE, warning=FALSE}
require("tidyverse")
require("knitr")
require("colSBM")
require("ggplot2")
require("patchwork")
source(paste0(path_to_add, "temporary_plot.R"))
```
```{r better_collection_extraction, echo = FALSE, warning=FALSE}
extract_unlist_reorder <- function(clustering_data_path) {
clustering <- readRDS(clustering_data_path)
if (!is.list(clustering)) {
clustering <- list(clustering)
}
best_partition <- extract_best_bipartite_partition(clustering)
best_partition_unlist <- unlist(best_partition)
if (!is.list(best_partition_unlist)) {
best_partition_unlist <- list(best_partition_unlist)
}
size <- length(best_partition_unlist)
return(setNames(lapply(best_partition_unlist, function(collection) {
reorder_parameters(collection)
}), paste(rep("Collection", size), seq_len(size))))
}
```
```{r load data, echo = FALSE, include = FALSE, warning=FALSE}
# All results
iid_unlist <- extract_unlist_reorder(paste0(path_to_add, "data/dore_collection_clustering_nb_run1_iid_123networks_24-05-23-21:40:42.Rds"))
```
Here we apply the network clustering procedure (we refer to it as *netclustering*)
to the data from \cite{doreRelativeEffectsAnthropogenic2021}. These data are
plant-pollinator bipartite networks from differents areas and times.
In a second part we will use additional information for the networks to
try to identify the impact and correlations with the observed structures.
## Netclustering with the $iid\text{-}colBiSBM$ model
We obtained the more interpretable results with $iid\text{-}colBiSBM$ model.
This resulted in `r length(iid_unlist)` collections to partition the $M = 123$
networks.
```{r meso-plots, echo = FALSE, results='asis'}
#| fig.cap=sapply(seq_along(iid_unlist), function(idx) paste0("Collection N°", idx)),
##| fig.cap = "Structure of the collections in the partition and respective proportions of blocks",
##| fig.subcap = sapply(seq_along(iid_unlist), function(idx) paste0("Collection N°", idx)),
#| fig.asp = 0.5
meso_print <- function(unlisted_partition) {
for (idx in seq_along(unlisted_partition)) {
print(plot(unlisted_partition[[idx]], type = "meso", mixture = TRUE) + ggtitle(paste("Collection ", idx)))
cat("\\newline")
}
}
meso_print(iid_unlist)
```
In all the obtained collections the structure is the classical nested structure.
As this is a well-known structure for plant-pollinator data this tends to
indicate that we are not going in a wrong direction.
The \nth{3} collection consists of only one network, indicating that for this
model, the small76 network was really different of all the others.
One reason might be that it's the oldest network and maybe the data collection
protocol is different.
## Comparison with additional information
```{r supinfo, echo = FALSE}
supinfo <- readxl::read_xlsx(paste0(path_to_add, "data/supinfo.xlsx"), sheet = 2)
interaction_data <- read.table(file = paste0(path_to_add, "data/interaction-data.txt"), sep = "\t", header = TRUE)
seq_ids_network_aggreg <- unique(interaction_data$id_network_aggreg)
incidence_matrices <- readRDS(file = paste0(path_to_add, "data/dore-matrices.Rds"))
names_aggreg_networks <- names(incidence_matrices)
vectorClusteringNet <- numeric(nrow(supinfo))
for (k in 1:length(iid_unlist)) {
idclust <- match(iid_unlist[[k]]$net_id, names_aggreg_networks)
supinfoclust <- match(seq_ids_network_aggreg[idclust], supinfo$Idweb)
vectorClusteringNet[supinfoclust] <- k
}
```
Using supplementary information we obtain the following boxplots.
A
```{r boxplot-function, echo = FALSE}
supinfo_boxplot <- function(parameter, pretty_name) {
return(ggplot(supinfo) +
aes(
x = vectorClusteringNet, y = parameter,
fill = as.factor(vectorClusteringNet), group = as.factor(vectorClusteringNet)
) +
geom_boxplot() +
labs(
x = "Collection number", y = pretty_name,
fill = "Collection number"
))
}
```
```{r boxplots_annual_timespan, echo = FALSE}
#| fig.cap = "\\label{fig:boxplot-annual-time-span}Boxplot of annual time span in function of the collection number"
ggplot(supinfo) +
aes(x = vectorClusteringNet, y = Annual_time_span,
fill = as.factor(vectorClusteringNet), group = as.factor(vectorClusteringNet)) +
geom_boxplot() +
labs(
x = "Collection number", y = "Annual time span",
fill = "Collection number"
)
```
The annual time span is the number of days the sampling period lasted. So we can
thus see in figure \ref{fig:boxplot-annual-time-span} that collections 1 and 4 were
sampled for a larger period of time than collections 2 and 5.
This could explain observed differences in the structure detected : the
"checkerboard" appearance of the alpha matrices representations may represent
interactions that only occurs at a given period of time.
Thus the shorter time period doesn't capture such interactions.
```{r boxplot_rainfall, echo = FALSE}
#| fig.cap = "\\label{fig:boxplot-total-rainfall}Boxplot of total rainfall in function of the collection number"
supinfo_boxplot(supinfo$Tot_Rainfall_IPCC, "Total rainfall")
```
There seems to be the same trend for the total rainfall.
```{r boxplot_sampling_effort, echo = FALSE}
#| fig.cap = "\\label{fig:boxplot-sampling-effort}Boxplot of the sampling effort in function of the collection number"
supinfo_boxplot(supinfo$Sampling_effort, "Sampling effort")
```
The sampling effort seems to be quite higher for collection 5 and a little
higher for collection 2. And collection 1 and 4 have the inverse trend. The
dichotomy between collections 1,4 and 2,5 seems to still hold.

View file

@ -0,0 +1,80 @@
\hypertarget{application-to-data}{%
\section{\texorpdfstring{Application to
\cite{doreRelativeEffectsAnthropogenic2021}
data}{Application to data}}\label{application-to-data}}
\label{sec:application-to-dorerelativeeffectsanthropogenic2021-data}
Here we apply the network clustering procedure (we refer to it as
\emph{netclustering}) to the data from
\cite{doreRelativeEffectsAnthropogenic2021}. These data are
plant-pollinator bipartite networks from differents areas and times.
In a second part we will use additional information for the networks to
try to identify the impact and correlations with the observed
structures.
\hypertarget{netclustering-with-the-iidtext-colbisbm-model}{%
\subsection{\texorpdfstring{Netclustering with the
\(iid\text{-}colBiSBM\)
model}{Netclustering with the iid\textbackslash text\{-\}colBiSBM model}}\label{netclustering-with-the-iidtext-colbisbm-model}}
We obtained the more interpretable results with \(iid\text{-}colBiSBM\)
model. This resulted in 5 collections to partition the \(M = 123\)
networks.
\includegraphics{./img/22d3409f045c956ffc0773e508871c61db4ad1e9.png}\newline\includegraphics{./img/2859d1c94af6539cced6aee6ee6bf6d49498518d.png}\newline\includegraphics{./img/037bcbcbc85f8a9562f98706ad7766c4099516ef.png}\newline\includegraphics{./img/f730f05cb60a7cdc837102601660f03edd767a60.png}\newline\includegraphics{./img/90d21c2459f68c2a6bc6cce93f9f1e10c3f0fef5.png}\newline
In all the obtained collections the structure is the classical nested
structure. As this is a well-known structure for plant-pollinator data
this tends to indicate that we are not going in a wrong direction.
The \nth{3} collection consists of only one network, indicating that for
this model, the small76 network was really different of all the others.
One reason might be that it's the oldest network and maybe the data
collection protocol is different.
\hypertarget{comparison-with-additional-information}{%
\subsection{Comparison with additional
information}\label{comparison-with-additional-information}}
Using supplementary information we obtain the following boxplots.
A
\begin{figure}
\centering
\includegraphics{./img/de77b630fb66744d3a3ed68e45be765532d1eb0f.png}
\caption{\label{fig:boxplot-annual-time-span}Boxplot of annual time span
in function of the collection number}
\end{figure}
The annual time span is the number of days the sampling period lasted.
So we can thus see in figure \ref{fig:boxplot-annual-time-span} that
collections 1 and 4 were sampled for a larger period of time than
collections 2 and 5. This could explain observed differences in the
structure detected : the ``checkerboard'' appearance of the alpha
matrices representations may represent interactions that only occurs at
a given period of time. Thus the shorter time period doesn't capture
such interactions.
\begin{figure}
\centering
\includegraphics{./img/5bbc4b4b07c0e990a3ae2755165958ffbf517902.png}
\caption{\label{fig:boxplot-total-rainfall}Boxplot of total rainfall in
function of the collection number}
\end{figure}
There seems to be the same trend for the total rainfall.
\begin{figure}
\centering
\includegraphics{./img/c75a33aa046b6f1bbcff45268346c4ec39067917.png}
\caption{\label{fig:boxplot-sampling-effort}Boxplot of the sampling
effort in function of the collection number}
\end{figure}
The sampling effort seems to be quite higher for collection 5 and a
little higher for collection 2. And collection 1 and 4 have the inverse
trend. The dichotomy between collections 1,4 and 2,5 seems to still
hold.

View file

@ -1,2 +0,0 @@
# Application to \cite{doreRelativeEffectsAnthropogenic2021} data
\label{sec:application-to-dorerelativeeffectsanthropogenic2021-data}

View file

@ -1,6 +0,0 @@
\hypertarget{application-to-data}{%
\section{\texorpdfstring{Application to
\cite{doreRelativeEffectsAnthropogenic2021}
data}{Application to data}}\label{application-to-data}}
\label{sec:application-to-dorerelativeeffectsanthropogenic2021-data}

View file

@ -1,18 +1,5 @@
---
title: "Présentation de l'application de colSBM sur Doré et al. 2020"
output:
html_document:
toc: true
theme: united
pdf_document:
keep_tex: true
---
```{r, setup, include=FALSE, warning=FALSE}
knitr::opts_chunk$set(echo = FALSE)
options(knitr.table.format = function() {
if (knitr::is_latex_output()) "latex" else "pandoc"
})
```
```{r require_lib, echo = FALSE, include=FALSE, warning=FALSE}
@ -47,13 +34,13 @@ knit_print.latex <- function(x, ...) {
# Now, define a method as_latex for matrix
as_latex.matrix <- function(x, ...) {
as_latex(c(
"\\begin{bmatrix}",
"\\begin{pmatrix}",
paste(
t(x),
rep(c(rep("&", nrow(x) - 1), "\\\\"), ncol(x)),
collapse = ""
),
"\\end{bmatrix}"
"\\end{pmatrix}"
))
}
@ -82,10 +69,17 @@ extract_unlist_reorder <- function(clustering_data_path) {
meso_print <- function(unlisted_partition) {
for (idx in seq_along(unlisted_partition)) {
cat(paste("\n\n\n\nPour la collection", idx, "\n\n"))
cat(paste("\\subsubsection{Pour la collection", idx, "}"))
print(plot(unlisted_partition[[idx]], type = "meso", mixture = TRUE))
cat("\n\n")
print(knitr::kable(unlisted_partition[[idx]]$net_id, col.names = "Networks"))
cat("\\newline \\tiny")
print(knitr::kable(unlisted_partition[[idx]]$net_id,
col.names = "Networks",
format = "latex",
position = "!h",
booktabs = TRUE
))
cat("\\normalsize\\newline")
cat(knitr::knit_print(unlisted_partition[[idx]]$alpha))
}
}
@ -251,12 +245,17 @@ pi_unlist <- extract_unlist_reorder("data/dore_collection_clustering_nb_run1_pi_
pirho_unlist <- extract_unlist_reorder("data/dore_collection_clustering_nb_run1_pirho_123networks_26-05-23-19:22:55.Rds")
```
# Application to \cite{doreRelativeEffectsAnthropogenic2021} data
\label{sec:application-to-dorerelativeeffectsanthropogenic2021-data}
## Clustering avec le modèle iid
Avec le modèle *iid* nous obtenons les `r length(iid_unlist)` collections et
les structures suivantes:
## Clustering with model iid
With the *iid-colBiSBM* we obtain `r length(iid_unlist)` collections with the
following structures:
```{r iid_meso_plot, echo = FALSE, message=FALSE, results="asis", fig.cap=paste(names(iid_unlist), rep("- iid",length(iid_unlist))), warning=FALSE}
```{r iid_meso_plot, echo = FALSE, message=FALSE, results="asis", warning=FALSE}
#| fig.cap=paste(names(iid_unlist), rep("- iid",length(iid_unlist))),
#| fig.asp = 0.5,
#| dpi = 300
meso_print(iid_unlist)
```
@ -352,7 +351,7 @@ iid_taxonomy_long %>%
```
## Clustering avec le modèle pi
## Clustering with model pi
Avec le modèle *pi* nous obtenons les `r length(pi_unlist)` collections et
les structures suivantes:
@ -410,7 +409,7 @@ taxonomy_plot(
)
```
## Clustering avec le modèle rho
## Clustering with model rho
Avec le modèle *rho* nous obtenons les `r length(rho_unlist)` collections et
les structures suivantes:
@ -468,7 +467,7 @@ taxonomy_plot(
)
```
## Clustering avec le modèle pirho
## Clustering with model pirho
Avec le modèle *pirho* nous obtenons les `r length(pirho_unlist)` collections et
les structures suivantes:

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
figure/boxplots-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 97 KiB

BIN
figure/meso-plots-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
figure/meso-plots-10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
figure/meso-plots-11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
figure/meso-plots-12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
figure/meso-plots-13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
figure/meso-plots-14.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
figure/meso-plots-15.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
figure/meso-plots-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

BIN
figure/meso-plots-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
figure/meso-plots-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

BIN
figure/meso-plots-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

BIN
figure/meso-plots-6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
figure/meso-plots-7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

BIN
figure/meso-plots-8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
figure/meso-plots-9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Some files were not shown because too many files have changed in this diff Show more