Note that there are some explanatory texts on larger screens.

plurals
  1. POExtract values of a pairwise matrix given similar samples names
    text
    copied!<p>Imagine a pairwise distance matrix formed by several samples, some of which have replicates, i.e. a sample with the same name except for _r at the end of it, and some which not. The matrix obviously gives the distance between all the pairs of samples, replicates or not. What I am interested in is only in the value between each of the sample-replicate pairs. </p> <p>For example given a matrix with samples such as:</p> <pre><code> Sample1 Sample1_r Sample2 Sample2_r Sample3 Sample1 0 79 111 113 110 Sample1_r 79 0 110 112 109 Sample2 111 110 0 80 115 Sample2_r 113 112 80 0 117 Sample3 110 109 115 117 0 </code></pre> <p>Ideally I would like to obtain a dataframe with:</p> <pre><code>Sample1 79 Sample2 80 </code></pre> <p>How can I extract this in an easy to repeat way? I have several matrices and they are all different, so I can't do it by position. I know I should use <code>grep</code> but beyond that my creativity is null now. Help much appreciated.</p> <p>Example with dput</p> <pre><code>m&lt;-structure(c(0, 79.0003888816214, 111.103209038065, 113.10726184344, 110.411316165512, 79.0003888816214, 0, 110.512687922526, 112.516740727902, 109.820795049973, 111.103209038065, 110.512687922526, 0, 80.1995887790629, 115.32854184629, 113.10726184344, 112.516740727902, 80.1995887790629, 0, 117.332594651665, 110.411316165512, 109.820795049973, 115.32854184629, 117.332594651665, 0), .Dim = c(5L, 5L), .Dimnames = list(c("Sample1", "Sample1_r", "Sample2", "Sample2_r", "Sample3"), c("Sample1", "Sample1_r", "Sample2", "Sample2_r", "Sample3"))) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload