diff --git a/CODE/DEMOS/demoLoadXLSandPlot.m b/CODE/DEMOS/demoLoadXLSandPlot.m index 5abdeea..9b372a8 100644 --- a/CODE/DEMOS/demoLoadXLSandPlot.m +++ b/CODE/DEMOS/demoLoadXLSandPlot.m @@ -12,6 +12,9 @@ mcrsght_info('Loaded table (first 10 columns):'); disp(dataTable(1:10,:)); +controlplot = dataStructure.controlplot; +mutantplot = dataStructure.mutantplot; + preaxis = [-27 18 -12 13]; figure(2) clf; diff --git a/CODE/DEMOS/demoStatisticalAnalysis.m b/CODE/DEMOS/demoStatisticalAnalysis.m new file mode 100644 index 0000000..0f9d3e1 --- /dev/null +++ b/CODE/DEMOS/demoStatisticalAnalysis.m @@ -0,0 +1,55 @@ +clc; +mcrsght_info('LOAD CONTACT EVENTS FROM SAVED EXPERIMENT - BRIEF ANALYSIS.'); +mcrsght_info('This demo uses the experiment in [./DATA/ctrlvshot3/demo2_*],'); +mcrsght_info('and performs a simple T-test and boxplots. '); + +basefilename = fullfile(MACROHOME_,'DATA','ctrlvshot3'); +dataStructure = load(fullfile(basefilename, 'demo2_angleChanges.mat')); +dataTable = readtable(fullfile(basefilename, 'demo2_angleChanges.xlsx')); + +mcrsght_info('Loaded variables:'); +disp(dataStructure); + +controltrackfeatures = dataStructure.controltrackfeatures; +mutanttrackfeatures = dataStructure.mutanttrackfeatures; +setnames = {dataStructure.generalinfocontrol(1).typeExperiment ... + dataStructure.generalinfomutant(1).typeExperiment}; + + + +[boxdata,boxgroups] = getBoxplotComparisonData(controltrackfeatures, mutanttrackfeatures); + +subplot(141) +boxplot(boxdata.clumpsize, boxgroups); +ylabel('clumpsize'); +title('Boxplot example - 1'); + +subplot(142) +boxplot(boxdata.thx, boxgroups); +ylabel('anglechange'); +title('Boxplot example - 2'); + +subplot(143) +boxplot(abs(boxdata.thx), boxgroups); +ylabel('abs(anglechange)'); +title('Boxplot example - 3'); + +subplot(144) +hold on; +for ix=1:2 + scatter(boxdata.clumpsize(boxgroups==ix), abs(boxdata.thx(boxgroups==ix)), 110); +end +legend(setnames); +xlabel('clumpsize'); +ylabel('abs(angle change)'); +title('Scatterplot example'); + +set(gcf, 'Position', [560 579 983 369]); + +[M, SD, H, P] = compareAngleChanges(controltrackfeatures, mutanttrackfeatures, setnames); +mcrsght_info(sprintf('SET: [%s] MEAN(STDev) = %2.2f(%2.2f) ', ... + setnames{1}, M.(setnames{1}), SD.(setnames{1})), 'RESULTS'); +mcrsght_info(sprintf('SET: [%s] MEAN(STDev) = %2.2f(%2.2f) ', ... + setnames{2}, M.(setnames{2}), SD.(setnames{2})), 'RESULTS'); +mcrsght_info(sprintf('TESTS: T-test p-value = %2.2f ', P.ttest), 'RESULTS'); +mcrsght_info(sprintf('TESTS: Wilcoxon p-value = %2.2f ', P.wilcoxon), 'RESULTS'); diff --git a/CODE/compareAngleChanges.m b/CODE/compareAngleChanges.m new file mode 100644 index 0000000..a38ab3a --- /dev/null +++ b/CODE/compareAngleChanges.m @@ -0,0 +1,65 @@ +function [M, SD, H, P] = compareAngleChanges(trackfeatures_set1, trackfeatures_set2, setnames, absbool) +% + +if nargin < 3 + setnames = {'set1', 'set2'}; + absbool = true; +elseif nargin < 4 + absbool = true; +end + +if absbool + mcrsght_info('ABS(Angle)'); +else + mcrsght_info('Angles unchanged'); +end + +angleContact = vertcat(trackfeatures_set1.thx); +angleNoContact = vertcat(trackfeatures_set2.thx); + + +if absbool + angleContact = abs(angleContact); + angleNoContact = abs(angleNoContact); +end + +m = [mean(angleContact) mean(angleNoContact)]; +sd = [std(angleContact) std(angleNoContact)]; + +[pwill, hwill] = ranksum(angleContact, angleNoContact); +[httest, pttest] = ttest2(angleContact, angleNoContact); + +if hwill==1 + rejwill = 'reject'; +else + rejwill = sprintf('nope\t'); +end +if httest==1 + rejttest = 'reject'; +else + rejttest = sprintf('nope\t'); +end + +M.(setnames{1}) = m(1); +M.(setnames{2}) = m(2); + +SD.(setnames{1}) = sd(1); +SD.(setnames{2}) = sd(2); + +H.ttest = httest; +H.wilcoxon = hwill; + +P.ttest = pttest; +P.wilcoxon = pwill; + + +if nargout == 0 + mcrsght_info(sprintf(' & With cell-cell & NO contact & WILLCOXON & T-TEST &')); + mcrsght_info(sprintf('mean (std) & mean (std) & p-value & Can reject? & p-value & Can reject? &')); + + mcrsght_info(sprintf('& %3.2f (%2.2f) & %3.2f (%2.2f) & %2.2f & %s & %2.2f & %s &', ... + m(1), sd(1), m(2), sd(2), pwill, rejwill, pttest, rejttest)); + +end + + diff --git a/CODE/getBoxplotComparisonData.m b/CODE/getBoxplotComparisonData.m new file mode 100644 index 0000000..185ede2 --- /dev/null +++ b/CODE/getBoxplotComparisonData.m @@ -0,0 +1,19 @@ +function [boxdata, boxgroups] = getBoxplotComparisonData(varargin) +% GET DATA FOR BOXPLOTS AND STATISTICAL ANALYSIS. +% + +numGroups = length(varargin); +fnames = fieldnames(varargin{1}); + +boxgroups = []; +for ix=1:length(fnames) + Tab = []; + for jx=1:numGroups + thisVector = vertcat(varargin{jx}.(fnames{ix})); + Tab = [Tab; thisVector]; + if ix==1 + boxgroups = [boxgroups; jx.*ones(size(thisVector))]; + end + end + boxdata.(fnames{ix}) = Tab; +end diff --git a/init_phagosight.m b/CODE/pre-release-scripts/init_phagosight.m similarity index 100% rename from init_phagosight.m rename to CODE/pre-release-scripts/init_phagosight.m diff --git a/scr_courseshiftAcquisition.m b/CODE/pre-release-scripts/scr_courseshiftAcquisition.m similarity index 100% rename from scr_courseshiftAcquisition.m rename to CODE/pre-release-scripts/scr_courseshiftAcquisition.m diff --git a/scr_courseshiftCalculation.m b/CODE/pre-release-scripts/scr_courseshiftCalculation.m similarity index 100% rename from scr_courseshiftCalculation.m rename to CODE/pre-release-scripts/scr_courseshiftCalculation.m diff --git a/scr_courseshiftResults.m b/CODE/pre-release-scripts/scr_courseshiftResults.m similarity index 100% rename from scr_courseshiftResults.m rename to CODE/pre-release-scripts/scr_courseshiftResults.m diff --git a/CODE/scr_reviewDatasetForInteractions.m b/CODE/pre-release-scripts/scr_reviewDatasetForInteractions.m similarity index 100% rename from CODE/scr_reviewDatasetForInteractions.m rename to CODE/pre-release-scripts/scr_reviewDatasetForInteractions.m diff --git a/README.md b/README.md index cd01ae0..e587951 100644 --- a/README.md +++ b/README.md @@ -4,64 +4,60 @@ This code is based on the [phagosight](https://github.com/phagosight/phagosight) software, but modules for the analysis of overlapping cells within a video sequence have been added. -## Quick start -A brief summary to start the analysis as quickly as possible. - -### Installation -To clone this repository **and its dependencies (phagosight)** use the following -command: +## Installation +To clone this repository use the following command: ```bash -git clone --recursive https://github.com/alonsoJASL/macrosight/ +git clone https://github.com/alonsoJASL/macrosight/ ``` -This will allow @phagosight and macrosight to be pulled into nested folders. To -configure the paths automatically, **inside Matlab** Run the command `configureMacrosight`. -### Requirements of the data -The macrophages dataset need to be in individual files, with the following naming -convention: +To configure the paths automatically, **inside Matlab**, run the command +`configureMacrosight`. If you have @phagosight, then the configuration will +walk you through adding it to your path. Otherwise, you can choose not to use +it. + +## Quick start +The best way to see Macrosight's functionalities is through the demos. In +Matlab run ```Matlab -/path/to/data/MACROSN/T000ix.tif +macrosight_demo +``` +to get a list of ready-made examples of the software functionalities: +``` +macrosight_demo +[MACROSIGHT_DEMOS] Select the demo from the list: +[1] Select contact events - save to xls. +[2] Load from saved data - plot results +[3] Load from saved data - statistical analysis +[9] Demo tidy function +[C] Cancel +Your choice [default=1]: ``` -where `N` corresponds to the nth experiment and `ix` correspond to each image's -identifier. - -Functionalities will soon be included to prepare the data automatically. -### Quick start guide -Macrosight takes images storede in a hard drive, and saves the output to other -folders following a specific naming scheme. +### Quick start using phagosight functionalies (from scratch) +Tracking needs PhagoSight, clone it with the +command: +```bash +git clone https://github.com/phagosight/phagosight/ +``` +and then in Matlab run `configureMacrosight`. -For **segmentation**, see the file [`preinit_segmentation.m`](../preinit_segmentation.m). +Macrosight takes images stored in a hard drive, and saves the output to other +folders following a specific naming scheme. For **segmentation**, see the file [`preinit_segmentation.m`](./CODE/pre-release-scripts/preinit_segmentation.m). This script arranges the data into the cooresponding output folders + `_data_Ha` + `_data_Re` -+ `_data_La ++ `_data_La` -**Tracking** and inclusion of **clump information**, is done in the initialisation -file: [`initscript.m`](../initscript.m). The file allows the user to select an -experiment and continue on a previously loaded dataset. +**Tracking** and inclusion of **clump information**, is done with the setup +function: [`setupInitialStructures.m`](./CODE/setupInitialStructures.m). +The function allows the user to select an experiment and continue on a +previously loaded dataset. + +```Matlab +[tablenet, clumptracktable, clumpidcodes, ~] = setupInitialStructures(); +``` ## Troubleshooting and questions -Macrosight is an ongoing project at an early stage. We welcome all feedback and -comments in the [issues](https://github.com/alonsoJASL/macrosight/issues) +Macrosight is an ongoing project at an early stage. We welcome all feedback and +comments in the [issues](https://github.com/alonsoJASL/macrosight/issues) page. - -## Log files -The log files kept for this package are not written for a full explanation, but -rather as a way to keep track of the developments made. So if there is some -problem with it, just ask me! The log files can be read in the following order: -+ [Shape analysis log](./md-logs/shapeanalysis-log.md) -+ [Single cell following log](./md-logs/shapeanalysis-singlecell.md), a -previous step from __shape evolution__. -+ [Shape evolution](./md-logs/shapeevolution-log.md) **CURRENTLY under development**. -Some of the images present can be hard to see, but the MATLAB fig or EPS files are -present in the [`figs` folder](./figs). -+ (Original development, then switched approach to **shape evolution**) -[SOM shape evolution log](./md-logs/shapeandsom-log.md). This is not finalised. - -Also, please notice that this research is ongoing, so bugs are likely to appear. -Some of the functions might not be present, because they are part of another package -that has not been uploaded. -If you are thinking of using our code, please feel free to submit any issues to the -[issues page](https://github.com/alonsoJASL/macrosight/issues), so that small bugs are -dealt with. diff --git a/configureMacrosight.m b/configureMacrosight.m index af26417..69fc73d 100644 --- a/configureMacrosight.m +++ b/configureMacrosight.m @@ -34,31 +34,42 @@ fprintf('\t%d: %s\n', ix, b_{ix}); end folderchoice_ = input(sprintf(... - '\nChoose the folder containing PhagoSight \n%s\n%s\n%s:__', ... - '0 := it is not found', '1 := default', 'Your choice')); + '\nChoose the folder containing PhagoSight \n%s\n%s\n%s\n%s:__', ... + '0 := it is not found', '1 := default', 'C := not using phagosight', 'Your choice'),'s'); end if isempty(folderchoice_) - folderchoice_ = 1; + folderchoice_ = '1'; end -if folderchoice_== 0 % not found - disp('Pick the location of PhagoSight'); - pause(0.5); - PHAGOHOME_ = uigetdir(MACROHOME_,'Pick a directory'); +if strcmpi(folderchoice_, 'c') + mcrsght_info('Not using PhagoSight - some features might not work.', 'ATTENTION'); + fprintf('Adding the following to the MATLAB path:\n%s\n%s\n', ... + fullfile(MACROHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE', 'DEMOS')); + + addpath(fullfile(MACROHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE', 'DEMOS')); else - PHAGOHOME_ = b_{folderchoice_}; + + if strcmpi(folderchoice_,'0') % not found + disp('Pick the location of PhagoSight'); + pause(0.5); + PHAGOHOME_ = uigetdir(MACROHOME_,'Pick a directory'); + else + PHAGOHOME_ = b_{str2num(folderchoice_)}; + end + fprintf('Adding the following to the MATLAB path:\n%s\n%s\n%s\n', ... + fullfile(PHAGOHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE', 'DEMOS')); + + addpath(fullfile(PHAGOHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE'), ... + fullfile(MACROHOME_, 'CODE', 'DEMOS')); end -fprintf('Adding the following to the MATLAB path:\n%s\n%s\n%s\n', ... - fullfile(PHAGOHOME_, 'CODE'), ... - fullfile(MACROHOME_, 'CODE'), ... - fullfile(MACROHOME_, 'CODE', 'DEMOS')); - -addpath(fullfile(PHAGOHOME_, 'CODE'), ... - fullfile(MACROHOME_, 'CODE'), ... - fullfile(MACROHOME_, 'CODE', 'DEMOS')); clear a_ b_ folderchoice_ ix test_; diff --git a/macrosight_demo.m b/macrosight_demo.m index 7443a76..cf7dcb1 100644 --- a/macrosight_demo.m +++ b/macrosight_demo.m @@ -1,7 +1,10 @@ mcrsght_info('Select the demo from the list:', 'MACROSIGHT_DEMOS'); mcrsght_info('Select contact events - save to xls.', '1'); -mcrsght_info('Load from xls - plot results','2'); +mcrsght_info('Load from saved data - plot results','2'); +mcrsght_info('Load from saved data - statistical analysis','3'); +mcrsght_info('Demo tidy function','9'); +mcrsght_info('Cancel','C'); demoinput_ = input('Your choice [default=1]: ', 's'); if isempty(demoinput_) @@ -13,5 +16,11 @@ demoSelectContactSingle; case '2' demoLoadXLSandPlot; + case '3' + demoStatisticalAnalysis; + case '9' + tidy; + otherwise + mcrsght_info('Cancelled demo.'); end - +clear demoinput_; \ No newline at end of file