File changes are not being recorded

1 view (last 30 days)
kgk
kgk on 18 Jul 2014
I have two files.
1. run_matlab.sh
2. drawdendrograms.m
I have update the drawdendrograms.m file with the proper color.mat file information. But still when I run MATLAB script, it is reading the older file path and not the changed one.
~~~~~~~~~~~~~~
cat run_matlab.sh
#!/bin/sh
# script for execution of deployed applications
#
# Sets up the MCR environment for the current $ARCH and executes
# the specified command.
#
exe_name=$0
exe_dir=`dirname "$0"`
echo "------------------------------------------"
if [ "x$1" = "x" ]; then
echo Usage:
echo $0 \<deployedMCRroot\> args
else
echo Setting up environment variables
MCRROOT="$1"
echo ---
TMPDIR=/data/cache/temp${RANDOM};
mkdir $TMPDIR;
export MCR_CACHE_ROOT=$TMPDIR;
LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/bin/glnxa64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/os/glnxa64;
MCRJRE=${MCRROOT}/sys/java/jre/glnxa64/jre/lib/amd64 ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/native_threads ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/server ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE}/client ;
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRJRE} ;
XAPPLRESDIR=${MCRROOT}/X11/app-defaults ;
export LD_LIBRARY_PATH;
export XAPPLRESDIR;
echo LD_LIBRARY_PATH is ${LD_LIBRARY_PATH};
shift 1
args=
while [ $# -gt 0 ]; do
token=`echo "$1" | sed 's/ /\\\\ /g'` # Add blackslash before each blank
args="${args} ${token}"
shift
done
##eval "${exe_dir}"/makeViz /usr/local/matlab-compiler/v711 $args
eval "${exe_dir}"/makeViz $args
fi
rm -rf $TMPDIR;
exit
~~~
cat drawdendrograms.m
function [] = drawExpressionAndDendograms(dir)
% 1) reads the expression values (counts of mirs in sample)(vals_fn),
% reads the names of the mirs/samples(mirs_labels, sample_labels_fn),
% reads the dendrograms information - the distances as they have been computed.
% 2) computes the frequences: log2(mirs count/total mirs counts per sample)
% (if the value in the paranthesis is 0 then the log2(0) is replaced with -15)
% 3) draw the expression matrix, the dendrograms and the labels
% 4) exports the image as png, eps and pdf
% arguments
% input dir and file names
%dir = input('directory= ', 's');
sample_dendr_fn = '/sample_dendrogram';
mirs_dendr_fn = '/mirs_dendrogram';
vals_fn = '/selcount.vals';
mirs_labels_fn = '/out.names';
sample_labels_fn = '/out.header';
output_fn = '/expressionDendrogramsInMatlab';
total_mirs_per_sample_fn = '/total_mirs_per_sample.count';
% graphical parameters
% used for the dendrogram representation
sample_scale = 0.01; %50;
mirs_scale = 0.00007;
border = 0.5;
image_scale = 12;
negative_infinity = -22; % old: -17 %Value used to denote -infinity obtained in log(0)
%Also used when zero padding is done (at the right
%of the expression matrix)
% load the input files
EXPR = load([dir vals_fn]);
TOTAL_MIRS_PER_SAMPLE = load([dir total_mirs_per_sample_fn]);
LabelsMirs = importdata([dir mirs_labels_fn]);
LabelsTissues = importdata([dir sample_labels_fn]);
%MB added to handle sample labeled with numbers
if (~iscell(LabelsTissues))
LabelsTissues=num2str(LabelsTissues);
LabelsTissues=cellstr(LabelsTissues);
LabelsTissues=strtrim(LabelsTissues);
end
if (size(EXPR,1)>1 && size(EXPR,2)>1)
SAMPLE_DENDR = load([dir sample_dendr_fn]);
MIRS_DENDR = load([dir mirs_dendr_fn]);
end;
% get the length of the longest miRNA/Sample Label
mirsLabelMaxLen = size(char(LabelsMirs),2)-4;
sampleLabelMaxLen = size(char(LabelsTissues),2)-5;
% space for the labels
sample_shift = sampleLabelMaxLen;
mirs_shift = mirsLabelMaxLen;
% get the dimensions
cols = size(LabelsTissues,1);
rows = size(LabelsMirs,1);
if (size(EXPR,1)>1 && size(EXPR,2)>1)
sampleDendHeight = max(SAMPLE_DENDR(:,3));
mirsDendHeight = max(MIRS_DENDR(:,3));
else
sampleDendHeight = 0;
mirsDendHeight = 0;
end
if (mirs_scale * mirsDendHeight > 90)
mirs_scale = 90 / mirsDendHeight;
end
if (sampleDendHeight * sample_scale > 10)
sample_scale = 10 / sampleDendHeight;
end
if (mirs_scale * mirsDendHeight < 2)
mirs_scale = 2 / mirsDendHeight;
end
if (sampleDendHeight * sample_scale < 10)
sample_scale = 10 / sampleDendHeight;
end
%XLim, YLim
xMin = border-mirs_scale*mirsDendHeight-mirs_shift-1; %measured in points; <0
xMax = cols+border;
yMin = border-sample_scale*sampleDendHeight-sample_shift-1; %measured in points; <0
yMax = rows+border+1;
%Graphical options
width = (-xMin + xMax)*image_scale;
height = (-yMin + yMax)*image_scale;
figure;
set(gcf,...
'visible','off',... % the figure is not shown
'PaperUnits', 'points',... % The unit is points
'PaperSize',[width height],... % the size of the paper is given by weight and height
'Position',[0 0 width height],...
'PaperPositionMode','auto',... % Keeps the ratio between height/weight
'InvertHardcopy','on');
% load the colormap
load('/home/smiRNADB_colormap.mat','mycmap');
colormap(mycmap);
% compute and draw dendograms
if (size(EXPR,1)>1 && size(EXPR,2)>1)
[H1,T1,sample_perm] = dendrogramInSamePlot(SAMPLE_DENDR,sample_shift,sample_scale,'orientation','top'); % perm contains the permutation of the elements
hold on;
[H2,T2,mirs_perm] = dendrogramInSamePlot(MIRS_DENDR,mirs_shift,mirs_scale,'orientation','right'); % perm contains the permutation of the elements
hold on;
% permute the cols oF the expression matrix according to sample_perm
EXPR1=EXPR(:,sample_perm);
EXPR_Perm = EXPR1(mirs_perm,:);
TOTAL_MIRS_PER_SAMPLE = TOTAL_MIRS_PER_SAMPLE(:,sample_perm);
colTotal = sum(EXPR_Perm);
else
%sample_perm = 1:size(EXPR,2);
%mirs_perm = 1:size(EXPR,1);
%EXPR_Perm = EXPR;
%one sample
if size(EXPR,2)==1
[EXPR_Perm, mirs_perm] = sort(EXPR(:,1),'descend');
sample_perm = 1;
colTotal = sum(EXPR_Perm);
end
%one mirs
if size(EXPR,1)==1
sample_perm = 1:size(EXPR,2);
mirs_perm = 1;
EXPR_Perm = EXPR;
end;
end
for iRowIndex = 1:size(EXPR_Perm,1)
for iColIndex = 1:size(EXPR_Perm,2)
EXPR_Perm(iRowIndex,iColIndex) = getFrequence(EXPR_Perm(iRowIndex,iColIndex),TOTAL_MIRS_PER_SAMPLE(iColIndex),negative_infinity);
end;
end;
%one mirs
if size(EXPR,1)==1
[EXPR_Perm, sample_perm] = sort(EXPR_Perm(1,:),'descend');
colTotal = EXPR_Perm;
TOTAL_MIRS_PER_SAMPLE = TOTAL_MIRS_PER_SAMPLE(:,sample_perm);
end;
rest = TOTAL_MIRS_PER_SAMPLE-colTotal;
for iColIndex = 1:size(rest,2)
rest(iColIndex) = getFrequence(rest(iColIndex),TOTAL_MIRS_PER_SAMPLE(iColIndex),negative_infinity);
end;
% plot the expression matrix
image([EXPR_Perm; rest],'CDataMapping','scaled')
xlim([xMin xMax]);
ylim([yMin yMax]);
set(gca,...
'YDir','reverse');
% write the labels
for i=1:rows
rw=mirs_perm(i);
%rw = i;
text(0,i,LabelsMirs(rw,1),'HorizontalAlignment','right','VerticalAlignment','middle','FontSize',image_scale-1, 'Interpreter','none','FontName','FixedWidth');
%text((from+to)/2,-2,descr,'Rotation',90);
end
% the all other label
text(0,rows+1,'all-other mirs','HorizontalAlignment','right','VerticalAlignment','middle','FontSize',image_scale-1, 'Interpreter','none','FontName','FixedWidth');
for i=1:cols
cw=sample_perm(i);
%cw = i;
text(i,0,LabelsTissues(cw,1),'HorizontalAlignment','left','VerticalAlignment','middle','FontSize',image_scale-1,'Rotation',90,'Interpreter','none','FontName','FixedWidth')
end
% axes
set(gca,...
'Position',[0.01 0.01 0.98 0.98],... % position of the ases inside the figure
'DataAspectRatio',[1 1 1],... % when resizing keep the ratio constant
'Visible','off');
%createcolorbar(gca,[0.02, 0.93, 0.03, 0.065]);
bar_height = (sample_scale*sampleDendHeight+sample_shift)*image_scale;
bar_width = 20;
bar_border = border*image_scale;
createcolorbar(gca,[bar_border, height-bar_border-bar_height, bar_width, bar_height]);
set(0,'DefaultFigureRenderer','Painters'); % Default renderer (choice between OpenGL and ...)
%export files
print('-depsc2','-r0','-loose',[dir output_fn '.eps'])
print('-dpng','-r0',[dir output_fn '.png'])
%print('-dpdf','-r0','-loose',[dir output_fn '.pdf'])
%exit;
%------------------------------------------------------------------------
function createcolorbar(axes1,position)
%CREATECOLORBAR(AXES1)
% AXES1: colorbar axes
%%Create colorbar
colorbar1 = colorbar('peer', axes1,...
'Units','pixels',...
'Position',position,...
'Box','on',...
'XLim',[-0.5 1.5]);
%-------------------------------------------------------------------------
function freq = getFrequence(value,total,negativeInf)
%choose 1e-6 instead of 0 to evoit cases where value is ~ 0 (e.g. 1e-12)
%when log(value/total) < negativeInf; this happens when computing the freq
%of the rest of mirs
%if value > 1e-6
% freq = log(value/total)/log(2);
%else
% freq = negativeInf;
%end
if total > 0 && log2(value/total) > negativeInf
freq = log2(value/total);
else
freq = negativeInf;
end
On line 110 above, the load function is not reading the proper mat file, it is reading the path before the changes have been made. Any help is appreciated.
I am new to MATLAB, so I am guessing I have to flush the cache or something.
Thanks in advance.

Answers (0)

Categories

Find more on Interactive Control and Callbacks 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!