rdrop_annotations: Randomly drop leaf annotations

View source: R/simulation.R

rdrop_annotationsR Documentation

Randomly drop leaf annotations

Description

The function takes an annotated tree and randomly selects leaf nodes to set annotations as 9 (missing). The function allows specifying a proportion of annotations to drop, and also the relative probability that has dropping a 0 with respecto to a 1.

Usage

rdrop_annotations(
  x,
  pcent,
  prob.drop.0 = 0.5,
  informative = getOption("aphylo_informative", FALSE)
)

Arguments

x

An object of class aphylo.

pcent

Numeric scalar. Proportion of the annotations to remove.

prob.drop.0

Numeric scalar. Probability of removing a 0, conversely, 1 - prob.drop.0 is the probability of removing a 1.

informative

Logical scalar. If TRUE (the default) the algorithm drops annotations only if the number of annotations to drop of either 0s or 1s are less than the currently available in the data.

Value

x with fewer annotations (more 9s).

Examples

# The following tree has roughtly the same proportion of 0s and 1s
# and 0 mislabeling.
set.seed(1)
x <- raphylo(200, Pi=.5, mu_d=c(.5,.5), psi=c(0,0))
summary(x)

# Dropping half of the annotations
summary(rdrop_annotations(x, .5))

# Dropping half of the annotations, but 0 are more likely to drop
summary(rdrop_annotations(x, .5, prob.drop.0 = 2/3))


USCbiostats/phylogenetic documentation built on Oct. 28, 2023, 7:23 a.m.