Skip to content

Instantly share code, notes, and snippets.

View SimonGoring's full-sized avatar

Simon SimonGoring

View GitHub Profile
@SimonGoring
SimonGoring / sql_source.R
Created May 30, 2016 21:41
Script for the SQL commands used in DOI assignment.
# SQL queries:
default_call <- function(x) {
paste0("SELECT CONCAT(SiteName, ' ', DatasetType, ' dataset') AS SiteName,
'Title' AS titleType, ContactName AS creatorName, 'ORCID' AS nameIdentifierScheme,
'http://orcid.org' AS schemeURI, Address AS affiliation, YEAR(ds.RecDateCreated) as publicationyear
FROM (SELECT * FROM datasets WHERE DatasetID = ", x, ") AS ds INNER JOIN datasetpis ON ds.DatasetID = datasetpis.DatasetID
INNER JOIN collectionunits AS cu ON ds.CollectionUnitID = cu.CollectionUnitID INNER JOIN sites AS sts ON cu.SiteID = sts.SiteID
INNER JOIN datasettypes AS dst ON ds.DatasetTypeID = dst.DatasetTypeID INNER JOIN contacts ON datasetpis.ContactID = contacts.ContactID;")
}
We can't make this file beautiful and searchable because it's too large.
"AwardNumber","Title","NSFOrganization","Program.s.","StartDate","LastAmendmentDate","PrincipalInvestigator","State","Organization","AwardInstrument","ProgramManager","EndDate","AwardedAmountToDate","Co.PIName.s.","OrganizationStreet","OrganizationCity","OrganizationState","OrganizationZip","OrganizationPhone","NSFDirectorate","ProgramElementCode.s.","ProgramReferenceCode.s.","ARRAAmount","Abstract"
1440066,"EarthCube RCN: An EarthCube Oceanography and Geobiology Environmental Omics Research Coordination Network (ECOGEO RCN)","ICER","EarthCube","9/1/2014","8/17/2015","Edward DeLong","HI","University of Hawaii","Standard Grant","Eva E. Zanzerkia","2/28/2017","$359,995.00 ","","2440 Campus Road, Box 368","HONOLULU","HI",968222234,8089567800,"GEO","8074","7433, 9150, OTHR, 0000","$0.00 ","The network elements of the ECOGEO RCN reach across diverse communities of ocean scientists, geoscientists, computer scientists and bioinformaticians, and will forge new cross-disciplinary connections. Although the scientific g
@SimonGoring
SimonGoring / Description.md
Created August 16, 2016 05:29
Making responsive webforms for Neotoma

Bryan McBride had a really useful gist posted that helped link a Google Form to a GitHub repository. For Neotoma we have a number of associated tools and products and we'd like to be able to track feature requests and bug reports more centrally. To do this I decided to link a Google Form to our related GitHub repositories.

The form itself is found here.

To actually link the form to the repositories requires a bit of work. The use of the Google Apps Script Editor was pretty new to me, but it's fairly straightforward, especially given the fairly clear instructions provided on Bryan's gist.

I got a GitHub personal access token at the repo level and plugged that into the top of the script.

Some of this is a bit messy.

@SimonGoring
SimonGoring / simple_data_exploration.R
Created August 29, 2016 23:45
Simple paleo-data visualization in R, linking the `rioja`, `neotoma` and `dplyr` packages.
library("neotoma", "rioja", "dplyr")
site <- get_site(sitename = "Carp Lake") %>% get_download %>% compile_taxa("P25")
par(mar = c(5, 7, 2, 4))
inkspot(counts(site[[1]]), site[[1]]$sample.meta$age, x.axis = "gradient", cex.axis = 0.6)
@SimonGoring
SimonGoring / simple_data_exploration.R
Created August 29, 2016 23:45
Simple paleo-data visualization in R, linking the `rioja`, `neotoma` and `dplyr` packages.
library("neotoma", "rioja", "dplyr")
site <- get_site(sitename = "Carp Lake") %>% get_download %>% compile_taxa("P25")
par(mar = c(5, 7, 2, 4))
inkspot(counts(site[[1]]), site[[1]]$sample.meta$age, x.axis = "gradient", cex.axis = 0.6)
@SimonGoring
SimonGoring / match_neotoma_taxa.R
Created October 1, 2016 18:06
Matching Neotoma taxa
# Coding to obtain a long list of fully resolved taxonomies for taxa in the Netoma Paleoecological Database.
# This work is to support (generally) export to other databases, allowing researchers to match at multiple
# levels, and across resources, providing a clear and unambiguous reference for taxonomies within Neotoma.
# Coded by: Simon Goring
# Neotoma Paleoecological Database: http://neotomadb.org
library(neotoma)
library(taxize)
neotoma_taxa <- neotoma::get_table("taxa")
@SimonGoring
SimonGoring / find_elevations.R
Created October 19, 2016 19:46
Get all site elevations for pollen records in the United States
library(neotoma)
all_ds <- get_dataset(datasettype = "pollen", gpid = "United States")
as_sites <- get_site(all_ds)
site_elevations <- as_sites$elev
# It's also within the datasets:
site_elevations <- sapply(all_ds, function(x)x$site.data$elev)
@SimonGoring
SimonGoring / multiInst_cypher
Created February 11, 2017 00:45
Every person associated with multiple institutions in the NSF database
MATCH (n:person)-[r:employed_by]->(:institution)
WITH n, count(r) AS count
WHERE count > 1
MATCH (n)-[r:employed_by]->(m:institution)
RETURN n,r,m;
@SimonGoring
SimonGoring / getSampleAges.R
Created February 17, 2017 22:44
Sample ages from Goring et al PLSS data
library(rgdal)
library(raster)
readOGR('../../data/input/shapes/')
base.rast <- raster(xmn = -71000, xmx = 2297000, ncols = 296,
ymn = 58000, ymx = 1498000, nrows = 180,
crs = '+init=epsg:3175')
used.data <- readOGR('../../data/output//aggregated_midwest//minn.wisc.mich.clean_v1_8.shp',
@SimonGoring
SimonGoring / diagnostic-report.txt
Created April 2, 2017 05:57
RStudio Diagnostic report
[1] "1.0.136"
$R
[1] "/usr/bin/R"
$pdflatex
[1] ""
$bibtex
[1] ""