get_nltt_values: Get the nLTT values in time

Description Usage Arguments Value Author(s) See Also Examples

View source: R/get_nltt_values.R

Description

Collect the nLTT values in time over all phylogenies in the long form.

Usage

1
get_nltt_values(phylogenies, dt)

Arguments

phylogenies

the phylogenies, supplied as either a list or a multiPhylo object, where the phylogenies are of type 'phylo'

dt

The timestep resolution, where 1/dt is the number of points evaluated

Value

A dataframe of timepoints with the nLTT value of each phylogeny in time

Author(s)

Richel Bilderbeek

See Also

Usenltts_diff to compare nLTT statistic between one focal tree and a set of one or more other trees

Examples

 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  library(ape)
  library(ggplot2)
  library(nLTT)

  # Create some random phylogenies
  phylogeny1 <- rcoal(10)
  phylogeny2 <- rcoal(20)
  phylogeny3 <- rcoal(30)
  phylogeny4 <- rcoal(40)
  phylogeny5 <- rcoal(50)
  phylogeny6 <- rcoal(60)
  phylogeny7 <- rcoal(70)
  phylogenies <- c(phylogeny1, phylogeny2, phylogeny3,
    phylogeny4, phylogeny5, phylogeny6, phylogeny7
  )

  # Obtain the nLTT values
  dt <- 0.2
  nltt_values <- get_nltt_values(phylogenies, dt = dt)

  # Check properties of nltt_values
  testit::assert(names(nltt_values) == c("id", "t", "nltt"))
  nltt_values_per_phylogeny <- (1 + (1 / dt))
  n_phylogenies <- length(phylogenies)
  testit::assert(nrow(nltt_values)
    == nltt_values_per_phylogeny * n_phylogenies
  )

  # Plot the phylognies, where the individual nLTT values are visible
  qplot(t, nltt, data = nltt_values, geom = "point",
    ylim = c(0,1),
    main = "Average nLTT plot of phylogenies", color = id, size = I(0.1)
  ) + stat_summary(
    fun.data = "mean_cl_boot", color = "red", geom = "smooth"
  )

  # Plot the phylognies, where the individual nLTT values are omitted
  qplot(
    t, nltt, data = nltt_values, geom = "blank", ylim = c(0,1),
    main = "Average nLTT plot of phylogenies"
  ) + stat_summary(
    fun.data = "mean_cl_boot", color = "red", geom = "smooth"
  )

nLTT documentation built on Jan. 13, 2020, 9:06 a.m.