nested cell arrays from tables
2 views (last 30 days)
Show older comments
Hello,
I have got a question regarding nested cell arrays. I have two tables, one which is giving me values per participant for 50 000 so-called SNPs in total. A second table is referring those 50 000 SNPs to roughly 20 000 genes. Each gene consists of a number of SNPs.
What I want is a cell array which shows the 20 000 genes on it's first interface, and if I click on one of the genes, I want it to open the corresponding table of all associated SNPs and the single values per participant, as given in the first table.
I have looked but found no solution to how to do that, especially because of the size of data, I cannot do that manually, but it needs to be automated in some way. I was also wondering how to take the information about the genes-SNP-correspondance and to sort the SNP values from the other table based on that classification.
I hope it gets clear what I am asking for and excuse me, if I am not clear enough or there is a solution I can adapt from somewhere else.
Best regards
0 Comments
Answers (1)
Bob Thompson
on 25 Feb 2019
Without having seen your data I don't know that I will be able to come up with something perfect, but hopefully this will give you somewhere to start.
I think that cells may not be the best choice for you, simply because I think it will be very easy to get lost. I would suggest a structure instead, as then you can have direct names to keep things organized.
SNP = tableread('SNPsFile.txt'); % Just loading your data to define my variable names
Genes = tableread('GenesFile.txt'); % Loading table of gene data
organized = struct('gene',Genes(:,1)); % Put genes into 'gene' field of new structure array.
% Also helps to preallocate.
for i = 1:size(Genes,1); % Loop through each gene
[organized(i).SNPs] = SNP(SNP(:,1) == organized(i).gene,2:end); % No idea how these exactly relate
% You will need to adjust the logic yourself, or describe how things are related
end
Due to the size of the data you're working with it's going to take a few minutes, that's just a guarenteed thing with MATLAB, but this concept should get you started on how to move things around.
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!