function fcs_plot_all(files) %{ stem = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/sorted_data/calibration/'; blankfile = DataFile('fcs', [stem 'SBD042_A07-non-filtered_MAC.fcs']); gate = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/analysis/haemocytes_gating.mat'; % Autodetect gating with an N-dimensional gaussian-mixture-model TASBEConfig.reset() TASBEConfig.set('gating.plot', true); TASBEConfig.set('gating.visiblePlots', true); TASBEConfig.set('gating.selectedComponents',[1 2]); %TASBEConfig.set('gating.channelNames',{'FSC-A','SSC-A','FSC-H','SSC-H','FL1-A','FL2-A', 'FL3-A', 'FL4-A'}); TASBEConfig.set('gating.channelNames',{'FSC-A','SSC-A','FSC-H','SSC-H'}); debris = GMMGating(blankfile); %[~,fcshdr,data] = fca_readfcs([stem 'SBD039-G01_42-cells.fcs']); % make sure it can apply properly, without errors %gated_data = applyFilter(gate,fcshdr,data); fcs = DataFile('fcs', [stem 'SBD039-G01_42-cells.fcs']); gated = DataMath('neg_filter', fcs, debris); full_scale = [2 2; 7.2 7.2]; density = 5; [~, h] = fcs_scatter(fcs,'FSC-A','SSC-A',density,full_scale,true, true); [~, h] = fcs_scatter(gated,'FSC-A','SSC-A',density,full_scale,true, true); %outputfig(h,'Botryls_all-S2', plots); keyboard return; %} stem = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/sorted_data/calibration/'; ref = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/analysis/all_stains_parameters.csv'; gate = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/analysis/haemocytes_gating.mat'; TASBEConfig.reset() haemocytes_gates = load(gate); plots = '/home/blanchou/Documents/Projects/Blastogenesis/HaematologicalComparison/BDAccuriC6/plots/staged'; mkdir(plots); [files,dpt,expm,species,strain,repeat] = textread(ref, '%s,%d,%s,%s,%d,%d', 'Delimiter', ','); full_scale = [2 2; 7.2 7.2]; density = 5; botryllus = cell(7,6); botrylloides = cell(7,6); for i=2:length(files) if repeat(i)==1 %[dir, name, ext] = fileparts(files{i}); indx = (strcmp(expm,expm(i)) & strain==strain(i) & repeat==2); name = [expm{i} '-' num2str(strain(i)) '-all']; f1 = DataFile('fcs', files{i}); f2 = DataFile('fcs', files{indx}); fcs = DataMath('filter', DataMath('neg_filter',DataMath('sum', {f1, f2}), haemocytes_gates.debris), haemocytes_gates.singlets); is_botrylloides = (species{i}(1)=='T'); for j=1:6 if (~is_botrylloides && isempty(botryllus{dpt(i),j})) botryllus{dpt(i),j} = fcs; break elseif (is_botrylloides && isempty(botrylloides{dpt(i),j})) botrylloides{dpt(i),j} = fcs; break end end plot_all(fcs, density, full_scale, name, plots) end end keyboard vleachii = (~cellfun('isempty', botrylloides)); vschloss = (~cellfun('isempty', botryllus)); %{ for i=1:size(botrylloides,1) botryl = botrylloides(i,:); fcs = DataMath('mean', botryl(vleachii(i,:))); plot_all(fcs, density, full_scale, ['Botrylloides_' num2str(i) 'dpt'], plots) botrul = botryllus(i,:); fcs = DataMath('mean', botrul(vschloss(i,:))); plot_all(fcs, density, full_scale, ['Botryllus_' num2str(i) 'dpt'], plots) fcs = DataMath('mean', [botryl(vleachii(i,:)) botrul(vschloss(i,:))]); plot_all(fcs, density, full_scale, ['Botryls_' num2str(i) 'dpt'], plots) end %} %fcs = DataMath('mean', botrylloides(vleachii)); %plot_all(fcs, density, full_scale, ['Botrylloides_all'], plots) %fcs = DataMath('mean', botryllus(vschloss)); %plot_all(fcs, density, full_scale, ['Botryllus_all'], plots) fcs = DataMath('mean', [botrylloides(vleachii); botryllus(vschloss)]); %plot_all(fcs, density, full_scale, ['Botryls_all'], plots) TASBEConfig.reset() TASBEConfig.set('gating.plot', true); TASBEConfig.set('gating.visiblePlots', true); TASBEConfig.set('gating.channelNames',{'FSC-A','FL2-A'}); gate1 = GMMGating(fcs); TASBEConfig.set('gating.channelNames',{'SSC-A','FL2-A'}); gate2 = GMMGating(fcs); TASBEConfig.set('gating.channelNames',{'FSC-A','FL2-A', 'SSC-A'}); gate3 = GMMGating(fcs); [~, h] = fcs_scatter(fcs,'SSC-A','FL2-A',density,full_scale,true, true); outputfig(h,'Botryls_all-S2', plots); delete(h); %[~,fcshdr,data] = fca_readfcs(fullfile(stem, 'SBD039-G01_42-cells.fcs')); % make sure it can apply properly, without errors %gated_data = applyFilter(gate1,fcshdr,data); %smoothhist2D([data(:,1) data(:,2)],5,[500, 500],[]); %smoothhist2D([gated_data(:,1) gated_data(:,4)],5,[500, 500],[]); keyboard return; stem0312 = './TASBEFlowAnalytics-Tutorial/example_controls/2012-03-12_'; blankfile = DataFile('fcs', [stem0312 'blank_P3.fcs']); % Autodetect gating with an N-dimensional gaussian-mixture-model TASBEConfig.reset() TASBEConfig.set('gating.plot', true); TASBEConfig.set('gating.channelNames',{'FSC-A','FL1-A'}); %TASBEConfig.set('gating.selectedComponentLocations',[4.5 3.3]); TASBEConfig.set('gating.channelNames',{'FSC-A','SSC-A','FSC-H','SSC-H','FSC-W','SSC-W'}); gate = GMMGating(blankfile); [~,fcshdr,data] = fca_readfcs([stem0312 'EYFP_P3.fcs']); % make sure it can apply properly, without errors gated_data = applyFilter(gate,fcshdr,data); smoothhist2D([data(:,1) data(:,2)],5,[500, 500],[]); keyboard return; gate = struct(gate); assertEqual(gate.selected_components, 2); expected_mu = [5.1117 3.4087; 4.5555 3.3427]; GDS = struct(gate.distribution); assertElementsAlmostEqual(GDS.mu,expected_mu,'absolute',0.01); expected_sigma(:,:,1) = [0.0130 0.0149; 0.0149 0.0328]; expected_sigma(:,:,2) = [0.2053 0.0548; 0.0548 0.0515]; assertElementsAlmostEqual(GDS.Sigma,expected_sigma,'absolute',0.01); return; end function plot_all(fcs, density, full_scale, name, fdir) [~, h] = fcs_scatter(fcs,'FSC-A','SSC-A',density,full_scale,true, true); outputfig(h,[name '-FS'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'FSC-A','FSC-H',density,full_scale,true, true); outputfig(h,[name '-FF'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'SSC-A','SSC-H',density,full_scale,true, true); outputfig(h,[name '-SS'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'FSC-A','FL1-A',density,full_scale,true, true); outputfig(h,[name '-F1'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'SSC-A','FL2-A',density,full_scale,true, true); outputfig(h,[name '-F2'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'FSC-A','FL3-A',density,full_scale,true, true); outputfig(h,[name '-F3'], fdir); delete(h); [~, h] = fcs_scatter(fcs,'FSC-A','FL4-A',density,full_scale,true, true); outputfig(h,[name '-F4'], fdir); delete(h); return; end