Calculating percentage for values in cell
1 次查看(过去 30 天)
显示 更早的评论
fnl =
{1127x4 cell}
{1126x4 cell}
{1125x5 cell}
for each cell i have some vaues
fn1{1,1}-(variable editor)
'Genes' 'T0' 'T2' 'T4'
'YAR029W' 'd' 'u' 'd'
'YBL095W' 'd' 'd' 'd'
'YBL111C' 'u' 'u' 'd'
'YBL113C' 'u' 'u' 'u'
fn1{2,1}
'Genes' 'T0' 'T3' 'T4'
'YAR062W' 'd' 'u' 'd'
'YAR068W' 'd' 'u' 'u'
'YBL095W' 'd' 'd' 'd'
'YBL111C' 'u' 'u' 'd'
fn1{3,1}
'Genes' 'T0' 'T1' 'T2' 'T3'
'YAR068W' 'd' 'u' 'u' 'u'
'YBL095W' 'd' 'u' 'u' 'd'
'YBL111C' 'u' 'u' 'u' 'u'
'YBL113C' 'u' 'u' 'u' 'u'
for example in fn1{1,1} taking 1st gene 'YAR029W' i want to count how many 'd' and 'u' are there in each interval and divide by total number of genes(percentage)
for example in interval T0'YAR029W' has 'd'=50%,'u'=50%,T2-'d'=25%,'u'=75%,T4-'d'=75%,'u'=25%
next for fn1{2,1} and so on,,,
only 1st gene must be considered for calculation
I have posted many questions in this forum regarding this topic ,I am thankful to all who helped me,for my final question in this topic please help me
Only 1st gene must be conisidered for calculation means ,only for IST gene in fn1{1,1},fn{2,1} must be taken for calculating percentage(only for 1st gene percentage must be calculated)
1 个评论
Azzi Abdelmalek
2012-7-25
in your example, where is YAR029W'?
what do you mean: only 1st gene must be considered for calculation. ,
采纳的回答
Azzi Abdelmalek
2012-7-25
编辑:Azzi Abdelmalek
2012-7-25
%try this
ni=size(fn1,1);
for k=1:ni
B=fn1{k,1}; [n,m]=size(B);A=B(2:n,2:m);c=cellfun(@(x)any(regexp(x,'d')),A);
perd=100*sum(c)/(n-1);peru=100-perd;d=num2cell(perd);u=num2cell(peru);
d1=cellfun(@(x) strcat('d=',sprintf('%d%%',x)),d,'UniformOutput',false);
u1=cellfun(@(x) strcat('u=',sprintf('%d%%',x)),u,'UniformOutput',false);
du1=[d1;u1]';q=[strcat('fn1(',num2str(k),')'); strcat(du1(:,1),',', du1(:,2))];
res=[['interval' ;B(1,2:end)'] q],Result{k}=res;
end
%you find all the result in the variable Result, Result{1},Result{2},Result{3}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analysis and Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!