Organize Data into Different Matrices by Column entry

Hey guys,
I have a massive set of data that covers all 23 human chromosomes. Although I'd like it to be divided based on the chromosome. The first column reads 'chr1'....all the way down to 'chr23' for approximately 1300000 entries, so I want to divide the matrix into separate ones based on that feature. Something like de-concatenate...I'm just not sure how to do that as I import it, since I think it would be faster to combine the two steps. The file has no header rows, and is tab delimited. All other columns contain doubles.
I appreciate the advice!
Kevin

 채택된 답변

Matt J
Matt J 2013년 7월 2일
You could read in the entire data set into a 1300000 x 23 matrix A using DLMREAD and then do
Acell=num2cell(A,1);
Then each Acell{i} will be a column of your data, available as it s own matrix.

댓글 수: 4

The matrix is 1300000 x 5, the issue is that each chromosome name is listed in the same column.
Matt J
Matt J 2013년 7월 3일
편집: Matt J 2013년 7월 3일
Once you've used textscan() to import the data into a cell C, you can do
[~,~,j]=unique(C(:,1));
result=cell(1,23);
for k=1:23
result{k} = C(j==k,:);
end
Many thanks! unique is the trick there :)
In this case I'm going to add the 'stable' flag to the setOrder parameter, in order to preserve the original ordering of my data.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

태그

질문:

2013년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by