-
Notifications
You must be signed in to change notification settings - Fork 2
/
GeneFPKM.m
37 lines (33 loc) · 1.04 KB
/
GeneFPKM.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
function GeneFPKM = GeneFPKM(FPKM, SortYes)
%GeneFPKM is a function to plot the stacked bars of gene counts at different abundance levels
%Useful for investigating the qualities of RNA-seq libraries
%GeneFPKM = GeneFPKM(FPKM,head)
%The FPKM table should have rows for genes and columns for samples
if nargin < 2
SortYes = 0;
end;
[m n]=size(FPKM);
GeneFPKM=[];
CutOffs=[0 0.1 1 5 10 50 500 5000 Inf];
for i=1:n
for j=1:8
GeneFPKM(j,i)=sum(FPKM(:,i)>CutOffs(j) & FPKM(:,i)<=CutOffs(j+1));
end
end
figure;
if SortYes == 0
b=bar(GeneFPKM(8:-1:1,:)','stack','FaceColor','flat');
for k=1:size(GeneFPKM(8:-1:1,:)',2)
b(k).CData = k;
end
else
[P I]=sort(sum(GeneFPKM));
b=bar(GeneFPKM(8:-1:1,I)','stack','FaceColor','flat');
for k=1:size(GeneFPKM(8:-1:1,:)',2)
b(k).CData = k;
end
end
cmap = colormap(flipud(colormap(jet))); %Create Colormap
cbh = colorbar ; %Create Colorbar
cbh.TickLabels = num2cell(fliplr(CutOffs(1:8))) ; %Replace the labels of these 8 ticks
end