calculating percentage value and cancanating
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have values as
gene =
{6x3 cell}
{6x4 cell}
{5x5 cell}
{4x6 cell}
{3x6 cell}
{2x6 cell}
In gene{1,1}
'Genes' 'T0&T2' 'T2&T4' 'T4&T6'
'YAR029W' 'd' 'd' 'd'
'YAR062W' 'du' 'ud' 'du'
'YAR068W' 'du' 'uu' 'uu'
'YBL095W' 'du' 'ud' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'ud'
i want to calculate percentage starting from 3rd row
result{1,1}
'Genes' 'T0&T2' 'T2&T4' 'T4&T6' ''
'YAR029W' 'd' 'd' 'd' ''
'YAR062W' 'du' 'ud' 'du' 60
'YAR068W' 'du' 'uu' 'uu' 60
'YBL095W' 'du' 'ud' 'du' 60
'YBL111C' 'uu' 'ud' 'du' 60
'YBL113C' 'uu' 'uu' 'ud' 60
percentage is calclated by (no of rows/5*100)=3/5*100
i tried
emptycells = cell2mat(cellfun(@(x) ~isempty(x),gene,'uni',0));
perempty = sum(emptycells(2:end,2:end),2);
perempty = (perempty./5)*100;
result=[gene(2:end,2:end) perempty]
but get error ,getting all values as zeros
0 commentaires
Réponse acceptée
Andrei Bobrov
le 3 Sep 2012
result = gene;
for jj = 1:numel(gene)
emptycells = cell2mat(cellfun(@(x) ~isempty(x),result{jj},'un',0));
perempty = sum(emptycells(2:end,2:end),2)./5*100;
result{jj} =[result{jj} [{''};num2cell(perempty)]];
end
0 commentaires
Plus de réponses (1)
Azzi Abdelmalek
le 3 Sep 2012
A={'Genes' 'T0&T2' 'T2&T4' 'T4&T6'
'YAR029W' 'd' 'd' 'd'
'YAR062W' 'du' [] 'du'
'YAR068W' 'du' 'uu' 'uu'
'YBL095W' 'du' 'ud' 'du'
'YBL111C' 'uu' 'ud' 'du'
'YBL113C' 'uu' 'uu' 'ud'};
[n,m]=size(A)
B=cellfun(@(x) ~isempty(x),A)
perc=(sum(B(3:end,2:end),2)/5)*100
A{1,m+1}='perc';
A(3:end,m+1)=num2cell(perc)
Voir également
Catégories
En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!