Skip to content

Instantly share code, notes, and snippets.

@jhpoelen
jhpoelen / interactions.csv
Created February 7, 2014 20:46
my great dataset
predator name prey name
Homo sapiens Canis familiaris
@jhpoelen
jhpoelen / Home.adoc
Last active February 22, 2019 13:35
Global Biotic Interactions - Getting Started with Cypher Queries

What do great white sharks (Carcharodon carcharias) eat?

Global Biotic Interactions (GloBI, http://globalbioticinteractions.org) uses neo4j to capture recorded interactions between living organisms on our planet. This page give an introduction into how the interactions are currently captured and how to make queries to retrieve specific information.

This page not only serves as a getting started guide, but also as a way to solicit feedback on the way the data is modeled. So . . . please don’t hesitate to share comments or ask questions.

@jhpoelen
jhpoelen / createDistributionMap.R
Last active August 29, 2015 14:10
Generate Global Biotic Interaction Distribution Maps
# see Jorrit H. Poelen, James D. Simons and Chris J. Mungall. (2014). Global Biotic Interactions: An open infrastructure to share and
# analyze species-interaction datasets. Ecological Informatics. http://dx.doi.org/10.1016/j.ecoinf.2014.08.005
# rasterize locations, retrieve stats for bounding boxes, plot graphs
if (!'package:raster' %in% search()) {
install.packages(c('raster','maps'), repos='http://cran.us.r-project.org')
library('raster')
library('maps')
}
@jhpoelen
jhpoelen / interactMap.geojson
Created January 20, 2015 17:50
interaction map
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhpoelen
jhpoelen / gbif_globi_example.R
Last active August 29, 2015 14:20
Example of how to use GBIF to generate a species list for a specific are and use GloBI to retrieve interactions for those species. Please refer to http://ropensci.org to learn more about the packages.
# install rgbif and rglobi libraries (see http://ropensci.org for more info)
install.packages(c('rgbif', 'rglobi'))
# define geometric bounding box (around california)
geo1 <- "POLYGON((-126 32, -114 32, -114 41, -126 41, -126 32))"
# retrieve a bunch of occurrences of Mustelidae with the geometric area
mustelidaeOcc <- rgbif::occ_search(scientificName='Mustelidae', fields='minimal', geometry = geo1)$data
# get any interactions records involving unique taxa occurrences at bbox geo1
#install rglobi (see ropensci.org for more info)
install.packages(c('rglobi'))
# read species list after exporting as csv
krak <- read.csv(file='Krak_list_DELETE.csv', stringsAsFactors=F)
# pick unique families
taxonList <- unique(krak$Family)
# find and aggregate interactions for each species . . . one by one
interactions <- Reduce(function(accum, taxon) {
@jhpoelen
jhpoelen / filter.json
Last active August 29, 2015 14:23
GBIF download script - requests archive that includes all of GBIF spatial records without (spatial) issues.
{
"creator":"jhpoelen",
"notification_address": ["jhpoelen+gbif@gmail.com"],
"predicate":
{
"type":"and",
"predicates": [
{"type":"equals","key":"HAS_GEOSPATIAL_ISSUE","value":"false"},
{"type":"equals","key":"HAS_COORDINATE","value":"true"}
]
@jhpoelen
jhpoelen / McLarenFoodWeb.R
Created February 16, 2016 22:18
McLaren Park Observations and Interactions
# retrieve trophic interactions related to species
# that were recorded at or near McLaren Park
# using GloBI and GBIF
install.packages(c('rglobi', 'rgbif'))
mcLarenWKT <- 'POLYGON((-122.435 37.726,-122.406 37.726, -122.406 37.710, -122.435 37.710, -122.435 37.726))'
mcLarenObs <- rgbif::occ_search(geometry= mcLarenWKT)
gbifSpeciesKeys <- na.omit(unique(mcLarenObs$data$speciesKey))
@jhpoelen
jhpoelen / .block
Last active March 1, 2016 01:10 — forked from mbostock/.block
Phoibos2 Specimen Identifier Graph (small)
license: gpl-3.0
@jhpoelen
jhpoelen / .block
Last active March 1, 2016 02:03
Phoibos2 Specimen Identifier Graph (manual only)
license: gpl-3.0