collapsed.intervals: Collapsed Coalescent Intervals

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/collapsed.intervals.R

Description

This function takes a "coalescentIntervals" objects and collapses neighbouring coalescent intervals into a single combined interval so that every collapsed interval is larger than epsilon. Collapsed coalescent intervals are used, e.g., to obtain the generalized skyline plot (skyline). For epsilon = 0 no interval is collapsed.

Usage

1
collapsed.intervals(ci, epsilon=0)

Arguments

ci

coalescent intervals (i.e. an object of class "coalescentIntervals").

epsilon

collapsing parameter that controls the amount of smoothing (allowed range: from 0 to ci$total.depth)

Details

Proceeding from the tips to the root of the tree each small interval is pooled with the neighboring interval closer to the root. If the neighboring interval is also small, then pooling continues until the composite interval is larger than epsilon. Note that this approach prevents the occurrence of zero-length intervals at the present. For more details see Strimmer and Pybus (2001).

Value

An object of class "collapsedIntervals" with the following entries:

lineages

A vector with the number of lineages at the start of each coalescent interval.

interval.length

A vector with the length of each coalescent interval.

collapsed.interval

A vector indicating for each coalescent interval to which collapsed interval it belongs.

interval.count

The total number of coalescent intervals.

collapsed.interval.count

The number of collapsed intervals.

total.depth

The sum of the lengths of all coalescent intervals.

epsilon

The value of the underlying smoothing parameter.

Author(s)

Korbinian Strimmer

References

Strimmer, K. and Pybus, O. G. (2001) Exploring the demographic history of DNA sequences using the generalized skyline plot. Molecular Biology and Evolution, 18, 2298–2305.

See Also

coalescent.intervals,skyline.

Examples

1
2
3
4
5
6
7
8
9
data("hivtree.table") # example tree
# colescent intervals from vector of interval lengths
ci <- coalescent.intervals(hivtree.table$size)
ci
# collapsed intervals
cl1 <- collapsed.intervals(ci,0)
cl2 <- collapsed.intervals(ci,0.0119)
cl1
cl2

Example output

