二次元キャラの分化(成長)を多次元データ解析法で真面目にやってみる

MikuHatsune2014-02-02

SPADEが使いやすくなったので、二次元キャラのプロフィールデータを多次元データとみなして、年齢とプロフィールがどう変わっていくのかをながめた。
グラフレイアウトが前回と変わっているが、左上がロリで右下が年を取っていっている感じ。年齢の作用が強いのか、ラブライブの面子は学年が同じだとすべて同じクラスターに属していたし、如月千早及川雫が同じクラスターというのはちょっとどうかと思う。
(^q^)「くおえうえーーーるえうおおおwwwwwwwwwwwwwwwwwwwww」は真ん中だった。というのも、彼女自体はグラマラスなのだが、年齢が18歳と全体平均ちょっと上なくらいなので、分化としては中間っぽい。

$`0`
                  name age height weight  B  W  H     type
1             新垣雛菜  17    155     47 79 55 80       GF
3             見吉奈央  17    170     45 83 53 85       GF
6             椎名心実  17    160     48 83 58 85       GF
7   ミス・モノクローム  17    155     46 78 57 80       GF
8             遠山未涼  17    160     45 70 56 70       GF
13            山田はな  17    151     43 68 60 70       GF
15            前田彩賀  17    159     49 76 58 78       GF
18            川淵一美  17    158     46 73 59 74       GF
20            岸田稚慧  17    154     44 71 62 73       GF
22          加賀美茉莉  17    153     44 73 53 78       GF
23            霧生典子  17    171     49 74 58 78       GF
25          赤瀬川摩姫  17    160     45 77 56 79       GF
29          南條クミコ  17    162     48 78 62 81       GF
30          戸村美知留  17    162     48 85 58 87       GF
33            夏目真尋  17    153     44 79 57 77       GF
35            掛井園美  17    156     47 82 60 83       GF
36          螺子川来夢  17    155     48 78 60 81       GF
40          伊勢崎郁歩  17    157     48 75 55 80       GF
46            古谷朱里  17    163     48 75 59 85       GF
52            皆口英里  17    166     52 78 63 80       GF
53          八束由紀恵  17    161     45 70 56 73       GF
56            上条るい  17    158     44 70 53 73       GF
58            南田七星  17    157     47 78 58 80       GF
60            櫻井明音  17    160     48 85 58 87       GF
62          石田いすき  17    146     45 69 55 74       GF
66            川上瀬莉  17    163     48 80 62 81       GF
69            黒川凪子  17    158     48 79 56 81       GF
71          姫島木乃子  17    145     42 69 53 70       GF
73            湯川基世  17    148     44 72 54 75       GF
74              押井知  17    153     44 75 57 79       GF
75            雪風真弥  17    173     49 68 64 69       GF
76            相楽エミ  17    152     45 83 56 84       GF
77          春宮つぐみ  17    165     46 80 57 78       GF
79              李春燕  17    160     48 82 58 85       GF
80              東野梓  17    158     50 76 63 77       GF
81            佐伯鞠香  17    155     46 79 56 82       GF
83              羽鳥晶  17    166     51 78 60 80       GF
88            高崎瑠依  17    163     48 82 58 85       GF
90        不知火五十鈴  17    146     43 78 55 81       GF
91            風町陽歌  17    156     46 80 56 83       GF
92            東雲レイ  17    153     46 70 55 73       GF
96          白瀬つづり  17    154     44 72 55 74       GF
97            白鳥詩織  17    156     45 76 54 80       GF
99            早見英子  17    165     53 70 61 73       GF
100           熊田一葉  17    162     48 78 62 78       GF
102             岩本樹  17    164     49 73 57 76       GF
106           桐山優月  17    155     46 78 55 80       GF
109           吉川繭子  17    163     50 85 58 86       GF
112           鈴河凜乃  17    157     42 73 57 72       GF
119           岡本未夕  17    162     48 80 60 86      WUG
120           岩崎志保  17    163     45 82 55 81      WUG
127             東條希  17    156     43 90 60 82 LoveLive
128           絢瀬絵里  17    162     47 88 60 84 LoveLive
135           矢澤にこ  17    154     41 74 57 79 LoveLive
136           天海春香  17    158     46 83 56 82     imas
138             菊地真  17    159     44 75 57 78     imas
140           島村卯月  17    159     45 83 59 87     imas
147         三村かな子  17    153     52 90 65 89     imas
150         小日向美穂  17    155     42 82 59 86     imas
166         西園寺琴歌  17    156     46 87 57 85     imas
167             双葉杏  17    139     30 72 52 76     imas
173         道明寺歌鈴  17    155     43 80 57 83     imas
175           井村雪菜  17    163     48 85 60 88     imas
177           榊原里美  17    162     46 91 56 86     imas
182           安部菜々  17    146     40 84 57 84     imas
203           神谷奈緒  17    154     44 83 58 81     imas
207         多田李衣菜  17    152     41 80 55 81     imas
228         綾瀬穂乃香  17    161     46 85 57 84     imas
232           吉岡沙紀  17    166     43 86 60 85     imas
243             速水奏  17    162     43 86 55 84     imas
247           古澤頼子  17    165     45 80 59 83     imas
250           萩原雪歩  17    155     42 81 56 81     imas
267             大槻唯  17    155     42 84 56 83     imas
271         海老原菜帆  17    162     58 92 65 93     imas
280           若林智香  17    156     45 82 57 83     imas
281         城ヶ崎美嘉  17    162     43 80 56 82     imas
284             日野茜  17    148     40 80 60 82     imas
285         諸星きらり  17    182     60 91 64 86     imas
294           北川真尋  17    158     43 75 57 79     imas
299           難波笑美  17    158     45 82 56 80     imas

