-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_compute_meiotic_segregants.m
executable file
·186 lines (123 loc) · 8.42 KB
/
plot_compute_meiotic_segregants.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
function meioitic_segregants=plot_compute_meiotic_segregants()
% PLOT_COMPUTE_MEIOTIC_SEGREGATNS plots meoitic segregant data
% returns counts of BC187 like and YJM978. Computes mean and area metric.
path_data='/Users/RenanEscalante/Dropbox/Phenotypic_diversity/var_facs/20120427_meiotic_segregant_classification/output/';
load([path_data 'plates_bfp.mat']);
load([path_data 'plates_mCh.mat']);
load([path_data 'plates_other.mat']);
%Dependency on a map of 96 well plates
load('map_plate_96');
channels={'bfp_yfp','mCh_yfp','other_yfp'};
%% Pick the threshold of induction for percentage calculation
threshold=2.5;
n_min_events=10;
counts=1;
counter=1;
%% Import off peak distribution GET OFF DISTRIBUTION
offStrain_data=plates_other.('Plate_Plate_1').('C03').FITC_H;
offStrain_data=plates_other.('Plate_Plate_10').('B07').FITC_H;
[offStrain_y1,offStrain_x1]=ksdensity(log10(offStrain_data));
% figure;
% plot(offStrain_x1,offStrain_y1);
%%
% Check that all the fields are the same for all the plates to be combined
plates=fieldnames(plates_bfp);
for a=1:length(plates)
strains=fieldnames(plates_bfp.(plates{a}));
for iRow=1:8
for jCol=1:12
if(sum(strcmp(Well(iRow,jCol),strains))==1)
for ichannel=1:length(channels)
switch channels{ichannel}
case 'bfp_yfp'
dat_bfp_yfp=log10(plates_bfp.(plates{a}).(Well{iRow,jCol}).FITC_H);
if (length(dat_bfp_yfp)>n_min_events)
%BFP
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_bfp_yfp>threshold)./length(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=length(dat_bfp_yfp);
else
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_bfp_yfp>threshold)./length(dat_bfp_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=0;
end
case 'mCh_yfp'
dat_mCh_yfp=log10(plates_mCh.(plates{a}).(Well{iRow,jCol}).FITC_H);
if (length(dat_mCh_yfp)>n_min_events)
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_mCh_yfp>threshold)./length(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=length(dat_mCh_yfp);
else
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).f=0;
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).xi=0;
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_mCh_yfp>threshold)./length(dat_mCh_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=0;
end
case 'other_yfp'
dat_other_yfp=log10(plates_other.(plates{a}).(Well{iRow,jCol}).FITC_H);
if (length(dat_other_yfp)>n_min_events)
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_other_yfp>threshold)./length(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=length(dat_other_yfp);
meioitic_segregants(counter,1)=nanmean(dat_other_yfp);
meioitic_segregants(counter,2)=nanmean(dat_bfp_yfp);
meioitic_segregants(counter,3)=nanmean(dat_mCh_yfp);
other_strain=dat_other_yfp;
other_strain(isnan(other_strain))=[];
if mean(other_strain)<1.5
display('ajlksjalk')
end
[y,x]=ksdensity(other_strain);
[perc_area] = compute_area(y,x,offStrain_y1,offStrain_x1);
meioticSegregants_area(counter,1)=perc_area;
counter=counter+1;
else
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).f=0;
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).xi=0;
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).mean=nanmean(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).median=nanmedian(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).perc_ind=sum(dat_other_yfp>threshold)./length(dat_other_yfp);
plates_hists.(plates{a}).(Well{iRow,jCol}).(channels{ichannel}).counts=0;
end
end
end
end
counts=counts+1;
end
end
end
%% Remove cases where mCherry was too high
idx_to_remove_2=meioitic_segregants(:,3)>1.85;
meioitic_segregants(idx_to_remove_2,:)=[];
meioticSegregants_area(idx_to_remove_2,:)=[];
meioticSegregants_mean=meioitic_segregants(:,1);
%%
plot_distribution(meioticSegregants_mean)
%%
plot_distribution(meioticSegregants_area)
%% The area metric is much more biased
figure;
%plot(meioticSegregants_mean,meioticSegregants_area,'.')
scatterhist(meioticSegregants_mean,meioticSegregants_area)
axis square;
filename=['Distribution of meiotic segregants_mean_vs_area_more_events.pdf'];
export_fig_specific_path(filename,'-pdf', '-transparent', '-nocrop')
%% Compute chi-square statistic
E1=sum(N)./2;
O1=YJM978_like;
%O1=450;
E2=sum(N)./2;
O2=BC187_like;
%O2=906-O1;
chi_square=(O1-E1)^2./E1+(O2-E2)^2./E2;
p=1-chi2cdf(chi_square,1)
%%
filename=['Distribution of meiotic segregants.pdf'];
export_fig_specific_path(filename,'-pdf', '-transparent', '-nocrop')
end