Commit 83e80f12 authored by Nora Castaneda-Alvarez's avatar Nora Castaneda-Alvarez Committed by Matija Obreza

genesysr tutorial

parent 37211d91
......@@ -5,3 +5,4 @@
man
README.Rmd
cran-comments.md
inst/doc
......@@ -15,3 +15,6 @@ License: Apache License 2.0
RoxygenNote: 6.0.1
URL: https://gitlab.croptrust.org/genesys-pgr/genesysr
BugReports: https://gitlab.croptrust.org/genesys-pgr/genesysr/issues
Suggests: knitr,
rmarkdown
VignetteBuilder: knitr
---
title: "genesysr"
author: "Nora Castaneda & Matija Obreza"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Vignette Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Genesys data download
=====================
Genesys provides data primarily through the `fetch_accessions` function. Data download using **genesysr** is equivalent to downloading data from www.genesys-pgr.org, with the advantage that **genesysr** ensures reproducibility.
Filters to query Genesys are:
- `fetch_accessions(filters = list(taxonomy.genus = c('Musa')))` - Retrieve all accession data for genus *Musa*
- `fetch_accessions(list(institute.code = c('BEL084')))` - Retrieve all accession data for the Musa International Transit Center, Bioversity International
- `fetch_accessions(list(institute.code = c('BEL084','COL003')))` - Retrieve all accession data for the Musa International Transit Center, Bioversity International (BEL084) and the International Center for Tropical Agriculture (COL003)
And also by using [Multi-Crop Passport Descriptors (MCPD)](https://www.genesys-pgr.org/doc/0/basics#mcpd) definitions:
- `fetch_accessions(mcpd_filter(ORIGCTY = c("DEU", "SVN")))` - Retrieve data by country of origin (MCPD)
# Selecting columns for data download
Genesys fetches all accession data by data. One can reduce the amount of data fetched by selecting only the columns of interest:
- `fetch_accessions(list(taxonomy.genus = c('Musa')), selector = function(x) {list(id = x$id, acceNumb = x$acceNumb, instCode = x$institute$code)`- Fetch only **id**, **acceNumb** and **instCode** for *Musa* data.
# Processing fetched data
Fetched data is provided as a deeply nested list. To flatten such list, we recommend the following procedure:
```r
require(tidyverse)
musa.flatten <- lapply(musa$content, unlist) #looks good
musa.flatten <- musa.flatten %>% map_df(bind_rows)
```
Let's take a look of all the process:
## Load genesysr
```r
library(genesysr)
```
## Setup using credentials
```r
setup_sandbox()
user_login()
```
## Fetch data
```r
musa <- genesysr::fetch_accessions(list(taxonomy.genus = c('Musa')))
```
## Flatten data into data frame
```r
require(tidyverse)
musa.flatten <- lapply(musa$content, unlist) #looks good
musa.flatten <- musa.flatten %>% map_df(bind_rows)
```
\ No newline at end of file
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