Skip to content

Instantly share code, notes, and snippets.

View rmaia's full-sized avatar

Rafael Maia rmaia

View GitHub Profile
@rmaia
rmaia / phylostan_Ktrees.R
Last active May 23, 2017 12:55
Bayesian phylogenetic regression incorporating phylogenetic uncertainty by sampling from multiple trees (work in progress)
require(rstan)
require(geiger)
require(MCMCglmm)
# load data
data(geospiza)
dat <- geospiza$geospiza.data
# create fake sample of trees
tr <- drop.tip(geospiza$geospiza.tree, 'olivacea')
@rmaia
rmaia / phylostan_1tree.R
Created July 5, 2013 18:55
Bayesian phylogenetic regression
require(rstan)
require(geiger)
require(MCMCglmm)
# load data
data(geospiza)
# get the inverse of the phylogenetic variance-covariance matrix
tr <- drop.tip(geospiza$geospiza.tree, 'olivacea')
invA <- solve(vcv.phylo(tr))
@rmaia
rmaia / ggplot_chulls.R
Last active November 29, 2023 07:54
Plot convex hulls according to a factor
require(ggplot2)
require(plyr)
# make toy data
set.seed(1)
dataf <- data.frame(
x = rnorm(100),
y = c(rnorm(50,-1), rnorm(50,1)),
cat = rep(c("A","B"), each=50)
)