-
Notifications
You must be signed in to change notification settings - Fork 0
/
heatmap_plot.m
67 lines (51 loc) · 1.48 KB
/
heatmap_plot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function hhm = heatmap_plot(cvals, opts)
arguments
cvals
opts.xorder=[]
opts.yorder=[]
opts.cmap=[]
opts.isdiverging=false
opts.title=[] %label to use as title
opts.fig=[] %specify figure to plot in (if empty, new figure)
opts.margins=[0.1,0.1,0.1,0.1] %[left, bottom, right, top]
opts.cbgap=0.01 %space between ax and cb
opts.cbdims=[0.3,0.01] %[length, width]
opts.cblabel=[]
opts.cbLoc {mustBeMember(opts.cbLoc,["east","west","north","south"])}='east'
opts.cbJust {mustBeMember(opts.cbJust,["low","midlo","mid","midhi","high"])}='mid'
opts.cbDigits=1
end
%indicate ids using scatter with 'Clipping', 'off'?
l=opts.margins(1);
b=opts.margins(1);
r=opts.margins(1);
t=opts.margins(1);
ax=tight_subplot(1,1,1,0,[b,t],[l,r]);
% need an attached mini-axis for cell annotation
% ax=tight_subplot(1,1,1,0,[b,t],[l,r]);
% imagesc(cg.clust.clusterID(1:10:end,1)')
% colormap(opts.gcols)
IM=vals;
IM=smoothdata(IM,2,"loess",100);
IM(IM<0)=0;
IM=normalize(IM,2,'range');
% clustering genes
IMs=smoothdata(IM,2,"loess",500);
D=pdist(IMs,'euclidean');
Z=linkage(D,"ward");
o=optimalleaforder(Z,D,Criteria="group");
%order by peak
% [~,pix]=max(IMs,[],2);
% [~,o]=sort(pts(pix));
IM=IM(o,:);
glabs="\it"+glist(o);
imagesc(ax,pts,1:length(glist),IM)
% axis("tight")
yticks(1:length(glabs))
yticklabels(glabs)
if isdiverging
cmap=split_cmap;
else
cmap=cbrewer('seq','Reds',256); cmap(1,:)=[1,1,1];%cmap(1,:)=rgb('lightgray');
end
colormap(cmap)