dibas: DIstance-Based Assignment

Description Usage Arguments Author(s) Examples

Description

These functions are under development. Please do not use them unless asked by the author.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
dibas(x, ...)

## S3 method for class 'matrix'
dibas(x, grp, method = c("default", "leaveOneOut"), ...)

## S3 method for class 'vector'
dibas(x, grp, method = c("default", "leaveOneOut"),
  n.items = NULL, ...)

## S3 method for class 'phylo'
dibas(x, grp, method = c("default", "leaveOneOut"),
  fromRoot = FALSE, metric = c("Abouheif", "nNodes", "patristic", "sumDD"),
  n.items = NULL, ...)

## S3 method for class 'dist'
dibas(x, grp, method = c("default", "leaveOneOut"), ...)

Arguments

x

a phylo object, or a symmetric matrix of pairwise distances of class matrix or dist.

...

further arguments passed to other methods. Can be used to provide arguments to table.phylo4d in plot method.

grp

a factor indicating the groups of observations.

method

a character string indicating the method to be used for estimating the distribution of pairwise distances within groups. The default method ("default") uses all observations, while the "leaveOneOut" estimates separate group distributions for each individual, leaving this one out in the estimation process.

n.items

a vector of integers of the same length as x, stating how many times each items in 'x' should be repeated; used to take into account differences in abundances of the different items (e.g. sequences in multiple copies).

fromRoot

a logical indicating if distances from the root, rather than between groups, should be used.

metric

a character string matching "nNodes", "patristic", "Abouheif", or "sumDD" indicating the distance measure to be used. See distTips for more information. Note that patristic distances should be avoided in presence of one or more highly diverse group because of the 'hand fan' syndrome (see example).

Author(s)

Thibaut Jombart tjombart@imperial.ac.uk

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
## Not run: 
if(require(ape)){
#### SIMPLE SIMULATED DATA ####
## 50 variables, 2 groups, 30 indiv
dat <- simDatGroups(k=2, p=50, n=c(15,15), mu=c(0,1))
names(dat)

## make a tree
tre <- nj(dist(dat$dat))
plot(tre,type="unr", tip.col=c("blue","red")[as.integer(dat$grp)],
   main="simulated data - tree")
 
## use dibas method
res <- dibas(tre, dat$grp, metric="nNodes")
res

barplot(t(res$prob), main="group membership probabilities")



#### NON-PARAMETRIC TEST BASED ON MEAN SUCCESSFUL ASSIGNMENT ####
## use dibas method
distHo <- replicate(100,
   dibas(tre, sample(dat$grp), metric="patristic")$mean.ok)
pval <- mean(res$mean.ok<=c(distHo,res$mean.ok))
pval

hist(c(distHo,res$mean.ok), col="grey",
   main="Mean successful assignement - permuted values")
abline(v=res$mean.ok, col="red")
mtext(side=3, text="Observed value in red")



#### HAND FAN SYNDROME ####
## 50 variables, 2 groups, 30 indiv
dat <- simDatGroups(k=2, p=50, n=c(15,15), mu=c(0,1), sigma=c(2,4))
names(dat)

## make a tree
tre <- nj(dist(dat$dat))
plot(tre,type="unr", tip.col=c("blue","red")[as.integer(dat$grp)],
   main="simulated data - tree")
mtext(side=3, text="hand-fan syndrome")

## use dibas method
res.patri <- dibas(tre, dat$grp, metric="patristic")
res.patri$grp.tab # poor results
plot(table(res.patri$groups), main="Group assignment - dibas patristic")

res <- dibas(tre, dat$grp, metric="nNodes")
res$grp.tab # results OK
plot(table(res$groups), main="Group assignment - dibas nNodes")




#### MORE COMPLEX DATASET ####
if(require(adegenet)){

dat <- simDatGroups(k=5, p=50, n=c(5,10,10,30,60), mu=sample(1:5, 5,
   replace=TRUE), sigma=sample(1:5)/2)
names(dat)

## make a tree
tre <- nj(dist(dat$dat))
plot(tre,type="unr", tip.col=fac2col(dat$grp),main="simulated data - tree")

## use dibas method
res <- dibas(tre, dat$grp, metric="Abouheif")
res

plot(table(res$groups), main="Group assignment - dibas Abouheif")

}
}

## End(Not run)

adephylo documentation built on May 1, 2019, 7:21 p.m.