Skip to content

Instantly share code, notes, and snippets.

View neilfws's full-sized avatar

Neil Saunders neilfws

View GitHub Profile
@neilfws
neilfws / gantt.R
Created April 13, 2010 13:59
Gantt chart (per day) using ggplot2
library(ggplot2)
# read data file tasks.csv - it looks like this:
# task,date,start,end
# task1,2010-03-05,09:00:00,13:00:00
# task2,2010-03-06,10:00:00,15:00:00
# task3,2010-03-06,11:00:00,18:00:00
# task4,2010-03-07,08:00:00,11:00:00
# task5,2010-03-08,14:00:00,17:00:00
# task6,2010-03-09,12:00:00,16:00:00
@neilfws
neilfws / gxa-jsonp.haml
Created January 19, 2011 06:38
Corrected version of sample code from http://www.ebi.ac.uk/gxa/help/AtlasApis, using Haml
:javascript
function processData(data) {
if(data.error) {
alert(data.error);
return;
}
alert('Accession: ' + data.results[0].experimentInfo.accession + '\nDescription: ' +
data.results[0].experimentInfo.description);
}
Here are the names of the deb packages that you can *sudo apt-get install* on Ubuntu-like systems,
to install Perl dependencies for biopieces:
libmodule-build-perl
libbit-vector-perl
libsvg-perl
libterm-readkey-perl
libdbi-perl
libxml-parser-perl
libcarp-clan-perl
@neilfws
neilfws / gist:1dff7fceb641dba374db
Last active August 29, 2015 14:06
BioStars 111791
gse <- getGEO("GSE45016") # you want GSEMatrix = TRUE
# ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE45nnn/GSE45016/matrix/
# Found 1 file(s)
# GSE45016_series_matrix.txt.gz
# trying URL 'ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE45nnn/GSE45016/matrix/GSE45016_series_matrix.txt.gz'
# ftp data connection made, file length 1486394 bytes
# opened URL
# ==================================================
# downloaded 1.4 Mb
@neilfws
neilfws / pmid2bibtex.rb
Last active July 5, 2017 14:32
BioRuby: convert a PubMed PMID to BibTeX citation format
# pmid2bibtex.rb
# convert a PubMed PMID to BibTeX citation format
# updated version of http://chrisamiller.com/science/2010/12/13/using-bioruby-to-fetch-citations-from-pubmed/
# works as of 2015-03-18
require 'bio'
Bio::NCBI.default_email = "me@me.com" # required for EUtils
id = "18265351"
pm = Bio::PubMed::efetch(id) # array of MEDLINE-formatted string
# taken from http://sciencecases.lib.buffalo.edu/cs/files/mini_eco_stats.pdf
#
# NATIONAL CENTER FOR CASE STUDY TEACHING IN SCIENCE
# Mini Cases on Choosing Appropriate
# Statistical Tests for Ecological Data
# by
# Alyssa M. Gleichsner, Department of Biological Sciences
# Elizabeth A. Flaherty, Department of Forestry and Natural Resources
# Purdue University, West Lafayette, IN
# Instructions
@neilfws
neilfws / basic_rentrez.R
Last active June 30, 2017 04:49
The very basics of PubMed search using rentrez
library(rentrez)
# search for "epigenetics"
es <- entrez_search("pubmed", "epigenetics")
es$count
[1] 20759
# search for "epigenetics" published in 2014
# for all publications in 2014 just drop the "epigenetics"
es <- entrez_search("pubmed", "epigenetics 2014[dp]")
@neilfws
neilfws / mappify.R
Created August 29, 2017 06:39
Mappify API in R example
library(httr)
req <- POST("http://mappify.io/api/rpc/address/geocode/",
body = list(streetAddress = "252 Botany St",
suburb = "Sydney",
postCode = "2000",
state = "NSW"),
encode = "json")
res <- content(req, "parsed")
# taken from the fifer package
# https://github.com/dustinfife/fifer
excelCols <- function (n)
{
vec1 = LETTERS
if (n <= 26) {
res = vec1[seq_len(n)]
}
else if (n > 26 & n <= 702) {
# function to make the cloud
# assumes rtweet authentication configured as per documentation
make_tweetcloud <- function(user = "neilfws", tweets = 100) {
require(tidyverse)
require(tidytext)
require(rtweet)
require(wordcloud)
get_timeline(user, n = tweets, full_text = TRUE) %>%