This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Example of using ExitStack to make a highly efficient file splitter """ | |
| from contextlib import ExitStack | |
| # Example file is a BED file where Col 7 is in the form of "genomeA:genomeB" | |
| # and the goal is to split it into files based on if genomeA == genomeB. | |
| f_in = "head1000tail1000_biser.bed" | |
| def get_outfile(col): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| knitr::knit_hooks$set(wrapf = function(before, options, envir) { | |
| # Inspired by user "CL."'s answer in https://stackoverflow.com/questions/34017777/wrapping-figure-with-latex-environment-in-knitr-rmarkdown-with-hooks | |
| align <- ifelse(is.null(options$fig.align), "left", options$fig.align) | |
| width <- ifelse(is.null(options$out.width), "0.3", gsub("\\linewidth", "", options$out.width, fixed = T)) # fixes out.width to work with either pct or dec | |
| num <- options$fig.num | |
| label <- options$label | |
| caption <- options$fig.cap | |
| if(before) { | |
| return(sprintf("\\begin{wrapfigure}{%s}{%s\\textwidth}\n", align, width)) # Initiates wrapfigure |