首页 文章

来自seqrep的代表性序列的SPS格式

提问于
浏览
1

有谁知道如何从SPS格式给出的seqrep输出中提取代表性序列?这对seqrplot的情节 Spectator 非常有帮助 .

1 回答

  • 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形式检索代表性序列,可以使用 seqformatseqconc

    biofam.rep.sps <- seqconc(seqformat(biofam.rep, to='SPS'))
    

    结果是单个列矩阵,每个代表性序列存储为字符串 .

相关问题