Skip to content

Instantly share code, notes, and snippets.

View cmt2's full-sized avatar

Carrie M Tribble cmt2

View GitHub Profile
@cmt2
cmt2 / convertTreeFormat.R
Created May 31, 2024 23:26
format a standard phylo object for use in RevGadgets plotting functions
# randomly sample a tree for this example
t <- rtree(10)
# check that the example tree is a phylo object
class(t) == "phylo"
# convert to RevGadgets plotting format
t_td <- convertTreeFormat(t) # [note, run the function code below before executing this line of code]
# The function:
# `tree` is the argument for your phylo object.
@cmt2
cmt2 / reviewerCOI.R
Created September 19, 2023 00:14
Reviewer conflicts code
##### Script to check if the authors of a paper have co-authored with
##### a potential reviewer within the past 4 years (following COI for
##### NSF and various journals). I make o guarantees this will work,
##### as name changes, variations in spellings, etc. might interfere
##### with the code. Please note that this does not check for other
##### potential conflicts such as mentorship relationships, etc.
library(lubridate)
library(scholar)
@cmt2
cmt2 / readStochasticMaps.R
Created April 7, 2022 21:09
load RevBayes stochastic mapping files into R to plot with phytools, etc.
readStochasticMaps <- function(map_paths,
burnin = 0.1,
combine_runs = TRUE) {
# read in map logs and remove burnin
maps <- vector("list", length = length(map_paths))
for (i in 1:length(map_paths)) {
message(paste0("Reading in map log file ", i, "\n",
"This may take a while."))
maps[[i]] <- read.table(file = map_paths[i],
@cmt2
cmt2 / bgb_to_revgadgets.R
Last active May 12, 2022 18:47
convert biogeobears output for plotting revgadgets
bgb_to_revgadgets <- function(results_path, geo_data_path, tree_path, area_names = NULL) {
# load biogeobears results object
load(results_path)
# change data directories in results object
res[["inputs"]]$geogfn <- geo_data_path
res[["inputs"]]$trfn <- tree_path
##### Process data for plotting #####
# read in tree separately