how to make a dynamic code from this one in matlab

조회 수: 1 (최근 30일)
Jwana
Jwana 2012년 10월 27일
hi all,
I have 2 cells functions (resulted from certain code) in GO Ontology (bioinformatics) as follows:
p =
'GO:0008150'
'GO:0016740'
'GO:0016787'
'GO:0008150'
'GO:0016740'
'GO:0016740'
'GO:0016787'
'GO:0016787'
'GO:0016787'
'GO:0006810'
'GO:0006412'
'GO:0004672'
'GO:0008150'
'GO:0008150'
'GO:0006810'
'GO:0016192'
'GO:0006810'
'GO:0005215'
c =
'GO:0016740'
'GO:0016787'
'GO:0006810'
'GO:0006412'
'GO:0004672'
'GO:0016779'
'GO:0004386'
'GO:0003774'
'GO:0016298'
'GO:0016192'
'GO:0005215'
'GO:0030533'
'GO:0016787'
'GO:0006810'
'GO:0006412'
'GO:0003774'
'GO:0005215'
'GO:0030533'
then I make a=[p c] note that vector 'p' is vector of parents of vector node 'c' which is the children vector... I have to find the root node (level1_root) which can be determined by comparing cells array 'p' with 'c' and it is the cell in 'p' not included in 'c' cells vector. this root node or level1_root will help me after that in finding the children of it (level2) by: looking in all terms in 'p' and check if there is a root node, if we find any,we have to see the mapped one in cells vector'c' which will be its child and level 2) .. and then we have to look in nodes of level 2 to check if there is any inside 'p' and then mapped it to vector 'c' to make level3 ..and so on.. I have a code that it can find the level for each value using above technique as follows:
level1_root=setdiff(p,c)
level2=[];
%for k=1:length(m)
for i=1:length(p)
a=[p(i),c(i)];
if isequal(a(1), level1_root)
level2=[level2 a(2)];
else
end
end
level3=[];
for j=1:length(level2)
for i=1:length(p)
a=[p(i),c(i)];
if strcmp(a{1}, level2(j))
level3=[level3 a(2)];
else
end
end
end
level4=[];
for j=1:length(level3)
for i=1:length(p)
a=[p(i),c(i)];
if strcmp(a{1}, level3(j))
level4=[level4 a(2)];
else
end
end
end
level5=[];
for j=1:length(level4)
for i=1:length(p)
a=[p(i),c(i)];
if strcmp(a{1}, level4(j))
level5=[level5 a(2)];
else
end
end
end
in this code, I already know the number of levels which should be created in the code because of that I made this code for 5 levels. my question is:how can I made the same code for undecided number of levels for undecided cells arrays 'p' and 'c'. i think we have to use 'isempty' somewhere..
thnx
  댓글 수: 1
Jan
Jan 2012년 10월 27일
What are "levels"? What does the code do? Why do you create "a=[p(i),c(i)]", when you do not use it?

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

답변 (1개)

Walter Roberson
Walter Roberson 2012년 10월 27일
level1_root is generally going to be multiple cell entries. a(1,:) is going to be a single entry. When you compare the single entry to that list with multiple entries, what do you want the result to be? Are you asking whether the single entry is in the list? Or are you asking whether the list is only a single entry long and that one entry is the same as the single entry? Or are you asking whether all entries in the list are identical to the single entry?
It is not clear to me that your code is taking into account that the output of setdiff() will be sorted.
I am not sure what your code is trying to do, but it appears to me that it could be largely replaced by using the multi-output version of ismember() and some small logical indexing.
  댓글 수: 2
Jwana
Jwana 2012년 10월 27일
편집: Jwana 2012년 10월 27일
well.. it is very complicated to discuss its purpose that it is in the field of bioinformatics and genes terms. the root node should be single value only, and we compare in the first stage ( to find level2) to the 'p' vector. and then the result(s) we have to map them to their 'c' term... and then we took the result from 'c' term and compare it with 'p' and find the mapped values in 'c' ..to find level 3 .. and so on but the problem is not in the code as it is to how can I manage this code to be in a dynamic process with the clue of that the root(level1) should be single value.. then the other levels will depends on the data it self
Walter Roberson
Walter Roberson 2012년 10월 28일
If you are _sure- that level1 will only be a single value, then access it as level1_root{1}

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

카테고리

Help CenterFile Exchange에서 Design of Experiments (DOE)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by