How use genesysr to download passport data
Initially it is necessary to install and load the libraries or packages. In this example the Rstudio
IDE will be used.
# install packages
install.packages(c('genesysr','tidyverse'))
# load packages
library(genesysr) # Api conect to Genesys library(tidyverse) # maps and data tools
Then we must set the work environment (production or test) and login to Genesys for connect with api service.
# Setting up the working environment
setup_production() # Work in production
# login in Genesy
user_login() # Login
After login this message is displayed:
Once logged in, the system displays a message, confirming successful authentication.
To make the filters, we must know the information of the Multi-Crop Passport Descriptors (MCPD). In this example we will download information from the International Center of Tropical Agriculture (CIAT), selecting the genus Phaseolus with the biological status wild and weedy.
Filter data by CIAT (COL003), genus (), and biological status wild and weedy.
filter_1 <- get_accessions(mcpd_filter(INSTCODE = 'COL003',
GENUS = 'Phaseolus',
SAMPSTAT =c('100','110','120','200')))
Clean and editing names
filter_1_2 <- filter_1 |>
count(sampStat) |>
mutate(sampStat_2= c('Wild','Semi-natural/wild','Weedy'))
Creating a bar chart can significantly enhance the visualization of the downloaded data, making it easier to analyze and interpret.
ggplot(filter_1_2, aes(x = sampStat_2, y = n, fill = sampStat_2)) +
geom_bar(stat = 'identity') +
theme_bw() +
geom_text(aes(x=sampStat_2,y=n, label=n), vjust=-0.2) +
theme(legend.position = "none",
axis.title.x = element_blank(), axis.title.y = element_blank()) +
labs(title = expression(paste("Distribution of wild species of ", italic("Phaseolus"), " sp. in COL003")),
caption = 'Fuente: Genesys',
x = 'Longitude', y = 'Latitude') +
theme(legend.position = 'none', panel.background=element_rect(colour="black"))
The following example involves the International Maize and Wheat Improvement Center (CIMMYT) (MEX002). This example focuses on the search for the genus Zea, specifically the species mays and nicaraguensis, which include both wild types and inbred lines.
filter_3 <- get_accessions(mcpd_filter(INSTCODE = 'MEX002',
GENUS = 'Zea',
SPECIES = c('mays','nicaraguensis'),
SAMPSTAT = c('100','414')))
filter_3_2 <- filter_3 |> count(sampStat) |>
mutate(sampStat_2= c('Wild','Inbred line'))
ggplot(filter_3_2, aes(x = sampStat_2, y = n, fill = sampStat_2)) +
geom_bar(stat = 'identity') +
theme_bw() +
geom_text(aes(x=sampStat_2,y=n, label=n), vjust=-0.2) +
theme(legend.position = "none",
axis.title.x = element_blank(),
axis.title.y = element_blank()) +
labs(title = 'Distribution of wild and Inbred line of Z. mays \n and Z. nicaraguensis in MEX002',
caption = 'Data from Genesys')
The leaflet
R library allows us to create dynamic, interactive maps, making it easy to visualize the locations of various accessions.
install.packages('leaflet')
library(leaflet)
leaflet() |>
addProviderTiles("Esri.WorldImagery") |>
addCircles(data=filter_3,
lng=filter_3$longitude,
lat =filter_3$latitude,
color = 'purple')
Another example involves data from the International Center of Potato (PER001), where we filter for the genus Solanum and the species acaule and stoloniferum that are in a wild biological state. This is illustrated below.
filter_4 <- get_accessions(mcpd_filter(INSTCODE = 'PER001',
GENUS = 'Solanum',
SPECIES = c('acaule','stoloniferum'),
SAMPSTAT = '100'))
filter_4 |>
leaflet() |>
addProviderTiles("Esri.WorldImagery") |>
addCircles(data=filter_4,
lng=filter_4$longitude,
lat =filter_4$latitude,
color = 'red')
Enjoy the code!
We hope this example proves helpful.