有人知道如何从SPS格式中提取的seqrep输出中提取代表性序列吗?这对seqrplot的情节观众非常有帮助。
答案 0 :(得分:0)
您可以使用format = 'SPS'
参数打印输出。我用biofam
数据
data(biofam)
biofam.lab <- c("Parent", "Left", "Married", "Left+Marr",
"Child", "Left+Child", "Left+Marr+Child", "Divorced")
biofam.seq <- seqdef(biofam, 10:25, labels=biofam.lab)
## Computing the distance matrix
costs <- seqcost(biofam.seq, method="INDELSLOG")
biofam.om <- seqdist(biofam.seq, method="OM", sm=costs$sm, indel=costs$indel)
## Representative set using the neighborhood density criterion
biofam.rep <- seqrep(biofam.seq, diss=biofam.om, criterion="density")
print(biofam.rep, format="SPS")
## Sequence
## [1] (0,16)
## [2] (0,9)-(3,1)-(6,6)
## [3] (0,6)-(1,10)
如果您想要以SPS形式检索代表性序列,可以使用seqformat
和seqconc
:
biofam.rep.sps <- seqconc(seqformat(biofam.rep, to='SPS'))
结果是单个列矩阵,每个代表性序列存储为字符串。