### Install TransPhylo from GitHub Source: https://xavierdidelot.github.io/TransPhylo/articles/TransPhylo.html Use this command to install the TransPhylo package from the specified GitHub repository. ```R devtools::install_github('xavierdidelot/TransPhylo') ``` -------------------------------- ### simulateOutbreak usage examples Source: https://xavierdidelot.github.io/TransPhylo/reference/simulateOutbreak.html Examples of calling simulateOutbreak with default settings and with custom parameters for offspring distribution and outbreak dates. ```R simulateOutbreak() #> Colored phylogenetic tree #> Number of sampled individuals=3 #> Total number of hosts=5 simulateOutbreak(off.r=2,dateStartOutbreak=2010,dateT=2015) #> Note that rejection sampling was used 1 times #> Colored phylogenetic tree #> Number of sampled individuals=12 #> Total number of hosts=16 ``` -------------------------------- ### Plotting a ctree example Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ctree.html A basic example showing how to plot a ctree object generated by simulateOutbreak. ```R plot(simulateOutbreak()) ``` -------------------------------- ### Plotting a ptree example Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ptree.html Example of plotting a ptree object created from a random phylogenetic tree. ```R plot(ptreeFromPhylo(ape::rtree(5),2020)) ``` -------------------------------- ### plotTTree example usage Source: https://xavierdidelot.github.io/TransPhylo/reference/plotTTree.html An example of plotting a transmission tree by extracting it from a simulated outbreak. ```R plotTTree(extractTTree(simulateOutbreak()),2,1) ``` -------------------------------- ### ptreeFromPhylo example with ape::rtree Source: https://xavierdidelot.github.io/TransPhylo/reference/ptreeFromPhylo.html Example call converting a random ape phylo tree with 5 tips to a phylogenetic tree, with the last sample date set to 2020. The output shows the resulting tree has 5 sampled individuals. ```R ptreeFromPhylo(ape::rtree(5),2020) #> Phylogenetic tree #> Number of sampled individuals=5 ``` -------------------------------- ### inferTTree example usage Source: https://xavierdidelot.github.io/TransPhylo/reference/inferTTree.html A basic example of running the inferTTree function with a generated phylogenetic tree and 100 MCMC iterations. ```R inferTTree(ptreeFromPhylo(ape::rtree(5),2020),mcmcIterations=100) #> | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% ``` -------------------------------- ### plotCTree example usage Source: https://xavierdidelot.github.io/TransPhylo/reference/plotCTree.html A basic example of using plotCTree with a simulated outbreak dataset. ```R plotCTree(simulateOutbreak()) #> Note that rejection sampling was used 1 times ``` -------------------------------- ### Print ctree object example Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ctree.html Example of printing a ctree object generated by simulateOutbreak, including the expected console output. ```R print(simulateOutbreak()) #> Note that rejection sampling was used 1 times #> Colored phylogenetic tree #> Number of sampled individuals=1 #> Total number of hosts=1 ``` -------------------------------- ### plotTTree2 example usage Source: https://xavierdidelot.github.io/TransPhylo/reference/plotTTree2.html An example of plotting a transmission tree by extracting it from a simulated outbreak. ```R plotTTree2(extractTTree(simulateOutbreak())) #> Note that rejection sampling was used 1 times ``` -------------------------------- ### Print a transmission tree example Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ttree.html Example of printing a transmission tree object generated by simulateOutbreak and extracted via extractTTree. ```R print(extractTTree(simulateOutbreak())) #> Note that rejection sampling was used 1 times #> Transmission tree #> Number of sampled individuals=5 #> Total number of hosts=9 ``` -------------------------------- ### Example: extractTTree on simulated outbreak Source: https://xavierdidelot.github.io/TransPhylo/reference/extractTTree.html Example call to extractTTree with simulateOutbreak() and its expected output showing the transmission tree summary. ```r extractTTree(simulateOutbreak()) #> Transmission tree #> Number of sampled individuals=1 #> Total number of hosts=1 ``` -------------------------------- ### Load TransPhylo and ape libraries Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Initial setup to load the required R packages for phylogenetic and transmission tree analysis. ```R library(ape) library(TransPhylo) ``` -------------------------------- ### Load the TransPhylo library Source: https://xavierdidelot.github.io/TransPhylo/articles/TransPhylo.html Load the installed TransPhylo package into your R session. ```R library('TransPhylo') ``` -------------------------------- ### Example of phyloFromPTree with simulation Source: https://xavierdidelot.github.io/TransPhylo/reference/phyloFromPTree.html Converts a simulated outbreak tree into a phylo object and displays the resulting tree structure. ```R phyloFromPTree(extractPTree(simulateOutbreak())) #> #> Phylogenetic tree with 8 tips and 7 internal nodes. #> #> Tip labels: #> 1, 2, 3, 4, 5, 6, ... #> #> Rooted; includes branch lengths. ``` -------------------------------- ### Print a ptree object Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ptree.html Example of printing a ptree object generated from a simulated outbreak. ```R print(extractPTree(simulateOutbreak())) #> Phylogenetic tree #> Number of sampled individuals=1 ``` -------------------------------- ### Get date of last sample Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Retrieves the date of the last sample from the simulation object. ```R dateLastSample(simu) ## [1] 2007.964 ``` -------------------------------- ### Simulate outbreak Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Generates an outbreak simulation starting in 2005 and observed until 2008. ```R simu <- simulateOutbreak(neg=neg,pi=pi,off.r=off.r,w.shape=w.shape, w.scale=w.scale,dateStartOutbreak=2005,dateT=2008) ``` -------------------------------- ### Plotting a simulated outbreak ttree Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ttree.html Example of plotting a transmission tree generated from a simulated outbreak. ```R plot(extractTTree(simulateOutbreak())) ``` -------------------------------- ### makeTTree(off.r, off.p, pi, w.shape, w.scale, ws.shape, ws.scale, maxTime, nSampled) Source: https://xavierdidelot.github.io/TransPhylo/reference/makeTTree.html Simulates a transmission tree based on the provided parameters for offspring distribution, sampling probability, and generation/sampling time distributions. Returns a matrix with infection times, sampling times, and infector information. ```APIDOC ## makeTTree(off.r, off.p, pi, w.shape, w.scale, ws.shape, ws.scale, maxTime, nSampled) ### Description Simulates a transmission tree. ### Usage makeTTree(off.r, off.p, pi, w.shape, w.scale, ws.shape = w.shape, ws.scale = w.scale, maxTime = Inf, nSampled = NA) ### Arguments - **off.r** (numeric) - Required - First parameter of the negative binomial distribution for offspring number. - **off.p** (numeric) - Required - Second parameter of the negative binomial distribution for offspring number. - **pi** (numeric) - Required - Probability of sampling an infected individual. - **w.shape** (numeric) - Required - Shape parameter of the Gamma probability density function representing the generation time. - **w.scale** (numeric) - Required - Scale parameter of the Gamma probability density function representing the generation time. - **ws.shape** (numeric) - Optional - Shape parameter of the Gamma probability density function representing the sampling time. Defaults to w.shape. - **ws.scale** (numeric) - Optional - Scale parameter of the Gamma probability density function representing the sampling time. Defaults to w.scale. - **maxTime** (numeric) - Optional - Duration of simulation (can be Inf). Defaults to Inf. - **nSampled** (numeric) - Optional - Number of sampled individuals (can be NA for any). Defaults to NA. ### Value A N*3 matrix in the following format with one row per infected host, first column is time of infection, second column is time of sampling, third column is infector. ``` -------------------------------- ### simulateOutbreak() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Simulates an outbreak, generating a transmission tree and phylogenetic tree. ```APIDOC ## simulateOutbreak() ### Description Simulate an outbreak. ### Usage simulateOutbreak(...) ### Arguments - **...** - Parameters for the simulation. ### Value A list containing simulated trees. ``` -------------------------------- ### Plot the first simulated outbreak Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Visualize the phylogenetic and transmission trees for the first simulated outbreak. ```R plot(simu1) ``` -------------------------------- ### makeCTreeFromPTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Creates a transmission tree compatible with the provided phylogenetic tree. ```APIDOC ## makeCTreeFromPTree() ### Description Create a transmission tree compatible with the provided phylogenetic tree. ### Usage makeCTreeFromPTree(ptree, ...) ### Arguments - **ptree** - A phylogenetic tree (ptree) object. - **...** - Additional parameters. ### Value A combined tree (ctree) object. ``` -------------------------------- ### getOffspringDist(record, burnin = 0.5, k, show.plot = F) Source: https://xavierdidelot.github.io/TransPhylo/reference/getOffspringDist.html Extracts and returns the offspring distribution of given sampled case(s) from MCMC output produced by inferTTree. The function returns a vector or matrix of posterior offspring distributions depending on the number of cases specified. ```APIDOC ## getOffspringDist(record, burnin = 0.5, k, show.plot = F) ### Description Extract and return offspring distribution of given sampled case(s). ### Usage ```r getOffspringDist(record, burnin = 0.5, k, show.plot = F) ``` ### Arguments - **record** - MCMC output produced by inferTTree - **burnin** - Proportion of the MCMC output to be discarded as burnin (default: 0.5) - **k** - Case(s) whose offspring distribution are to be extracted. Either a string matching one of the case names in the data, or a vector of such strings - **show.plot** - Show a barplot of the distribution (default: FALSE) ### Value Posterior offspring distribution for the case(s) in k. If length(k)==1 then a vector is returned, otherwise a matrix. ``` -------------------------------- ### Assess MCMC convergence with CODA Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Uses the CODA package to calculate the effective sample size (ESS) of parameters. ```R library(coda) mcmc=convertToCoda(res) effectiveSize(mcmc) ``` -------------------------------- ### Visualize simulation Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Plots the colored phylogenetic tree representing the transmission and within-host trees. ```R plot(simu) ``` -------------------------------- ### Define simulation parameters Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Specifies the effective within-host population size, reproduction number, generation time distribution, and sampling density. ```R neg=100/365 off.r=5 w.shape=10 w.scale=0.1 pi=0.25 ``` -------------------------------- ### print(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ctree.html S3 method for ctree objects that prints details of the colored phylogenetic tree. ```APIDOC ## print(x, ...) ### Description Print function for ctree objects, i.e. colored phylogenetic trees. ### Usage print(x, ...) ### Arguments - **x** (ctree) - Required - Object of class ctree, i.e. a colored phylogenetic tree. - **...** - Optional - Additional parameters are passed on. ### Value Print out details of the ctree. ### Examples ```r print(simulateOutbreak()) #> Note that rejection sampling was used 1 times #> Colored phylogenetic tree #> Number of sampled individuals=1 #> Total number of hosts=1 ``` ``` -------------------------------- ### simulateOutbreak function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/simulateOutbreak.html The function signature for simulateOutbreak with default parameter values. ```R simulateOutbreak( off.r = 1, off.p = 0.5, neg = 0.25, nSampled = NA, pi = 0.5, w.shape = 2, w.scale = 1, ws.shape = NA, ws.scale = NA, w.mean = NA, w.std = NA, ws.mean = NA, ws.std = NA, dateStartOutbreak = 2000, dateT = Inf ) ``` -------------------------------- ### Plot MCMC traces Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Visualizes the MCMC iteration traces to check for stability. ```R plot(res) ``` -------------------------------- ### Run single and multiple tree inference with inferTTree and infer_multittree_share_param Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Extracts phylogenetic trees from simulated data and runs single tree inference for each tree separately, then runs joint inference using infer_multittree_share_param while sharing parameters neg, off.r, off.p, and pi. The off.p parameter is included but not updated by default. The beta prior parameters are set to 1 for a uniform prior on the sampling rate. ```R ptree1 <- extractPTree(simu1) ptree2 <- extractPTree(simu2) iters <- 2e3; thin <- 10 record_tp1 <- inferTTree(ptree1, w.shape, w.scale, ws.shape, ws.scale, mcmcIterations = iters, thinning = thin, dateT = 2005) record_tp2 <- inferTTree(ptree2, w.shape, w.scale, ws.shape, ws.scale, mcmcIterations = iters, thinning = thin, dateT = 2005) record_tpj <- infer_multittree_share_param(list(ptree1,ptree2), w.shape, w.scale, ws.shape, ws.scale, mcmcIterations = iters, thinning = thin, dateT = 2005, share = c("neg", "off.r", "off.p", "pi")) ``` -------------------------------- ### probTTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Calculates the log-probability of a transmission tree. ```APIDOC ## probTTree() ### Description Calculates the log-probability of a transmission tree. ### Usage probTTree(ttree, ...) ### Arguments - **ttree** - A transmission tree (ttree) object. - **...** - Additional parameters. ### Value The log-probability value. ``` -------------------------------- ### consTTree(record, burnin = 0.5, minimum = 0.2, debug = F) Source: https://xavierdidelot.github.io/TransPhylo/reference/consTTree.html Builds a consensus transmission tree from an MCMC output. The function discards a proportion of the MCMC output as burnin and includes partitions with a minimum probability in the consensus. ```APIDOC ## consTTree(record, burnin = 0.5, minimum = 0.2, debug = F) ### Description Builds a consensus transmission tree from an MCMC output. ### Usage consTTree(record, burnin = 0.5, minimum = 0.2, debug = F) ### Arguments - **record** - Output from inferTTree function. - **burnin** - Proportion of the MCMC output to be discarded as burnin. - **minimum** - Minimum probability for inclusion of a partition in the consensus. - **debug** - Used for debugging. ### Value The consensus transmission tree. ``` -------------------------------- ### Plot the second simulated outbreak Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Visualize the phylogenetic and transmission trees for the second simulated outbreak. ```R plot(simu2) ``` -------------------------------- ### getOffspringDist() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Extracts and returns offspring distribution of given sampled case(s). ```APIDOC ## getOffspringDist() ### Description Extract and return offspring distribution of given sampled case(s). ### Usage getOffspringDist(res, k, ...) ### Arguments - **res** - An object of class resTransPhylo. - **k** - Index of sampled case(s). - **...** - Additional parameters. ### Value A vector of offspring counts. ``` -------------------------------- ### ptreeFromPhylo() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Converts an ape phylo object into a phylogenetic tree. ```APIDOC ## ptreeFromPhylo() ### Description Converts an ape phylo object into a phylogenetic tree. ### Usage ptreeFromPhylo(phylo) ### Arguments - **phylo** - An ape phylo object. ### Value A phylogenetic tree (ptree) object. ``` -------------------------------- ### phyloFromPTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Converts a phylogenetic tree into an ape phylo object. ```APIDOC ## phyloFromPTree() ### Description Converts a phylogenetic tree into an ape phylo object. ### Usage phyloFromPTree(ptree) ### Arguments - **ptree** - A phylogenetic tree (ptree) object. ### Value An ape phylo object. ``` -------------------------------- ### plotTTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plots a transmission tree in a detailed format. ```APIDOC ## plotTTree() ### Description Plot a transmission tree in a detailed format. ### Usage plotTTree(ttree, ...) ### Arguments - **ttree** - A transmission tree (ttree) object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### computeMatWIW(record, burnin = 0.5) Source: https://xavierdidelot.github.io/TransPhylo/reference/computeMatWIW.html Builds a matrix of probability of who infected whom from a MCMC output. The function takes the output from inferTTree and an optional burnin proportion, and returns a matrix of infection probabilities. ```APIDOC ## computeMatWIW(record, burnin = 0.5) ### Description Builds a matrix of probability of who infected whom from a MCMC output. ### Usage computeMatWIW(record, burnin = 0.5) ### Arguments - **record** - Output from inferTTree function - **burnin** - Proportion of the MCMC output to be discarded as burnin ### Value Matrix of probability of who infected whom ``` -------------------------------- ### plotTraces() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plots MCMC traces. ```APIDOC ## plotTraces() ### Description Plot MCMC traces. ### Usage plotTraces(res, ...) ### Arguments - **res** - An object of class resTransPhylo. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### plotTTree2() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plots a transmission tree in an economic format. ```APIDOC ## plotTTree2() ### Description Plot a transmission tree in an economic format. ### Usage plotTTree2(ttree, ...) ### Arguments - **ttree** - A transmission tree (ttree) object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### print() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Print function for ptree objects. ```APIDOC ## print() ### Description Print function for ptree objects. ### Usage print(x, ...) ### Arguments - **x** - A ptree object. - **...** - Additional printing parameters. ### Value No return value, used for printing. ``` -------------------------------- ### probTTreeR() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Calculates the log-probability of a transmission tree (R implementation). ```APIDOC ## probTTreeR() ### Description Calculates the log-probability of a transmission tree. ### Usage probTTreeR(ttree, ...) ### Arguments - **ttree** - A transmission tree (ttree) object. - **...** - Additional parameters. ### Value The log-probability value. ``` -------------------------------- ### plot() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plotting for ptree objects. ```APIDOC ## plot() ### Description Plotting for ptree. ### Usage plot(x, ...) ### Arguments - **x** - A ptree object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### Set generation time parameters Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Defines the shape and scale parameters for the Gamma distribution of generation times. ```R w.shape=10 w.scale=0.1 ``` -------------------------------- ### getGenerationTimeDist(record, burnin, maxi, numBins, show.plot) Source: https://xavierdidelot.github.io/TransPhylo/reference/getGenerationTimeDist.html Extracts and returns the realised generation time distribution from MCMC output. It allows specifying burnin proportion, maximum generation time, number of bins, and whether to show a plot. ```APIDOC ## getGenerationTimeDist(record, burnin, maxi, numBins, show.plot) ### Description Extract and return realised generation time distribution. ### Usage ``` getGenerationTimeDist( record, burnin = 0.5, maxi = 2, numBins = 20, show.plot = F ) ``` ### Arguments - **record** - MCMC output produced by inferTTree - **burnin** - Proportion of the MCMC output to be discarded as burnin - **maxi** - Maximum generation time to consider - **numBins** - Number of time bins to compute and display distribution - **show.plot** - Show a barplot of the distribution ### Value Vector of times between becoming infected and infecting others (generation times) in the posterior ``` -------------------------------- ### print() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Print function for ctree objects. ```APIDOC ## print() ### Description Print function for ctree objects. ### Usage print(x, ...) ### Arguments - **x** - A ctree object. - **...** - Additional printing parameters. ### Value No return value, used for printing. ``` -------------------------------- ### plot() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plotting for ctree objects. ```APIDOC ## plot() ### Description Plotting for ctree. ### Usage plot(x, ...) ### Arguments - **x** - A ctree object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### Run MCMC inference Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Executes the MCMC procedure to infer the transmission tree. ```R res<-inferTTree(ptree,mcmcIterations=1000,w.shape=w.shape,w.scale=w.scale,dateT=dateT) ``` -------------------------------- ### Plot offspring distribution for specific individuals Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Plots the offspring distribution for individuals '1' and '2'. ```R a=getOffspringDist(res,k=c('1','2'),show.plot = T) ``` -------------------------------- ### computeMatTDist(record, burnin = 0.5) Source: https://xavierdidelot.github.io/TransPhylo/reference/computeMatTDist.html Builds a matrix indicating for each pair of individuals how many intermediates there are in the transmission chain. It takes the output from the inferTTree function and an optional burnin proportion, and returns a matrix of intermediates. ```APIDOC ## computeMatTDist(record, burnin = 0.5) ### Description Builds a matrix indicating for each pair of individuals how many intermediates there are in the transmission chain. ### Usage computeMatTDist(record, burnin = 0.5) ### Arguments - **record** - Output from inferTTree function - **burnin** - Proportion of the MCMC output to be discarded as burnin ### Value Matrix of intermediates in transmission chains between pairs of hosts ``` -------------------------------- ### print() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Print function for ttree objects. ```APIDOC ## print() ### Description Print function for ttree objects. ### Usage print(x, ...) ### Arguments - **x** - A ttree object. - **...** - Additional printing parameters. ### Value No return value, used for printing. ``` -------------------------------- ### getOffspringDist function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/getOffspringDist.html The function signature for extracting the offspring distribution from MCMC output. ```R getOffspringDist(record, burnin = 0.5, k, show.plot = F) ``` -------------------------------- ### getSamplingTimeDist(record, burnin, maxi, numBins, show.plot) Source: https://xavierdidelot.github.io/TransPhylo/reference/getSamplingTimeDist.html Extracts and returns the realised sampling time distribution from MCMC output. The function returns a vector of times between becoming infected and becoming sampled in the posterior. ```APIDOC ## getSamplingTimeDist(record, burnin, maxi, numBins, show.plot) ### Description Extracts and returns the realised sampling time distribution from MCMC output. The function returns a vector of times between becoming infected and becoming sampled in the posterior. ### Usage ``` getSamplingTimeDist( record, burnin = 0.5, maxi = 2, numBins = 20, show.plot = F ) ``` ### Arguments - **record** - MCMC output produced by inferTTree. - **burnin** - Proportion of the MCMC output to be discarded as burnin. Default is 0.5. - **maxi** - Maximum generation time to consider. Default is 2. - **numBins** - Number of time bins to compute and display distribution. Default is 20. - **show.plot** - Show a barplot of the distribution. Default is FALSE. ### Value Vector of times between becoming infected and becoming sampled in the posterior. ``` -------------------------------- ### plotCTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plots both phylogenetic and transmission trees using colors on the phylogeny. ```APIDOC ## plotCTree() ### Description Plot both phylogenetic and transmission trees using colors on the phylogeny. ### Usage plotCTree(ctree, ...) ### Arguments - **ctree** - A combined tree (ctree) object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### plot() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Plotting for ttree objects. ```APIDOC ## plot() ### Description Plotting for ttree. ### Usage plot(x, ...) ### Arguments - **x** - A ttree object. - **...** - Additional plotting parameters. ### Value No return value, used for plotting. ``` -------------------------------- ### summary(object, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/summary.resTransPhylo.html S3 method for resTransPhylo objects that prints details of TransPhylo results. The object is the output from inferTTree, and additional arguments are passed to print.phylo. ```APIDOC ## summary(object, ...) ### Description S3 method for resTransPhylo objects that prints details of TransPhylo results. ### Usage summary(object, ...) ### Arguments - **object** - Output from inferTTree. - **...** - Passed on to print.phylo. ### Value Print out details of TransPhylo results. ``` -------------------------------- ### print(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/print.resTransPhylo.html S3 method for resTransPhylo objects that prints out details of TransPhylo results. ```APIDOC ## print(x, ...) ### Description S3 method for resTransPhylo objects that prints out details of TransPhylo results. ### Method print ### Signature print(x, ...) ### Parameters - **x** - output from inferTTree - **...** - Additional parameters are passed on ### Value Print out details of TransPhylo results ``` -------------------------------- ### Extract and plot phylogenetic tree Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Extracts the phylogenetic tree from the simulation and displays it. ```R ptree<-extractPTree(simu) plot(ptree) ``` -------------------------------- ### selectTTree function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/selectTTree.html The basic syntax for calling the selectTTree function. ```R selectTTree(record, burnin = 0.5) ``` -------------------------------- ### Find and plot medoid tree Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Identifies the most representative (medoid) tree from the MCMC sample and plots it. ```R med=medTTree(res) plot(med) ``` -------------------------------- ### computeMatTDist() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Builds a matrix indicating for each pair of individuals how many intermediates there are in the transmission chain. ```APIDOC ## computeMatTDist() ### Description Build a matrix indicating for each pairs of individuals how many intermediates there are in the transmission chain. ### Usage computeMatTDist(res, ...) ### Arguments - **res** - An object of class resTransPhylo. - **...** - Additional parameters. ### Value A matrix of distances. ``` -------------------------------- ### S3 method for ptree print signature Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ptree.html The signature for the print method for ptree objects. ```R # S3 method for ptree print(x, ...) ``` -------------------------------- ### Display Newick string Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Prints the Newick representation of the tree to the console. ```R write.tree(p,'') ## [1] "((4:1.257652937,(1:1.231048819,5:1.519248672):0.303038892):0.784065883,(3:1.643413444,(6:0.656820028,2:0.007344035611):0.7562780805):1.293120815);" ``` -------------------------------- ### infer_multittree_share_param function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/infer_multittree_share_param.html The function signature for infer_multittree_share_param, showing all available parameters including the 'share' argument for parameter sharing. ```R infer_multittree_share_param( ptree_lst, w.shape = 2, w.scale = 1, ws.shape = w.shape, ws.scale = w.scale, mcmcIterations = 1000, thinning = 1, startNeg = 100/365, startOff.r = 1, startOff.p = 0.5, startPi = 0.5, prior_pi_a = 1, prior_pi_b = 1, updateNeg = TRUE, updateOff.r = TRUE, updateOff.p = FALSE, updatePi = TRUE, share = NULL, startCTree_lst = rep(NA, length(ptree_lst)), updateTTree = TRUE, optiStart = 2, dateT = Inf, delta_t = 0.01, verbose = F ) ``` -------------------------------- ### Extract and plot transmission tree Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Extracts the transmission tree from the simulation and displays it. ```R ttree<-extractTTree(simu) plot(ttree) ``` -------------------------------- ### medTTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Returns the medoid from a MCMC output. ```APIDOC ## medTTree() ### Description Return the medoid from a MCMC output. ### Usage medTTree(res, ...) ### Arguments - **res** - An object of class resTransPhylo. - **...** - Additional parameters. ### Value The medoid transmission tree. ``` -------------------------------- ### plot(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ptree.html S3 method for ptree objects that plots the phylogenetic tree. Additional parameters are passed to ape::plot.phylo. ```APIDOC ## plot(x, ...) ### Description S3 method for ptree objects that plots the phylogenetic tree. Additional parameters are passed to ape::plot.phylo. ### Usage plot(x, ...) ### Arguments - **x** (ptree) - Required - Object of class ptree, i.e., a phylogenetic tree. - **...** - Optional - Additional parameters passed to ape::plot.phylo. ### Value Plot of ptree. ### Examples ```r plot(ptreeFromPhylo(ape::rtree(5), 2020)) ``` ``` -------------------------------- ### S3 method print.ctree signature Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ctree.html The signature for the S3 print method for ctree objects. ```R # S3 method for ctree print(x, ...) ``` -------------------------------- ### Extract and combine parameter estimates from three runs Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Defines a helper function get_param_estimates to extract a named parameter from each element of a record list. Builds a data frame with columns run, pi, off.r, and neg, combining estimates from record_tp1, record_tp2, and record_tpj[[1]]. The run column labels each group as tp1, tp2, or tp_multitree. ```R get_param_estimates <- function(record, p){ sapply(record, function(x) x[[p]]) } df <- data.frame(run = rep(c("tp1","tp2","tp_multitree"), each = length(record_tp1)), pi = c(get_param_estimates(record_tp1, "pi"), get_param_estimates(record_tp2, "pi"), get_param_estimates(record_tpj[[1]], "pi")), off.r = c(get_param_estimates(record_tp1, "off.r"), get_param_estimates(record_tp2, "off.r"), get_param_estimates(record_tpj[[1]], "off.r")), neg = c(get_param_estimates(record_tp1, "neg"), get_param_estimates(record_tp2, "neg"), get_param_estimates(record_tpj[[1]], "neg"))) ``` -------------------------------- ### Convert TransPhylo output to coda mcmc format Source: https://xavierdidelot.github.io/TransPhylo/reference/as.mcmc.resTransPhylo.html Converts the result of inferTTree into an mcmc object, with an optional burnin parameter to discard a portion of the MCMC output. ```R as.mcmc.resTransPhylo(x, burnin = 0.5) ``` -------------------------------- ### probPTreeGivenTTreeR() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Calculates the probability of a phylogenetic tree given a transmission tree (R implementation). ```APIDOC ## probPTreeGivenTTreeR() ### Description Calculate the probability of a phylogenetic tree given a transmission tree. ### Usage probPTreeGivenTTreeR(ctree, ...) ### Arguments - **ctree** - A combined tree (ctree) object. - **...** - Additional parameters. ### Value The probability value. ``` -------------------------------- ### print(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ttree.html S3 method for ttree objects that prints details of the transmission tree. It accepts the ttree object and optional additional arguments. ```APIDOC ## print(x, ...) ### Description S3 method for ttree objects that prints out details of the transmission tree. ### Usage print(x, ...) ### Arguments - **x** (ttree) - Required - Object of class ttree, i.e., a transmission tree. - **...** - Optional - Additional parameters are passed on. ### Value Print out details of the ttree. ### Examples ```r print(extractTTree(simulateOutbreak())) #> Note that rejection sampling was used 1 times #> Transmission tree #> Number of sampled individuals=5 #> Total number of hosts=9 ``` ``` -------------------------------- ### as.mcmc.resTransPhylo() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Converts TransPhylo results to coda mcmc format. ```APIDOC ## as.mcmc.resTransPhylo() ### Description Convert to coda mcmc format. ### Usage as.mcmc.resTransPhylo(res) ### Arguments - **res** - An object of class resTransPhylo. ### Value An mcmc object. ``` -------------------------------- ### plotTraces function usage Source: https://xavierdidelot.github.io/TransPhylo/reference/plotTraces.html Basic syntax for calling the plotTraces function to visualize MCMC traces. ```R plotTraces(record, burnin = 0, extend = F) ``` -------------------------------- ### Load and plot dated phylogeny Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Loads a dated phylogeny tree and visualizes it. ```R library(ape) phy<-read.tree(text='((4:1.257652937,(1:1.231048819,5:1.519248672):0.303038892):0.784065883,(3:1.643413444,(6:0.656820028,2:0.007344035611):0.7562780805):1.293120815);') plot(phy) axisPhylo(backward = F) ``` -------------------------------- ### summary() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Summary function for resTransPhylo objects. ```APIDOC ## summary() ### Description Summary function for resTransPhylo objects. ### Usage summary(object, ...) ### Arguments - **object** - A resTransPhylo object. - **...** - Additional summary parameters. ### Value A summary object. ``` -------------------------------- ### print(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ptree.html S3 method for ptree objects that prints details of the phylogenetic tree. It accepts an object of class ptree and optional additional parameters. ```APIDOC ## print(x, ...) ### Description Print function for ptree objects. Prints out details of the ptree. ### Method S3 method for ptree ### Signature print(x, ...) ### Parameters - **x** (ptree) - Required - Object of class ptree, i.e., a phylogenetic tree. - **...** - Optional - Additional parameters are passed on. ### Value Print out details of the ptree. ### Example ```r print(extractPTree(simulateOutbreak())) #> Phylogenetic tree #> Number of sampled individuals=1 ``` ``` -------------------------------- ### plotTraces(record, burnin = 0, extend = F) Source: https://xavierdidelot.github.io/TransPhylo/reference/plotTraces.html Plots MCMC traces from the output of the inferTTree function. The burnin argument specifies the proportion of the MCMC output to discard, and extend controls whether to also show traces of off.r and off.p. ```APIDOC ## plotTraces(record, burnin = 0, extend = F) ### Description Plots MCMC traces from the output of the inferTTree function. ### Usage plotTraces(record, burnin = 0, extend = F) ### Arguments - **record** - Output from inferTTree function. - **burnin** - Proportion of the MCMC output to be discarded as burnin. - **extend** - Whether to also show traces of off.r and off.p. ### Value Returns invisibly the first parameter. ``` -------------------------------- ### dateLastSample(x) Source: https://xavierdidelot.github.io/TransPhylo/reference/dateLastSample.html Returns the date of the last sample from a transmission tree, colored tree, or phylogenetic tree. ```APIDOC ## dateLastSample(x) ### Description Returns the date of the last sample from a transmission tree, colored tree, or phylogenetic tree. ### Usage ```r dateLastSample(x) ``` ### Arguments - **x** - A transmission tree or colored tree or phylogenetic tree. ### Value The date of the last sample. ``` -------------------------------- ### Save tree to Newick file Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Exports the phylogenetic tree to a Newick file for use in inference tutorials. ```R write.tree(p,'tree.nwk') ``` -------------------------------- ### Usage of phyloFromPTree Source: https://xavierdidelot.github.io/TransPhylo/reference/phyloFromPTree.html Basic syntax for converting a phylogenetic tree object. ```R phyloFromPTree(ptree) ``` -------------------------------- ### Plot infection time distribution for specific individuals Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Plots the distribution of infection times for individuals '1' and '2'. ```R a=getInfectionTimeDist(res,k=c('1','2'),show.plot = T) ``` -------------------------------- ### getIncidentCases function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/getIncidentCases.html The function signature for getIncidentCases, showing parameters for MCMC burnin, binning, date constraints, and plotting. ```R getIncidentCases( record, burnin = 0.5, numBins = 10, dateT = NA, show.plot = FALSE ) ``` -------------------------------- ### print() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Print function for resTransPhylo objects. ```APIDOC ## print() ### Description Print function for resTransPhylo objects. ### Usage print(x, ...) ### Arguments - **x** - A resTransPhylo object. - **...** - Additional printing parameters. ### Value No return value, used for printing. ``` -------------------------------- ### getSamplingTimeDist() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Extracts and returns realised sampling time distribution. ```APIDOC ## getSamplingTimeDist() ### Description Extract and return realised sampling time distribution. ### Usage getSamplingTimeDist(res, ...) ### Arguments - **res** - An object of class resTransPhylo. - **...** - Additional parameters. ### Value A vector of sampling times. ``` -------------------------------- ### probPTreeGivenTTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Calculates the probability of a phylogenetic tree given a transmission tree. ```APIDOC ## probPTreeGivenTTree() ### Description Calculate the probability of a phylogenetic tree given a transmission tree. ### Usage probPTreeGivenTTree(ctree, ...) ### Arguments - **ctree** - A combined tree (ctree) object. - **...** - Additional parameters. ### Value The probability value. ``` -------------------------------- ### Convert and plot phylo object Source: https://xavierdidelot.github.io/TransPhylo/articles/simulate.html Converts the extracted phylogenetic tree to an ape phylo object and plots it with a time axis. ```R library(ape) p<-phyloFromPTree(ptree) plot(p) axisPhylo(backward = F) ``` -------------------------------- ### selectTTree() Source: https://xavierdidelot.github.io/TransPhylo/reference/index.html Selects the most representative transmission tree from a MCMC output. ```APIDOC ## selectTTree() ### Description Select the most representative transmission tree from a MCMC output. ### Usage selectTTree(res, ...) ### Arguments - **res** - An object of class resTransPhylo. - **...** - Additional parameters. ### Value The selected transmission tree. ``` -------------------------------- ### plot(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ctree.html S3 method for ctree objects that plots a colored phylogenetic tree. Additional parameters are passed on to the underlying plotting function. ```APIDOC ## plot(x, ...) ### Description S3 method for ctree objects that plots a colored phylogenetic tree. ### Usage plot(x, ...) ### Arguments - **x** (ctree) - Required - Object of class ctree, i.e., a colored phylogenetic tree. - **...** - Optional - Additional parameters are passed on. ### Value Plot of ctree ### Examples ```r plot(simulateOutbreak()) ``` ``` -------------------------------- ### Take the last 50% of MCMC samples Source: https://xavierdidelot.github.io/TransPhylo/articles/multitree.html Computes the indices for the last 50% of the MCMC iterations and subsets the recorded results for both single and multiple tree inference. The multiple tree inference returns a list of length two, each element corresponding to one input phylogenetic tree. ```R begin <- (iters * 0.5) / thin + 1 end <- iters / thin record_tp1 <- record_tp1[begin:end] record_tp2 <- record_tp2[begin:end] record_tpj[[1]] <- record_tpj[[1]][begin:end] record_tpj[[2]] <- record_tpj[[2]][begin:end] ``` -------------------------------- ### S3 method for ptree plot signature Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.ptree.html The signature for the plot method for ptree objects. ```R # S3 method for ptree plot(x, ...) ``` -------------------------------- ### S3 method for ttree print function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/print.ttree.html The signature for the print method for ttree objects. ```R # S3 method for ttree print(x, ...) ``` -------------------------------- ### ptreeFromPhylo function signature Source: https://xavierdidelot.github.io/TransPhylo/reference/ptreeFromPhylo.html Shows the usage of ptreeFromPhylo with arguments tr and dateLastSample. ```R ptreeFromPhylo(tr, dateLastSample) ``` -------------------------------- ### Extract and plot transmission tree Source: https://xavierdidelot.github.io/TransPhylo/articles/infer.html Extracts the transmission tree from the medoid tree and plots it in detail. ```R ttree=extractTTree(med) plot(ttree,type='detailed',w.shape,w.scale) ``` -------------------------------- ### plot(x, ...) Source: https://xavierdidelot.github.io/TransPhylo/reference/plot.resTransPhylo.html S3 method for resTransPhylo that plots TransPhylo results. The primary argument is the output from inferTTree, and additional parameters are passed on to the plotting function. ```APIDOC ## plot(x, ...) ### Description S3 method for resTransPhylo that plots TransPhylo results. ### Method S3 method for class resTransPhylo ### Signature plot(x, ...) ### Parameters - **x** - Output from inferTTree - **...** - Additional parameters are passed on ### Value Plot of TransPhylo results ```