Skip to content

Instantly share code, notes, and snippets.

@josephwb
josephwb / find_large_files.sh
Created June 7, 2018 09:10
Recursively find large files
#!/bin/bash
# report files greater than some size (default 100 MB)
# does so recursively starting at some dir (default pwd)
# to make executable, do:
# chmod +x find_large_files.sh
print_help () {
echo "Recursively find all files larger than some size"
@josephwb
josephwb / check_genus_monophyly.R
Last active August 26, 2020 13:48
Check the monophyletic status of every genus in a tree
require(phangorn);
# check the monophyletic status of every genus in the tree `phy`
check_genus_monophyly <- function (phy) {
# get genera. assumes form: Genus_species_whatever
gens <- sort(unique(sub("_.*", "", phy$tip.label)));
n <- length(gens);
cat("Checking ", n, " genera for monophyly status.\n", sep="");
# the number of descendant tips of the MRCA. preallocate for monotypic genera
ndec <- rep(1, n);
@josephwb
josephwb / keep.nodes.R
Last active April 27, 2021 13:39
like ape::keep.tip, but can also keep internal nodes (which become new tips)
library(ape);
# like keep.tip, but you can keep internal nodes toooooo
keep.nodes <- function (phy, nds) {
# stats
Ntip <- length(phy$tip.label);
NEWROOT <- Ntip + 1;
Nnode <- phy$Nnode;
hasNL <- !is.null(phy$node.label);