calculating percentage for row values

3 次查看(过去 30 天)
final =
'Genes' 'T0&T2' 'T1&T3' 'T2&T4' 'T3&T5' 'T4&t6'
'YAR029W' 'd' [] 'd' [] 'd'
'YBL095W' 'd' [] [] 'd' 'd'
'YBL111C' 'u' 'u' 'u' 'u' []
'YBL113C' 'u' 'u' 'u' 'u' 'u'
'YBR096W' 'u' 'u' 'u' 'u' []
'YBR138C' 'd' [] [] 'd' 'd'
I have a above matrix in which i want to calculate the percentage for every gene
for example 'YAR029W' has 3 values so percentage is 60%(3/5*100)
'YBL095W'- 60%
'YBL111C' -80%
YBL113C' -100%
i need to perform for all genes,please help

采纳的回答

Wayne King
Wayne King 2012-8-18
One thing you can do
emptycells = cell2mat(cellfun(@(x) ~isempty(x),final,'uni',0));
perempty = sum(emptycells(2:end,2:end),2);
perempty = (perempty./5)*100;
  1 个评论
Jan
Jan 2012-8-28
~cellfun('isempty', C) is more efficient than ~cellfun(@isempty, C). But with anonymous functions, cellfun is even slower.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by