File: tree-plot2-3D.R

package info (click to toggle)
bali-phy 3.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,608 kB
  • sloc: cpp: 67,094; xml: 4,074; perl: 3,715; haskell: 1,861; yacc: 1,067; python: 555; lex: 528; sh: 259; makefile: 20
file content (32 lines) | stat: -rw-r--r-- 578 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
args = commandArgs(trailingOnly=T)
N1 = as.numeric(args[1])
N2 = as.numeric(args[2])
infile = args[3]

M = as.matrix(read.table(infile))

L = dim(M)[1]

if (dim(M)[2] != L) { stop("Matrix not square") }
if (N1 + N2 != L) { stop("Wrong number of points.") }

# Actually do the MDS
library(stats)
points = cmdscale(M,k=3)


#library(MASS)
#mds = isoMDS(M)
#points = mds$points

first = 1
group = 1
for (i in 1:L)
{
    if (i == N1+1)
    {
        group = 2
        first = N1+1
    }
    cat(sprintf("%f\t%f\t%f\t%i\t%i\n",points[i,1], points[i,2], points[i,3],group,i-first))
}