How is the average and normalization of each column in the table using "for" loop?
1 次查看(过去 30 天)
显示 更早的评论
I have a table with 50x10. In the table, first column is Genes and the second column will be reference column for normalization. Other 8 column will divide reference column. Afterward, this table will be normalized and each column will be averaged after normalization. Therefore there will be one row and 8 columns. How can I do this process in a table. Is it necessary to convert this table to a matrix or dataset, or can we solve it with a simle loop?
I m trying this code for table:
%import data
data = readtable("data.xlsx", "UseExcel", false);
%I coverted table to matrix form by deleting first row
for i = 2:10
res(:,i-1) = data(:,i)./data(:,1);
res_m = mean(res);
end
Bu code is not working as I want and I want to try this with table or dataset form
% Genes gsm335244 gsm335245 gsm335246
% A1CF 1,194 0,848 0,905
% A2M 0,325 6,301 0,607
% A4GALT 1,048 0,592 1,964
2 个评论
KALYAN ACHARJYA
2019-11-18
编辑:KALYAN ACHARJYA
2019-11-18
In the RHS, what does it mean?
res(:,i-1)=data(:,i)./data(:,1); % RHS > Same Parameters
Please attach data file
回答(1 个)
Srijith Kasaragod
2021-8-4
编辑:Srijith Kasaragod
2021-8-5
From my understanding you have a 50x10 table, columns 3 to 10 must be divided with corresponding elements from column 2, followed by taking the mean of those eight columns. The required output can be obtained by simple manipulation of the table. Following code implements the steps:
%reading the table
data= readtable('data.xlsx');
%perform normalization and take mean of columns
data{:,3:end}=data{:,3:end}./data{:,2};
data= mean(data{:,3:end})
Final result is a table of size 1x8 which contains mean of columns 3 to 10.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!