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
################################################################################ | |
# A by-column concatenator for excel through R. | |
# | |
# Arguments: | |
# row - indicate the row you wish to concatenate. | |
# cell - the first cell containing the information you want to concatenate. | |
# lastcell - the last cell containing the information you want to concatenate. | |
# | |
# Usage: combine_excel(row = 1, cell = "A", lastcell = "D") | |
# |
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
#==============================================================================# | |
# Usage: | |
# x <- getfile() # for a single file. | |
# x <- getfile(multi = TRUE) # for multiple files | |
# x <- getfile(multi = TRUE, pattern = "^.+?csv$") # grabs all *.csv files. | |
# setwd(x$path) | |
# read.csv(x$files) | |
#==============================================================================# | |
getfile <- function(multi=FALSE, pattern=NULL, combine=TRUE){ |
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
if (!require('devtools')) install.packages('devtools'); require('devtools') | |
if (!require('data.table')) install.packages('data.table'); require('data.table') | |
install_github('installr', 'talgalili') # get the latest installr R package | |
# or run the code from here: | |
# https://github.com/talgalili/installr/blob/master/R/RStudio_CRAN_data.r | |
require(installr) | |
if(!require(ISOcodes)) install.packages("ISOcodes", repos = "http://cran.at.r-project.org"); require(ISOcodes) |
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
#==============================================================================# | |
# hapmap2df.r Convert hapmap files to a data frame. | |
# | |
# Author: Zhian N. Kamvar | |
# License: GPLv3 | |
# Year: 2013 | |
# Waranty: NONE | |
# | |
# This function will read in hapmap formatted files and convert them to a data | |
# frame for the purposes of importing them to genlight objects. Example: |
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
pic <- function(gid){ | |
if (gid@type != "PA"){ | |
gid_loc <- seploc(gid) | |
return(vapply(gid_loc, pic_loc, 1)) | |
} | |
else{ | |
return(vapply(1:nLoc(gid), function(x) pic_loc(gid[, x]), 1)) | |
} | |
} |
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
#==============================================================================# | |
# insert_sep.r Insert a separator into a character vector containing two pieces | |
# of information where one piece has a constant width. | |
# | |
# Author: Zhian N. Kamvar | |
# License: GPLv3 | |
# Year: 2014 | |
# Waranty: NONE | |
# | |
# Arguments: |
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
#' Performs lazy load on a directory | |
#' | |
#' @param path a filepath containing the necessary files for lazy loading | |
#' @return NULL | |
#' | |
#' @details This function will go into a directory, search for all the files | |
#' that seem like they can be lazily loaded and attempt to load them. | |
#' | |
lazierLoad <- function(path){ | |
files <- dir(path) |
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
#!/usr/bin/perl | |
# | |
# This script was created because I had a problem with inkscape not recognizing | |
# fonts generated by R's pdf generator. This will go through and make these fonts | |
# scaleable. | |
# | |
# Workflow: Generate PDF > open in inkscape > save as svg > run this script | |
# | |
# Usage: perl -i inkscape_pdf_font.pl <my_file.svg> | |
# |
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
#==============================================================================# | |
# Function to print genotypes in the MLG table created from a genind or genclone | |
# object. This allows for quick identification for small numbers of loci. | |
# | |
# Requirements: the R package "poppr" | |
# | |
# usage: my.mlg.table(genind_object) | |
# | |
# arguments: | |
# ... arguments passed on to "mlg.table" |
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
#' Test repeat length consistency. | |
#' | |
#' This function will test for consistency in the sense that all alleles are | |
#' able to be represented as discrete units after division and rounding. | |
#' @param gid a genind object | |
#' @param replen a numeric vector of repeat motif lengths. | |
#' @return a logical vector indicating whether or not the repeat motif length is | |
#' consistent. | |
#' | |
#' @details This function is modified from the version used in |
OlderNewer