Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ce63797
added "find.networks" and examples
olli0601 Jul 9, 2019
0a3533d
added function "plot.network"
olli0601 Jul 10, 2019
d34c662
updating man pages
olli0601 Jul 10, 2019
31de28d
added example to "plot.network"
olli0601 Jul 10, 2019
3874660
added function "plot.chain"
olli0601 Jul 10, 2019
401ada8
updated help, and syntax changes to network functions
olli0601 Jul 16, 2019
161e695
added missing man page
olli0601 Jul 16, 2019
298752e
ggnet2 is now part of GGally
Jul 18, 2019
57926f7
bugfix in determining ML chain, thanks Matthew
olli0601 Jul 19, 2019
4acdd56
Merge branch 'ordev' of https://github.com/BDI-pathogens/phyloscanner…
olli0601 Jul 19, 2019
27d59d8
Namespace change
Aug 6, 2019
3af5acb
Merge branch 'ordev' of https://github.com/BDI-pathogens/phyloscanner…
Aug 6, 2019
fee9ae6
bugfix to "find.most.likely.chains.RBGLedmonds" when ties are present
olli0601 Aug 27, 2019
05c16a8
Merge branch 'ordev' of https://github.com/BDI-pathogens/phyloscanner…
olli0601 Aug 27, 2019
80e9be2
updated NAMESPACE (need network for plot.network)
olli0601 Aug 27, 2019
8e54586
update Namespace using importFrom
olli0601 Aug 27, 2019
f6a153c
added vignette "reconstruct_transmission_networks.Rmd"
olli0601 Sep 2, 2019
597efe8
added casting to SIMMAP trees
olli0601 Sep 9, 2019
7766ef4
added phyloflows vignette: first example
olli0601 Sep 10, 2019
99495af
updated and added phyloflow vignettes
olli0601 Sep 10, 2019
0a8d6d8
File name typo in example
Oct 1, 2019
1db3964
Changed find.pairs.in.networks to work without reading from files. Ch…
Oct 1, 2019
3772fd8
Updated for new unnest() syntax
Oct 11, 2019
2c3aaca
Updates to .gitignore
Oct 11, 2019
6d61089
prj update
olli0601 Oct 29, 2019
71c235e
added man files
olli0601 Oct 29, 2019
e0f79cf
Merge remote-tracking branch 'origin/ordev' into ordev
olli0601 Oct 29, 2019
d0a8c72
restored previous find.networks, updated plotting
olli0601 Nov 21, 2019
66db2e3
updated find.pairs.in.networks
olli0601 Nov 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions InfoAndInputs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
1 change: 1 addition & 0 deletions phyloscannerR/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.Rproj.user
.Rhistory
.RData
.DS_Store
2 changes: 1 addition & 1 deletion phyloscannerR/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Version: 1.8.0
Authors@R: c(person("Matthew", "Hall", email = "[email protected]", role = c("aut", "cre")), person("Chris", "Wymant", email = "[email protected]", role = c("aut")), person("Oliver", "Ratmann", email = "[email protected]", role = c("aut")))
Description: An R package for the second half of phyloscanner (tree analysis).
Depends: R (>= 3.4.0)
Imports: ape, argparse, extraDistr, ff, GGally, ggtree, grid, gtable, kimisc, network, pegas, phangorn, phytools, prodlim, RColorBrewer, reshape2, scales, sna, tidyverse, treeio (>= 1.6.2), viridis
Imports: ape, argparse, extraDistr, ff, GGally, ggtree, grid, gtable, kimisc, network, pegas, phangorn, phytools, prodlim, RColorBrewer, reshape2, RBGL, scales, sna, tidyverse, treeio (>= 1.6.2), viridis
License: GPL
Encoding: UTF-8
LazyData: true
Expand Down
16 changes: 16 additions & 0 deletions phyloscannerR/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ export(downsample.host)
export(downsample.tree)
export(draw.summary.statistics)
export(drop.tip.get.map)
export(extract.subgraph)
export(extract.subtrees.for.hosts)
export(extract.tt.subgraph)
export(find.bam.and.references)
export(find.duplicate.tips)
export(find.gaps)
export(find.networks)
export(find.pairs.in.networks)
export(form.rectangles)
export(gather.summary.statistics)
export(get.ancestral.sequence)
Expand Down Expand Up @@ -110,6 +113,9 @@ export(phyloscanner.analyse.tree)
export(phyloscanner.analyse.trees)
export(phyloscanner.generate.blacklist)
export(phyloscanner.reconstruct)
export(phyloscanner.to.simmap)
export(plot.chain)
export(plot.network)
export(prepare.tree)
export(process.tree)
export(produce.host.graphs)
Expand All @@ -127,6 +133,7 @@ export(reconstruct.host.ancestral.sequences)
export(rename.blacklisted.tips)
export(resolve.tree.into.host.clades)
export(select.windows.by.read.and.tip.count)
export(simmap.to.phyloscanner)
export(simplified.transmission.summary)
export(simplify.summary)
export(simplify.summary.multinomial)
Expand All @@ -141,9 +148,12 @@ export(transmission.summary)
export(write.ann.nexus)
export(write.ann.tree)
export(write.annotated.tree)
import(GGally)
import(RColorBrewer)
import(dplyr)
import(ggplot2)
import(ggtree)
import(glue)
import(grid)
import(gtable)
import(purrr)
Expand All @@ -152,6 +162,7 @@ import(tidyr)
import(tidyverse)
import(viridis)
importFrom(GGally,ggnet2)
importFrom(RBGL,edmondsOptimumBranching)
importFrom(ape,.compressTipLabel)
importFrom(ape,.uncompressTipLabel)
importFrom(ape,as.DNAbin)
Expand All @@ -175,7 +186,11 @@ importFrom(ggtree,geom_point2)
importFrom(ggtree,geom_tiplab)
importFrom(ggtree,geom_treescale)
importFrom(ggtree,ggtree)
importFrom(igraph,clusters)
importFrom(igraph,graph.data.frame)
importFrom(igraph,igraph.to.graphNEL)
importFrom(network,as.network.matrix)
importFrom(network,network)
importFrom(phangorn,Ancestors)
importFrom(phangorn,Children)
importFrom(phangorn,Descendants)
Expand All @@ -188,6 +203,7 @@ importFrom(phangorn,phyDat2alignment)
importFrom(phangorn,pml)
importFrom(phytools,nodeheight)
importFrom(readr,read_csv)
importFrom(reshape2,dcast)
importFrom(reshape2,melt)
importFrom(scales,pretty_breaks)
importFrom(tibble,as.tibble)
Expand Down
File renamed without changes.
37 changes: 27 additions & 10 deletions phyloscannerR/R/main_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ blacklist <- function(ptrees,
#' @importFrom tidyr unnest
#' @importFrom phangorn Ancestors Descendants Children mrca.phylo getRoot
#' @export phyloscanner.analyse.trees
#' @seealso \code{\link{find.pairs.in.networks}}, \code{\link{find.networks}}
#' @example inst/example/ex.phyloscanner.analyse.trees.R
#'
phyloscanner.analyse.trees <- function(
Expand Down Expand Up @@ -1253,7 +1254,7 @@ multipage.summary.statistics <- function(ptrees, sum.stats, hosts = all.hosts.fr
#' @import ggplot2
#' @export write.annotated.tree

write.annotated.tree <- function(ptree, file.name, format = c("pdf", "nex"), pdf.scale.bar.width = 0.01, pdf.w = 50, pdf.hm = 0.15, verbose = F){
write.annotated.tree <- function(ptree, file.name, format = c("pdf", "nex", "ggplot"), tree.colours=NULL, pdf.scale.bar.width = 0.01, pdf.w = 50, pdf.hm = 0.15, verbose = F){
tree <- ptree$tree
read.counts <- ptree$read.counts

Expand All @@ -1266,12 +1267,26 @@ write.annotated.tree <- function(ptree, file.name, format = c("pdf", "nex"), pdf

if(verbose) cat(paste0("Writing .",format," tree to file ",file.name,"\n"))

if(format == "pdf"){
if(!format %in% c("pdf","nex","ggplot")){
stop("Unknown tree output format")
}

if(format == "nex"){
write.ann.nexus(tree, file=file.name, annotations = c("INDIVIDUAL", "SPLIT", "READ_COUNT"))
}

if(is.null(tree.colours)){
hue.pal <- scales:::hue_pal(h= c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1)
tree.colours <- hue.pal(length(levels(attr(tree,'INDIVIDUAL'))))
names(tree.colours) <- levels(attr(tree,'INDIVIDUAL'))
}

if(format %in% c("pdf","ggplot")){

tree.display <- ggtree(tree, aes(color=BRANCH_COLOURS)) +
tree.display <- ggtree(tree, aes(color=BRANCH_COLOURS)) +
geom_point2(aes(subset=SUBGRAPH_MRCA, color=INDIVIDUAL), shape = 23, size = 3, fill="white") +
geom_point2(aes(color=INDIVIDUAL, shape=BLACKLISTED), size=1) +
scale_color_hue(na.value = "black", drop=F) +
scale_color_manual(values=tree.colours, na.value = "black", drop=F) +
scale_shape_manual(values=c(16, 4)) +
theme(legend.position="none") +
geom_tiplab(aes(col=INDIVIDUAL)) +
Expand All @@ -1296,12 +1311,14 @@ write.annotated.tree <- function(ptree, file.name, format = c("pdf", "nex"), pdf

tree.display <- tree.display + ggplot2::xlim(0, 1.1*x.max)
tree.display
ggsave(file.name, device="pdf", height = pdf.hm*length(tree$tip.label), width = pdf.w, limitsize = F)

} else if(format == "nex"){
write.ann.nexus(tree, file=file.name, annotations = c("INDIVIDUAL", "SPLIT", "READ_COUNT"))
} else {
stop("Unknown tree output format")
}

if(format == "pdf"){
ggsave(file.name, device="pdf", height = pdf.hm*length(tree$tip.label), width = pdf.w, limitsize = F)
}

if(format == "ggplot"){
return(tree.display)
}
}

Expand Down
2 changes: 1 addition & 1 deletion phyloscannerR/R/parsimony_reconstruction_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ split.hosts.to.subgraphs <- function(tree,
rs.subgraphs <- rs.subgraphs %>%
mutate(host = map_chr(subgraph, function(x) unlist(strsplit(x, "-SPLIT"))[1]),
tip = map(subgraph, function(x) tree$tip.label[results$split.tips[[x]]])) %>%
unnest() %>%
unnest(c(host, subgraph, tip)) %>%
select(host, subgraph, tip)

list(tree=tree, rs.subgraphs=rs.subgraphs)
Expand Down
Loading