$`1`
                name age height weight   B  W  H type
2             弓削楓  18    164     43  78 53 80   GF
9         三嶋ゆらら  18    154     45  77 58 78   GF
10        神楽坂砂夜  18    164     44  88 55 88   GF
12          玉井麗巳  18    163     48  76 56 78   GF
14          村上文緒  18    160     45  86 56 86   GF
16            九重忍  18    164     48  87 58 80   GF
24        望月エレナ  18    165     48  88 55 88   GF
27          栢嶋乙女  18    166     44  68 54 71   GF
28  クロエ・ルメール  18    167     49  86 60 88   GF
31            緒川唯  18    164     48  92 60 85   GF
32        時谷小瑠璃  18    148     43  73 57 78   GF
37        笹原野々花  18    164     47  90 58 89   GF
38          正岡真衣  18    149     38  69 53 70   GF
39        林田たまき  18    160     49  78 58 75   GF
41          一色愛瑠  18    157     49  85 65 87   GF
47      千代浦あやめ  18    161     44  71 55 68   GF
48        小野寺千鶴  18    164     49  82 60 83   GF
50          重藤秋穂  18    169     48  78 57 82   GF
59          日野奏恵  18    163     45  82 56 80   GF
63            浅見景  18    173     51  89 63 89   GF
67        天都かなた  18    162     49  85 54 80   GF
68        伊勢谷里都  18    165     53  76 60 78   GF
70            五代律  18    170     48  68 55 68   GF
72        鍋島ちより  18    159     46  81 62 83   GF
101     有栖川小枝子  18    157     45  80 55 78   GF
104         皆藤蜜子  18    168     53 100 58 85   GF
108         飛原鋭子  18    165     49  77 60 79   GF
118         菊間夏夜  18    164     50  85 59 83  WUG
126     小早川ティナ  18    165     49  88 60 86  WUG
141         中野有香  18    149     40  77 57 81 imas
162         松原早耶  18    156     43  83 58 86 imas
171           月宮雅  18    153     44  86 56 82 imas
189         丹羽仁美  18    157     43  81 55 79 imas
195         四条貴音  18    169     49  90 62 92 imas
204         上条春菜  18    156     42  79 56 80 imas
215           水野翠  18    164     47  80 54 81 imas
218           松永涼  18    160     47  90 56 86 imas
240         塩見周子  18    163     45  82 56 81 imas
259         木村夏樹  18    159     41  82 57 83 imas
265           愛野渚  18    163     47  84 58 85 imas
277         相葉夕美  18    158     42  81 57 80 imas
286         十時愛梨  18    161     46  86 58 88 imas
290         向井拓海  18    163     53  95 60 87 imas
292           杉坂海  18    162     45  88 58 86 imas

