[Traminer-users] plot # representatives & quality by coverage

Alexis Gabadinho alexis.gabadinho at unige.ch
Mon Nov 25 11:42:08 CET 2013


Dear Jeremy,

Provided you store the output of the seqrep function in an object 
"seq.rep",  the statistics are stored in a data.frame that can be 
accessed as follows:

attr(seq.rep, "Statistics")

The number of representatives required to achieve the selected coverage 
can be obtained by counting the number of rows of the data.frame (minus 
one because it also contains the overall statistics):

stats <- attr(seq.rep, "Statistics")
nbrep <- nrow(stats)-1

The overall quality used in Figure 4 can be accessed easily as follows:

quality <- attr(seq.rep, "Quality")

Indeed, you have use seqrep with increasing coverage, and concatenate 
the results in a vector. To turn the number of selected representatives 
as a percentage of the sequences in a set, you just have to use the 
number of rows of the corresponding sequence object (here I call it 
"myseq")  e.g.

nbrep25 <- (nrow(attr(seq.rep25, "Statistics"))-1)/nrow(myseq)*100
nbrep50 <- (nrow(attr(seq.rep50, "Statistics"))-1)/nrow(myseq)*100

nbrep.all <- c(nbrep25, nbrep50)

Then plot it:

cov <- c(25, 50)
plot(cov, stats.all, type="b", col="blue")

To add a line corresponding to another cluster, you have to use the 
"lines" function:

nbrep.all.clust2 <- c(nbrep25.clust2, nbrep50.clust2)

lines(cov, nbrep.all.clust2, type="b", col="red")

Best,
Alexis



Le 24. 11. 13 20:30, Jeremy Reynolds a écrit :
> Dear TraMineR users,
>
> Does anyone know how to produce plots that show the # of
> representatives or quality by coverage for a set of representative
> sequences as in Figures 3 and 4 of the paper below?  They would be
> really helpful in choosing a set of representative sequences, but I
> can't figure out how to make them.
>
> It would seem to require repeated use of seqrep.grp and the
> extraction, assembly, and plotting of the results.  As a novice R
> users, I'm not sure where to start.
>
> Thanks,
>
> Jeremy
>
> "Extracting and Rendering Representative Sequences" by Alexis
> Gabadinho, Gilbert Ritschard, Matthias Studer, and Nicolas S. Müller.
> http://mephisto.unige.ch/pub/publications/gr/Gabadinho-etal-Repr_seq_CCIS2011.pdf
>
>
>



More information about the Traminer-users mailing list