# clustering the data

조회 수: 2 (최근 30일)
FIR 2011년 11월 17일
i have 100 gene ,cluster the 100 data into 20 groups using the K-means method
so i will lhave in first column the cluster number(1 to100) 2nd column-total no of genes(ex 3)(for cluster no 1) genes included (9,7,8)(for cluster no 1)
i have to do it for all 20 rows
##### 댓글 수: 2없음 표시없음 숨기기
Amith Kamath 2011년 11월 17일
if you are clustering into 20 groups, then the cluster number for each gene will be one of 1 to 20, and not 1 to 100. Also, how many samples do you have, meaning if each gene is a column, how many rows do you have? You'll have to run kmeans columnwise then, as far as I know!
FIR 2011년 11월 19일
yes amith gene will be one of 1 to 20,I have one 100 rows and one column

댓글을 달려면 로그인하십시오.

### 채택된 답변

Amith Kamath 2011년 11월 19일
OK, so from what I understand, you are clustering the genes, and not the samples, which means that you need to transpose your sample-gene matrix, and then run kmeans. If you then type in:
IDX = kmeans(genedata',20); %where genedata is a matrix containing genes in rows, and samples in columns,
IDX will contain 100 elements, which contains numbers from 1 to 20, corresponding to which cluster the gene is in.
for i = 1:20
genenum(i) = sum(IDX == i);
end
and genenum will contain the number of genes in each cluster. You could alternatively take the histogram of IDX, and the resulting array will contain the same info as genenum.
If you'd want to include the genes included in each cluster as well, you can't store it in the same matrix as the numbers of elements are not the same in each 'cell' of the matrix, and hence I advise using cell variables instead. Hope this answers your questions!
##### 댓글 수: 2없음 표시없음 숨기기
FIR 2011년 11월 19일
yes amith i git it but please answer include the genes included in each cluster..i need it badly..trying these for long time but could not get...
my genedata is =[1:1:100]
Amith Kamath 2011년 11월 21일
I don't really know how your code will work if the genedata is just a set of 100 numbers! Whatever I answered was for a matrix of size 100x100, where each sample has a value for each gene, and there are (arbitrarily) 100 samples. Assuming the above is true, you should extract the indices of IDX that are 1, which are the gene indices in each cluster.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Cluster Analysis and Anomaly Detection에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by