MATLAB Examples

Contents

function healthyvsdisease_box_plot_general(data_ptr_healthy_1,data_ptr_disease_1,data_ptr_healthy_2,data_ptr_disease_2,...
                                            compound_name,yaxis_label)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Name - healthyvsdisease_box_plot_general
% Creation Date - 15th July 2014
% Author: Soumya Banerjee
% Website: https://sites.google.com/site/neelsoumya/
%
% Description:
%  Takes a row vector of some measured quantity (say one compound) from healthy and disease cohort 1
%  and another row vector of a measured quantity (say compound abundance
%  again) from healthy and disease cohort 2,
%  and finally does a boxplot of the measured quantity in
%  cohort 1 and cohort 2 side by side (disease vs. healthy is shown
%   within each cohort)
%
% Input:
%       data_ptr_healthy_1: row vector of measured quantity from
%           healthy cohort 1
%       data_ptr_disease_1: row vector of measured quantity from
%           disease cohort 1
%       data_ptr_healthy_2: row vector of measured quantity from
%           healthy cohort 2
%       data_ptr_disease_2: row vector of measured quantity from
%           disease cohort 2
%       compound_name: name of measured quantity (e.g. name of measured compound/bug/metabolite etc)
%           represented in data_ptr_healthy_1,
%           data_ptr_disease_1, data_ptr_healthy_2 and data_ptr_disease_2
%       yaxis_label:   label for y-axis of boxplots (for example compound abundance)
%
% Output:
%       A boxplot of the measured quantity (say compound relative abundance) within each cohort (disease vs. healthy)
%
% Example usage:
%       healthyvsdisease_box_plot_general([0.1 0.1 0.2 0.3],[1.9 1.9 2.1 2.2],...
%             [0.3 0.2 0.4 0.3],[1.7 2.3 2.1 2.0],'Riboflavin','Compound abundance')
%
% License - BSD
%
% Change History -
%                   15th July 2014  - Creation by Soumya Banerjee
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Combined data for cohort 1

data_box_plot_1 = [ data_ptr_healthy_1' ; data_ptr_disease_1'];

replicates labels for cohort 1

group_1 = [repmat('healthy cohort 1',size(data_ptr_healthy_1,2),1); repmat('disease cohort 1',size(data_ptr_disease_1,2),1)];

create figures for boxplots (cohort 1)

figID = figure;
subplot(1,2,1)
boxplot(data_box_plot_1,group_1,'notch','on')
title(compound_name)
ylabel(yaxis_label)

Combined data for cohort 2

data_box_plot_2 = [ data_ptr_healthy_2' ; data_ptr_disease_2'];

replicates labels for cohort 2

group_2 = [repmat('healthy cohort 2',size(data_ptr_healthy_2,2),1); repmat('disease cohort 2',size(data_ptr_disease_2,2),1)];

create figures for boxplots (cohort 2)

subplot(1,2,2)
boxplot(data_box_plot_2,group_2,'notch','on')
title(compound_name)
ylabel(yaxis_label)

save boxplot to disk

print(figID, '-djpeg', sprintf('boxplot_%s.jpg', date));