• 实战--利用Lloyd算法进行酵母基因表达数据的聚类分析


    背景:酵母会在一定的时期发生diauxic shift,有一些基因的表达上升,有一些基因表达被抑制,通过聚类算法,将基因表达的变化模式聚成6类。

    ORF	Name	R1.Ratio	R2.Ratio	R3.Ratio	R4.Ratio	R5.Ratio	R6.Ratio	R7.Ratio
    1	YDR025W	RPS18A	0.136061549576028	-0.111031312388744	-0.189033824390017	-0.782408564927373	-0.75702324650746	-0.855989697308481	-2.30451104180995
    2	YDR031w		-0.286881147788162	-0.0840642647884746	0.184424571137428	0.136061549576028	0.535331732996556	2.32192809488736	1.25153876699596
    3	YDR060w		-0.0426443374084937	-0.0976107966264223	-0.0143552929770701	-0.799087306074004	-0.839959587489532	-2.24792751344359	-2.38681094647222
    4	YDR064W	YS15	-0.0565835283663676	-0.124328135002202	-0.070389327891398	-0.545968369105293	-0.55581615506164	-2.10433665981474	-2.36737106564853
    5	YDR070c		0.0144995696951152	0.0740005814437768	0.0588936890535686	0.0144995696951152	0.251538766995964	2.39592867633114	1.68965987938785
    6	YDR144C	MKC7	0.136061549576028	-0.0426443374084937	-0.298658315564515	-0.871843648509318	-1.14404636961671	-2.42223300068305	-2.72246602447109
    7	YDR171W	HSP42	0.0740005814437768	0.136061549576028	0.434402824145775	0.836501267717121	0.943416471633632	3.64385618977472	3.32192809488736
    8	YDR178W	SDH4	-0.189033824390017	-0.028569152196771	0.599462070416271	0.888968687611256	0.836501267717121	2.55639334852439	2.64385618977472
    9	YDR258C	HSP78	-0.250961573533219	0.136061549576028	-0.22650852980868	0.862496476250065	0.62148837674627	2.55639334852439	2.39592867633114
    10	YBL015W	ACH1	-0.111031312388744	0.0588936890535686	0.0144995696951152	0.104697378666693	0.3040061868901	2.73696559416621	3.32192809488736
    11	YDR272W	GLO2	-0.028569152196771	-0.0976107966264223	0.358453970912476	0.434402824145775	0.377069649079823	2.55639334852439	1.25153876699596
    12	YDR272W		0.0740005814437768	0.3040061868901	0.494109070270043	0.473931188332412	0.377069649079823	2.32192809488736	1.47393118833241
    13	YDR342C	HXT7	0.184424571137428	0.434402824145775	0.943416471633632	1.51457317282976	1.64385618977472	2.32192809488736	1.59946207041627
    14	YDR343C	HXT6	0.15200309344505	0.761213140412884	1.28630418515664	1.94341647163363	1.51457317282976	2.18442457113743	2.64385618977472
    15	YBL027W	RPL19A	0.0439433475875972	0.0144995696951152	0.395928676331139	-0.16349873228288	-0.27500704749987	-1.11103131238874	-2.44360665147561
    16	YDR382W	RPLA4	0.104697378666693	0.15200309344505	0.104697378666693	0.0588936890535686	0.0439433475875972	-0.604071323668861	-2.36457243229586
    17	YDR398W		-0.0143552929770701	-0.0840642647884746	-0.124328135002202	-1.03562390973072	-1.1243281350022	-2.02147972741045	-2.799087306074
    18	YDR417C		0.321928094887362	0.120294233717712	0.0892673380970873	-0.344828496997441	-0.250961573533219	-1.64616265715789	-2.54596836910529
    19	YDR418W	RPL15A	0.200912693925996	0.168122758808327	0.286304185156641	-0.20163386116965	-0.20163386116965	-1.75274859140713	-2.99638874644762
    20	YDR516C		-0.137503523749935	0.2688167584278	0.415037499278844	0.785875194647153	0.713118852211838	2.32192809488736	1.02914634565952
    21	YBL043W		-0.516015147003665	0.0740005814437768	0	-0.214124805352847	-0.53605290024021	1.94341647163363	2.32192809488736
    22	YDR529C	QCR7	0.168122758808327	0.0291463456595165	0.377069649079823	0.862496476250065	0.810966175609983	2.18442457113743	2.55639334852439
    23	YDR533C		-0.070389327891398	0.0588936890535686	0.577766999316952	0.415037499278844	0.0144995696951152	2.73696559416621	2.39592867633114
    24	YBL045C	COR1	0.0740005814437768	0	0.68965987938785	0.514573172829758	0.15200309344505	1.68965987938785	2.47393118833241
    25	YEL011w	GLC3	-0.286881147788162	0.120294233717712	0.494109070270043	0.836501267717121	0.494109070270043	2.64385618977472	2.83650126771712
    26	YEL012w	UBC8	-0.0840642647884746	-0.298658315564515	0.0740005814437768	0.0740005814437768	-0.356143810225275	1.32192809488736	2.32192809488736
    27	YEL024w	RIP1	0.0892673380970873	0.2688167584278	0.556393348524385	0.888968687611256	0.943416471633632	1.94341647163363	2.32192809488736
    28	YBL048W		-0.250961573533219	0.104697378666693	-0.150559676575381	-0.22650852980868	-0.356143810225275	2.55639334852439	2.18442457113743
    29	YBL049W		-0.584962500721156	0.168122758808327	0.184424571137428	-0.150559676575381	-0.823749360308273	2.47393118833241	2.64385618977472
    30	YEL054c	RPL15A	0.200912693925996	0.0892673380970873	0.321928094887362	-0.321928094887362	-0.475084882948783	-1.64154602908752	-2.46466826700344
    31	YER024w		-0.27500704749987	-0.150559676575381	0.168122758808327	-0.356143810225275	-0.495695162624069	1.12029423371771	3.18442457113743
    32	YER053c		-0.189033824390017	0.358453970912476	1.02914634565952	1.51457317282976	1.64385618977472	2.18442457113743	2.64385618977472
    33	YER065c	ICL1	0.120294233717712	0.168122758808327	0.535331732996556	0.0892673380970873	-0.150559676575381	0.535331732996556	3.64385618977472
    34	YER067w		-0.070389327891398	0.15200309344505	0.761213140412884	1.02914634565952	0.377069649079823	3.18442457113743	2.55639334852439
    35	YBL064C		0.377069649079823	0.0439433475875972	0.736965594166206	0.888968687611256	0.761213140412884	3.47393118833241	2.83650126771712
    36	YER131w	RPS26B	0.358453970912476	0.136061549576028	0.473931188332412	0.0439433475875972	-0.0143552929770701	-1.36737106564853	-2.48800077083407
    37	YER150w		-0.0143552929770701	0.184424571137428	1.15200309344505	1.51457317282976	1.59946207041627	3.47393118833241	3.32192809488736
    38	YAL003W	TEF5	0.234465253637023	0	-0.0426443374084937	-0.641546029087524	-0.933572638261024	-1.53605290024021	-2.33342373372519
    39	YFL014W	HSP12	-0.150559676575381	0.377069649079823	0.62148837674627	1.59946207041627	2.25153876699596	3.64385618977472	3.47393118833241
    40	YFL054C		-0.678071905112638	-0.36737106564853	-0.137503523749935	-0.27500704749987	-0.176322772640463	2.47393118833241	0.971430847803229
    41	YBL078C		-0.400537929583729	-0.16349873228288	0.136061549576028	0.234465253637023	0.321928094887362	2.32192809488736	2.12029423371771
    42	YFR015C	GSY1	-0.22650852980868	0.0439433475875972	0.415037499278844	1.55639334852439	1.02914634565952	2.73696559416621	2.73696559416621
    43	YFR033C	QCR6	0.0588936890535686	-0.111031312388744	0.0291463456595165	0.321928094887362	0.62148837674627	2.39592867633114	1.88896868761126
    44	YFR053C	HXK1	0.184424571137428	0.321928094887362	0.395928676331139	1	1.47393118833241	2.55639334852439	0.377069649079823
    45	YGL031C	RPL30A	0.0291463456595165	0	0.0439433475875972	-0.137503523749935	0	-0.669026765509631	-2.31324585178756
    46	YGL037C		0.200912693925996	0.377069649079823	0.286304185156641	1.15200309344505	1.47393118833241	2.83650126771712	1.83650126771712
    47	YGL076C	RPL6A	0.0740005814437768	-0.411426245726465	-0.028569152196771	-0.790772037862	-0.839959587489532	-1.6959938131099	-2.78868571061353
    48	YGL078C		-0.0143552929770701	-0.250961573533219	0.321928094887362	-0.831877241191673	-0.831877241191673	-1.46988597627446	-2.4594316186373
    49	YGL102C		0.0291463456595165	-0.0976107966264223	0.168122758808327	0	-0.028569152196771	-1.39506279951758	-2.55090066464752
    50	YBL100C		0.136061549576028	0.217591435072627	0.415037499278844	0.577766999316952	0.888968687611256	1.28630418515664	2.39592867633114
    51	YGL191W	COX13	0.0439433475875972	-0.070389327891398	0.0291463456595165	0.0291463456595165	0.888968687611256	2.47393118833241	2.32192809488736
    52	YBL108W		0.0439433475875972	0.0892673380970873	0.395928676331139	0.217591435072627	0.971430847803229	0.888968687611256	2.39592867633114
    53	YGL259W		-0.137503523749935	-0.070389327891398	0.473931188332412	0.643856189774725	0.377069649079823	1.68965987938785	2.83650126771712
    54	YGR008C	STF2	-0.0565835283663676	0.0439433475875972	0.494109070270043	1.12029423371771	1.05889368905357	2.73696559416621	2.05889368905357
    55	YGR043C		-0.432959407276106	-0.7311832415722	-0.0565835283663676	-0.111031312388744	-0.16349873228288	3.47393118833241	2.64385618977472
    56	YGR067C		0.0439433475875972	-0.0976107966264223	0.168122758808327	-0.344828496997441	-0.37851162325373	0.599462070416271	2.39592867633114
    57	YGR088W	CTT1	0.15200309344505	0.0588936890535686	0.217591435072627	0.736965594166206	0.971430847803229	3.64385618977472	2.94341647163363
    58	YGR103W		0.15200309344505	-0.0565835283663676	0.321928094887362	-0.903038270112912	-1.10433665981474	-1.64154602908752	-2.56315813040281
    59	YGR148C	RPL30B	0.200912693925996	0.104697378666693	0.0588936890535686	-0.286881147788162	-0.27500704749987	-1.81966818349646	-2.61588707391606
    60	YGR160W		0.321928094887362	0.104697378666693	-0.250961573533219	-1.48542682717024	-1.48026512205446	-2.50842865253186	-3.21412480535285
    61	YGR214W	NAB1A	0.2688167584278	0.15200309344505	0.454031630894707	-0.36737106564853	-0.286881147788162	-1.66902676550963	-2.45154083301783
    62	YGR236C		-0.124328135002202	-0.189033824390017	-0.298658315564515	-0.495695162624069	-0.641546029087524	3.47393118833241	2.83650126771712
    63	YGR243W		-0.344828496997441	-0.27500704749987	-0.37851162325373	-0.20163386116965	-0.411426245726465	3.18442457113743	2.47393118833241
    64	YGR244C		0.0439433475875972	0.2688167584278	0.761213140412884	0.943416471633632	1.47393118833241	2.39592867633114	2.05889368905357
    65	YGR248W		-0.298658315564515	-0.389566811762726	0.434402824145775	0.666576266274808	1.39592867633114	4.05889368905357	2.47393118833241
    66	YGR264C	MES1	0.415037499278844	0.434402824145775	0	-0.722466024471091	-0.815575428862572	-2.55581615506164	-2.08746284125034
    67	YHL015W	URP2	0.168122758808327	0.321928094887362	0.104697378666693	-0.0840642647884746	-0.176322772640463	-1.80322703643493	-2.85598969730848
    68	YHL021C		-0.443606651475615	0.120294233717712	0.643856189774725	1	0.785875194647153	2.94341647163363	2.47393118833241
    69	YHL033C	RPL4A	0.340075441597622	0.217591435072627	0.184424571137428	-0.176322772640463	-0.505890929729957	-1.56559717585423	-2.51349074558812
    70	YBR032W		0	0.15200309344505	0.395928676331139	0.136061549576028	-0.0565835283663676	-1.09761079662642	-2.39780296186249
    71	YAL012W	CYS3	0.104697378666693	-0.0143552929770701	0.556393348524385	-0.575312330687437	-0.7311832415722	-1.25096157353322	-2.52105073690096
    72	YHR051W	COX6	0.200912693925996	0.0291463456595165	0.200912693925996	0.415037499278844	0.761213140412884	2.18442457113743	2.47393118833241
    73	YHR087W		-0.411426245726465	-0.422233000683048	-0.111031312388744	0.104697378666693	0.888968687611256	2.94341647163363	0.971430847803229
    74	YHR089C	GAR1	-0.20163386116965	-0.333423733725192	-0.137503523749935	-0.713695814843359	-0.464668267003444	-2.16992500144231	-2.63459326844576
    75	YHR096C	HXT5	-0.124328135002202	-0.0426443374084937	0.666576266274808	0.321928094887362	-0.321928094887362	1.43440282414577	3.05889368905357
    76	YHR104W		0.286304185156641	0.2688167584278	0.556393348524385	0.643856189774725	0.577766999316952	2.39592867633114	1.25153876699596
    77	YHR128W	FUR1	0.234465253637023	0.0740005814437768	0.234465253637023	-0.713695814843359	-0.669026765509631	-1.87184364850932	-2.34482849699744
    78	YBR048W	RPS18B	0.120294233717712	0.200912693925996	0.0740005814437768	-0.411426245726465	-0.992768430768924	-1.51601514700366	-2.48026512205446
    79	YBR051W		-0.150559676575381	0.200912693925996	0	-0.400537929583729	-0.941106310946431	0.321928094887362	2.64385618977472
    80	YIL018W	RPL5A	0.3040061868901	0.0892673380970873	0.2688167584278	-0.214124805352847	-0.176322772640463	-1.37295209791183	-2.33913738491959
    81	YIL053W	GPP1	0.2688167584278	-0.0143552929770701	-0.22650852980868	-0.941106310946431	-1.23878685958712	-2.32768736417605	-2.95791459863299
    82	YIL069C	RP50B	-0.0565835283663676	-0.495695162624069	-0.411426245726465	-0.641546029087524	-0.704871964456353	-1.9560566524124	-2.44625622988956
    83	YIL111W	COX5B	-0.0840642647884746	0.136061549576028	0.666576266274808	1.08926733809709	1.47393118833241	2.94341647163363	1.08926733809709
    84	YIL113W		-0.333423733725192	-0.356143810225275	-0.298658315564515	0.0439433475875972	-0.0840642647884746	2.39592867633114	1.28630418515664
    85	YIL125W	KGD1	0.234465253637023	0.556393348524385	0.377069649079823	0.120294233717712	0.494109070270043	1.43440282414577	2.94341647163363
    86	YIL136W	OM45	-0.978195629681652	-0.263034405833794	0.217591435072627	-0.250961573533219	1.32192809488736	3.47393118833241	1.78587519464715
    87	YIL162W	SUC2	0.0588936890535686	0.377069649079823	0.785875194647153	0.377069649079823	0.0439433475875972	2.73696559416621	1.35845397091248
    88	YBR072W	HSP26	-0.0143552929770701	0.395928676331139	0.358453970912476	1	1.43440282414577	3.47393118833241	2.83650126771712
    89	YJL045W		-0.333423733725192	-0.189033824390017	0.415037499278844	-0.0840642647884746	-0.485426827170242	1	2.32192809488736
    90	YJL089W	SIP4	-0.632268215499513	-0.344828496997441	-0.238786859587116	-0.189033824390017	-0.250961573533219	1.12029423371771	3.05889368905357
    91	YJL109C		-0.0840642647884746	0.0291463456595165	-0.111031312388744	-1.17632277264046	-1.08406426478847	-3.23419472295381	-1.98913900736823
    92	YJL136C	RPS25B	0.184424571137428	-0.0840642647884746	0.340075441597622	-0.070389327891398	-0.475084882948783	-1.46466826700344	-2.35895882583233
    93	YJL148W		0.0892673380970873	-0.20163386116965	0.168122758808327	-0.75702324650746	-0.678071905112638	-1.29278174922785	-2.41413553298445
    94	YJL177W	RPL20B	0.340075441597622	0.136061549576028	0.136061549576028	-0.422233000683048	-0.622930350920177	-1.93357263826102	-2.38956681176273
    95	YJL190C	RPS24A	0.120294233717712	-0.189033824390017	0.340075441597622	0.0892673380970873	-0.0840642647884746	-1.4594316186373	-2.32481060342048
    96	YJR095W	ACR1	-0.613531652917927	-0.464668267003444	1.08926733809709	-0.124328135002202	-0.176322772640463	1.35845397091248	3.64385618977472
    97	YJR096W		-0.411426245726465	0.217591435072627	0.200912693925996	0.340075441597622	0.943416471633632	2.83650126771712	1.43440282414577
    98	YJR123W	RPS5	0.104697378666693	0.0892673380970873	0.168122758808327	-0.37851162325373	-0.411426245726465	-1.85598969730848	-2.48026512205446
    99	YJR145C	RPS7B	0.0740005814437768	0.0588936890535686	-0.250961573533219	-0.565597175854225	-0.422233000683048	-1.53605290024021	-2.61353165291793
    100	YKL009W		-0.150559676575381	-0.443606651475615	-0.0976107966264223	-0.790772037862	-1.07724299893246	-2.03913839390696	-2.52105073690096
    101	YKL026C		-0.189033824390017	-0.150559676575381	0.0291463456595165	0.2688167584278	0.535331732996556	3.64385618977472	2.73696559416621
    102	YBR116C		-0.16349873228288	0.184424571137428	0.0439433475875972	-0.22650852980868	-0.422233000683048	1.78587519464715	2.39592867633114
    103	YBR117C	TKL2	0.358453970912476	0.643856189774725	0.68965987938785	0.0439433475875972	-0.27500704749987	1.64385618977472	2.47393118833241
    104	YKL081W	TEF4	0.0740005814437768	-0.150559676575381	-0.0143552929770701	-0.925999418556223	-0.722466024471091	-2.15704371014558	-2.43562859405209
    105	YKL085W	MDH1	0.0439433475875972	0.0144995696951152	0.286304185156641	0.915935735211525	1.35845397091248	2.83650126771712	2.55639334852439
    106	YKL103C	LAP4	-0.070389327891398	0.377069649079823	0.473931188332412	0.888968687611256	1.32192809488736	2.39592867633114	1.68965987938785
    107	YKL109W	HAP4	0.234465253637023	0.577766999316952	1.02914634565952	0.666576266274808	0.62148837674627	2.55639334852439	3.18442457113743
    108	YKL141W	SDH3	0.358453970912476	0.168122758808327	0.643856189774725	0.785875194647153	1.15200309344505	1.94341647163363	2.64385618977472
    109	YKL142W	MRP8	-0.070389327891398	0.217591435072627	0.234465253637023	0.494109070270043	1.02914634565952	2.47393118833241	1.15200309344505
    110	YKL151C		-0.124328135002202	0.234465253637023	0.577766999316952	0.62148837674627	0.251538766995964	2.55639334852439	1.78587519464715
    111	YKL187C		0.0439433475875972	0.0740005814437768	0.200912693925996	-0.16349873228288	-0.400537929583729	2.12029423371771	3.32192809488736
    112	YKL193C	SDS22	-0.0565835283663676	-0.124328135002202	-0.263034405833794	0.184424571137428	0.514573172829758	2.47393118833241	1.43440282414577
    113	YKL217W	JEN1	-0.485426827170242	-0.070389327891398	0.0439433475875972	-0.333423733725192	0.120294233717712	3.47393118833241	3.83650126771712
    114	YKR059W	TIF1	0.217591435072627	0.0740005814437768	0.473931188332412	-0.27500704749987	-0.505890929729957	-1.44360665147561	-2.3305584000308
    115	YBR139W		0.120294233717712	0.514573172829758	0.434402824145775	1.08926733809709	0.888968687611256	2	2.39592867633114
    116	YKR097W	PCK1	-0.124328135002202	-0.176322772640463	0.434402824145775	-0.0840642647884746	-0.250961573533219	0.415037499278844	3.83650126771712
    117	YLL026w	HSP104	0.0144995696951152	0.0144995696951152	-0.189033824390017	0.836501267717121	1	2.39592867633114	2.64385618977472
    118	YBR147W		-0.0976107966264223	0.340075441597622	-0.028569152196771	0.0740005814437768	0.251538766995964	3.05889368905357	2.47393118833241
    119	YLL041c	SDH2	-0.0565835283663676	-0.0976107966264223	0.494109070270043	1.05889368905357	1.43440282414577	2.55639334852439	2.64385618977472
    120	YLL044W		0.286304185156641	0.0144995696951152	-0.16349873228288	-0.443606651475615	-0.713695814843359	-2.09085343045111	-2.53356334821451
    121	YLL045c	RPL4B	0.184424571137428	-0.176322772640463	-0.0840642647884746	-0.111031312388744	-0.111031312388744	-1.94860084749336	-3.06522762277562
    122	YLR048w	NAB1B	0.321928094887362	0.234465253637023	0.454031630894707	-0.111031312388744	-0.344828496997441	-1.9297909977186	-2.58736499093646
    123	YLR062C		0.184424571137428	-0.0565835283663676	0.0588936890535686	-0.356143810225275	-0.0976107966264223	-1.91073266190291	-2.86591881455221
    124	YLR076C		0.217591435072627	-0.0426443374084937	0.0892673380970873	0.0740005814437768	-0.31034012061215	-1.49569516262407	-2.32481060342048
    125	YLR129w	DIP2	-0.344828496997441	-0.37851162325373	-0.286881147788162	-0.887525270741588	-0.863938450423972	-2.81147103052984	-2.09423606984577
    126	YLR142w	PUT1	-0.176322772640463	-0.464668267003444	-0.505890929729957	-0.263034405833794	-0.20163386116965	0.514573172829758	2.39592867633114
    127	YLR149C		-0.263034405833794	-0.124328135002202	-0.189033824390017	0.599462070416271	0.286304185156641	2.47393118833241	2.73696559416621
    128	YLR174W	IDP2	-0.111031312388744	-0.286881147788162	0.713118852211838	0.120294233717712	-0.137503523749935	1.28630418515664	3.32192809488736
    129	YLR178C	TFS1	-0.22650852980868	-0.214124805352847	-0.0565835283663676	0.761213140412884	1.25153876699596	2.64385618977472	1.78587519464715
    130	YLR180W	SAM1	0.184424571137428	0.2688167584278	0.217591435072627	-0.925999418556223	-1.0703893278914	-2.54596836910529	-3.06350294230616
    131	YLR186W		0.0740005814437768	-0.0426443374084937	-0.298658315564515	-1	-0.687060688339892	-1.38956681176273	-2.42223300068305
    132	YLR196W	PWP1	0.251538766995964	0.0892673380970873	0.2688167584278	-0.855989697308481	-0.925999418556223	-1.53605290024021	-2.78240856492737
    133	YLR198C		0.3040061868901	0.0144995696951152	0.454031630894707	-0.150559676575381	-0.22650852980868	-1.36176835941915	-2.47767732756531
    134	YLR249W	YEF3	0.0588936890535686	0.0291463456595165	0.120294233717712	-0.765534746362977	-0.0565835283663676	-1.47508488294878	-2.76128527336162
    135	YLR258W	GSY2	0.104697378666693	0.434402824145775	0.454031630894707	1.88896868761126	2	3.32192809488736	2.55639334852439
    136	YLR267W		-0.124328135002202	0.120294233717712	0.2688167584278	-0.111031312388744	-0.485426827170242	1.64385618977472	2.73696559416621
    137	YLR270W		0.104697378666693	-0.028569152196771	0.217591435072627	0.62148837674627	0.377069649079823	3.05889368905357	1.51457317282976
    138	YLR304C	ACO1	0.200912693925996	0.556393348524385	0.494109070270043	1.02914634565952	1.21759143507263	1.94341647163363	2.64385618977472
    139	YLR312C		-0.613531652917927	-0.659924558402378	0	0.184424571137428	-0.27500704749987	1.25153876699596	2.32192809488736
    140	YBR181C	RPS101	0.184424571137428	0.217591435072627	0.200912693925996	0.0892673380970873	0.120294233717712	-1.58496250072116	-2.56803210477128
    141	YLR325C		0.0439433475875972	0.0144995696951152	0.120294233717712	0.0291463456595165	-0.298658315564515	-1.54596836910529	-2.59454854955035
    142	YLR327C		-0.189033824390017	-0.333423733725192	0.0892673380970873	0.915935735211525	1.08926733809709	3.32192809488736	2.64385618977472
    143	YLR339C		0.321928094887362	0.473931188332412	0.3040061868901	-0.214124805352847	-0.669026765509631	-1.78240856492737	-2.55826763405574
    144	YLR340W	RPLA0	0.200912693925996	0.321928094887362	0.473931188332412	-0.0840642647884746	-0.443606651475615	-1.8073549220576	-2.77610398807316
    145	YBR183W		-0.36737106564853	-0.400537929583729	0.395928676331139	1.05889368905357	0.862496476250065	2.55639334852439	1.43440282414577
    146	YLR344W	RPL33A	-0.0840642647884746	-0.176322772640463	-0.356143810225275	-0.704871964456353	-0.505890929729957	-1.56559717585423	-2.37851162325373
    147	YLR355C	ILV5	0.358453970912476	0.0588936890535686	-0.454175893185802	-1.24488705912353	-1.22032995487956	-2.39231742277876	-2.13422093976063
    148	YLR356W		-0.111031312388744	0.599462070416271	0.535331732996556	0.862496476250065	0.810966175609983	2.83650126771712	1.88896868761126
    149	YLR377C	FBP1	-0.22650852980868	-0.028569152196771	0.251538766995964	-0.16349873228288	-0.124328135002202	0.473931188332412	3.83650126771712
    150	YBR189W	SUP46	-0.028569152196771	-0.31034012061215	0.0291463456595165	-0.27500704749987	-0.545968369105293	-1.97819562968165	-2.65535182861255
    151	YLR413W		0.217591435072627	0.358453970912476	0.535331732996556	-0.650764559116902	-0.669026765509631	-2.4032677223393	-2.82781902461732
    152	YBR191W	URP1	0.0740005814437768	-0.250961573533219	0.0588936890535686	-0.238786859587116	-0.55581615506164	-1.73552217729654	-2.66902676550963
    153	YLR448W	YL16B	0.340075441597622	0.0291463456595165	-0.214124805352847	-0.613531652917927	-0.704871964456353	-1.89530262133331	-2.32768736417605
    154	YLR449W		-0.0426443374084937	-0.028569152196771	0.136061549576028	-1.19534759832222	-0.970853654340484	-2.61353165291793	-2.20789285164133
    155	YML054C	CYB2	-0.575312330687437	-0.0976107966264223	0.434402824145775	-0.111031312388744	-0.0426443374084937	2.32192809488736	2.94341647163363
    156	YML063W	RP10B	0.217591435072627	0.217591435072627	0.395928676331139	0.0144995696951152	-0.028569152196771	-1.58014548442338	-2.48542682717024
    157	YML128C		-0.124328135002202	0.200912693925996	0.971430847803229	1.55639334852439	1.35845397091248	4.32192809488736	3.47393118833241
    158	YMR090W		-0.176322772640463	0.0892673380970873	0.577766999316952	0.321928094887362	0.971430847803229	2.32192809488736	1.02914634565952
    159	YMR093W		0.0740005814437768	0	-0.454175893185802	-1.27500704749987	-1.33913738491959	-1.85199883711245	-2.46205231879643
    160	YMR105C	PGM2	0.136061549576028	0.535331732996556	0.713118852211838	1.73696559416621	1.47393118833241	3.18442457113743	2.64385618977472
    161	YMR107W		-0.411426245726465	-0.263034405833794	-0.20163386116965	-0.298658315564515	-0.111031312388744	2.32192809488736	2.32192809488736
    162	YMR121C	RPL13B	0.340075441597622	-0.0426443374084937	0.340075441597622	0.321928094887362	-0.111031312388744	-1.36176835941915	-2.4594316186373
    163	YMR131C		0.217591435072627	0.104697378666693	0.321928094887362	-0.411426245726465	-0.831877241191673	-1.33342373372519	-2.59693514238723
    164	YMR170C	ALD2	0.184424571137428	0.234465253637023	0.200912693925996	0.434402824145775	0.713118852211838	3.64385618977472	2.25153876699596
    165	YMR191W		-0.0143552929770701	0.15200309344505	0.599462070416271	0.514573172829758	0.377069649079823	1.83650126771712	2.32192809488736
    166	YMR217W	GUA1	0.15200309344505	0.120294233717712	0.184424571137428	-1.07724299893246	-1.27500704749987	-1.62293035092018	-2.7311832415722
    167	YMR250W		-0.0840642647884746	0.473931188332412	1.02914634565952	1.78587519464715	2.12029423371771	3.05889368905357	3.18442457113743
    168	YMR290C		0.120294233717712	-0.22650852980868	-0.238786859587116	-1.15704371014558	-1.40599235967584	-2.67129337248158	-3
    169	YNL002C	RLP7	-0.0976107966264223	-0.36737106564853	-0.250961573533219	-1.18269229751619	-0.871843648509318	-2.8011586560937	-2.38956681176273
    170	YBR238C		0.15200309344505	0.943416471633632	0.377069649079823	-0.782408564927373	-0.978195629681652	-1.50080205305716	-2.33913738491959
    171	YNL015W	PBI2	-0.070389327891398	-0.321928094887362	0.514573172829758	0.810966175609983	0.915935735211525	3.05889368905357	2.25153876699596
    172	YBR241C		-0.978195629681652	0.0588936890535686	0.415037499278844	0.184424571137428	-0.189033824390017	2.47393118833241	1.55639334852439
    173	YNL052W	COX5A	-0.238786859587116	-0.238786859587116	-0.0976107966264223	0.0892673380970873	0.643856189774725	1.78587519464715	2.32192809488736
    174	YNL065W		0	0.286304185156641	-0.214124805352847	-0.992768430768924	-0.214124805352847	-2.19219416528334	-2.39780296186249
    175	YNL067W	RPL9B	0.0439433475875972	-0.36737106564853	-0.137503523749935	-0.389566811762726	-0.22650852980868	-0.722466024471091	-2.38681094647222
    176	YNL069C	RP23	-0.0976107966264223	-0.0426443374084937	0.3040061868901	-0.20163386116965	-0.0840642647884746	-1.10433665981474	-2.74631276642546
    177	YNL096C		0.120294233717712	-0.028569152196771	-0.321928094887362	-0.495695162624069	-0.400537929583729	-2.19534759832222	-2.790772037862
    178	YBR247C	ENP1	-0.028569152196771	-0.214124805352847	-0.070389327891398	-1.17632277264046	-1.03562390973072	-1.20789285164133	-2.76553474636298
    179	YNL117W	MLS1	-0.31034012061215	-0.0426443374084937	0.713118852211838	-0.298658315564515	-0.263034405833794	0.761213140412884	3.18442457113743
    180	YNL119W		0.136061549576028	-0.028569152196771	0.3040061868901	-0.214124805352847	-0.20163386116965	-1.15704371014558	-2.79701297783614
    181	YBR249C	ARO4	0.15200309344505	0.0439433475875972	0.136061549576028	-0.432959407276106	-0.594548549550354	-2.02147972741045	-2.36176835941915
    182	YNL134C		0.136061549576028	0.0892673380970873	0.0740005814437768	0.104697378666693	0.2688167584278	2.32192809488736	2.05889368905357
    183	YNL141W		-0.16349873228288	-0.0426443374084937	-0.070389327891398	-1.25701061820602	-1.19534759832222	-2.81557542886257	-3.13093086982645
    184	YNL160W	YGP1	0.234465253637023	0.340075441597622	1.12029423371771	1.47393118833241	1.73696559416621	3.05889368905357	2.83650126771712
    185	YNL173C		-0.070389327891398	-0.250961573533219	0.104697378666693	0.862496476250065	0.785875194647153	2.64385618977472	1.68965987938785
    186	YNL174W		0.0588936890535686	-0.214124805352847	0.0144995696951152	-0.963474123974886	-0.879705766282288	-2.38681094647222	-1.18903382439002
    187	YNL175C		0.200912693925996	-0.189033824390017	0.120294233717712	-0.650764559116902	-0.903038270112912	-1.70043971814109	-2.62293035092018
    188	YNL194C		-0.286881147788162	0.0291463456595165	0.136061549576028	-0.16349873228288	0.3040061868901	3.83650126771712	3.32192809488736
    189	YNL195C		-0.321928094887362	-0.238786859587116	-0.111031312388744	-0.150559676575381	0.0291463456595165	0.761213140412884	2.32192809488736
    190	YNL200C		-0.22650852980868	-0.028569152196771	0.358453970912476	1.25153876699596	1.51457317282976	3.83650126771712	2.55639334852439
    191	YNL274C		0.0144995696951152	0.0588936890535686	0.358453970912476	0.643856189774725	0.494109070270043	2.73696559416621	1.68965987938785
    192	YNL301C	RP28B	0.217591435072627	-0.124328135002202	0.251538766995964	-0.298658315564515	-0.545968369105293	-1.89917563048051	-2.48284828306847
    193	YNL303W		-0.389566811762726	-0.748461233004036	-0.344828496997441	-0.613531652917927	-1.11103131238874	-2.56315813040281	-2.49569516262407
    194	YNL305C		-0.124328135002202	0.104697378666693	0.494109070270043	0.136061549576028	0.888968687611256	2.39592867633114	1.12029423371771
    195	YNR001C	CIT1	0.184424571137428	0.454031630894707	0.643856189774725	0.713118852211838	1.21759143507263	2.64385618977472	3.18442457113743
    196	YAL054C	ACS1	-0.669026765509631	-0.189033824390017	0	-0.189033824390017	-0.298658315564515	1.47393118833241	3.64385618977472
    197	YNR053C		0.200912693925996	0.415037499278844	0.286304185156641	-0.495695162624069	-0.594548549550354	-1.73984810269933	-2.39506279951758
    198	YOL120C	RP28A	0.2688167584278	-0.0840642647884746	0.395928676331139	-0.16349873228288	-0.594548549550354	-1.8073549220576	-2.41683974191283
    199	YOL032W		-0.070389327891398	-0.028569152196771	0.286304185156641	0.184424571137428	0.0892673380970873	2.55639334852439	1.68965987938785
    200	YOL039W	RPLA2	0.0740005814437768	-0.028569152196771	0.104697378666693	0	0	-0.16349873228288	-2.30158764660319
    201	YOL040C	RPS21	0.104697378666693	0.0588936890535686	-0.137503523749935	-0.411426245726465	-0.55581615506164	-1.53106949272595	-2.65535182861255
    202	YOL053C	DDR2	-0.111031312388744	-0.16349873228288	0.0892673380970873	0.888968687611256	0.915935735211525	2.55639334852439	1.78587519464715
    203	YOL084W		-0.31034012061215	0.120294233717712	0.434402824145775	0	-0.070389327891398	1.32192809488736	2.64385618977472
    204	YOR065W	CYT1	0.168122758808327	0.104697378666693	0.321928094887362	0.286304185156641	0.943416471633632	1.68965987938785	2.39592867633114
    205	YOR178C	GAC1	-0.189033824390017	-0.070389327891398	0.473931188332412	0.2688167584278	0.136061549576028	2.32192809488736	2.05889368905357
    206	YOR215C		0.0740005814437768	0	0.377069649079823	0.785875194647153	0.943416471633632	3.47393118833241	2.83650126771712
    207	YOR234C	RPL37B	0.0740005814437768	0.0740005814437768	-0.124328135002202	-0.36737106564853	-0.485426827170242	-1.6959938131099	-2.30158764660319
    208	YOR309C		0.200912693925996	0.0291463456595165	0.234465253637023	-0.641546029087524	-0.37851162325373	-2.09761079662642	-2.96347412397489
    209	YOR310C		0.15200309344505	-0.0143552929770701	0.340075441597622	-0.604071323668861	-0.641546029087524	-1.81966818349646	-3.09592441999854
    210	YCL025C		0	-0.028569152196771	0.434402824145775	0.0439433475875972	0.643856189774725	0.666576266274808	2.47393118833241
    211	YOR312C	RPL18B	0.234465253637023	-0.0143552929770701	0.251538766995964	-0.422233000683048	-0.454175893185802	-1.51601514700366	-2.53106949272595
    212	YOR374W		0	0.494109070270043	0.340075441597622	1	1.32192809488736	2.47393118833241	2.47393118833241
    213	YPL012W		0.0892673380970873	-0.27500704749987	-0.150559676575381	-1.17632277264046	-1.58496250072116	-2.9560566524124	-3.07553263116736
    214	YCL035C		0.0291463456595165	0.321928094887362	0.535331732996556	0.666576266274808	0.2688167584278	2.55639334852439	1.51457317282976
    215	YPL131W	RPL1	0.0588936890535686	0.0892673380970873	0.15200309344505	-0.823749360308273	-0.22650852980868	-1.65535182861255	-2.53356334821451
    216	YPL220W	SSM1A	0.0439433475875972	-0.0143552929770701	0.395928676331139	-0.356143810225275	-0.0426443374084937	-1.60407132366886	-2.76765479823735
    217	YPL226W		0.0439433475875972	0.0740005814437768	-0.0976107966264223	-0.839959587489532	-1.17632277264046	-1.88752527074159	-2.45680614923047
    218	YPR137W		0.0740005814437768	-0.176322772640463	-0.20163386116965	-0.887525270741588	-0.918386234446348	-1.6959938131099	-2.95419631038688
    219	YPR149W	NCE2	0.15200309344505	0.120294233717712	0.395928676331139	0.810966175609983	0.915935735211525	2.05889368905357	2.32192809488736
    220	YPR184W	GDE	-0.238786859587116	-0.0840642647884746	-0.27500704749987	0.200912693925996	0.556393348524385	1.51457317282976	2.64385618977472
    221	YDL215C	GDH2	-0.070389327891398	0.0439433475875972	0.0439433475875972	-0.464668267003444	-0.0565835283663676	0.3040061868901	2.32192809488736
    222	YDR258C	HSP78	-0.214124805352847	-0.0840642647884746	-0.263034405833794	0.666576266274808	0.915935735211525	2.18442457113743	2.47393118833241
    223	YCR010C		-0.485426827170242	-0.36737106564853	0.234465253637023	-0.36737106564853	-0.422233000683048	0.535331732996556	2.64385618977472
    224	YCR021c	HSP30	-0.790772037862	0.0144995696951152	1.88896868761126	1.55639334852439	0.862496476250065	3.64385618977472	3.32192809488736
    225	YDL083C		0.104697378666693	-0.286881147788162	-0.189033824390017	-0.650764559116902	-0.799087306074004	-1.17632277264046	-2.40053792958373
    226	YDL085w		-0.111031312388744	1	0.0588936890535686	-0.124328135002202	-0.27500704749987	2.05889368905357	2.83650126771712
    227	YDL136w		-0.070389327891398	-0.0143552929770701	-0.0426443374084937	-0.36737106564853	-0.214124805352847	-1.55090066464752	-2.56315813040281
    228	YDL199c		-0.0426443374084937	0.494109070270043	0.415037499278844	0.184424571137428	-0.344828496997441	1.73696559416621	2.32192809488736
    229	YDL204w		-0.36737106564853	0.915935735211525	-0.505890929729957	0.2688167584278	0.0892673380970873	4.05889368905357	3.05889368905357
    230	YDL208W	NHP2	0.0439433475875972	-0.150559676575381	0.0439433475875972	-0.575312330687437	-0.485426827170242	-2.14404636961671	-2.63691458035588
    230个基因的表达水平变化
    算法1 Lloyd Algorithm  k_mean clustering
    * Centers to Clusters: After centers have been selected, assign each data point to the cluster corresponding to its nearest center; ties are broken arbitrarily.
    * Clusters to Centers: After data points have been assigned to clusters, assign each cluster’s center of gravity to be the cluster’s new center.

     程序利用Lloyd算法,随机选取起始的Centers,并进行2000次迭代,选取最佳结果。

    python源码

      1 from os.path import dirname
      2 import numpy as np
      3 import math
      4 import random
      5 import matplotlib.pyplot as plt
      6 
      7 def  square_EuclideanDistance(vId,wId,Centers):
      8     s = 0
      9     for i in range(m):
     10         s += (points[vId][i]-Centers[wId][i])**2
     11     return s
     12 
     13 def Centers_to_Clusters(Centers):
     14     global Cluster
     15     Cluster = [[] for i in range(k)]
     16     Distortion = 0
     17     for i in range(len(points)):
     18         minVal = INF
     19         minId = -1
     20         for c in range(k):
     21             tmp = square_EuclideanDistance(i, c,Centers)
     22             if tmp < minVal:
     23                 minVal = tmp
     24                 minId = c
     25         Cluster[minId].append(i)
     26         Distortion += minVal
     27     return Distortion/points_num
     28             
     29 def Clusters_to_Centers():
     30     #print(Cluster)
     31     Centers = []
     32     for i in range(k):
     33         coordinate = [0 for i in range(m)]
     34         for pId in Cluster[i]:
     35             for j in range(m):
     36                 coordinate[j] += points[pId][j]        
     37         if len(Cluster[i])==0:
     38             coordinate = [0.5 for item in coordinate]
     39         else:
     40             coordinate = [item/len(Cluster[i]) for item in coordinate]
     41         Centers.append(coordinate)
     42     #print(Centers)
     43     return Centers
     44 
     45 def LloydClustering():
     46     global Cluster
     47     Centers = random.sample(points,k)
     48     minDistortion = INF    
     49     Distortion = Centers_to_Clusters(Centers)
     50     i = 0
     51     while(Distortion < minDistortion):
     52         i += 1
     53         #print('*%d iteration*...'%i)
     54         minDistortion = Distortion
     55         Centers = Clusters_to_Centers()
     56         Distortion = Centers_to_Clusters(Centers)        
     57     return [Centers,Distortion]
     58 
     59 if __name__ == '__main__':
     60     INF = 999999
     61     dataset = open(dirname(__file__)+'230genes_log_expression.txt').read().strip().split('
    ')
     62     dataset = [line.split() for line in dataset]
     63     name = [item[1] for item in dataset[1:]]
     64     k = 6 # 分成 6 类
     65     m = 7 # 数据的维度
     66     #print(m)
     67     # print(m,k)
     68     points = []
     69     for line in dataset[1:]:
     70         if(len(line)==10):
     71             points.append(list(map(float,line[3:])))
     72         elif(len(line)==9):
     73             points.append(list(map(float,line[2:])))
     74     
     75     points_num = len(points)
     76     out_Distortion = INF
     77     out_Centers = []
     78     out_i = -1
     79     for i in range(2000):
     80         [Centers,Distortion] = LloydClustering() #Distortion 精确度
     81         if Distortion<out_Distortion:
     82             out_Distortion = Distortion
     83             out_Centers = Centers
     84             out_i = i
     85     
     86     print(out_i,out_Distortion)
     87     
     88     for c in out_Centers:
     89         for i in range(len(c)):
     90             if i != 0:
     91                 print(' ',end='')
     92             print('%.3f'%c[i],end='')
     93         print('')
     94     
     95     x = [i for i in range(1,8)]
     96     
     97     plt.rcParams['figure.figsize']=(12,8)
     98     for i in range(len(points)):
     99             plt.plot(x,points[i],color='#C0C0C0',linewidth=1.5,linestyle='-',marker='.')
    100 
    101     for i in range(k):
    102         plt.plot(x,Centers[i],linewidth=1.5,linestyle='-',marker='.')
    103     plt.show()

     运行结果:

  • 相关阅读:
    ArcGis面要素空间连接,取相交面积最大者 C#
    迅雷下载器无限制版_无敏感_无限速
    redhat 6.8 配置 centos6 163 的 yum 源
    apache cgi 程序: End of script output before headers
    centos php 安装 decrypt
    url传输中+转为%2B取到变空格的问题
    快速搭建自己的搜索引擎
    ffmpeg 文件推流 rtsp和rtmp
    svn 服务器操作
    edusoho迁移
  • 原文地址:https://www.cnblogs.com/lokwongho/p/9903577.html
Copyright © 2020-2023  润新知