Skip to content

Instantly share code, notes, and snippets.

View neilfws's full-sized avatar

Neil Saunders neilfws

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

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.

---
title: "ztable"
author: "Neil Saunders"
date: "19 March 2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# 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) %>%
# 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 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")
@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]")
# 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 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
@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
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