-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsupp2_AB.R
65 lines (57 loc) · 1.94 KB
/
supp2_AB.R
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
rm(list=ls());
pdf("supp2_AB.pdf", 15,10);
layout(matrix(c(1,2,3,4,5,6), nrow = 2, ncol = 3, byrow = TRUE))
par("mar"=c(7, 7, 7, 2))
options(stringsAsFactors = F);
source("supp_func.R");
dat <- read.table("../data/01/do_tsne30_2000.txt", header=T);
clu <- read.table("../data/01/03clust_table.txt", header=T);
# Show clusters by color
col0 <- rainbow(10, alpha=0.6);
clu.n <- c(50, 100, 1000);
for (n in clu.n){
clu.name <- paste0("clu", n);
clu.i <- which(colnames(clu) %in% clu.name);
clu.v <- clu[,clu.i];
clu.u <- unique(clu.v);
clu.j <- length(clu.u)
set.seed(123);
cols <- rainbow(clu.j, alpha=0.6);
cols <- sample(cols);
main <- paste0("cluster number:", clu.j)
plot(dat[,c(1,2)], pch=19, col=cols[clu.v], cex=0.2, xlab="", ylab="", main='');
title(font.main = 1,main= main, xlab="", ylab = "",pch=19, cex.main=3,cex.lab=2, cex.axis= 2.5);
title(ylab="tSNE 2", line=4, cex.lab=2, family = "sans")
title(xlab="tSNE 1", line=4, cex.lab=2, family = "sans")
if (n==50){
for (j in 1:50){
c.i <- which(clu.v==j);
x <- mean(dat[c.i,1]);
y <- mean(dat[c.i,2]);
shadowtext(x, y, j);
fig_label('A', pos='topleft',cex=5)
}
}
}
# Show clusters by circle
for (n in clu.n){
clu.name <- paste0("clu", n);
clu.i <- which(colnames(clu) %in% clu.name);
clu.v <- clu[,clu.i];
clu.u <- unique(clu.v);
clu.j <- length(clu.u)
set.seed(1234);
cols <- rainbow(clu.j, alpha=0.6);
cols <- sample(cols)
out <- mapper(dat, clu.v);
cex <- out$coord[,3]/100;
main <- paste0("cluster number:", clu.j)
plot(out$coord[,1], out$coord[,2], pch=19, col=cols, cex=cex, xlab="", ylab="", main='');
title(font.main = 1,main= main, xlab="", ylab = "",pch=19, cex.main=3,cex.lab=2, cex.axis= 2.5);
title(ylab="tSNE 2", line=4, cex.lab=2, family = "sans")
title(xlab="tSNE 1", line=4, cex.lab=2, family = "sans")
if(n == 50){
fig_label('B', pos='topleft',cex=5)
}
}
dev.off()