$`3`
                    name age height weight   B  W  H     type
4             綾小路美麗  16    152     43  73 53 80       GF
5                 鴫野睦  16    150     43  71 53 73       GF
11            江藤くるみ  16    155     48  78 60 80       GF
17              音羽ユリ  16    154     46  73 58 75       GF
19              小泉由佳  16    163     45  80 55 82       GF
21                甘利燈  16    153     43  72 54 74       GF
26         小日向いちご   16    146     45  83 57 82       GF
34              夢前春瑚  16    150     43  76 54 79       GF
43                柊真琴  16    148     42  85 63 83       GF
45            山野こだま  16    146     48  80 63 82       GF
49              森園芽以  16    157     46  78 55 78       GF
51              三科果歩  16    155     45  74 58 80       GF
54            成瀬まなみ  16    153     43  72 54 73       GF
55              葉月柚子  16    153     44  79 56 80       GF
57                宮内希  16    153     45  77 58 79       GF
61              君嶋里琉  16    160     46  68 55 67       GF
64                小倉愛  16    156     46  78 58 80       GF
65                島田泉  16    154     43  77 53 78       GF
82            円城寺小菊  16    147     38  68 53 70       GF
86              新田萌果  16    145     45  85 56 85       GF
87            朝比奈桃子  16    145     44  75 58 78       GF
94  ユーリヤ・ヴャルコワ  16    157     43  73 60 75       GF
95                優木苗  16    143     42  68 53 70       GF
98              林田希羅  16    165     48  83 58 85       GF
103           長谷川美卯  16    153     42  70 63 72       GF
105         竜ヶ崎珠里椏  16    172     50  85 60 83       GF
107           芙来田伊吹  16    154     43  77 58 75       GF
110             西野彩音  16    148     39  69 54 71       GF
111           大山真由里  16    155     46  77 58 77       GF
116             七瀬佳乃  16    159     44  70 58 82      WUG
122               吉川愛  16    155     40  74 56 80      WUG
130             南ことり  16    159     42  80 58 80 LoveLive
132           高坂穂乃果  16    157     45  78 58 82 LoveLive
133             園田海未  16    159     48  76 58 80 LoveLive
139             我那覇響  16    152     41  83 56 80     imas
145             今井加奈  16    153     41  81 56 79     imas
151           緒方智絵里  16    153     42  79 57 80     imas
156             長富蓮実  16    161     45  83 56 85     imas
161           赤西瑛梨華  16    154     55  92 59 88     imas
179               安斎都  16    156     41  78 55 77     imas
180             浅野風香  16    160     48  88 59 84     imas
183               工藤忍  16    154     41  78 54 81     imas
187           佐久間まゆ  16    153     40  78 54 80     imas
192             如月千早  16    162     41  72 55 78     imas
213               藤原肇  16    161     43  80 55 84     imas
225             北条加蓮  16    155     42  83 55 81     imas
237           西川保奈美  16    155     55  88 60 86     imas
241             脇山珠美  16    145     38  72 53 75     imas
242             岡崎泰葉  16    153     43  79 55 80     imas
256             高森藍子  16    155     42  74 60 79     imas
272               及川雫  16    170     56 105 64 92     imas

$`30`
                  name age height weight  B  W  H type
