forming a cell array from matrix

I want to include the genes included in each cluster .
i have genedata =[1:1:100]
the code given below is for number of genes in cluster. Now i want to include the genes included
genedata=[1:1:100]
IDX = kmeans(genedata',20)
for i = 1:20
genenum(i) = sum(IDX == i);
end

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Nov. 2011

0 Stimmen

First off, the loop you have is okay, but you could also replace it with the more efficient
genenum = accumarray(IDX(:));
As for including the genes included: you are not clear as to what you mean by that, so I will guess:
genes = cell(20,1);
for K = 1 : 20
genes{K} = genedata(IDX==K);
end

3 Kommentare

Andrei Bobrov
Andrei Bobrov am 19 Nov. 2011
genenum = accumarray(IDX(:),ones(numel(IDX),1));
genes = accumarray(IDX(:),genedata,[],@(x){x});
FIR
FIR am 21 Nov. 2011
thanks andrei
FIR
FIR am 21 Nov. 2011
andrei if i do yhe following operation i get error
Error using ==> horzcat
CAT arguments dimensions are not consistent.
Error in ==> v at 10
fix=[j genenum genes]
where j=[1:20]'
please help

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Genomics and Next Generation Sequencing finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by