Skip to content

Instantly share code, notes, and snippets.

Avatar

Neil Saunders neilfws

View GitHub Profile
@neilfws
neilfws / welcome.md
Last active Nov 25, 2021
Stock first comment for new Stack Overflow [r] questions :)
View welcome.md

Welcome to Stack Overflow. We cannot read data into R from images. Please make this question reproducible by including a small representative dataset in a plain text format - for example the output from dput(yourdata), if that is not too large.

View ztable.Rmd
---
title: "ztable"
author: "Neil Saunders"
date: "19 March 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
View tweetcloud.R
# 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) %>%
View excelCols.R
# 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) {
@neilfws
neilfws / mappify.R
Created Aug 29, 2017
Mappify API in R example
View mappify.R
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")
@neilfws
neilfws / basic_rentrez.R
Last active Jun 30, 2017
The very basics of PubMed search using rentrez
View basic_rentrez.R
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]")
View statstests.R
# 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 / pmid2bibtex.rb
Last active Jul 5, 2017
BioRuby: convert a PubMed PMID to BibTeX citation format
View pmid2bibtex.rb
# 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
View gist:1dff7fceb641dba374db
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
View biopieces
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