42            月白陽子  22    161     49 86 57 88   GF
44              橘響子  22    148     45 83 60 80   GF
85          神崎ミコト  22    168     53 91 58 88   GF
146         持田亜里沙  21    156     45 77 54 76 imas
159             太田優  21    159     45 89 57 87 imas
163           相原雪乃  22    160     51 92 58 90 imas
172           兵藤レナ  27    167     48 92 56 84 imas
174             柳清良  23    158     47 85 58 86 imas
193         三浦あずさ  21    168     48 91 59 86 imas
198         松本沙理奈  22    165     48 92 58 85 imas
200           高橋礼子  31    167     51 91 62 90 imas
201           相川千夏  23    161     43 82 56 85 imas
202           川島瑞樹  28    159     44 87 57 85 imas
206           東郷あい  23    167     45 82 57 83 imas
208           水木聖來  23    155     43 82 55 80 imas
210           三船美優  26    165     46 85 60 85 imas
211           服部瞳子  25    169     48 78 57 80 imas
212         木場真奈美  25    172     50 88 60 89 imas
217             ヘレン  24    158     46 90 58 81 imas
220           高峯のあ  24    168     48 87 55 86 imas
221             高垣楓  25    171     49 81 57 83 imas
223           伊集院惠  21    160     44 86 56 81 imas
224             柊志乃  31    167     43 84 54 83 imas
230             篠原礼  27    171     49 93 58 88 imas
231         和久井留美  26    168     49 81 60 86 imas
257         並木芽衣子  22    160     44 80 57 82 imas
260         松山久美子  21    161     44 81 56 81 imas
262         沢田麻里菜  26    166     47 87 57 87 imas
266         真鍋いつき  22    165     46 85 57 83 imas
274         衛藤美紗希  22    160     45 84 56 80 imas
276           片桐早苗  28    152     47 92 58 84 imas
279         浜川愛結奈  22    168     50 92 58 85 imas
283           仙崎恵磨  21    156     45 81 55 81 imas
288           相馬夏美  25    160     46 83 60 89 imas
307         トレーナー  23    160     45 84 56 85 imas
308 ベテラントレーナー  26    163     45 83 56 84 imas
309 マスタートレーナー  28    166     45 82 56 83 imas

$`42`
          name age height weight  B  W  H type
78  久保田友季  20    160     48 79 61 82   GF
84      荒井薫  20    165     51 81 60 83   GF
89    畑山政子  20    163     49 86 55 85   GF
93    水野楓夏  20    163     47 83 62 82   GF
121   近藤麻衣  20    168     48 85 58 88  WUG
125   鈴木玲奈  20    162     44 78 52 85  WUG
149   間中美里  20    160     46 84 57 85 imas
176 日下部若葉  20    148     40 77 54 78 imas
181 大西由里子  20    156     44 81 58 83 imas
186   クラリス  20    166     45 80 55 82 imas
190   原田美世  20    163     46 86 59 85 imas
197   黒川千秋  20    163     45 86 57 86 imas
205   荒木比奈  20    157     43 83 57 82 imas
226     ケイト  20    157     45 83 59 85 imas
249 鷹富士茄子  20    160     43 88 57 88 imas
261   斉藤洋子  20    157     46 85 57 82 imas
268   姫川友紀  20    161     44 80 57 80 imas

$`53`
                  name age height weight  B  W  H     type
113           島田真夢  15    159     46 75 57 83      WUG
114           林田藍里  15    155     45 77 58 85      WUG
129           小泉花陽  15    156     44 82 60 83 LoveLive
131         西木野真姫  15    161     43 78 56 83 LoveLive
134             星空凛  15    155     43 75 59 80 LoveLive
142         水本ゆかり  15    155     42 81 56 82     imas
152         五十嵐響子  15    154     43 81 58 80     imas
160           前川みく  15    152     45 85 55 81     imas
165         小早川紗枝  15    148     42 78 56 80     imas
168             楊菲菲  15    152     41 82 58 84     imas
169         桃井あずき  15    145     40 80 55 78     imas
184           栗原ネネ  15    161     44 77 54 78     imas
188         村松さくら  15    145     38 75 55 77     imas
196             渋谷凛  15    165     44 80 56 81     imas
244             大石泉  15    157     41 83 55 82     imas
245           松尾千鶴  15    161     45 78 54 81     imas
253           星井美希  15    161     45 86 55 83     imas
254           水瀬伊織  15    153     40 77 54 79     imas
255           本田未央  15    161     46 84 58 87     imas
269           喜多見柚  15    156     43 82 57 82     imas
275             星輝子  15    142     35 73 53 75     imas
278         野々村そら  15    157     46 84 57 85     imas
293         喜多日菜子  15    151     38 78 56 78     imas
298 キャシー・グラハム  15    168     49 83 56 85     imas
300         浜口あやめ  15    154     42 78 55 80     imas
302           土屋亜子  15    156     42 85 54 83     imas

