Skip to content

Instantly share code, notes, and snippets.

View joelnitta's full-sized avatar

Joel Nitta joelnitta

View GitHub Profile
@joelnitta
joelnitta / test.md
Created August 8, 2022 21:46
test md file for po4a

This a markdown document

# a comment to be translated
ls
@joelnitta
joelnitta / 1K_SARS-CoV-2_SG-thorney.xml
Created June 28, 2022 05:41
XML file for thorney beast run with relaxed clock
<?xml version="1.0" standalone="yes"?>
<!-- Generated by BEAUTi v1.10.4 -->
<!-- by Alexei J. Drummond, Andrew Rambaut and Marc A. Suchard -->
<!-- Department of Computer Science, University of Auckland and -->
<!-- Institute of Evolutionary Biology, University of Edinburgh -->
<!-- David Geffen School of Medicine, University of California, Los Angeles-->
<!-- http://beast.community/ -->
@joelnitta
joelnitta / contentid_fern_example.R
Last active May 27, 2022 21:42
Example of using contentid
library(tidyverse)
#' Parse fossil calibration data in Sundue and Testo 2016 SI
#'
#' Testo WL, Sundue MA (2016) A 4000-species dataset provides new insight into
#' the evolution of ferns. Molecular Phylogenetics and Evolution 105:200–211.
#' https://doi.org/10.1016/j.ympev.2016.09.003
#'
#' @param testo_sundue_2016_si_path Path to Sundue and Testo 2016 SI file
#' (xlsx format).
@joelnitta
joelnitta / fix_jr_yaml.R
Last active April 7, 2022 02:32
Fix "Jr." in a YAML reference file rendered with CSL
library(yaml)
library(stringr)
# Names with "Jr." need to have this in the "suffix" field, or they won't get rendered properly
# Zotero apparently doesn't know about this, so fix them with this script.
# Read in a reference library in YAML format
# (e.g. exported from zotero)
refs_yaml <- read_yaml("main_library.yaml")
@joelnitta
joelnitta / filmy_taxonomy.csv
Created December 3, 2021 22:04
Example CSV in Darwin Core Taxon format
taxonID datasetID datasetName acceptedNameUsageID parentNameUsageID taxonomicStatus taxonRank verbatimTaxonRank scientificName kingdom phylum class order family genericName genus subgenus specificEpithet infraspecificEpithet scientificNameAuthorship namePublishedIn nameAccordingTo modified taxonConceptID scientificNameID references
54115096 140 World Ferns in Species 2000 & ITIS Catalogue of Life: 2019 NA 54830341 accepted name species NA Cephalomanes atrovirens Presl Plantae Tracheophyta Polypodiopsida Hymenophyllales Hymenophyllaceae Cephalomanes Cephalomanes NA atrovirens NA Presl NA Hassler M. Nov 2018 NA ferns-1911-colgen http://www.catalogueoflife.org/col/details/species/id/f5950556e578afe0332ef6a18360dd97
54133783 140 World Ferns in Species 2000 & ITIS Catalogue of Life: 2019 54115097 NA synonym species NA Trichomanes crassum Copel. Plantae NA NA NA NA Trichomanes Cephalomanes NA crassum NA Copel. NA NA NA NA ferns-1915-syn-1 http://www.catalogueoflife.org/col/details/species/id/bb5e2f017639f8fb9de177c
@joelnitta
joelnitta / check_args.R
Created October 5, 2021 03:45
Function to check names of input to a function
# This function can be called inside of other functions to check
# if the names of the input match the names of the arguments
check_args <- function(call_match) {
call_names <- as.character(call_match)
arg_names <- names(as.list(call_match))
stopifnot(
"Names of input must match names of arguments" = isTRUE(all.equal(call_names[-1], arg_names[-1]))
)
}
@joelnitta
joelnitta / checksums.R
Created September 8, 2021 01:53
Make a list of MD5 checksums for files in a folder
library(tidyverse)
# Specify directory with files to get checksums
dir <- "my_folder"
# Get checksums
list.files(dir, full.names = TRUE) %>%
tools::md5sum() %>%
tibble(file = names(.), checksum = .) %>%
filter(!is.na(checksum)) %>%
@joelnitta
joelnitta / offset_example.xml
Last active August 19, 2021 02:22
offset example for babette
<?xml version="1.0" encoding="UTF-8" standalone="no"?><beast beautitemplate='Standard' beautistatus='' namespace="beast.core:beast.evolution.alignment:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood" required="" version="2.6">
<data
id="primates"
spec="Alignment"
name="alignment">
<sequence id="seq_Gorilla" spec="Sequence" taxon="Gorilla" totalcount="4" value="AAGCTTCACCGGCGCAGTTGTTCTTATAATTGCCCACGGACTTACATCATCATTATTATTCTGCCTAGCAAACTCAAACTACGAACGAACCCACAGCCGCATCATAATTCTCTCTCAAGGACTCCAAACCCTACTCCCACTAATAGCCCTTTGATGACTTCTGGCAAGCCTCGCCAACCTCGCCTTACCCCCCACCATTAACCTACTAGGAGAGCTCTCCGTACTAGTAACCACATTCTCCTGATCAAACACCACCCTTTTACTTACAGGATCTAACATACTAATTACAGCCCTGTACTCCCTTTATATATTTACCACAACACAATGAGGCCCACTCACACACCACATCACCAACATAAAACCCTCATTTACACGAGAAAACATCCTCATATTCATGCACCTATCCCCCATCCTCCTCCTATCCCTCAACCCCGATATTATCACCGGGTTCACCTCCTGTAAATATAGTTTAACCAAAACATCAGATTGTGAATCTGATAAC
@joelnitta
joelnitta / example-poster.Rmd
Created July 12, 2021 06:09
example posterdown document
---
title: "`posterdown`: Generate Reproducible & Live HTML and PDF Conference Posters Using RMarkdown"
author:
- name: Brent Thorne
affil: 1
orcid: '0000-0002-1099-3857'
- name: Another G. Author
affil: 2
affiliation:
- num: 1
@joelnitta
joelnitta / force_ultrametric.R
Created June 22, 2021 06:27
Force the branch lengths of a tree to be ultrametric
#' force_ultrametric
#'
#' Force the branch lengths of a tree to be ultrametric. Most useful in cases
#' when a time-tree is imported into R but the branch lengths are not exactly
#' ultrametric due to rounding error. Uses a different (faster) method from
#' phytools::force.ultrametric()
#'
#' @param tree Input tree; list of class "phylo". Should already be ultrametric
#' within rounding error.
#' @param force.positive Logical; should the branch lengths be forced to be