data(biofam)
## Building one channel per type of event (left, children or married)
cases <- 200
bf <- as.matrix(biofam[1:cases, 10:25])
children <- bf==4 | bf==5 | bf==6
married <- bf == 2 | bf== 3 | bf==6
left <- bf==1 | bf==3 | bf==5 | bf==6
## Building sequence objects
require(colorspace)
m.col <- sequential_hcl(2, palette = "PurpOr")
c.col <- sequential_hcl(2, palette = "Mint")
l.col <- sequential_hcl(2, palette = "OrYel")
child.seq <- seqdef(children, weights=biofam[1:cases,"wp00tbgs"], cpal=c.col)
marr.seq <- seqdef(married, weights=biofam[1:cases,"wp00tbgs"], cpal=m.col)
left.seq <- seqdef(left, weights=biofam[1:cases,"wp00tbgs"], cpal=l.col)
seqdom <- list(LeftHome=left.seq,Marr=marr.seq,Child=child.seq)
seqplotMD(seqdom, type="d", group=biofam[1:cases,"sex"], xaxis="bottom")
seqplotMD(seqdom, type="dH", group=biofam[1:cases,"sex"], dom.byrow=TRUE,
xaxis="bottom", yaxis="left")
seqplotMD(seqdom, type="mt", group=biofam[1:cases,"sex"])
seqplotMD(seqdom, type="I", group=biofam[1:cases,"sex"],
xaxis="bottom", sortv="from.end")
## sorting on first domain
seqplotMD(seqdom, type="I", group=biofam[1:cases,"sex"],
xaxis="bottom", sortv="from.start", dom.crit=1)
seqplotMD(seqdom, type="f", group=biofam[1:cases,"sex"],
xaxis="bottom", yaxis="left")
## distances betweem MD sequences
MDseq <- seqMD(seqdom, what="MDseq", ch.sep="+")
diss <- seqdist(MDseq, method="OM", sm="INDELSLOG")
seqplotMD(seqdom, type="rf", group=biofam[1:cases,"sex"],
xaxis="bottom", sortv="from.end", dom.crit=0, diss=diss, k=10)
seqplotMD(seqdom, type="r", group=biofam[1:cases,"sex"],
xaxis="bottom", dom.crit=0, diss=diss)
Run the code above in your browser using DataLab