This file contains 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
#' Download all the files in a google drive folder. | |
#' | |
#' \code{dribble_data} should be obtained using \code{\link[googledrive]{drive_ls}}. | |
#' | |
#' @param dribble_data Data frame of class \code{dribble}. | |
#' @param folder Path to local folder to download data. | |
#' @param pattern Optional grep pattern; only file names matching this pattern | |
#' will be included. | |
#' @param negate Logical; should only file names that don't match the pattern | |
#' be included instead? |
This file contains 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
# List all functions and packages used by R scripts in a project. | |
library(NCmisc) | |
# IMPORTANT: Also load any libraries used by the project | |
# Make list of all functions by package | |
funcs <- | |
list.files(here::here(), pattern ="\\.R$", recursive = TRUE, full.names = TRUE) %>% | |
map(list.functions.in.file) %>% | |
flatten |
This file contains 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
# Convert ape::DNAbin format to Biostrings::DNAStringSet format, | |
# optionally removing gaps | |
DNAbin_to_DNAstringset <- function (seqs, remove_gaps = TRUE) { | |
if(isTRUE(remove_gaps)) { | |
seqs %>% as.list() %>% as.character %>% | |
lapply(.,paste0,collapse="") %>% | |
lapply( function (x) gsub("-", "", x)) %>% | |
unlist %>% Biostrings::DNAStringSet() | |
} else { | |
seqs %>% as.list() %>% as.character %>% |
This file contains 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
#' Concatenate a list of aligned genes | |
#' | |
#' @param dna_list List of matrices of class DNAbin | |
#' | |
#' @return Matrix of class DNAbin | |
#' | |
#' @examples | |
#' data(woodmouse) | |
#' gene_1 <- woodmouse[,1:100] | |
#' gene_2 <- woodmouse[,101:200] |
This file contains 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
#' Run IQ-TREE | |
#' | |
#' For details, see http://www.iqtree.org/doc/ | |
#' | |
#' @param alignment DNA alignment to use for phylogenetic analysis. Must be matrix | |
#' (i.e., aligned sequences) of class DNAbin | |
#' @param wd Path to working directory. The alignment and IQ-TREE intermediate files | |
#' and results will be written here. | |
#' @param bb Optional; number of ultrafast bootstrap replicates to run. | |
#' @param nt Optional; number of cores to use. Set to "AUTO" to determine automatically. |
This file contains 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
preview_pal <- function(colors) { | |
labels <- if(is.null(names(colors))) {colors} else {names(colors)} | |
pie( | |
rep(1, length(colors)), | |
labels = labels, | |
col = colors) | |
} |
This file contains 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
#' Compare the contents of two folders | |
#' | |
#' Comparison is done by checking file names and the MD5 hash of each | |
#' file. No recursion is used, so files in subfolders will not be checked. | |
#' | |
#' @param x The absolute path to the first folder. | |
#' @param y The absolut path the second folder. | |
#' | |
#' @return A confirmation if all files in the two folders are equal. | |
#' Otherwise, a list of two tibbles. Each tibble contains a column for |
This file contains 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
# Scale a color palette centered on zero | |
#' Get the lower, upper, or absolute maximum value | |
#' of a variable in a dataframe | |
#' | |
#' For setting plotting limits manually | |
#' | |
#' @param data Dataframe | |
#' @param var Name of variable (column) in dataframe | |
#' @param digits Number of digits desired in output |
This file contains 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
library(hexSticker) | |
library(ggplot2) | |
# Make a blank plot because hexSticker::sticker() expects something. | |
p <- ggplot(mtcars, aes(wt, mpg)) + geom_blank() + theme_void() + theme_transparent() | |
sticker(p, | |
package="generic", | |
p_size=8, s_x=1, s_y=.8, s_width=1.2, s_height=1, | |
h_color = "grey", |
This file contains 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
country | |
Afghanistan | |
Albania | |
Algeria | |
American Samoa | |
Andorra | |
Angola | |
Anguilla | |
Antarctica | |
Antigua and Barbuda |
OlderNewer