Skip to content

Instantly share code, notes, and snippets.

View jimmyodonnell's full-sized avatar
🌴
wondering

Jimmy O'Donnell jimmyodonnell

🌴
wondering
View GitHub Profile
@jimmyodonnell
jimmyodonnell / transect_layout
Created July 8, 2014 04:11
Calculate coordinates for sampling points along large spatial transects
library(geosphere)
# First, pick a starting point for one of the transects.
start.point.1 <- matrix(data = c(-122.54727, 47.57078), nrow=1)
# Set two other starting points, 1000 meters from the first, in opposite directions
start.point.2 <- destPoint(start.point.1, 30, 1000)
start.point.3 <- destPoint(start.point.1, 210, 1000)
# Pick the distances along each transect you want to sample
@jimmyodonnell
jimmyodonnell / sample_structure_plots
Last active December 15, 2022 09:24
Create sample plots from the population genetics software STRUCTURE
# sample structure plots
# to suppress axis ticks, use:
# xaxt = "n", yaxt = "n"
# no borders lty=0 or border=0
par(mfcol=c(4,2), mar=c(2,2,1,1), oma=c(2,4,2,2))
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
rect(0,0,100,1, col="yellow", border=0)
plot(0,1,type="n", ylim=c(0,1), xlim=c(0,100), xlab=NA, ylab=NA, yaxp = c(0, 1, 2))
@jimmyodonnell
jimmyodonnell / heterozygote_combine
Last active August 29, 2015 13:57
Combine heterozygous DNA sequences into one sequence that reflects ambiguities
# For any two DNA sequences, this code will generate a single sequence which represents differences among them with the IUPAC ambiguities.
het.cbm <- function(x1, x2){
if (length(x1)!=length(x2)) stop("sequences are not the same length!")
oot <- paste(x1, x2, sep="")
# define nucleotides
nucleotides<-c("A", "C", "G", "T")
# make a matrix of all possible combinations of nucleotides
combos <- matrix(NA, 4,4)