### Install TransPhylo from GitHub using devtools Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/TransPhylo.html Install the TransPhylo package from GitHub using the devtools package. Run this command in R if you have not already installed TransPhylo. ```R devtools::install_github('xavierdidelot/TransPhylo') ``` -------------------------------- ### Example: plot(simulateOutbreak()) Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plot.ctree.html Example usage of plotting a ctree object generated by simulateOutbreak(). ```r plot(simulateOutbreak()) ``` -------------------------------- ### simulateOutbreak examples with output Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/simulateOutbreak.html Two example calls to simulateOutbreak with their console output. The first uses default parameters; the second specifies off.r, dateStartOutbreak, and dateT, and shows a rejection sampling note. ```R simulateOutbreak() #> Colored phylogenetic tree #> Number of sampled individuals=3 #> Total number of hosts=5 ``` ```R 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 ``` -------------------------------- ### Example: ptreeFromPhylo with ape::rtree(5) Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/ptreeFromPhylo.html Example usage of ptreeFromPhylo with a random tree of 5 tips and dateLastSample=2020. The output shows the resulting phylogenetic tree with 5 sampled individuals. ```r ptreeFromPhylo(ape::rtree(5),2020) #> Phylogenetic tree #> Number of sampled individuals=5 ``` -------------------------------- ### extractTTree example with simulateOutbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/extractTTree.html Example call to extractTTree using simulateOutbreak() as input, with the expected output showing a transmission tree with 1 sampled individual and 1 total host. ```r extractTTree(simulateOutbreak()) #> Transmission tree #> Number of sampled individuals=1 #> Total number of hosts=1 ``` -------------------------------- ### extractPTree example with simulateOutbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/extractPTree.html Example call to extractPTree with a simulated outbreak. The output shows a phylogenetic tree with one sampled individual. ```r extractPTree(simulateOutbreak()) #> Phylogenetic tree #> Number of sampled individuals=1 ``` -------------------------------- ### Example: plot a simulated ptree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plot.ptree.html Plots a ptree created from a random phylogenetic tree with 5 tips and a date of 2020. ```r plot(ptreeFromPhylo(ape::rtree(5),2020)) ``` -------------------------------- ### plotCTree example with simulateOutbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plotCTree.html Example usage of plotCTree with a simulated outbreak. The output note indicates rejection sampling was used once. ```r plotCTree(simulateOutbreak()) #> Note that rejection sampling was used 1 times ``` -------------------------------- ### Example: plotTTree2 with simulated outbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plotTTree2.html Example usage of plotTTree2 with a simulated outbreak. The output note indicates rejection sampling was used once. ```r plotTTree2(extractTTree(simulateOutbreak())) #> Note that rejection sampling was used 1 times ``` -------------------------------- ### inferTTree example: infer transmission tree from a random phylogenetic tree Source: https://github.com/xavierdidelot/transphylo/blob/master/man/inferTTree.Rd Calls inferTTree with a phylogenetic tree generated from a random tree of 5 tips using ape::rtree, dated to 2020, and runs 100 MCMC iterations. This is the minimal example shown in the documentation. ```R inferTTree(ptreeFromPhylo(ape::rtree(5),2020),mcmcIterations=100) ``` -------------------------------- ### plotTTree example with simulated outbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plotTTree.html Example usage of plotTTree with a simulated outbreak, extracting the transmission tree and specifying shape=2 and scale=1. ```r plotTTree(extractTTree(simulateOutbreak()),2,1) ``` -------------------------------- ### Load TransPhylo library in R Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/TransPhylo.html Load the TransPhylo package into your R session. This should be done after installation to access its functions. ```R library('TransPhylo') ``` -------------------------------- ### Print a simulated ctree object Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ctree.html Example of printing a simulated ctree object. The output shows the number of rejection sampling iterations, a colored phylogenetic tree, and counts of sampled individuals and total hosts. ```r print(simulateOutbreak()) #> Note that rejection sampling was used 1 times #> Colored phylogenetic tree #> Number of sampled individuals=1 #> Total number of hosts=1 ``` -------------------------------- ### Convert a simulated phylogenetic tree to an ape phylo object Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/phyloFromPTree.html Example usage of phyloFromPTree with the output of extractPTree(simulateOutbreak()). The output shows a phylogenetic tree with 8 tips and 7 internal nodes, with tip labels 1 through 8 and branch lengths included. ```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. ``` -------------------------------- ### Convert an ape phylo object to a phylogenetic tree with ptreeFromPhylo Source: https://github.com/xavierdidelot/transphylo/blob/master/man/ptreeFromPhylo.Rd Converts an ape phylo object into a phylogenetic tree. The example creates a random tree with 5 tips using ape::rtree and sets the date of the last sample to 2020. ```r ptreeFromPhylo(ape::rtree(5),2020) ``` -------------------------------- ### Print a ctree object Source: https://github.com/xavierdidelot/transphylo/blob/master/man/print.ctree.Rd Prints details of a ctree object. The example calls print on the result of simulateOutbreak(), which returns a ctree object. ```r print(simulateOutbreak()) ``` -------------------------------- ### Print a ptree object Source: https://github.com/xavierdidelot/transphylo/blob/master/man/print.ptree.Rd Prints details of a ptree object created from a simulated outbreak. The example uses extractPTree and simulateOutbreak functions. ```r print(extractPTree(simulateOutbreak())) ``` -------------------------------- ### Print a ttree object from simulated outbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ttree.html Example usage of print on a ttree object obtained from extractTTree(simulateOutbreak()). The output shows a note about rejection sampling, the transmission tree header, and counts of sampled individuals and total hosts. ```r print(extractTTree(simulateOutbreak())) #> Note that rejection sampling was used 1 times #> Transmission tree #> Number of sampled individuals=5 #> Total number of hosts=9 ``` -------------------------------- ### Simulate an outbreak with default parameters Source: https://github.com/xavierdidelot/transphylo/blob/master/man/simulateOutbreak.Rd Runs simulateOutbreak with all default parameters, producing a simulated outbreak with default settings. ```R simulateOutbreak() ``` -------------------------------- ### Print date of last sample Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-Tutorial.pdf Prints the date of the last sample from the simulation, which is needed for the second part of the tutorial. ```R print(max(simu$ctree[,1])) ``` -------------------------------- ### makeTTree Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Creates a transmission tree. ```APIDOC ## makeTTree ### Description Creates a transmission tree. ### Usage ```r makeTTree(...) ``` ### Arguments - **...** - Additional arguments. ``` -------------------------------- ### makeTTree: Simulate a transmission tree Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Simulates a transmission tree using negative binomial offspring distribution and gamma generation/sampling times. Returns a matrix with infection time, sampling time, and infector for each host. ```R makeTTree(off.r, off.p, pi, w.shape, w.scale, ws.shape, ws.scale, maxTime, nSampled) ``` -------------------------------- ### Get date of last sample Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/simulate.html Returns the date of the last sample in the simulated outbreak, which is needed to use the tree later. ```R dateLastSample(simu) ``` -------------------------------- ### Set simulation parameters (neg, off.r, w.shape, w.scale, pi) Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-Tutorial.pdf Specifies the effective population size per day (neg=100/365), the basic reproduction number (off.r=5), the shape and scale of the Gamma distribution for generation and sampling times (w.shape=10, w.scale=0.1), and the sampling density (pi=0.25). ```R neg=100/365 off.r=5 w.shape=10 w.scale=0.1 pi=0.25 ``` -------------------------------- ### Plot a simulated ttree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/plot.ttree.html Example usage of plot on a ttree object extracted from a simulated outbreak. This produces a plot of the transmission tree. ```r plot(extractTTree(simulateOutbreak())) ``` -------------------------------- ### plotCTree: Plot combined phylogenetic and transmission trees Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Plots both phylogenetic and transmission trees using colors on the phylogeny. The example shows usage with simulateOutbreak(). ```R plotCTree(tree, showLabels = TRUE, cols = NA, maxTime = NA) ``` ```R plotCTree(simulateOutbreak()) ``` -------------------------------- ### Extract phylogenetic tree with extractPTree Source: https://github.com/xavierdidelot/transphylo/blob/master/man/extractPTree.Rd Extracts the phylogenetic tree from a combined tree object. The example uses the output of simulateOutbreak() as the combined tree input. ```r extractPTree(simulateOutbreak()) ``` -------------------------------- ### Simulate an outbreak with custom parameters Source: https://github.com/xavierdidelot/transphylo/blob/master/man/simulateOutbreak.Rd Runs simulateOutbreak with off.r set to 2, dateStartOutbreak set to 2010, and dateT set to 2015, simulating an outbreak with a higher offspring rate and a specific time window. ```R simulateOutbreak(off.r=2,dateStartOutbreak=2010,dateT=2015) ``` -------------------------------- ### makeCTreeFromPTree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/makeCtreeFromPTree.html Documentation for the makeCTreeFromPTree function, which creates a transmission tree compatible with a provided phylogenetic tree. ```APIDOC ## makeCTreeFromPTree ### Description Creates a transmission tree compatible with the provided phylogenetic tree. ### Usage ```r makeCTreeFromPTree( ptree, off.r = NA, off.p = NA, neg = NA, pi = NA, w.shape = NA, w.scale = NA, ws.shape = NA, ws.scale = NA, T = NA, optiStart = 0 ) ``` ### Arguments - **ptree** - Phylogenetic tree - **off.r** - First parameter of the negative binomial distribution for offspring number - **off.p** - Second parameter of the negative binomial distribution for offspring number - **neg** - The within-host effective population size (Ne) times generation duration (g) - **pi** - Probability of sampling an infected individual - **w.shape** - Shape parameter of the Gamma probability density function representing the generation time - **w.scale** - Scale parameter of the Gamma probability density function representing the generation time - **ws.shape** - Shape parameter of the Gamma probability density function representing the sampling time - **ws.scale** - Scale parameter of the Gamma probability density function representing the sampling time - **T** - Date when process stops (this can be Inf for fully simulated outbreaks) - **optiStart** - Method used to optimised colored tree (0=none, 1=slow, 2=fast) ### Value A minimal non-zero probability phylogenetic+transmission tree, or an optimised version if parameters are provided. ``` -------------------------------- ### Load TransPhylo package Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-Tutorial.pdf Loads the TransPhylo package into the R session. The output 'Loading required package: ape' indicates that the ape package is also loaded. ```R library(TransPhylo) ``` -------------------------------- ### Compute effective sample size with convertToCoda and effectiveSize Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/infer.html Converts the MCMC result to a CODA object and computes the effective sample size (ESS) for each parameter. The ESS should be at least 100 for each parameter; the example output shows low ESS values, indicating poor mixing. ```r library(coda) mcmc=convertToCoda(res) effectiveSize(mcmc) ``` ```r ## pi neg off.r off.p ## 6.648218 3.688619 6.650971 0.000000 ``` -------------------------------- ### simulateOutbreak() Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/index.html Simulates an outbreak. ```APIDOC ## simulateOutbreak() ### Description Simulate an outbreak ``` -------------------------------- ### Load required packages Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/multitree.html Loads the required R packages for the TransPhylo workflow. ```r library(ape) library(TransPhylo) ``` -------------------------------- ### Date of last sample output Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/simulate.html The date of the last sample as printed by the previous command. ```text ## [1] 2007.964 ``` -------------------------------- ### Define simulation parameters Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/simulate.html Specifies the effective within-host population size, reproduction number, generation time distribution, and sampling density for the simulation. ```R neg=100/365 off.r=5 w.shape=10 w.scale=0.1 pi=0.25 ``` -------------------------------- ### simulateOutbreak function signature Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/simulateOutbreak.html Function signature for simulateOutbreak with all parameters and defaults. ```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 ) ``` -------------------------------- ### Create data frame of parameter estimates from multiple runs Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/multitree.html Builds a data frame of posterior parameter estimates from three runs (tp1, tp2, tp_multitree) for comparison. The helper get_param_estimates extracts a named parameter from each element of a record list. Because parameters are shared, either element of record_tpj can be used. ```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"))) ``` -------------------------------- ### print.ttree() Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/index.html Prints a ttree object. ```APIDOC ## print.ttree() ### Description Print function for ttree objects ``` -------------------------------- ### print.ptree() Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/index.html Prints a ptree object. ```APIDOC ## print.ptree() ### Description Print function for ptree objects ``` -------------------------------- ### makeTTree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/makeTTree.html Function to simulate a transmission tree with parameters for offspring distribution, sampling probability, and generation/sampling time distributions. ```APIDOC ## makeTTree ### Description Simulate a transmission tree. ### Usage ```r 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. ``` -------------------------------- ### makeCtreeFromPTree Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Constructs a combined tree from a phylogenetic tree. ```APIDOC ## makeCtreeFromPTree ### Description Constructs a combined tree from a phylogenetic tree. ### Usage ```r makeCtreeFromPTree(ptree) ``` ### Arguments - **ptree** - Phylogenetic tree. ``` -------------------------------- ### Build and plot consensus transmission tree Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-Tutorial.pdf Constructs a consensus transmission tree from the MCMC record and plots it, using the generation time parameters for visualization. ```R cons=consTTree(record) plotTTree(cons,w.shape,w.scale) ``` -------------------------------- ### print.ctree() Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/index.html Prints a ctree object. ```APIDOC ## print.ctree() ### Description Print function for ctree objects ``` -------------------------------- ### Convert phylogenetic tree to phylo object Source: https://github.com/xavierdidelot/transphylo/blob/master/man/phyloFromPTree.Rd Demonstrates the conversion of a simulated outbreak tree into an ape phylo object. ```R phyloFromPTree(extractPTree(simulateOutbreak())) ``` -------------------------------- ### print(x, ...) Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ptree.html S3 method for printing ptree objects, which are phylogenetic trees used in TransPhylo. ```APIDOC ## print(x, ...) ### Description Print function for ptree objects. ### Usage ```r # S3 method for ptree print(x, ...) ``` ### Arguments - **x** (object) - Required - Object of class ptree, i.e., a phylogenetic tree. - **...** (additional parameters) - Optional - Additional parameters are passed on. ### Value Print out details of the ptree. ### Examples ```r print(extractPTree(simulateOutbreak())) #> Phylogenetic tree #> Number of sampled individuals=1 ``` ``` -------------------------------- ### makeCtreeFromPTree: Create transmission tree from phylogenetic tree Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Creates a transmission tree compatible with a given phylogenetic tree. Optional parameters for offspring distribution, sampling, and generation times can be provided to optimize the tree. ```R makeCtreeFromPTree(ptree, off.r = NA, off.p = NA, neg = NA, pi = NA, w.shape = NA, w.scale = NA, ws.shape = NA, ws.scale = NA, T = NA, allowTransPostSamp = NA) ``` -------------------------------- ### Simulate two outbreaks with simulateOutbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/multitree.html Defines simulation parameters and generates two outbreaks with the same parameters using TransPhylo's simulateOutbreak. The seed is set for reproducibility. ```r neg <- 100/365 off.r <- 1.5 w.shape <- 10 w.scale <- 0.1 ws.shape <- w.shape ws.scale <- w.scale pi <- 0.8 set.seed(1234) simu1 <- simulateOutbreak(neg=neg, off.r=off.r, pi=pi, w.shape=w.shape, w.scale=w.scale, dateStartOutbreak=2000,dateT=2005) simu2 <- simulateOutbreak(neg=neg, off.r=off.r, pi=pi, w.shape=w.shape, w.scale=w.scale, dateStartOutbreak=2000,dateT=2005) ``` -------------------------------- ### Run inferTTree with MCMC iterations Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/inferTTree.html Runs the inferTTree function on a phylogenetic tree generated with ape::rtree(5) and a date of 2020, using 100 MCMC iterations. The output shows a progress bar with percentages from 0% to 29% as the MCMC runs. ```r inferTTree(ptreeFromPhylo(ape::rtree(5),2020),mcmcIterations=100) #> | | | 0% | |= | 1% | |= | 2% | |== | 3% | |=== | 4% | |==== | 5% | |==== | 6% | |===== | 7% | |====== | 8% | |====== | 9% | |======= | 10% | |======== | 11% | |======== | 12% | |========= | 13% | |========== | 14% | |========== | 15% | |=========== | 16% | |============ | 17% | |============= | 18% | |============= | 19% | |============== | 20% | |=============== | 21% | |=============== | 22% | |================ | 23% | |================= | 24% | |================== | 25% | |================== | 26% | |=================== | 27% | |==================== | 28% | |==================== | 29% ``` -------------------------------- ### print(x, ...) Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ctree.html S3 method for ctree objects that prints details of the colored phylogenetic tree, such as the number of sampled individuals and total number of hosts. ```APIDOC ## print(x, ...) ### Description S3 method for ctree objects that prints details of the colored phylogenetic tree. ### Usage ```r # S3 method for ctree print(x, ...) ``` ### Arguments - **x** - Object of class ctree, i.e., a colored phylogenetic tree. - **...** - 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 ``` ``` -------------------------------- ### Plot generation time distribution with getGenerationTimeDist Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/infer.html Plots the distribution of realised generation times from the MCMC result. ```r a=getGenerationTimeDist(res,show.plot = T) ``` -------------------------------- ### Find and plot medoid tree with medTTree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/infer.html Finds the most representative (medoid) colored tree from the MCMC sample and plots it. ```r med=medTTree(res) plot(med) ``` -------------------------------- ### getOffspringDist() Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/index.html Extracts and returns the offspring distribution for specified sampled cases. ```APIDOC ## getOffspringDist() ### Description Extract and return offspring distribution of given sampled case(s) ``` -------------------------------- ### getOffspringDist(record, burnin = 0.5, k, show.plot = F) Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/getOffspringDist.html Extracts and returns the offspring distribution of given sampled case(s) from MCMC output produced by inferTTree. The function takes the MCMC record, a burnin proportion, the case(s) of interest, and an optional plotting flag. ```APIDOC ## getOffspringDist(record, burnin = 0.5, k, show.plot = F) ### Description Extract and return offspring distribution of given sampled case(s) from MCMC output produced by inferTTree. ### Function Signature ```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 is 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 is FALSE. ### Value Posterior offspring distribution for the case(s) in k. If length(k)==1 then a vector is returned, otherwise a matrix. ``` -------------------------------- ### S3 method signature for print.ptree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ptree.html Usage signature for the S3 method print for ptree objects. The method takes an object of class ptree and optional additional arguments. ```r # S3 method for ptree print(x, ...) ``` -------------------------------- ### Run MCMC inference with inferTTree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/infer.html Runs the MCMC procedure to infer the transmission tree from the phylogenetic tree, using 1000 iterations and the specified generation time and observation stop date. ```R res<-inferTTree(ptree,mcmcIterations=1000,w.shape=w.shape,w.scale=w.scale,dateT=dateT) ``` -------------------------------- ### S3 method signature for print.ctree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ctree.html S3 method signature for printing ctree objects. The x argument is the ctree object, and ... passes additional parameters. ```r # S3 method for ctree print(x, ...) ``` -------------------------------- ### Set generation time Gamma parameters Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/infer.html Sets the shape and scale parameters of the Gamma distribution representing the generation time. These values match the simulation tutorial; for your own data, set them appropriately for your pathogen. ```R w.shape=10 w.scale=0.1 ``` -------------------------------- ### simulateOutbreak usage Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Usage signature for the simulateOutbreak function, which simulates an outbreak with configurable parameters for offspring distribution, sampling, generation time, and outbreak timing. ```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 = w.shape, ws.scale = w.scale, dateStartOutbreak = 2000, dateT = Inf) ``` -------------------------------- ### Plot colored phylogenetic tree with plotCTree() Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-Tutorial.pdf Visualizes the simulated colored phylogenetic tree, where each host is represented by a unique color. ```R plotCTree(simu) ``` -------------------------------- ### summary.resTransPhylo(object, ...) Source: https://github.com/xavierdidelot/transphylo/blob/master/man/summary.resTransPhylo.Rd Prints a summary of a resTransPhylo object, which is the output from inferTTree. Additional arguments are passed to print.phylo. ```APIDOC ## summary.resTransPhylo(object, ...) ### Description Summary function for resTransPhylo objects, printing details of TransPhylo results. ### Usage \method{summary}{resTransPhylo}(object, ...) ### Arguments - **object** - Output from inferTTree. - **...** - Passed on to print.phylo. ### Value Print out details of TransPhylo results. ``` -------------------------------- ### Simulate an outbreak with simulateOutbreak Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/articles/simulate.html Runs the outbreak simulation from 2005 to 2008 using the previously defined parameters. ```R simu <- simulateOutbreak(neg=neg,pi=pi,off.r=off.r,w.shape=w.shape, w.scale=w.scale,dateStartOutbreak=2005,dateT=2008) ``` -------------------------------- ### probTTree usage Source: https://github.com/xavierdidelot/transphylo/wiki/TransPhylo-RefMan.pdf Usage signature for the probTTree function, which computes the probability of a transmission tree given parameters for the negative binomial offspring distribution, sampling probability, generation time, and sampling time distributions. ```R probTTree(ttree, off.r, off.p, pi, w.shape, w.scale, ws.shape, ws.scale, dateT, allowTransPostSamp) ``` -------------------------------- ### S3 method signature for print.ttree Source: https://github.com/xavierdidelot/transphylo/blob/master/docs/reference/print.ttree.html Signature for the S3 print method for objects of class ttree, which represents a transmission tree. Additional parameters are passed on. ```r # S3 method for ttree print(x, ...) ```