From c68e4ed9ba07f97a9ebe130bc976ac47c4dcbe40 Mon Sep 17 00:00:00 2001 From: jakebeal Date: Mon, 22 May 2017 13:22:29 -0500 Subject: [PATCH] add bead channel selection option --- @ColorModel/beads_to_mefl_model.m | 4 ++-- @ColorModel/set_bead_channel.m | 10 ++++++++++ @PlasmidExpressionModel/PlasmidExpressionModel.m | 6 ++++++ compute_sample_statistics.m | 10 ++++++---- fcs_scatter.m | 3 ++- 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 @ColorModel/set_bead_channel.m diff --git a/@ColorModel/beads_to_mefl_model.m b/@ColorModel/beads_to_mefl_model.m index cd34b5e2..d9d76e63 100644 --- a/@ColorModel/beads_to_mefl_model.m +++ b/@ColorModel/beads_to_mefl_model.m @@ -224,8 +224,8 @@ k_MEFL = 10^constrained_fit; else % 1 peak warning('TASBE:Beads','Only one bead peak found, assuming brightest'); - fit_error = 0; first_peak = 8; - k_MEFL = PeakMEFLs(7)/peak_means; + fit_error = 0; first_peak = numel(PeakMEFLs); + k_MEFL = PeakMEFLs(end)/peak_means; end; % Optional plot diff --git a/@ColorModel/set_bead_channel.m b/@ColorModel/set_bead_channel.m new file mode 100644 index 00000000..b905b76f --- /dev/null +++ b/@ColorModel/set_bead_channel.m @@ -0,0 +1,10 @@ +% Copyright (C) 2010-2017, Raytheon BBN Technologies and contributors listed +% in the AUTHORS file in TASBE analytics package distribution's top directory. +% +% This file is part of the TASBE analytics package, and is distributed +% under the terms of the GNU General Public License, with a linking +% exception, as described in the file LICENSE in the TASBE analytics +% package distribution's top directory. + +function CM=set_bead_channel(CM, v) + CM.bead_channel=v; diff --git a/@PlasmidExpressionModel/PlasmidExpressionModel.m b/@PlasmidExpressionModel/PlasmidExpressionModel.m index a8372954..c3fd2caf 100644 --- a/@PlasmidExpressionModel/PlasmidExpressionModel.m +++ b/@PlasmidExpressionModel/PlasmidExpressionModel.m @@ -60,6 +60,12 @@ %%%% GAUSSIAN MIXTURE MODEL METHOD which = cfp_data>drop_threshold; + if(sum(which)==0) + warning('Model:CFPDistributionSeparation','No data to model'); + PEM=class(PEM,'PlasmidExpressionModel'); + return; + end + % Seeded centers: [8], [5 8], [5 6.5 8], [5 6 7 8], ... min_center = log10(getMeanMEFL(CFP_af)); if n_components == 1, diff --git a/compute_sample_statistics.m b/compute_sample_statistics.m index 77e3adeb..59ea23a2 100644 --- a/compute_sample_statistics.m +++ b/compute_sample_statistics.m @@ -60,10 +60,12 @@ if numel(data), tmp_PEM = PlasmidExpressionModel(data(:,k),CFP_af,CFP_noise,getMEFLPerPlasmid(analysisParams),drop_threshold,n_components); dist = get_fp_dist(tmp_PEM); - sortable = zeros(n_components,3); - sortable(:,1) = dist.mu; sortable(:,2) = dist.Sigma(:); sortable(:,3) = dist.weight; - sortrows(sortable); - popcmeans(:,k) = sortable(:,1); popcstds(:,k) = sortable(:,2); popcweights(:,k) = sortable(:,3); + if ~isempty(dist) + sortable = zeros(n_components,3); + sortable(:,1) = dist.mu; sortable(:,2) = dist.Sigma(:); sortable(:,3) = dist.weight; + sortrows(sortable); + popcmeans(:,k) = sortable(:,1); popcstds(:,k) = sortable(:,2); popcweights(:,k) = sortable(:,3); + end if k==c_index, PEM = tmp_PEM; end; end end diff --git a/fcs_scatter.m b/fcs_scatter.m index 3c8a782a..9d506327 100644 --- a/fcs_scatter.m +++ b/fcs_scatter.m @@ -30,11 +30,12 @@ if linear(2), yv = yc; else yv = log10(yc(pos)); end; if nargin >= 4 && density + smoothing = 10; h = figure('PaperPosition',[1 1 5 5]); if ~visible, set(h,'visible','off'); end; if nargin < 5, range = []; end; if density >= 1, type = 'image'; else type = 'contour'; end - smoothhist2D([xv yv],10,[200, 200],[],type,range,largeoutliers); + smoothhist2D([xv yv],smoothing,[200, 200],[],type,range,largeoutliers); else h = figure('PaperPosition',[1 1 5 5]); if ~visible, set(h,'visible','off'); end;