Visualize fold change over multidimensional array

2 views (last 30 days)
Hello,
I have several large 3D arrays (for example, of dimensions around 1560x21x48 (double)) containing flux data, where 1560 would be the reaction over 21 instances (according to a function) across 48 conditions. I would like to visualize the change (like a heatmap) in flux for each reaction according to how they change over the 48 conditions. So, the table would be 1560x21, and the colors would be the amount of change. I'm not dearly attached to any specific way of doing this, as I simply want a visual representation to get an overview of how much change is taking place.
So far I'm just using a bare bones fraction approach
z=fluxes.AT_spent(:,:,1)./fluxes.AT_spent(:,:,2:end)
and then taking the mean for each i,j.
This does indeed result in a chart where of course 1 is neutral, in a 1560x21 matrix where values are the changes around 1, but the heatmap is just a black image, even though the scale uses blue for 1. I must be missing something, clearly.
I'm sure there's a more elegant approach though, since my approach clearly lacks finesse.
Any advice is appreciated!

Answers (1)

Akanksha
Akanksha on 28 Mar 2025
To visualize the change in flux for each reaction across different conditions using a heatmap, you can follow these steps to ensure that the data is represented accurately and visually appealing :
% Example 3D array (replace with your actual data)
flux_data = rand(1560, 21, 48); % Replace this with your actual data
% Compute relative change across conditions
% Using the first condition as a reference
relative_change = flux_data(:,:,2:end) ./ flux_data(:,:,1);
% Average the changes across all conditions
mean_change = mean(relative_change, 3);
% Create a heatmap
h = heatmap(mean_change);
% Customize the heatmap
h.Colormap = jet; % Use a colormap of your choice
h.ColorLimits = [min(mean_change(:)), max(mean_change(:))]; % Set color limits
% Add labels and title
h.XLabel = 'Instances';
h.YLabel = 'Reactions';
h.Title = 'Heatmap of Flux Changes';
% If you want to emphasize changes around 1
% You can adjust the color limits to highlight deviations from 1
h.ColorLimits = [0.5, 1.5]; % Adjust based on your data range
I have also attached the screenshot of heatmap I have visualized using above code.
Also please find the attached links to help you further :
Hope this helps!

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!