$lineages
  [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176
 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158
 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140
 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122
 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104
 [91] 103 102 101 100  99  98  97  96  95  94  93  92  91  90  89  88  87  86
[109]  85  84  83  82  81  80  79  78  77  76  75  74  73  72  71  70  69  68
[127]  67  66  65  64  63  62  61  60  59  58  57  56  55  54  53  52  51  50
[145]  49  48  47  46  45  44  43  42  41  40  39  38  37  36  35  34  33  32
[163]  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14
[181]  13  12  11  10   9   8   7   6   5   4   3   2

$interval.length
  [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754
  [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035
 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608
 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699
 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405
 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291
 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397
 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158
 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212
 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037
 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001
 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013
 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052
[105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872
[113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632
[121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001
[129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228
[137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129
[145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365
[153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092
[161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804
[169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904
[177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403
[185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214

$interval.count
[1] 192

$total.depth
[1] 0.209117

attr(,"class")
[1] "coalescentIntervals"
$lineages
  [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176
 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158
 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140
 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122
 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104
 [91] 103 102 101 100  99  98  97  96  95  94  93  92  91  90  89  88  87  86
[109]  85  84  83  82  81  80  79  78  77  76  75  74  73  72  71  70  69  68
[127]  67  66  65  64  63  62  61  60  59  58  57  56  55  54  53  52  51  50
[145]  49  48  47  46  45  44  43  42  41  40  39  38  37  36  35  34  33  32
[163]  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14
[181]  13  12  11  10   9   8   7   6   5   4   3   2

$interval.length
  [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754
  [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035
 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608
 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699
 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405
 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291
 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397
 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158
 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212
 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037
 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001
 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013
 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052
[105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872
[113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632
[121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001
[129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228
[137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129
[145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365
[153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092
[161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804
[169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904
[177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403
[185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214

$collapsed.interval
  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
 [19]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36
 [37]  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54
 [55]  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72
 [73]  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90
 [91]  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108
[109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
[127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
[145] 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
[163] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
[181] 181 182 183 184 185 186 187 188 189 190 191 192

$interval.count
[1] 192

$collapsed.interval.count
[1] 192

$total.depth
[1] 0.209117

$epsilon
[1] 0

attr(,"class")
[1] "collapsedIntervals"
$lineages
  [1] 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176
 [19] 175 174 173 172 171 170 169 168 167 166 165 164 163 162 161 160 159 158
 [37] 157 156 155 154 153 152 151 150 149 148 147 146 145 144 143 142 141 140
 [55] 139 138 137 136 135 134 133 132 131 130 129 128 127 126 125 124 123 122
 [73] 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104
 [91] 103 102 101 100  99  98  97  96  95  94  93  92  91  90  89  88  87  86
[109]  85  84  83  82  81  80  79  78  77  76  75  74  73  72  71  70  69  68
[127]  67  66  65  64  63  62  61  60  59  58  57  56  55  54  53  52  51  50
[145]  49  48  47  46  45  44  43  42  41  40  39  38  37  36  35  34  33  32
[163]  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15  14
[181]  13  12  11  10   9   8   7   6   5   4   3   2

$interval.length
  [1] 0.021163 0.028658 0.000237 0.004382 0.003138 0.000046 0.000956 0.000754
  [9] 0.000394 0.002115 0.001170 0.002138 0.000391 0.002226 0.000478 0.000035
 [17] 0.001063 0.000289 0.000093 0.000406 0.000374 0.000894 0.005766 0.000608
 [25] 0.000313 0.000351 0.000051 0.001306 0.000103 0.000196 0.000114 0.000699
 [33] 0.000014 0.000002 0.000340 0.000467 0.000706 0.000001 0.000281 0.000405
 [41] 0.000044 0.000269 0.000381 0.000727 0.000024 0.000061 0.001083 0.000291
 [49] 0.001460 0.000056 0.000268 0.000818 0.000041 0.000138 0.000037 0.000397
 [57] 0.000262 0.000060 0.000699 0.000008 0.000332 0.000197 0.000641 0.000158
 [65] 0.000722 0.000562 0.000023 0.000893 0.000232 0.000122 0.000045 0.000212
 [73] 0.000138 0.000158 0.000070 0.000316 0.000040 0.000221 0.000004 0.000037
 [81] 0.000795 0.000105 0.000162 0.000129 0.000588 0.000132 0.000065 0.000001
 [89] 0.002039 0.000083 0.000108 0.000152 0.000221 0.001135 0.000794 0.000013
 [97] 0.000069 0.000001 0.000439 0.000189 0.000468 0.000656 0.000163 0.000052
[105] 0.000456 0.000100 0.000206 0.000328 0.000001 0.000001 0.000162 0.000872
[113] 0.000142 0.000869 0.000222 0.000342 0.000699 0.000225 0.000149 0.000632
[121] 0.000661 0.001551 0.000325 0.000710 0.000084 0.000656 0.000343 0.000001
[129] 0.000062 0.000260 0.000149 0.000257 0.000169 0.000067 0.000146 0.001228
[137] 0.000108 0.001083 0.000115 0.000206 0.000214 0.000810 0.000113 0.000129
[145] 0.000211 0.000090 0.001179 0.000149 0.000080 0.000006 0.001562 0.000365
[153] 0.000148 0.000540 0.001173 0.000955 0.002667 0.000001 0.000001 0.000092
[161] 0.001009 0.001358 0.000001 0.000103 0.000742 0.000244 0.000833 0.002804
[169] 0.000700 0.000005 0.000116 0.004393 0.002747 0.001338 0.002033 0.001904
[177] 0.001861 0.001175 0.004338 0.009062 0.001534 0.000548 0.009855 0.001403
[185] 0.001063 0.002169 0.010997 0.004668 0.000001 0.007897 0.000001 0.004214

$collapsed.interval
  [1]  1  2  3  3  3  3  3  3  3  3  4  4  4  4  4  4  4  4  4  4  4  4  4  5  5
 [26]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5
 [51]  5  5  5  5  5  5  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6
 [76]  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  6  7  7  7  7  7
[101]  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7  7
[126]  7  7  7  7  7  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8  8
[151]  8  8  8  8  8  8  8  9  9  9  9  9  9  9  9  9  9  9  9  9  9  9 10 10 10
[176] 10 10 10 10 11 11 11 11 12 12 12 12 13 13 13 13 13

$interval.count
[1] 192

$collapsed.interval.count
[1] 13

$total.depth
[1] 0.209117

$epsilon
[1] 0.0119

attr(,"class")
[1] "collapsedIntervals"

ape documentation built on April 25, 2021, 9:06 a.m.