$`54`
          name age height weight  B  W  H type
115   片山実波  14    150     40 72 57 84  WUG
137 高槻やよい  14    145     37 74 54 78 imas
153 柳瀬美由紀  14    144     33 75 54 77 imas
157     関裕美  14    155     43 78 55 80 imas
178   輿水幸子  14    142     37 74 52 75 imas
191   池袋晶葉  14    148     39 75 53 74 imas
222   神崎蘭子  14    156     41 81 57 80 imas
246 森久保乃々  14    149     38 73 55 76 imas
263   矢口美羽  14    150     41 81 56 80 imas
270   上田鈴帆  14    158     42 76 55 79 imas
287 ナターリア  14    155     43 84 55 86 imas
297   三好紗南  14    149     39 75 56 80 imas
304     南条光  14    140     41 79 58 80 imas

$`55`
          name age height weight  B  W  H type
117 久海菜々美  13    148     39 74 50 79  WUG
124   鈴木萌歌  13    146     35 69 55 75  WUG
144   椎名法子  13    147     38 76 55 79 imas
234   白坂小梅  13    142     34 65 50 70 imas
236 氏家むつみ  13    152     42 78 57 80 imas
238   成宮由愛  13    150     40 72 51 73 imas
248     望月聖  13    150     37 82 56 86 imas
251   双海亜美  13    158     42 78 55 77 imas
252   双海真美  13    158     42 78 55 77 imas
273   小関麗奈  13    148     41 75 50 77 imas
301     村上巴  13    146     37 74 53 76 imas
303     首藤葵  13    145     39 73 53 75 imas

$`57`
                    name age height weight  B  W  H type
123           相沢菜野花  19    160     42 80 58 84  WUG
148             奥山沙織  19    156     47 83 57 81 imas
155               江上椿  19    161     46 80 57 80 imas
164       宮本フレデリカ  19    164     46 83 57 85 imas
170             涼宮星花  19    158     45 82 57 83 imas
194             秋月律子  19    156     43 85 57 85 imas
199             桐野アヤ  19    160     43 86 56 86 imas
214             新田美波  19    165     45 82 55 85 imas
219           小室千奈美  19    164     45 84 56 82 imas
227             瀬名詩織  19    165     48 85 58 83 imas
233             梅木音葉  19    172     49 86 58 85 imas
235             岸部彩華  19    162     46 89 59 85 imas
239               藤居朋  19    163     45 78 57 83 imas
289             槙原志保  19    162     46 86 57 91 imas
296             小松伊吹  19    165     48 85 59 88 imas
305 イヴ・サンタクロース  19    165     44 81 56 80 imas
306   ルーキートレーナー  19    157     45 77 56 82 imas

$`58`
          name age height weight  B  W  H type
154   櫻井桃華  12    145     39 72 53 75 imas
185   古賀小春  12    140     35 72 54 77 imas
216   橘ありす  12    141     34 68 52 67 imas
282 城ヶ崎莉嘉  12    149     36 72 54 75 imas

$`99`
                  name age height weight  B  W  H type
143             福山舞  10    132     28 64 56 70 imas
158           横山千佳   9    127     31 60 55 65 imas
209         佐々木千枝  11    139     33 73 49 73 imas
229           佐城雪美  10    137     30 63 47 65 imas
258             龍崎薫   9    132     32 65 51 70 imas
264         赤城みりあ  11    140     36 75 55 78 imas
291           市原仁奈   9    128     29 61 57 67 imas
295 メアリー・コクラン  11    150     40 83 58 87 imas
# SPADE
library(spade)
library(flowViz)
dat <- read.csv("animegirls.csv")
dat1 <- subset(dat, select=-c(name, type))
fcs <- new("flowFrame", as.matrix(dat1))
write.FCS(fcs, "animedata.fcs")

data_file_path = "animedata.fcs"
output_dir <- "fcs"
SPADE.driver(data_file_path, out_dir=output_dir)
# Compute and annotate FCS file with density
density_file_path <- "hoge.density.fcs"
SPADE.addDensityToFCS(data_file_path, density_file_path)

