Hi Maria
   
  When we want to do this we use a function 'dist2full' that was described in earlier R dist functions.  I searched and found it on a Duke web page:
   
  # below is a function that converts a distance structure to a matrix 
dist2full <- function(dis) 
{ 
        n <- attr(dis, "Size") 
        full <- matrix(0, n, n) 
        full[lower.tri(full)] <- dis 
        full + t(full) 
} 

  
   
  The dist fucntion stores the pairwise distances in a vector (the index is explained in the dist help file).  This function converts the dist object to a full matrix.  For an NxN matrix we generated a permutation vector of the integers and selected the rows/columns using it:
   
  x = dist2full(dist.object)
  perm = sample(1:n)
  x.perm = x[perm, perm]
   
  Thank you.

Bill Shannon, PhD
BioRankings, LLC
Founder and President
314-704-8725
http://BioRankings.com

Associate Professor of Biostatistics in Medicine
Washington University School of Medicine
http://ilya.wustl.edu/~shannon

  

prsmra01@uniroma2.it wrote:
  Dear All,

It may sound a trivial question...but I couldn't find a simple 
solution in R: I'm working
on all-against-all distance matrices, the values stored in these 
matrices representing
measures of similarities between pair of proteins; these matrices can 
be considered
representation of phylogenetic trees; I want to generate other 
matrices with the same
randomly permuted distances....how can I shuffle these matrices ?

thank you,

Maria
-- 
Maria Persico, PhD. student
http://cbm.bio.uniroma2.it/~maria/
MINT database group
Universita' di Tor Vergata, via della Ricerca scientifica 11
00133 Roma, Italy
Tel +39 0672594315 (Supervisor's room)
Fax +39 0672594766
Mobile phone: +393479715662
e-mail maria.persico@uniroma2.it

_______________________________________________
Bioconductor mailing list
Bioconductor@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


	[[alternative HTML version deleted]]

