]> git.donarmstrong.com Git - ape.git/blob - man/skylineplot.Rd
various bug fixes
[ape.git] / man / skylineplot.Rd
1 \name{skylineplot}
2 \alias{skylineplot}
3 \alias{plot.skyline}
4 \alias{lines.skyline}
5 \alias{skylineplot.deluxe}
6
7 \title{Drawing Skyline Plot Graphs}
8 \usage{
9 \method{plot}{skyline}(x, show.years=FALSE, subst.rate, present.year, \dots)
10 \method{lines}{skyline}(x, show.years=FALSE, subst.rate, present.year, \dots)
11 skylineplot(z, \dots)
12 skylineplot.deluxe(tree, \dots)
13 }
14 \arguments{
15   \item{x}{skyline plot data (i.e. an object of class \code{"skyline"}).}
16   
17   \item{z}{Either an ultrametric tree (i.e. an object of class \code{"phylo"}), 
18            or coalescent intervals (i.e. an object of class \code{"coalescentIntervals"}), or
19            collapsed coalescent intervals (i.e. an object of class \code{"collapsedIntervals"}).}
20   
21
22   \item{tree}{ultrametric tree (i.e. an object of class \code{"phylo"}).}
23   
24   
25   \item{show.years}{option that determines whether the time is plotted in units of
26         of substitutions (default) or in years (requires specification of substution rate
27         and year of present).}
28
29         
30  \item{subst.rate}{substitution rate (see option show.years).}  
31  \item{present.year}{present year (see option show.years).}     
32
33   \item{\dots}{further arguments to be passed on to \code{skyline()} and \code{plot()}.} 
34          
35 }
36 \description{
37
38  These functions provide various ways to draw \emph{skyline plot} graphs
39  on the current graphical device. Note that \code{skylineplot(z, \dots)} is simply
40  a shortcut for \code{plot(skyline(z, \dots))}.
41  The skyline plot itself is an estimate of effective population size through time,
42  and is computed using the function \code{\link{skyline}}.
43 }
44
45 \details{
46  See \code{\link{skyline}} for more details (incl. references) about the skyline plot method.
47 }
48
49
50 \author{Korbinian Strimmer (\url{http://www.stat.uni-muenchen.de/~strimmer/})}
51
52 \seealso{
53 \code{\link[graphics]{plot}} and \code{\link[graphics]{lines}} for the basic plotting
54 function in R, \code{\link{coalescent.intervals}}, \code{\link{skyline}}
55 }
56
57 \examples{
58 # get tree
59 data("hivtree.newick") # example tree in NH format
60 tree.hiv <- read.tree(text = hivtree.newick) # load tree
61
62
63 #### classic skyline plot
64 skylineplot(tree.hiv) # shortcut
65
66
67 #### plot classic and generalized skyline plots and estimate epsilon
68 sk.opt <- skylineplot.deluxe(tree.hiv) 
69 sk.opt$epsilon
70
71
72 #### classic and generalized skyline plot ####
73 sk1 <- skyline(tree.hiv)   
74 sk2 <- skyline(tree.hiv, 0.0119) 
75
76 # use years rather than substitutions as unit for the time axis
77 plot(sk1, show.years=TRUE, subst.rate=0.0023, present.year = 1997, col=c(grey(.8),1))
78 lines(sk2,  show.years=TRUE, subst.rate=0.0023, present.year = 1997)
79 legend(.15,500, c("classic", "generalized"), col=c(grey(.8),1),lty=1)
80
81
82 #### various skyline plots for different epsilons
83 layout(mat= matrix(1:6,2,3,byrow=TRUE))
84 ci <- coalescent.intervals(tree.hiv)
85 plot(skyline(ci, 0.0));title(main="0.0")
86 plot(skyline(ci, 0.007));title(main="0.007")
87 plot(skyline(ci, 0.0119),col=4);title(main="0.0119")
88 plot(skyline(ci, 0.02));title(main="0.02")
89 plot(skyline(ci, 0.05));title(main="0.05")
90 plot(skyline(ci, 0.1));title(main="0.1")
91 layout(mat= matrix(1:1,1,1,byrow=TRUE))
92 }
93 \keyword{hplot}