1 Download network data
This web interface provides a visualization of where data of a given network have been collected over the globe.
Clicking the the dot corresponding to a network, the relative metadata can be visualized both as 2D and 3D representation of the network.
The incidence matrix is also displayed and can be downloaded in different formats.
Networks are named according to the following convention
- interaction type: mutualistic (M) or antagonistic (A)
- network type: Plant-Ant (PAO), Plant-Epiphyte (PE), Pollination (PL), Seed Dispersal (SD), Food Webs (FW), Host-Parasite (HP), Host-Parasitoid (HPD), Plant-Herbivore (PH), Anemone-Fish (AF)
- id labeling a specific network.
1.1 Download one network
In a research projects it is often convenient to bypass the web interface and store data directly in a dataframe using a command line. This has several advantages in terms of efficiency and reproducibility of the analysis you are conducting. We will see how to do this in R
using the function fromJSON()
of the package jsonlite
, but similar commands can be run in python
or in other languages. To this aim, we have opened a few dedicated endpoints on the Application Programming Interface (API) of the web-of-life project.
Let us focus on the network number 002 of the Seed Dispersal type, named M_SD_002: the set of commands to download it are
# define the base url
<- "https://www.web-of-life.es/"
base_url # define the full url associated with the endpoint that download networks interactions
<- paste0(base_url,"get_networks.php?network_name=M_SD_002")
json_url # import the jsonlite package (if not done at the beginning)
library(rjson)
# and run it
<- jsonlite::fromJSON(json_url) SD_002_nw
It is good practice to have a look at the class of a newly defined object (dataframe) and display its first rows to understand how this data looks like, number of columns, their names, etc.
# check the class
class(SD_002_nw)
## [1] "data.frame"
# have a look at the dataframe
head(SD_002_nw)
## network_name species1 species2
## 1 M_SD_002 Manucodia keraudrenii Cissus hypoglauca
## 2 M_SD_002 Manucodia keraudrenii Ficus gul
## 3 M_SD_002 Manucodia keraudrenii Ficus odoardi
## 4 M_SD_002 Manucodia keraudrenii Chisocheton sp1 M_SD_002
## 5 M_SD_002 Manucodia keraudrenii Dysoxylum sp1 M_SD_002
## 6 M_SD_002 Manucodia keraudrenii Elmerrillia sp1 M_SD_002
## connection_strength
## 1 13
## 2 155
## 3 55
## 4 7
## 5 1
## 6 8
The content of a dataframe can be visualized more nicely using the package formattable
# import the formattable package (if not done at the beginning)
library(formattable)
# visualize the dataframe in nicer way
formattable(head(SD_002_nw)) # visualize the dataframe in a nicer way
network_name | species1 | species2 | connection_strength |
---|---|---|---|
M_SD_002 | Manucodia keraudrenii | Cissus hypoglauca | 13 |
M_SD_002 | Manucodia keraudrenii | Ficus gul | 155 |
M_SD_002 | Manucodia keraudrenii | Ficus odoardi | 55 |
M_SD_002 | Manucodia keraudrenii | Chisocheton sp1 M_SD_002 | 7 |
M_SD_002 | Manucodia keraudrenii | Dysoxylum sp1 M_SD_002 | 1 |
M_SD_002 | Manucodia keraudrenii | Elmerrillia sp1 M_SD_002 | 8 |
# formattable(SD_002_nw) # to see all the rows
1.2 Download multiple networks
If you hit the endpoint https://www.web-of-life.es/get_networks.php
without passing any argument into the url, all the networks available in the database are returned, namely a dataframe with columns
network_name, species1, species2, connection_strength:
<- paste0(base_url,"get_networks.php")
json_url <- jsonlite::fromJSON(json_url)
all_nws
# show results
formattable(head(all_nws))
network_name | species1 | species2 | connection_strength |
---|---|---|---|
M_PL_001 | Centris cineraria | Phacelia secunda | 1 |
M_PL_001 | Centris cineraria | Senecio bustillosianus | 1 |
M_PL_001 | Centris cineraria | Stachys albi | 1 |
M_PL_001 | Centris cineraria | Adesmia conferta | 1 |
M_PL_001 | Centris cineraria | Astragalus curvicaulis | 1 |
M_PL_001 | Centris cineraria | Adesmia radicifolia | 1 |
You can list and count all the distinct networks you have downloaded using the function distinct()
of the dplyr package for data manipulation:
# import the dplyr package (if not done at the beginning)
library(dplyr)
<- distinct(all_nws, network_name)
all_nw_names
# show results
formattable(head(all_nws))
network_name | species1 | species2 | connection_strength |
---|---|---|---|
M_PL_001 | Centris cineraria | Phacelia secunda | 1 |
M_PL_001 | Centris cineraria | Senecio bustillosianus | 1 |
M_PL_001 | Centris cineraria | Stachys albi | 1 |
M_PL_001 | Centris cineraria | Adesmia conferta | 1 |
M_PL_001 | Centris cineraria | Astragalus curvicaulis | 1 |
M_PL_001 | Centris cineraria | Adesmia radicifolia | 1 |
Another useful functionality provided by the dplyr package is the pipe operator %>%
which allows passing the output of a function to another one. For instance,
formattable(head(all_nws))
# is equivalent to
head(all_nws) %>% formattable()
Networks can be filtered by interaction type passing this as an argument in the url. Accepted values of the parameter interaction_type
are:
* Anemone-Fish
* FoodWebs
* Host-Parasite
* Plant-Ant
* Plant-Herbivore
* Pollination
* SeedDispersal
* [default ALL]
Here the example for pollination networks:
<- paste0(base_url,"get_networks.php?interaction_type=Pollination")
json_url <- jsonlite::fromJSON(json_url) pol_nws
Networks can also be filtered by data type setting the parameter data_type
equals to weighted or binary [default ALL]. To download weighted, pollination networks you can run the command:
<- paste0(base_url,"get_networks.php?interaction_type=Pollination&data_type=weighted")
json_url <- jsonlite::fromJSON(json_url) pol_weighted_nws
1.3 Download network metadata
You can obtain a csv file containing the information about species in a given network hitting the endpoint https://www.web-of-life.es/get_species_info.php
and passing the network name into the url, namely
# define the base url
<- "https://www.web-of-life.es/"
base_url # download dataframe
<- read.csv(paste0(base_url,"get_species_info.php?network_name=M_PL_073"))
M_PL_073_info # show results
head(M_PL_073_info) # %>% formattable()
## species abundance role is.resource taxonomic.resolution
## 1 Calystegia sepium 4 Plant 1 Species
## 2 Lapsana communis 17 Plant 1 Species
## 3 Polygonum amphibium 10 Plant 1 Species
## 4 Apocynum cannabinum 10 Plant 1 Species
## 5 Asclepias syriaca 58 Plant 1 Species
## 6 Cephalanthus occidentalis 79 Plant 1 Species
## kingdom order family
## 1 Plants Solanales Convolvulaceae
## 2 Plants Asterales Asteraceae
## 3 Plants Caryophyllales Polygonaceae
## 4 Plants Gentianales Apocynaceae
## 5 Plants Gentianales Apocynaceae
## 6 Plants Gentianales Rubiaceae
You can obtain a csv file with the metadata of all the networks hitting the endpoint
https://www.web-of-life.es/get_network_info.php
:
<- read.csv(paste0(base_url,"get_network_info.php"))
all_nw_info
# see what information is provided
colnames(all_nw_info)
## [1] "network_name" "network_type"
## [3] "author" "reference"
## [5] "number_components" "is_weighted"
## [7] "cell_values_description" "abundance_description"
## [9] "location" "location_address"
## [11] "country" "latitude"
## [13] "longitude"
# select only some specific columns
<- select(all_nw_info, network_name, location, latitude, longitude)
my_nw_info
head(my_nw_info) %>% formattable()
network_name | location | latitude | longitude |
---|---|---|---|
M_PL_027 | Arthur’s Pass, New Zealand | -42.95000 | 171.566667 |
M_PL_021 | Ashu, Kyoto, Japan | 35.33333 | 135.750000 |
M_PL_017 | Bristol, England | 51.57499 | -2.589902 |
M_PL_032 | Brownfield, Illinois, USA | 40.13333 | -88.166667 |
M_SD_003 | Caguana, Puerto Rico | 18.29694 | -66.781944 |
M_SD_015 | Campeche state, Mexico | 18.50698 | -89.486184 |
For completeness, we mention that passing the initial part of a network name into the url you can obtain the metadata for networks whose name starts, e.g., with M_PL_072
<- read.csv(paste0(base_url,"get_network_info.php?network_name=M_PL_072")) %>%
my_nws_info select(network_name, location, latitude,longitude)
# visualize data
%>% formattable() my_nws_info
network_name | location | latitude | longitude |
---|---|---|---|
M_PL_072 | Pampas, Argentina | -36.88333 | -63.03333 |
M_PL_072_01 | Amarante, Pampas, Argentina | -37.84202 | -58.35858 |
M_PL_072_02 | Cinco Cerros, Pampas, Argentina | -37.73904 | -58.23155 |
M_PL_072_03 | Difuntito, Pampas, Argentina | -37.75721 | -58.24848 |
M_PL_072_04 | Difuntos, Pampas, Argentina | -37.88535 | -57.84195 |
M_PL_072_05 | El Morro, Pampas, Argentina | -37.73848 | -58.43347 |
M_PL_072_06 | La Barrosa, Pampas, Argentina | -37.87348 | -58.26069 |
M_PL_072_07 | La Brava, Pampas, Argentina | -37.87288 | -57.99226 |
M_PL_072_08 | La Chata, Pampas, Argentina | -37.87547 | -58.38000 |
M_PL_072_09 | La Paja, Pampas, Argentina | -37.75336 | -58.28486 |
Example: networks in the tropical region
If you are interested in knowing which networks in Web of life have been collected in the tropical region, you can use function filter()
of the dplyr package for data manipulation:
tropical_nws_info <- my_nws_info %>% filter(.,between(latitude, -23.43647, 23.43647))