calculating percentage value and cancanating

2 visualizaciones (últimos 30 días)
Pat
Pat el 3 de Sept. de 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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 3 de Sept. de 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

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 3 de Sept. de 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 comentario
Pat
Pat el 3 de Sept. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by