Skip to content

Instantly share code, notes, and snippets.

mushroom mushroom

Zhian N. Kamvar zkamvar

mushroom mushroom
View GitHub Profile
zkamvar /
Last active Aug 18, 2020
pandoc markdown_github with section-divs booboo

This compares the differences between pandoc's markdown and markdown_github engines when parsing <div> tags within sections.


In essence, if a <div> tag contains a header out of order with the main document, its contents will be appended to the div in the html document with markdown_github. If the following div appears after a level 3 header:

<div class='boo'>

## level 2
View tink.R
# test file
sample_chunk <- "
```{r hello, testing=as.logical(1), another=1 + 1}
x <- 1 + 1 # this evaluates to two
the value of x is `r x`"
file = "sample.Rmd"
writeLines(sample_chunk, con = file)
# delete temp Rmd file
zkamvar / render-demo.R
Last active Aug 23, 2018
Render an R demo
View render-demo.R
#!/usr/bin/env Rscript
args <- commandArgs(trailingOnly = TRUE)
if (length(args) != 2) {
msg <- "
render-demo.R <demo> <package>
This utility will render the code and figures from a given package as a PDF
and place them into a directory called `<demo>-generated_files`. This requires
knitr, rmarkdown and LaTeX to be installed on your system.
zkamvar /
Last active Aug 21, 2018
Generating a bootstrap dendrogram with hierfstat's genet.dist
title author date
Generating a bootstrap dendrogram with hierfstat's genet.dist
Zhian N. Kamvar

This short tutorial is an answer to the question posed on the poppr forum:!msg/poppr/vEQ8vb2oObQ/RjTsndaCEQAJ

My ultimate goal when asking the previous question was to employ aboot in order to create a bootstraped dendrogram based on distances offered by the genet.dist function in hierfstat. That's why I was trying to create a tree based on Nei's distance this way - to verify that it worked! Unfortunately even after reading the aboot documentation, I still fail to understand how to do this. I would be grateful if someone could provide an example of using aboot in combination with genet.dist.

zkamvar / guide_generator.R
Created Jan 5, 2018
Generate guides for making a poster in inkscape
View guide_generator.R
#' Get the size of a single panel
#' @param n the number of panels
#' @param len the overall length of the side
#' @param margin the outer margin width (will be multiplied by 2)
#' @param gutter the space between panels
#' @return a numeric value specifying the panel width/length
#' @examples
zkamvar / statphi.R
Last active Dec 18, 2017
Get Phi statistics from amova object from either pegas or ade4
View statphi.R
ade4phi <- function(sig){
n <- length(sig)
f <- rep(0, n - 1)
if (length(sig) == 3) {
f <- rep(0, 1)
f[1] <- (sig[n] - sig[n - 1]) / sig[n]
if (length(f) > 1) {
s1 <- cumsum(sig[(n - 1):2])[-1]
zkamvar /
Created Nov 1, 2017
Find chromosome regions for given SSR GenBank IDs
#!/usr/bin/env python3
# This script will BLAST a series of GenBank IDs representing SSR sequences from
# Sirjusingh, C., Kohn, L.M., 2001. Characterization of microsatellites in the
# fungal plant pathogen, Sclerotinia sclerotiorum. Molecular Ecology 1, 267e269.
# This uses biopython to download the XML, save it to a file in the working
# directory, and then looks for matches that have Sclerotinia chromosome in the
# title and has a score of > 100. If there's a better way to do this, I would
# like to know it. Currently, it can download a few results at a time and then
zkamvar /
Created Oct 11, 2017
silly emoji for bash commands
# shruggie
# Source:
function shrug(){ echo -n "¯\_(ツ)_/¯" | pbcopy;echo "¯\_(ツ)_/¯ copied to your clipboard"; }
export -f shrug
# strollie
function stroll(){ echo -n "ᕕ( ᐛ )ᕗ" | pbcopy; echo "ᕕ( ᐛ )ᕗ copied to your clipboard"; }
export -f stroll
# flippy
View purr_mc.R
# This is from @drob on twitter:
transition_mc <- function(steps, start, mat){
i <- seq_len(nrow(mat))
transition <- ~ sample(i, prob = (i == .) %*% mat)
accumulate(seq_len(steps), transition, .init = start)
zkamvar / pastena.R
Last active Sep 14, 2017
Paste function that replaces NA characters with blanks
View pastena.R
#' paste function that replaces NA characters with blanks
#' All arguments are passed to paste.
#' Usage:
#' pastena(letters, sample(c(1:10, NA), 26, replace = TRUE))
pastena <- function(..., collapse = NULL, sep = " ") {
dots <- list(...)
dots <- lapply(dots, function(i) ifelse(, "", i))
res <-"paste", c(dots, list(collapse = collapse, sep = sep)))
You can’t perform that action at this time.