Skip to content

Commit 941a221

Browse files
committed
Seq.info defaults and data.rd fixes
1 parent 7c9665c commit 941a221

14 files changed

+257
-86
lines changed

Diff for: .Rhistory

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
h <- 40
2+
#simulate
3+
lhs <- maximinLHS(h,3)
4+
#minimum and maximum values for each parameter
5+
threshold.min <- 0.02
6+
threshold.max <- 0.07
7+
expansion.min <- 2
8+
expansion.max <- 10
9+
inflation.min <- 2
10+
inflation.max <- 10
11+
# generate a “parameter set” by rescaling our simulated latin hypercube sample
12+
params.set <- cbind(
13+
threshold = lhs[ ,1] * (threshold.max-threshold.min) + threshold.min,
14+
expansion = lhs[ ,2] * (expansion.max-expansion.min) + expansion.min,
15+
inflation = lhs[ ,3]*(inflation.max-inflation.min) + inflation.min
16+
)
17+
min(params.set[,1])
18+
#choose number of points
19+
h <- 40
20+
#simulate
21+
lhs <- maximinLHS(h,3)
22+
#minimum and maximum values for each parameter
23+
threshold.min <- 0.02
24+
threshold.max <- 0.07
25+
expansion.min <- 2
26+
expansion.max <- 10
27+
inflation.min <- 2
28+
inflation.max <- 10
29+
# generate a “parameter set” by rescaling our simulated latin hypercube sample
30+
params.set <- cbind(
31+
threshold = lhs[ ,1] * (threshold.max-threshold.min) + threshold.min,
32+
expansion = lhs[ ,2] * (expansion.max-expansion.min) + expansion.min,
33+
inflation = lhs[ ,3]*(inflation.max-inflation.min) + inflation.min
34+
)
35+
min(params.set[,1])
36+
#choose number of points
37+
h <- 40
38+
#simulate
39+
lhs <- maximinLHS(h,3)
40+
#minimum and maximum values for each parameter
41+
threshold.min <- 0.02
42+
threshold.max <- 0.07
143
expansion.min <- 2
244
expansion.max <- 10
345
inflation.min <- 2
@@ -460,53 +502,11 @@ inflation = lhs[ ,3]*(inflation.max-inflation.min) + inflation.min
460502
)
461503
min(params.set[,1])
462504
setwd("MountainPlot/")
463-
ls
464-
devtools::load_all()
465505
devtools::load_all()
466-
ls
467-
devtools::run_examples()
468-
system("inst/pplacer -h")
469-
devtools::run_examples()
470-
testthat::test_local()
471-
seq.info.ex
472-
seq.info <- pull.headers(alignment.ex, var.names = c("ID", "CollectionDate", "Subtype"),
473-
var.transformations =list(as.character, as.Date, as.factor))
474-
seq.info
475-
seq.info
476-
alignment.ex
477-
str(alignment.ex)
506+
old.tree.ex
507+
old.tree.ex
478508
alignment.ex
479-
cluster.ex
480-
devtools::load_all()
481-
generate.all()
482-
devtools::load_all()
483-
cluster.ex
484-
devtools::load_all()
485-
cluster.ex
486-
generate.all()
487-
cluster.ex
488-
load("data/cluster.ex")
489-
load("data/cluster.ex.RData")
490-
cluster.ex
491-
cluster.ex <- component.cluster.set <- component.cluster(graph.ex, dist.thresh = 0.03)
492-
save(cluster.ex, file="data/cluster.ex.RData")
493-
devtools::load_all()
494-
cluster.ex
495-
cluster.ex
496-
cluster.ex <- component.cluster.set <- component.cluster(graph.ex, dist.thresh = 0.06)
497-
save(cluster.ex, file="data/cluster.ex.RData")
498-
devtools::load_all()
499-
cluster.ex
500-
cluster.ex
501-
cluster.ex <- component.cluster.set <- component.cluster(graph.ex, dist.thresh = 0.05)
502-
save(cluster.ex, file="data/cluster.ex.RData")
503-
devtools::load_all()
504-
cluster.ex
505-
cluster.ex
506-
cluster.ex <- component.cluster.set <- component.cluster(graph.ex, dist.thresh = 0.055)
507-
cluster.ex
508-
cluster.ex
509-
save(cluster.ex, file="data/cluster.ex.RData")
510-
cluster.ex$Subtype
511-
graph.ex\
512-
graph.ex
509+
full.tree.ex
510+
full.tree.ex$node.label
511+
full.tree.ex$tip.label
512+
seq.info.ex