# Downsample FCS file based on density
downsample_file_path <- "hoge.density.fcs"
SPADE.downsampleFCS(density_file_path, downsample_file_path)

# Create tree from downsampled FCS file
cells_file_path <- paste(output_dir, "clusters.fcs", sep="")
clust_file_path <- paste(output_dir, "clusters.table", sep="")
graph_file_path <- paste(output_dir, "mst.gml", sep="")
SPADE.FCSToTree(downsample_file_path, cells_file_path, graph_file_path, clust_file_path)

## Add cluster to FCS files (known as "upsampling")
data_file_path = "animedata.fcs"
output_dir <- "fcs"
cells_file_path <- "clusters.fcs"
upsample_file_path <- "upsamle.fcs"
SPADE.addClusterToFCS(data_file_path, upsample_file_path, cells_file_path)
up <- read.FCS("upsamle.fcs")
write.table(up@exprs[, "cluster"], "clusterID.txt", row.names=FALSE, col.names=FALSE)
cl <- unlist(read.csv("clusterID.txt", header=FALSE))

sp <- split(dat, cl)
names(sp) <- sort(unique(cl)) - 1

mst_graph <- igraph0:::read.graph(paste(output_dir,"mst.gml",sep=.Platform$file.sep),format="gml")
clust <- read.table(paste(output_dir, "/clusters.table", sep=""), sep=" ", header=TRUE)
lay0 <- read.table(paste(output_dir,"layout.table", sep=.Platform$file.sep))
library(gplots)

plotlay <- rbind(matrix(rep(c(1,3,5), each=4), 2), matrix(rep(c(7,9,11), each=4), 2))
plotlay[2, c(1,3,5)] <- c(2,4,6)
plotlay[4, c(1,3,5)] <- c(8,10,12)
layout(plotlay, heights=rep(c(7,1), 2))

lay1 <- layout.norm(as.matrix(lay0), -1, 1, -1, 1)
rd0 <- 0.04
rd1 <- c(0.2, 0.1, 0.3, 0.3, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1)
th <- c(306, 200, 10, 80, -20, -20, 230, -10, 70, 20, -20)*pi/180
ch <- c("東條希\n絢瀬絵里\n矢澤にこ", "クロエ・ルメール", "南ことり\n高坂穂乃果\n園田海未\n如月千早",
        "三浦あずさ", "近藤麻衣\n鈴木玲奈", "小泉花陽\n西木野真姫\n星空凛\n渋谷凛\n星井美希", "神崎蘭子",
        "双海亜美\n双海真美", "秋月律子", "城ヶ崎莉嘉", "横山千佳")
pos <- c(4, 2, 4, 3, 4, 4, 1, 4, 4, 4, 4)
	
for(m in head(seq(ncol(clust)), -1)){
	cut0 <- seq(min(clust[,m]), max(clust[,m]), length=99) # ノードの色付け
	g0 <- mst_graph
	V(g0)$name <- seq(get.adjlist(g0))
	#V(g0)$label <- NA
	V(g0)$size <- clust[,m]+4
	V(g0)$frame.color <- "black"
	V(g0)$color <- bluered(100)[cut(clust[,m], cut0, include.lowest=TRUE)]
	par(mar=c(0, 0, 3, 0))
	plot(g0, layout=as.matrix(lay0))
	title(colnames(clust)[m], cex.main=3)
	
	for(s in seq(sp)){
		idx <- as.numeric(names(sp)[s])+1
		x1 <- lay1[idx, 1] + rd0*cos(th[s]); x0 <- x1 + rd1[s]*cos(th[s])
		y1 <- lay1[idx, 2] + rd0*sin(th[s]); y0 <- y1 + rd1[s]*sin(th[s])
		arrows(x0, y0, x1, y1, lwd=2, length=0.08)
		text(x0, y0, ch[s], pos=pos[s], cex=1)
	}
	par(mar=c(3, 2, 0, 0))
	x <- sort(clust[,m])
	image(x=seq(min(x), max(x), length=length(x)), z=as.matrix(x), col=bluered(100), yaxt="n")
}