R/admixtools.R

#' @import dplyr
#' @import readr
#' @import purrr
#' @import tidyr
#' @import stringr
#' @import ggplot2
# @import utils
#' @importFrom Rcpp sourceCpp
#' @importFrom magrittr set_colnames "%$%" "%<>%"
#' @importFrom abind abind
#' @importFrom crayon blue red green bold italic
#' @importFrom foreach foreach "%dopar%"
#' @importFrom tibble as_tibble deframe enframe add_column rownames_to_column
# @importFrom stats na.omit setNames runif
#' @importFrom igraph V E neighbors subcomponent get.edge.ids degree incident_edges all_simple_paths distances
#' graph_from_edgelist as_edgelist shortest_paths adjacent_vertices is.dag as_ids add_vertices delete_vertices
#' add_edges delete_edges difference set_vertex_attr
#' @useDynLib admixtools

TRUE

#' Tools for inferring demographic history from genetic data
#'
#' admixtools is a collection of several programs for calculating f-statistics
#' and using them to make inferences about demographic history from genetic data
#' Aside from the core functions \code{\link{qp3pop}}, \code{\link{qpdstat}}, \code{\link{qpadm}},
#' and \code{\link{qpgraph}}, there are also wrapper functions and parsing functions around the original
#' ADMIXTOOLS software, as well as functions to read genotype files and precompute the data necessary
#' to quickly compute f statistics.
#'
#' @author Robert Maier \email{<robertmaier@@gmx.net>}
#' @author Nick Patterson
#'
#' @references Patterson, N. et al. (2012) \emph{Ancient admixture in human history.} Genetics
#'
#' @seealso
#' \url{https://uqrmaie1.github.io/admixtools/index.html}
#'
#' @docType package
#' @name admixtools
NULL


#' Blocked f2-statistics for 7 populations
#'
#' @format A 3d array with populations along the first two dimensions,
#'         and SNP blocks along the 3rd dimension
"example_f2_blocks"

#' Admixture graph for 7 populations
#'
#' @format A two column matrix where each row represents one edge
"example_graph"

#' Admixture graph for 7 populations
#'
#' @format An `igraph` object
"example_igraph"

#' Data frame with one fitted admixture graph
#'
#' @format A data frame with a fitted admixture graph, generated by `find_graphs_old`
"example_opt"

#' Data frame with population triples
#'
#' @format A data frame with population triples, generated by `summarize_triples`
"example_triples"

#' Data frame with sample annotations
#'
#' @format A data frame with sample annotations
"example_anno"

#' example_graph fitted using qpGraph
#'
#' @format A list with parsed qpGraph output
"example_qpgraph_ref_results"


.onUnload = function (libpath) {
  library.dynam.unload("admixtools", libpath)
}


# a = devtools::check()
# a$notes[[2]] %>% str_split('’\n') %>% `[[`(1) %>% str_extract_all('‘.+') %>% unlist %>% str_sub(2) %>% unique %>% paste0(., collapse = '",\n"') %>% paste0('globalVariables(c("', ., '"))') %>% write_lines('r/admixtools.R', append = T)
# a$notes[3] %>% str_split('’\n') %>% `[[`(1) %>% str_extract_all('‘.+') %>% unlist %>% str_sub(2) %>% unique %>% paste0(., collapse = '", "') %>% paste0('globalVariables(c("', ., '"))') %>% write_lines('r/admixtools.R', append = T)

globalVariables(c("from", "to", "newg", "generation", "score", "prob", "igraph", "out", "combn", "na.omit", "var", "type", "weight", ".", "column_to_rownames", "graph_from_adjacency_matrix", "value", "name", "quantile", "pop3", "pop2", "cnt", "i", "j", "itree", "isoclass", "delete_vertices", "se2", "se", "lo", "hi", "v", "k", "lab", "v_mean", "v_lo", "v_hi", "lab_mean", "lab_lo", "lab_hi", "af", "afdat", "SNP", "A1", "A2", "a1", "a2", "aa1", "aa2", "a", "miss", "maf", "CHR", "poly", "mutation", ".snpindex", "pop", "ind", "f4mat", "qinvs", "fd", "f4rank", "dof", "chisq", "pchisq", "chisqdiff", "dofdiff", "p_nested", "wt", "p", "best", ".rep", "weighted.mean", "est", ".tot", ".rel_bl", "X3", "X1", "X2", "f2dat", "sts", "z", "b", "bnew", "rray", "f3dat", "fit", "pop1", "f2_1", "f2_2", "f4dat", "block", "pop4", "admixedge", "path", "w", "edge2", "leaf2", "run", "f21", "f22", "f2fit", "c1", "c2", "c3", "c4", "x", "xend", "y", "yend", "tot", "this", "shift", "g", "irl", "node", "s1", "s2", "cov", "graph2", "vertex_attr", "tail", "edge", "leaf", "numpaths", "bl", "aa", "nn", "p1", "p2", "ind2", "ind1", "pp", "pp1", "pp2", "f2uncorr", "corr1", "corr2", "loo", "xtau", "Var1", "Var2", "Var3", "V2", "V1", "label", "result", "nfrom", "nto", "lfrom", "lto", "time", "optim", "setNames", "runif", "group", "isn", "Z", "head", "feasible", "par", "l1", "lower", "l2", "upper", "fst", "ff3fit", "w2", "weight.x", "weight.y", "se.y", "se.x", "left", "pat", "all_of", "low", "high", "xmin", "xmax", "ymin", "ymax", "e", "rownum", "lon", "lat", "eid", "admix", "iid", "long", "PC1", "PC2", "s", "FID", "IID", "index", "right", "res", "name1", "name2", "name3", "powerset", "numleft", "numoginset", "target", "f14", "f23", "f13", "f24", "coef", "lm", "as.formula", "Estimate", "fun2", ".keep", "shift1", "pathnum", "pathnum2", "pathnum3", "path2", "path3", "top", "topo", "x13", "x23", "x31", "x32", "x12", "x21", "toposet", "cor", "pt", "sumna", "numpop", "nam", "n1", "n2", "pnorm"))
uqrmaie1/admixtools documentation built on June 14, 2024, 11:26 a.m.