calculating percentage value and cancanating

2 vues (au cours des 30 derniers jours)
Pat
Pat le 3 Sep 2012
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

Réponse acceptée

Andrei Bobrov
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

Plus de réponses (1)

Azzi Abdelmalek
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)
  1 commentaire
Pat
Pat le 3 Sep 2012
But Azzi i get answer as
gene =
{6x3 cell} 'perc'
{6x4 cell} []
{5x5 cell} [ 0 ]
{4x6 cell} [ 0 ]
{3x6 cell} [ 0 ]
{2x6 cell} [ 0 ]
for variable A above i get answer but for
gene =
{6x3 cell}
{6x4 cell}
{5x5 cell}
{4x6 cell}
{3x6 cell}
{2x6 cell}
i get that error

Connectez-vous pour commenter.

Catégories

En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by