Diff for: R/data.R

+21-29
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,22 @@
33
#'A dataset containing 10 HIV1, subtype B polymerase sequences collected in Northern Alberta Canada.
44
#'This a 10 sequence sample from popset# 1033910942 on NCBI's genbank Archive
55
#'
6-
#'@format An ape DNA object: 10 DNA sequences in binary format stored in a list. All sequences of same length: 1017
7-
#'
8-
#'@source \url{https://www.ncbi.nlm.nih.gov/popset?DbFrom=nuccore&Cmd=Link&LinkName=nuccore_popset&IdsFromResult=1033912042}
6+
#' @format An ape DNA object: 10 DNA sequences in binary format stored in a list. All sequences of same length: 1017
7+
#' @source \url{ https://www.ncbi.nlm.nih.gov/popset?DbFrom=nuccore&Cmd=Link&LinkName=nuccore_popset&IdsFromResult=1033912042 }
98
"alignment.ex"
109

11-
1210
#'An example set of sequence meta.data corresponding to alignment.ex
1311
#'
14-
#'A dataset describing 10 different HIV1 pol sequences collected in Northern Alberta Cabada.
12+
#'A dataset describing 10 different HIV1 pol sequences collected in Northern Alberta Canada.
1513
#'
1614
#' @format A data.table object with 9 variables:
1715
#' \describe{
18-
#' \item{ID} {Accession IDs (characters) of sequences}
19-
#' \item{CollectionDate} {Collection date of sequences. Full dates given as yyyy-mm-dd}
20-
#' \item{Subtype} {Subtypes (factors) within a cluster}
16+
#' \item{ID}{Accession IDs (characters) of sequences}
17+
#' \item{CollectionDate}{Collection date of sequences. Full dates given as yyyy-mm-dd}
18+
#' \item{Subtype}{Subtypes (factors) within a cluster}
2119
#' \item{Header}{The original headers from the alignement. This matches meta data to sequences}
22-
#' \
2320
#' }
24-
"cluster.ex"
25-
21+
"seq.info.ex"
2622

2723
#'An example set of clusters, built using component.cluster
2824
#'
@@ -33,15 +29,14 @@
3329
#' @format A data.table object with 9 variables:
3430
#' \describe{
3531
#' \item{ClusterID}{ The unique identifier number for this cluster. A numberic}
36-
#' \item{ID} {A list of vectors, each containing the accession IDs (characters) of sequences within a cluster}
37-
#' \item{CollectionDate} {A list of vectors, each containing the collection date of sequences within a cluster}
38-
#' \item{Subtype} {A list of vectors, each containing the subtypes (factors) within a cluster}
32+
#' \item{ID}{A list of vectors, each containing the accession IDs (characters) of sequences within a cluster}
33+
#' \item{CollectionDate}{A list of vectors, each containing the collection date of sequences within a cluster}
34+
#' \item{Subtype}{A list of vectors, each containing the subtypes (factors) within a cluster}
3935
#' \item{Header}{A list of vectors, each containing the original headers from the alignement used to build this set of clusters}
40-
#' \item{Size} {The original size of this cluster before being updated with new cases. This simply the number of sequences within the cluster}
41-
#' \item{Growth} {The growth of the cluster after new cases are added}
42-
#' \item{DistThresh} {The pairwise distance threshold used to create this complete set of clusters. Corresponds to a setID as an input parameter}
43-
#' \item{SetID} {The unique identifier for this set of clusters. A numeric}
44-
#' \
36+
#' \item{Size}{The original size of this cluster before being updated with new cases. This simply the number of sequences within the cluster}
37+
#' \item{Growth}{The growth of the cluster after new cases are added}
38+
#' \item{DistThresh}{The pairwise distance threshold used to create this complete set of clusters. Corresponds to a setID as an input parameter}
39+
#' \item{SetID}{The unique identifier for this set of clusters. A numeric}
4540
#' }
4641
"cluster.ex"
4742

@@ -50,7 +45,6 @@
5045
#'This implementation of a graph is a list, describing a set of sequences and the distances between them.
5146
#'See create.graph for more information on how this graph was created using alignment.ex as input
5247
#'
53-
#'
5448
#' @format A list of 3 variables
5549
#' \describe{
5650
#' \item{seq.info}{ See seq.info.ex, a data.table containing sequence meta data}
@@ -59,7 +53,6 @@
5953
#' In order to ensure that clusters do not merge upon growth, a new sequence may only
6054
#' join up to one old cluster. By default, new sequences join the cluster of the
6155
#' sequence they are most similar to. }
62-
#' \
6356
#' }
6457
"graph.ex"
6558

