Skip to content

Instantly share code, notes, and snippets.

@roblanf
roblanf / gist:6929493
Last active October 7, 2021 05:32
Setting up Python 2.7 on Windows

Below is a method to install Python 2.7 on Windows, using the Python distribution from python.org. Please note that THERE ARE EASIER WAYS THAN THIS. E.g. you can use the Anaconda distribution, which is one click, and has a nice windows installer. To do that, ignore everything below and just click here:

http://www.continuum.io/downloads

If for some reason you want to do it the slightly harder way:

  1. Install Python ================= Download the Python installer from here: http://www.python.org/getit/. Make sure you download version 2.7. The instructions that follow assume you have installed python in its default folder, which is c:\Python27.
@roblanf
roblanf / speciesplot
Last active October 24, 2018 16:04
Make a speciesplot in R
# Create a scatterplot with any species as the data points.
# To choose your species, go here: http://phylopic.org/ , then enter the name of the spp you want. Click on the image and click 'thumbnail', click on the picture, and then copy the link in the address bar of your browser. It should end with 'thumb.png' Paste it in place of the link below.
library(TeachingDemos)
library(png)
# Paste a link to a png of your favourite animal here. This will be an aardvarkplot. Make sure it ends with .thumb.png.
# If it doesn't end with .thumb.png reread the instructions above and try again.
link = "http://phylopic.org/assets/images/submissions/cfee2dca-3767-46b8-8d03-bd8f46e79e9e.thumb.png"
@roblanf
roblanf / genome_plots.r
Last active September 4, 2016 09:23
Make plots about genome sequencing, size, and gene content
source("http://bioconductor.org/biocLite.R")
biocLite("genomes")
library(genomes)
library(ggplot2)
valid <- c("released", "created", "submitted")
data(proks)
update(proks)
@roblanf
roblanf / gender.r
Last active January 24, 2021 08:57
code to make two basic plots showing gender balance in an institution. An example dataset is here: https://gist.github.com/roblanf/f0f9e331adc5aae84fb1. Full description here: www.robertlanfear.com/blog/files/visualising_gender_balance_R.html
library(ggplot2)
library(reshape2)
library(plyr)
all = read.csv("genderdata.csv")
######################## Plot 1 ###############################################
# The raw data: number of men and women in each role, by year
# we need to do a bit of work so we can plot roles in the right order
@roblanf
roblanf / repellent_primes.R
Created March 16, 2016 01:01
This gist is an attempt to recreate some of the analyses discussed in this article:
library(primes)
library(coda)
library(parallel)
library(ggplot2)
# set this to the number of processors on your machine
processors = 4
remainder <- function(number, divisor){ return(number%%divisor) }
@roblanf
roblanf / repellent_primes.R
Created March 16, 2016 01:01
This gist is an attempt to recreate some of the analyses discussed in this article:
library(primes)
library(coda)
library(parallel)
library(ggplot2)
# set this to the number of processors on your machine
processors = 4
remainder <- function(number, divisor){ return(number%%divisor) }
@roblanf
roblanf / repellent_primes.R
Last active March 16, 2016 22:16
This gist is an attempt to analyse the distribution of the last digits of prime numbers, inspired by this article: http://www.nature.com/news/peculiar-pattern-found-in-random-prime-numbers-1.19550?WT.mc_id=FBK_NatureNews
library(primes)
library(coda)
library(parallel)
library(ggplot2)
# set this to the number of processors on your machine
processors = 4
remainders <- function(divisor, numbers){
@roblanf
roblanf / AAL.tsv
Last active May 19, 2016 00:21
The AAL (ANU Acronym List) is a list to help out anyone who is struggling to understand the many wonderful acronyms so beloved of the Australian National University (ANU). To enter your own data, follow this link: http://goo.gl/forms/T1k7BBrqL3CEnmfF2.
Acronym Full Link
ANU Australian National University http://anu.edu.au/
BSB (Division of) Biomedical Science and Biochemistry http://biology.anu.edu.au/research/divisions/biomedical-science-and-biochemistry
CBA Centre for Biodiversity Analysis http://cba.anu.edu.au/
CBBU Computational Biology and Bioinformatics Unit http://biology.anu.edu.au/research/facilities/computational-biology-and-bioinformatics-unit
CGMB Centre for Genomics, Metabolomics, and Bioinformatics
CMBE Colloge of Medicine, Biology, and Environment http://science.anu.edu.au/
CSIRO Commonwealth Scientific and Industrial Research Organisation http://www.csiro.au/
EBL Ecogenomics and Bioinformatics Lab
EEG (Division of) Ecology, Evolution, and Genetics http://biology.anu.edu.au/research/divisions/evolution-ecology-and-genetics
# build the map for R9.5 flowcell, as a long-form dataframe that translates
# channels into rows and columns on the flowcell. Good for plotting in R.
p1 = data.frame(channel=33:64, row=rep(1:4, each=8), col=rep(1:8, 4))
p2 = data.frame(channel=481:512, row=rep(5:8, each=8), col=rep(1:8, 4))
p3 = data.frame(channel=417:448, row=rep(9:12, each=8), col=rep(1:8, 4))
p4 = data.frame(channel=353:384, row=rep(13:16, each=8), col=rep(1:8, 4))
p5 = data.frame(channel=289:320, row=rep(17:20, each=8), col=rep(1:8, 4))
p6 = data.frame(channel=225:256, row=rep(21:24, each=8), col=rep(1:8, 4))
p7 = data.frame(channel=161:192, row=rep(25:28, each=8), col=rep(1:8, 4))
p8 = data.frame(channel=97:128, row=rep(29:32, each=8), col=rep(1:8, 4))
echo "copying source pics"
mkdir source_pics
cp ~/pikrellcam/media/timelapse/* source_pics
cd source_pics
echo "renaming"
mkdir renamed
counter=1
ls -1tr *.jpg | while read filename; do cp $filename renamed/$(printf %05d $counter)_$filename; ((cou\
nter++)); done