Debian Codegraph @

man/sample.dendrogram.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/sample.dendrogram.R
3 \name{sample.dendrogram}
4 \alias{sample.dendrogram}
5 \title{Sample a tree}
6 \usage{
7 sample.dendrogram(
8 dend,
9 replace = FALSE,
10 dend_labels,
11 sampled_labels,
12 fix_members = TRUE,
13 fix_order = TRUE,
14 fix_midpoint = TRUE,
15 ...
16 )
17 }
18 \arguments{
19 \item{dend}{a dendrogram object}
20
21 \item{replace}{logical (FALSE). Should we shuffle the labels (if FALSE),
22 or should we replicate the same leaf over and over, while omitting other
23 leaves? (this is when set to TRUE).}
24
25 \item{dend_labels}{a character vector of the tree's labels.
26 This can save the time it takes for getting the tree labels (in case we run
27 a simulating, computing this once might save some running time).
28 If missing, it uses \link{labels} in order to get the labels.}
29
30 \item{sampled_labels}{a character vector of the tree's sampled labels.
31 This can help us if we wish to compare two trees. In such a case we'd like
32 to be able to have the same sample of labels used on both trees.
33 If missing, it uses \link{sample} in order to get the sampled labels.
34
35 Only works when replace=TRUE!}
36
37 \item{fix_members}{logical (TRUE). Fix the number of members in attr
38 using \link{fix_members_attr.dendrogram}}
39
40 \item{fix_order}{logical (TRUE). Fix the leaves order}
41
42 \item{fix_midpoint}{logical (TRUE). Fix the midpoint value.
43 If TRUE, it overrides "fix_members" and turns it into TRUE (since it must
44 have a correct number of members in order to work).
45 values using \link{rank_order.dendrogram}}
46
47 \item{...}{not used}
48 }
49 \value{
50 A dendrogram, after "sampling" its leaves.
51 }
52 \description{
53 Samples a tree, either by permuting the labels (which is usefull for
54 a permutation test), or by repeated sampling of the same labels (essential
55 for bootstraping when we don't have access to the original data which
56 produced the tree).
57
58 Duplicates a leaf in a tree. Useful for non-parametric bootstraping trees
59 since it emulates what would have happened if the tree was constructed based
60 on a row-sample with replacments from the original data matrix.
61 }
62 \examples{
63
64 \dontrun{
65 # define dendrogram object to play with:
66 dend <- USArrests[1:5, ] \%>\%
67 dist() \%>\%
68 hclust(method = "ave") \%>\%
69 as.dendrogram()
70 plot(dend)
71
72 # # same tree, with different order of labels
73 plot(sample.dendrogram(dend, replace = FALSE))
74
75 # # A different tree (!), with some labels duplicated,
76 # while others are pruned
77 plot(sample.dendrogram(dend, replace = TRUE))
78 }
79
80 }
81 \seealso{
82 \link{sample}, \link{duplicate_leaf}
83 }