@@ -90,13 +83,12 @@
9083
#' @format A , phylogenetic tree with 6 tips and 4 internal nodes. Node labels represent certainty
9184
#' See ape's implementation of phylogenetic tree objects for information about tags within this object.
9285
#' In addition, there are 4 new objects created by functions within tree.setup.R
86+
#' \describe{
9387
#' \item{seq.info}{ See seq.info.ex, a data.table containing sequence meta data}
94-
#' \item{node.info}{ Grouping of the meta.data present in seq.info assigned to various nodes in the tree, coupled with
95-
#' information important to clustering, such as mean divergence from root, or node certainty }
96-
#' \item{path.info} { Information regarding the path of edges from tips to the root of the tree. This is also necessary for some clustering algorithms,
97-
#' specifically step.cluster}
98-
#' \item{growth.info}{ a data.table pairing new sequences, to a single node in the tree
99-
#' based on placements assigned by guppy and pplacer.
88+
#' \item{node.info}{ Grouping of the meta.data present in seq.info assigned to various nodes in the tree,
89+
#' coupled with information important to clustering, such as mean divergence from root, or node certainty }
90+
#' \item{path.info}{ Information regarding the path of edges from tips to the root of the tree.
91+
#' This is also necessary for some clustering algorithms, specifically step.cluster}
92+
#' \item{growth.info}{ a data.table pairing new sequences, to a single node in the tree based on placements assigned by guppy and pplacer.}
10093
#' }
101-
"extended.tree.ex"
102-
94+
"extended.tree.ex"

Diff for: R/graph.setup.R

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
#' @return A graph, with sequences and edge info. New sequences are only linked by their minimum retrospective edge
1515
#' @export
1616
#' @example examples/create.graph_ex.R
17-
create.graph <- function(seq.info, edge.info, which.new=numeric(0), growth.resolution = minimum.retrospective.edge) {
17+
create.graph <- function(seq.info=data.table(), edge.info, which.new=numeric(0), growth.resolution = minimum.retrospective.edge) {
1818

1919
# Check inputs
20-
if (!all(colnames(edge.info) %in% colnames(edge.info))) {
21-
stop("The pairwise distance matrix does not contain the recognized headers")
20+
if (nrow(seq.info)==0){
21+
warning("No sequence meta-data included, creating default seq.info input from headers in edge.info")
22+
seq.info <- data.table("Header"=colnames(edge.info))
23+
}
24+
if (!all(colnames(edge.info) %in% seq.info$Header)) {
25+
stop("The pairwise distance matrix does not contain all recognized headers from alignment")
2226
}
2327

2428
# Assemble graph object

Diff for: R/tree.setup.R

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' @return The tree annotated with node information and seq.info
1313
#' @export
1414
#' @example examples/extend.tree_ex.R
15-
extend.tree <- function(t, seq.info, mc.cores = 1, log.file=NA, full.align=character(0), locus = "LOCUS") {
15+
extend.tree <- function(t, seq.info=data.table(), mc.cores = 1, log.file=NA, full.align=character(0), locus = "LOCUS") {
1616

1717
# Root the tree (if unrooted) and resolve multichotomies
1818
if (!ape::is.rooted(t)) {
@@ -21,6 +21,15 @@ extend.tree <- function(t, seq.info, mc.cores = 1, log.file=NA, full.align=chara
2121
t <- ape::multi2di(t)
2222

2323
# Check Sequence names inputs
24+
if (nrow(seq.info)==0){
25+
if(length(full.align)!=0){
26+
warning("No sequence meta-data included, creating default seq.info input from headers in alignment")
27+
seq.info <- data.table("Header"=names(full.align))
28+
}else{
29+
warning("No sequence meta-data included, creating default seq.info input from tree tip.labels")
30+
seq.info <- data.table("Header"=t$tip.label)
31+
}
32+
}
2433
var.names <- colnames(seq.info)
2534
if (!("Header" %in% var.names)) {
2635
stop("Header must be contained within var.names")

Diff for: man/alignment.ex.Rd

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/cluster.ex.Rd

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/extended.tree.ex.Rd

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/full.tree.ex.Rd

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/graph.ex.Rd

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: man/old.tree.ex.Rd

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)