Skip to content
Snippets Groups Projects
Commit 01b88ca5 authored by Tamas Borbath's avatar Tamas Borbath
Browse files

Worked on how to plot portrait figures. It is complicated. Don't scale the...

Worked on how to plot portrait figures. It is complicated. Don't scale the figure too much in the height to avoid rescaling of text.
Also try stepwise to export it and verify tiff.
Created multiple subplots for the correlation plots in plotSimulationResults
parent 8137b895
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,10 @@ titleLabels = {'\Delta\varphi_0', '\Delta\varphi_1', '\Delta\nu_g', '${\boldmath
'${\boldmath$\overline{\mid\Delta\nu_{e}\mid}$}$', '${\boldmath$\overline{\mid\Delta c\mid}$}$', '${\boldmath$\overline{\mid\Delta T_{2}\mid}$}$'};
units = { ' (degrees)', ' (degrees/ppm)', ' (Hz)', ' (Hz)',...
' (Hz)', ' (mmol/kg)', ' (ms)'};
titleOffset = {'\quad variations:\quad\quad','\quad variations:\quad', '\quad variations:\quad\quad\quad', '\quad variations:\quad\quad',...
'\quad variations:\quad\quad', '\quad variations:\quad', '\quad variations:\quad\quad'};
% titleOffset = {'\quad variations:\quad\quad','\quad variations:\quad', '\quad variations:\quad\quad\quad', '\quad variations:\quad\quad',...
% '\quad variations:\quad\quad', '\quad variations:\quad', '\quad variations:\quad\quad'};
titleOffset = {'\quad variations:\quad','\quad variations:\,\,', '\quad variations:\quad\quad', '\quad variations:\quad',...
'\quad variations:\quad', '\quad variations:\,\,', '\quad variations:\quad'};
% parameters = {'conc'};
useSubPlots = true;
......
......@@ -303,6 +303,7 @@ end
xlswrite([dataExportPathBase, 'SimulationsTable2.xlsx'],metaboliteTable);
end
%% get metabolite concentrations for a given paramKeyword and create the requested plots
function [allSimulMetConc, allLCModelMetConc, allProFitMetConc, allLCModelMetConcDev, allProFitMetConcDev, metaboliteTable, figIds, figIdsCorr,...
allMeanProFit, allStdProFit,allMeanProFitMain, allStdProFitMain] = ...
getConcentrations(metabolites, metabolitesLCModel, metabolitesProFit, metabolitesToDisplay, metabolitesLabels, ...
......@@ -355,6 +356,7 @@ metaboliteTable{numberOfMet+4,indexTable} = [num2str(allMeanProFitMain,'%.1f')
metaboliteTable{numberOfMet+4,indexTable+1} = [num2str(allMeanLCModelMain,'%.1f'), plusMinusSign, num2str(allStdLCModelMain,'%.1f')];
end
%% reorganize the fitted concentrations to 2D tables
function [allSimulMetConc, allLCModelMetConc, allProFitMetConc, allLCModelMetConcDev, allProFitMetConcDev] = ...
reorganizeMetConcentrationsToMatrices(metabolites, metabolitesLCModel, metabolitesProFit, ...
concentrationsRm, concentrationsLCModel, concentrationsProFit, activeMetabolites, scalingOn)
......@@ -407,6 +409,7 @@ for indexMetabolite = 1:numberOfMet
end
end
%% plot Correlation plots between the fitted ProFit, LCModel concentrations and the true simulated concentrations
function figIdsCorr = plotCorrelationFigs(concentrationsRm, allLCModelMetConc, allProFitMetConc,...
metabolitesToDisplay, numberOfMet, dataExportPathBase, paramKeyword, truncSuffix, figIdsCorr)
......@@ -416,40 +419,107 @@ if isempty(figIdsCorr)
else
emptyFigureIdsCorr = false;
end
% Main Figure = 12 subplots
figureMainRows = 4;
figureMainCols = 3;
metabolitesFigureMain = {'NAA(CH_2)', 'tCho+', 'mI', 'sI','Gly','Glu','Gln',...
'GABA', 'Lac', 'GSH', 'NAAG', 'MM spectrum'};
figID_Main = figure();
mainFigureRunningIndex = 0;
% Supporting Figure = 5 subplots
figureSupportingRows = 3;
figureSupportingCols = 4;
metabolitesFigureSupporting = {'tCr(CH_3)', 'tCr(CH_2)', 'NAA(CH_3)','Asp','Tau'};
figID_Supporting = figure();
supportingFigureRunningIndex = 0;
colorOriginal = [0 0 0];
colorProFit = [0.49 0.18 0.56];
colorLCModel = [0.85 0.33 0.1];
for indexMetabolite = 1:numberOfMet
simulatedMetConc = concentrationsRm(:, indexMetabolite);
fittedMetConcLCModel = allLCModelMetConc(:, indexMetabolite);
fittedMetConcProFit = allProFitMetConc(:, indexMetabolite);
if emptyFigureIdsCorr
figIdsCorr{indexMetabolite} = figure;
% if emptyFigureIdsCorr
% figIdsCorr{indexMetabolite} = figure;
% end
% figure(figIdsCorr{indexMetabolite});
if sum(contains(metabolitesFigureMain, metabolitesToDisplay{indexMetabolite}))
figure(figID_Main);
mainFigureRunningIndex = mainFigureRunningIndex + 1;
subplot(figureMainRows, figureMainCols, mainFigureRunningIndex);
if mod(mainFigureRunningIndex,figureMainCols)== 1
plotYLabel = true;
else
plotYLabel = false;
end
if round((mainFigureRunningIndex+1)/figureMainCols)== figureMainRows
plotXLabel = true;
else
plotXLabel = false;
end
elseif sum(contains(metabolitesFigureSupporting, metabolitesToDisplay{indexMetabolite}))
figure(figID_Supporting);
supportingFigureRunningIndex = supportingFigureRunningIndex + 2;
if round((supportingFigureRunningIndex+1)/figureSupportingCols)== figureSupportingRows % offset plot
supportingFigureRunningIndex = supportingFigureRunningIndex + 1;
end
subplot(figureSupportingRows, figureSupportingCols, supportingFigureRunningIndex-1:supportingFigureRunningIndex)
if mod(supportingFigureRunningIndex-1,figureSupportingCols)<= 2
plotYLabel = true;
else
plotYLabel = false;
end
if round((supportingFigureRunningIndex+1)/figureSupportingCols)>= figureSupportingRows-1
plotXLabel = true;
else
plotXLabel = false;
end
else
warning('Metabolite not associated with either main or supporting figure: ', metabolitesToDisplay{indexMetabolite});
figure();
plotYLabel = true;
plotXLabel = true;
end
if strcmp(metabolitesToDisplay(indexMetabolite),'MM spectrum')
simulatedMetConc = simulatedMetConc *1e-7;
fittedMetConcLCModel = fittedMetConcLCModel *1e-7;
fittedMetConcProFit = fittedMetConcProFit *1e-7;
end
figure(figIdsCorr{indexMetabolite});
hold on
scatter(simulatedMetConc, fittedMetConcLCModel);
scatter(simulatedMetConc, fittedMetConcProFit, 'x');
plot(simulatedMetConc,simulatedMetConc);
scatter(simulatedMetConc, fittedMetConcLCModel, 'MarkerEdgeColor', colorLCModel);
scatter(simulatedMetConc, fittedMetConcProFit, 'x', 'MarkerEdgeColor', colorProFit);
offSetEnds = max(simulatedMetConc)*0.05;
identityLine = min(simulatedMetConc)-offSetEnds:0.01:max(simulatedMetConc)+offSetEnds;
plot(identityLine,identityLine,'color',colorOriginal);
title(metabolitesToDisplay(indexMetabolite))
xlabel('Simulated concentrations {\boldmath$c$}$_{k}$ (mmol/kg)', 'Interpreter', 'latex')
ylabel('Fitted concentrations {\boldmath$c$}$_{k}$ (mmol/kg)', 'Interpreter', 'latex')
legend('LCModel {\boldmath$c$}$_{k}$', 'ProFit {\boldmath$c$}$_{k}$', 'Identity Line', 'Location', 'Northwest', 'Interpreter', 'latex')
set(gca, 'FontSize', 13)
xl = xlim;
if xl(2) > max(simulatedMetConc)
xl(2) = max(simulatedMetConc);
if plotXLabel
xlabel('$c_{k}^{simulated} \,\, (mmol/kg)$', 'Interpreter', 'latex')
end
xlim(xl);
pathName = [dataExportPathBase, paramKeyword, '/correlations/'];
if ~exist(pathName, 'dir')
mkdir(pathName);
if plotYLabel
ylabel('$c_k^{fitted} \,\, (mmol/kg)$', 'Interpreter', 'latex')
end
fileName = [metabolitesToDisplay{indexMetabolite}, '_', paramKeyword, truncSuffix];
saveas(figIdsCorr{indexMetabolite}, [pathName, fileName, '.tif']);
savefig(figIdsCorr{indexMetabolite}, [pathName,fileName, '.fig'],'compact');
legend('$LCModel \,\, c_k^{fitted}$', '$ProFit \,\, c_k^{fitted}$', '$Identity \, Line$', 'Location', 'best', 'Interpreter', 'latex')
set(gca, 'FontSize', 13)
xlim([min(identityLine),max(identityLine)])
ylim([min(identityLine),max(identityLine)])
% pathName = [dataExportPathBase, paramKeyword, '/correlations/'];
% if ~exist(pathName, 'dir')
% mkdir(pathName);
% end
% fileName = [metabolitesToDisplay{indexMetabolite}, '_', paramKeyword, truncSuffix];
% saveas(figIdsCorr{indexMetabolite}, [pathName, fileName, '.tif']);
% savefig(figIdsCorr{indexMetabolite}, [pathName,fileName, '.fig'],'compact');
end
end
%% plot Precision plots with boxplots showing percentages
function figIds = plotPrecisionFigs(figIds, numberOfMet, offsetPlot, secondaryFigures, plotColors, ...
allLCModelMetConcDev, allProFitMetConcDev, metabolitesLabels)
......@@ -498,6 +568,7 @@ function figIds = plotPrecisionFigs(figIds, numberOfMet, offsetPlot, secondaryFi
yline(0,':', 'Color',[0.5 0.5 0.5]);
end
%% setup the table to show metabolite concentration changes
function [metaboliteTable, indexTable] = setupTable(numberOfMet, numOfParameters, metabolitesLabels)
metaboliteTable = cell(numberOfMet+4,numOfParameters*2+1);
metaboliteTable(3:numberOfMet+2,1) = metabolitesLabels;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment