├── 3rdPartyLicenses ├── LICENSE_bhtsne.txt ├── license_MFquestdlg.txt ├── license_b2r.txt ├── license_cmcb.txt ├── license_fca.txt ├── license_freezecolors.txt ├── license_getGitInfo.txt ├── license_parforprogressbar.txt ├── license_selectdata.txt ├── license_uipickfiles.txt └── license_uisplitpane.txt ├── ESSENTIAL_LICENSE_CONDITIONS.txt ├── LICENSE_agpl-3.0.txt ├── README.md ├── SOFTWARE CONTRIBUTION AGREEMENT-UZH.doc ├── _config.yml ├── analytics.html ├── graphics ├── histoCAT.png └── histoCATIcon.png ├── histoCAT.fig ├── histoCAT.m ├── histoCAT.png ├── histoCAT ├── 3rdParty │ ├── MFquestdlg │ │ └── MFquestdlg.m │ ├── PhenoGraph │ │ ├── Graph2Binary.m │ │ ├── IEShims.dll │ │ ├── Louvain_d │ │ │ ├── Makefile │ │ │ ├── community │ │ │ ├── community.cpp │ │ │ ├── community.exe │ │ │ ├── community.h │ │ │ ├── community.o │ │ │ ├── convert │ │ │ ├── convert.exe │ │ │ ├── graph.cpp │ │ │ ├── graph.h │ │ │ ├── graph.o │ │ │ ├── graph_binary.cpp │ │ │ ├── graph_binary.h │ │ │ ├── graph_binary.o │ │ │ ├── hierarchy │ │ │ ├── hierarchy.exe │ │ │ ├── main_community.cpp │ │ │ ├── main_community.o │ │ │ ├── main_convert.cpp │ │ │ ├── main_convert.o │ │ │ ├── main_hierarchy.cpp │ │ │ ├── main_hierarchy.o │ │ │ ├── main_random.cpp │ │ │ ├── readme.txt │ │ │ ├── readme_also.txt │ │ │ └── ubuntu │ │ │ │ ├── community │ │ │ │ ├── convert │ │ │ │ └── hierarchy │ │ ├── LouvainfromBin.m │ │ ├── LouvainfromBin_Windows.m │ │ ├── LouvainfromBin_ubuntu.m │ │ ├── Run_Phenograph_Callback.m │ │ ├── WindowsAccessBridge-64.dll │ │ ├── atmfd.dll │ │ ├── atmlib.dll │ │ ├── concrt140.dll │ │ ├── dciman32.dll │ │ ├── dcomp.dll │ │ ├── fontsub.dll │ │ ├── java.exe │ │ ├── javaw.exe │ │ ├── javaws.exe │ │ ├── knn2jaccard.m │ │ ├── lpk.dll │ │ ├── phenograph.m │ │ └── vcruntime140.dll │ ├── b2r │ │ ├── b2r.m │ │ └── license.txt │ ├── bh_tsne │ │ ├── DataHash.m │ │ ├── LICENSE.txt │ │ ├── bh_tsne_linux32 │ │ ├── bh_tsne_linux64 │ │ ├── bh_tsne_mac64 │ │ ├── bh_tsne_win32.exe │ │ ├── bh_tsne_win64.exe │ │ ├── fast_tsne.m │ │ ├── libgcc_s_sjlj-1.dll │ │ └── libstdc++-6.dll │ ├── cm_and_cb_utilities │ │ ├── cbfreeze.m │ │ ├── cbhandle.m │ │ └── license.txt │ ├── cyt_functions_modified │ │ ├── plotScatter_Channels.m │ │ ├── plot_histograms.m │ │ ├── save_sessiondata.m │ │ ├── scatter_plot_Callback.m │ │ └── tSNE │ │ │ ├── Run_tsne_Callback.m │ │ │ ├── addChannels.m │ │ │ ├── mynormalize.m │ │ │ ├── read_data.m │ │ │ └── write_data.m │ ├── cyt_functions_unchanged │ │ ├── distinguishable_colors.m │ │ ├── dplot.m │ │ ├── getIntIndices.m │ │ ├── getSelectedIndices.m │ │ ├── get_channelnames_from_header.m │ │ ├── gethand.m │ │ ├── myplotclr.m │ │ ├── put.m │ │ ├── remove_repeating_strings.m │ │ └── retr.m │ ├── fca_fcs │ │ ├── fca_readfcs.m │ │ ├── fca_readfcs_J.m │ │ ├── fca_writefcs.m │ │ └── license.txt │ ├── freezeColors │ │ ├── freezeColors.m │ │ └── license.txt │ ├── getAllFiles.m │ ├── getGitInfo │ │ ├── getGitInfo.m │ │ └── license.txt │ ├── listdlg.m │ ├── parfor_progressbar │ │ ├── license.txt │ │ └── parfor_progressbar.m │ ├── selectdata │ │ ├── license.txt │ │ └── selectdata.m │ ├── uipickfiles │ │ ├── license.txt │ │ └── uipickfiles.m │ └── uisplitpane │ │ ├── license.txt │ │ └── uisplitpane.m ├── Custom_Clustering │ ├── custom_clusters.m │ └── parse_customclusters.m ├── GUI │ ├── Analyse_Data │ │ ├── Heatmap_slider_tSNE.m │ │ ├── RegressionLine_ScatterPlot.m │ │ ├── analyze_button_Callback.m │ │ ├── analyze_options_Callback.m │ │ ├── b2r_checkbox_callback.m │ │ ├── heatmap_of_selected.m │ │ ├── highlight_selectedsample.m │ │ ├── histmean.m │ │ ├── kmeans_callback.m │ │ ├── median_checkbox_callback.m │ │ ├── parse_Phenographclusters.m │ │ ├── pca_callback.m │ │ ├── percentile_cutoff_tSNE.m │ │ ├── plot_boxplots_per_gate.m │ │ └── regressionline_checkbox_callback.m │ ├── Gating_options │ │ ├── Area_selection_Tiff.m │ │ ├── Area_selection_heatmap.m │ │ └── Area_selection_plot.m │ ├── Listboxes │ │ ├── Find_selectedchannels.m │ │ ├── Merging_samples.m │ │ ├── Pixelexpansion_callback.m │ │ ├── Selection_save_questions.m │ │ ├── Set_listVisualSamples.m │ │ ├── ZScore_Normalize.m │ │ ├── import_gatedarea.m │ │ ├── import_neighbrs.m │ │ ├── list_change_Callback.m │ │ ├── list_channels_Callback.m │ │ ├── list_samples_Callback.m │ │ └── preparesample_button_Callback.m │ ├── Remove_button_options │ │ ├── Remove_channels_Callback.m │ │ ├── Remove_gates_Callback.m │ │ ├── clear_plots.m │ │ ├── clear_tiffs.m │ │ ├── clearall_gateselections.m │ │ ├── remove_options_Callback.m │ │ └── removegates_commonfunction.m │ ├── Save_button_options │ │ ├── ExportCSV_singlecells.m │ │ ├── SavePlot.m │ │ ├── Savetiff_fig.m │ │ └── export_fcs.m │ ├── Visualize_Images │ │ ├── Overlay_Tiffs │ │ │ ├── Comparetiffnames_tolistchannels.m │ │ │ ├── Heatmap_slider.m │ │ │ ├── ScaleTiff_Intensity.m │ │ │ ├── choosetiffs_overlay_Callback.m │ │ │ ├── fuse_images.m │ │ │ ├── getimageids_of_selectedgates.m │ │ │ ├── heatmap_images_overlay.m │ │ │ ├── java_slider.m │ │ │ ├── make_rgb.m │ │ │ ├── overlay_maskandchannels.m │ │ │ ├── percentile_cutoff.m │ │ │ └── plotAreaXY.m │ │ ├── areaxy_checkbox_Callback.m │ │ ├── plot_mask_Callback.m │ │ ├── show_selected_area_onTiff.m │ │ ├── show_ungatedareaonTiff.m │ │ ├── visualize_button_Callback.m │ │ └── visualize_options_Callback.m │ ├── Write_fcs_options │ │ ├── writefcs_gate.m │ │ ├── writefcs_merged.m │ │ └── writefcs_neighbors.m │ └── scatter_plot_Callback.asv ├── Loading_New │ ├── DataProcessing │ │ ├── DataProcessing_Master.m │ │ ├── MasterTiffNames_Generation.m │ │ ├── NeighbourID.m │ │ ├── NeighbrCells_histoCATsinglecells.m │ │ ├── Process_SingleCell_Tiff_Mask.m │ │ └── store_sessionData.m │ ├── Load_Functions │ │ ├── Load_MatrixDB.m │ │ ├── Load_SampleFolders.m │ │ ├── Load_mask.m │ │ ├── Load_sessionData.m │ │ └── Load_tiff.m │ └── Master_LoadSamples.m ├── Neighborhood_New │ ├── Asymmetric_heatmap.m │ ├── Calculate_STDandMean.m │ ├── Check_if_equal_and_replace.m │ ├── Heatmap_individual_images.m │ ├── Neighborhood_Individual_Image.m │ ├── Neighborhood_Master.m │ └── Neighborhood_callback.m ├── SpotDetection │ ├── 3rd_Party │ │ ├── 3rd_Party_Licenses │ │ │ └── license_CellProfiler.txt │ │ ├── CellProfiler_modified │ │ │ ├── IdentifySpots2D.m │ │ │ └── SourceExtractorDeblend.m │ │ └── CellProfiler_unmodified │ │ │ ├── FilterImageCP3D.m │ │ │ ├── ObjByFilter.m │ │ │ ├── RescaleImageCP3D.m │ │ │ ├── SourceExtractorDeblend.m │ │ │ ├── fspecialCP3D.m │ │ │ ├── getImageIntensityExtremaCP3D.m │ │ │ └── inputVectorsForEvalCP3D.m │ └── spot_detection_master.m └── antiquated_functions │ └── struct2array.m └── histoCAT_version.txt /3rdPartyLicenses/LICENSE_bhtsne.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Laurens van der Maaten (Delft University of Technology) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. All advertising materials mentioning features or use of this software 12 | must display the following acknowledgement: 13 | This product includes software developed by the Delft University of Technology. 14 | 4. Neither the name of the Delft University of Technology nor the names of 15 | its contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY LAURENS VAN DER MAATEN ''AS IS'' AND ANY EXPRESS 19 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | EVENT SHALL LAURENS VAN DER MAATEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | OF SUCH DAMAGE. -------------------------------------------------------------------------------- /3rdPartyLicenses/license_MFquestdlg.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Saeid 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_b2r.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, LoveUltraman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_cmcb.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2014, Carlos Adrian Vargas Aguilera 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_fca.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009, Laszlo Balkay 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_freezecolors.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, John Iversen 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_getGitInfo.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Andrew 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_parforprogressbar.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Daniel Terry 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | * Neither the name of the Cornell University nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_selectdata.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, John D'Errico 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_uipickfiles.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, Douglas M. Schwarz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdPartyLicenses/license_uisplitpane.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Yair Altman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /ESSENTIAL_LICENSE_CONDITIONS.txt: -------------------------------------------------------------------------------- 1 | HistoCAT offers a dual licensing model. 2 | 3 | You can redistribute HistoCAT and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 4 | 5 | The GNU Affero General Public License is designed to ensure that if a modified version is distributed or made accessible on a server (e.g. in a SaaS offering), the modified source code becomes available to the community. 6 | 7 | If you wish to use HistoCAT under alternate terms, you may obtain a commercial license to HistoCAT. Contact us for more information: 8 | 9 | Prof. Bernd Bodenmiller 10 | bernd.bodenmiller@imls.uzh.ch 11 | Institute of Molecular Life Sciences 12 | University of Zurich 13 | Winterthurerstrasse 190 14 | CH-8057 Zurich 15 | Switzerland 16 | 17 | 18 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 19 | 20 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see . 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | 3 | ![histoCAT Logo ](histoCAT.png) 4 | 5 | Histology Topography Cytometry Analysis Toolbox (histoCAT) is a package to visualize and analyse multiplexed image cytometry data interactively. 6 | 7 | Cite: 8 | 9 | ## Getting Started 10 | 11 | histoCAT is automatically installed from the web when running the app installer file corresponding to your operating system which is available at . 12 | 13 | Windows users must have Visual Studio installed for features like PhenoGraph to function. If it’s not already installed on your computer download it from . 14 | 15 | For further informations read the corresponding manual available at . 16 | 17 | ## Installation 18 | 19 | Detailed installation instructions are available in the installation manual at . 20 | 21 | ## User instructions 22 | 23 | We are currently working on the [histoCAT wiki](https://github.com/SchapiroLabor/histoCAT/wiki) 24 | 25 | For further details please read the corresponding manual available at . 26 | 27 | ## Using histoCAT from source 28 | 29 | Please use MATLAB2014b and load the full histoCAT folder into your MATLAB path. Run `histoCAT.m` to start histoCAT from source. 30 | 31 | -------------------------------------------------------------------------------- /SOFTWARE CONTRIBUTION AGREEMENT-UZH.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/SOFTWARE CONTRIBUTION AGREEMENT-UZH.doc -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | title: histoCAT 3 | # Google Analytics 4 | google_analytics: UA-169597249-2 5 | -------------------------------------------------------------------------------- /analytics.html: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /graphics/histoCAT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/graphics/histoCAT.png -------------------------------------------------------------------------------- /graphics/histoCATIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/graphics/histoCATIcon.png -------------------------------------------------------------------------------- /histoCAT.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT.fig -------------------------------------------------------------------------------- /histoCAT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT.png -------------------------------------------------------------------------------- /histoCAT/3rdParty/MFquestdlg/MFquestdlg.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/MFquestdlg/MFquestdlg.m -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Graph2Binary.m: -------------------------------------------------------------------------------- 1 | function Graph2Binary( G, filename ) 2 | 3 | 4 | 5 | % Write to binary file 6 | G = tril(G); 7 | t = tic; 8 | fprintf(1,'Writing graph to .bin file\n'); 9 | textname = [filename '.bin']; 10 | out = fopen( textname, 'w+' ); 11 | f = find( G > 0 ); 12 | [i,j] = ind2sub( size(G), f ); 13 | srctarget = uint32([i-1 j-1]); 14 | weights = G(f); 15 | pctdone = 10; 16 | tick = round(length(i)/10); 17 | fprintf(1,'Percent done: '); 18 | for idx = 1:length(srctarget) 19 | fwrite(out,srctarget(idx,:),'uint32'); 20 | fwrite(out,full(weights(idx)),'double'); 21 | if ~mod(idx,tick) && idx>1 22 | fprintf(1,'%i ',pctdone); 23 | pctdone = pctdone + 10; 24 | end 25 | end 26 | fprintf(1,'\n'); 27 | fprintf(1,'Finished writing .bin file in %.2f s\n', toc(t)); 28 | fclose(out); -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/IEShims.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/IEShims.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/Makefile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CC=g++ 4 | CFLAGS= -ansi -O5 -Wall 5 | LDFLAGS= -ansi -lm -Wall 6 | EXEC=community convert hierarchy 7 | OBJ1= graph_binary.o community.o 8 | OBJ2= graph.o 9 | 10 | all: $(EXEC) 11 | 12 | community : $(OBJ1) main_community.o 13 | $(CC) -o $@ $^ $(LDFLAGS) 14 | 15 | convert : $(OBJ2) main_convert.o 16 | $(CC) -o $@ $^ $(LDFLAGS) 17 | 18 | hierarchy : main_hierarchy.o 19 | $(CC) -o $@ $^ $(LDFLAGS) 20 | 21 | ########################################## 22 | # Generic rules 23 | ########################################## 24 | 25 | %.o: %.cpp %.h 26 | $(CC) -o $@ -c $< $(CFLAGS) 27 | 28 | %.o: %.cpp 29 | $(CC) -o $@ -c $< $(CFLAGS) 30 | 31 | clean: 32 | rm -f *.o *~ $(EXEC) 33 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/community: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/community -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/community.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/community.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/community.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/community.o -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/convert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/convert -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/convert.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/convert.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/graph.h: -------------------------------------------------------------------------------- 1 | // File: graph.h 2 | // -- simple graph handling header file 3 | //----------------------------------------------------------------------------- 4 | // Community detection 5 | // Based on the article "Fast unfolding of community hierarchies in large networks" 6 | // Copyright (C) 2008 V. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre 7 | // 8 | // This program must not be distributed without agreement of the above mentionned authors. 9 | //----------------------------------------------------------------------------- 10 | // Author : E. Lefebvre, adapted by J.-L. Guillaume 11 | // Email : jean-loup.guillaume@lip6.fr 12 | // Location : Paris, France 13 | // Time : February 2008 14 | //----------------------------------------------------------------------------- 15 | // see readme.txt for more details 16 | 17 | #ifndef GRAPH_H 18 | #define GRAPH_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #define WEIGHTED 0 31 | #define UNWEIGHTED 1 32 | 33 | using namespace std; 34 | 35 | class Graph { 36 | public: 37 | vector > > links; 38 | 39 | Graph (char *filename, int type); 40 | 41 | void clean(int type); 42 | void renumber(int type); 43 | void display(int type); 44 | void display_binary(char *filename, char *filename_w, int type); 45 | }; 46 | 47 | #endif // GRAPH_H 48 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/graph.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/graph.o -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/graph_binary.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/graph_binary.o -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/hierarchy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/hierarchy -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/hierarchy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/hierarchy.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/main_community.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/main_community.o -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/main_convert.cpp: -------------------------------------------------------------------------------- 1 | // File: main_convert.cpp 2 | // -- conversion of a graph from ascii to binary, sample main file 3 | //----------------------------------------------------------------------------- 4 | // Community detection 5 | // Based on the article "Fast unfolding of community hierarchies in large networks" 6 | // Copyright (C) 2008 V. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre 7 | // 8 | // This program must not be distributed without agreement of the above mentionned authors. 9 | //----------------------------------------------------------------------------- 10 | // Author : E. Lefebvre, adapted by J.-L. Guillaume 11 | // Email : jean-loup.guillaume@lip6.fr 12 | // Location : Paris, France 13 | // Time : February 2008 14 | //----------------------------------------------------------------------------- 15 | // see readme.txt for more details 16 | 17 | #include "graph.h" 18 | 19 | using namespace std; 20 | 21 | char *infile = NULL; 22 | char *outfile = NULL; 23 | char *outfile_w = NULL; 24 | int type = UNWEIGHTED; 25 | bool do_renumber = false; 26 | 27 | void 28 | usage(char *prog_name, const char *more) { 29 | cerr << more; 30 | cerr << "usage: " << prog_name << " -i input_file -o outfile [-r] [-w outfile_weight]" << endl << endl; 31 | cerr << "read the graph and convert it to binary format." << endl; 32 | cerr << "-r\tnodes are renumbered from 0 to nb_nodes-1 (the order is kept)." << endl; 33 | cerr << "-w filename\tread the graph as a weighted one and writes the weights in a separate file." << endl; 34 | cerr << "-h\tshow this usage message." << endl; 35 | exit(0); 36 | } 37 | 38 | void 39 | parse_args(int argc, char **argv) { 40 | for (int i = 1; i < argc; i++) { 41 | if(argv[i][0] == '-') { 42 | switch(argv[i][1]) { 43 | case 'i': 44 | if (i==argc-1) 45 | usage(argv[0], "Infile missing\n"); 46 | infile = argv[i+1]; 47 | i++; 48 | break; 49 | case 'o': 50 | if (i==argc-1) 51 | usage(argv[0], "Outfile missing\n"); 52 | outfile = argv[i+1]; 53 | i++; 54 | break; 55 | case 'w' : 56 | type = WEIGHTED; 57 | outfile_w = argv[i+1]; 58 | i++; 59 | break; 60 | case 'r' : 61 | do_renumber=true; 62 | break; 63 | default: 64 | usage(argv[0], "Unknown option\n"); 65 | } 66 | } else { 67 | usage(argv[0], "More than one filename\n"); 68 | } 69 | } 70 | if (infile==NULL || outfile==NULL) 71 | usage(argv[0], "In or outfile missing\n"); 72 | } 73 | 74 | int 75 | main(int argc, char **argv) { 76 | parse_args(argc, argv); 77 | 78 | Graph g(infile, type); 79 | 80 | g.clean(type); 81 | 82 | if (do_renumber) 83 | g.renumber(type); 84 | 85 | g.display_binary(outfile, outfile_w, type); 86 | 87 | } 88 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/main_convert.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/main_convert.o -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/main_hierarchy.cpp: -------------------------------------------------------------------------------- 1 | // File: main_hierarchy.cpp 2 | // -- output community structure handling (number of levels, communities of one level) 3 | //----------------------------------------------------------------------------- 4 | // Community detection 5 | // Based on the article "Fast unfolding of community hierarchies in large networks" 6 | // Copyright (C) 2008 V. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre 7 | // 8 | // This program must not be distributed without agreement of the above mentionned authors. 9 | //----------------------------------------------------------------------------- 10 | // Author : E. Lefebvre, adapted by J.-L. Guillaume 11 | // Email : jean-loup.guillaume@lip6.fr 12 | // Location : Paris, France 13 | // Time : February 2008 14 | //----------------------------------------------------------------------------- 15 | // see readme.txt for more details 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | using namespace std; 28 | 29 | int display_level = -1; 30 | char *filename = NULL; 31 | 32 | void 33 | usage(char *prog_name, const char *more) { 34 | cerr << more; 35 | cerr << "usage: " << prog_name << " input_file [options]" << endl << endl; 36 | cerr << "input_file: read the community tree from this file." << endl; 37 | cerr << "-l xx\t display the community structure for the level xx." << endl; 38 | cerr << "\t outputs the community for each node." << endl; 39 | cerr << "\t xx must belong to [-1,N] if N is the number of levels." << endl; 40 | cerr << "-n\t displays the number of levels and the size of each level." << endl; 41 | cerr << "\t equivalent to -l -1." << endl; 42 | cerr << "-h\tshow this usage message." << endl; 43 | exit(0); 44 | } 45 | 46 | void 47 | parse_args(int argc, char **argv) { 48 | if (argc<2) 49 | usage(argv[0], "Bad arguments number\n"); 50 | 51 | for (int i = 1; i < argc; i++) { 52 | if(argv[i][0] == '-') { 53 | switch(argv[i][1]) { 54 | case 'l': 55 | display_level = atoi(argv[i+1]); 56 | i++; 57 | break; 58 | case 'n': 59 | display_level = -1; 60 | break; 61 | default: 62 | usage(argv[0], "Unknown option\n"); 63 | } 64 | } else { 65 | if (filename==NULL) 66 | filename = argv[i]; 67 | else 68 | usage(argv[0], "More than one filename\n"); 69 | } 70 | } 71 | if (filename==NULL) 72 | usage(argv[0], "No input file has been provided.\n"); 73 | } 74 | int 75 | main(int argc, char **argv) { 76 | parse_args(argc, argv); 77 | 78 | vector >levels; 79 | 80 | ifstream finput; 81 | finput.open(filename,fstream::in); 82 | 83 | int l=-1; 84 | while (!finput.eof()) { 85 | int node, nodecomm; 86 | finput >> node >> nodecomm; 87 | 88 | if (finput) { 89 | if (node==0) { 90 | l++; 91 | levels.resize(l+1); 92 | } 93 | levels[l].push_back(nodecomm); 94 | } 95 | } 96 | 97 | if (display_level==-1) { 98 | cout << "Number of levels: " << levels.size() << endl; 99 | for (unsigned int i=0 ; i=levels.size()) { 102 | cerr << "Incorrect level\n"; 103 | } else { 104 | vector n2c(levels[0].size()); 105 | 106 | for (unsigned int i=0 ; i graph.tree 12 | ./hierarchy graph.tree 13 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/community: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/community -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/convert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/convert -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/hierarchy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/Louvain_d/ubuntu/hierarchy -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/LouvainfromBin.m: -------------------------------------------------------------------------------- 1 | function [c,Q,bestpartition,bestpartitionhierarchy] = LouvainfromBin( filename, numiters, random_seed ) 2 | % LOUVAINFROMBIN 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %the path to louvain in each histoCAT app 11 | [curr_path, ~, ~] = fileparts(mfilename('fullpath')); 12 | curr_path = [curr_path filesep]; 13 | ps = [curr_path 'Louvain_d' filesep]; 14 | 15 | filename = strrep( filename, '.bin', '' ); 16 | % begin 17 | fprintf(1, 'MATLAB: calling convert:\n'); 18 | command = [ps 'convert -i ' filename '.bin -o ' filename '_graph.bin -w ' filename '_graph.weights' ]; 19 | fprintf(1,'%s\n', command ); 20 | system( command ); 21 | hWaitbar = waitbar(0,'Running Phenograph, Please wait...'); 22 | % run community detection 23 | for iter = 1:numiters 24 | 25 | fprintf(1,'MATLAB: running community detection, ITERATION %i\n', iter ); 26 | if strcmpi(random_seed,'Yes') 27 | command = [ps 'community ' filename '_graph.bin -l -1 -v -w ' filename '_graph.weights > ' filename '.tree']; 28 | elseif strcmpi(random_seed,'No') 29 | command = [ps 'community ' filename '_graph.bin -l -1 -v -s 2 -w ' filename '_graph.weights > ' filename '.tree']; 30 | display(['iter' iter]); 31 | end 32 | 33 | fprintf( 1, '%s\n', command ); 34 | [~,r] = system( command ); 35 | fprintf(1, '\n'); 36 | try 37 | % find each iteration's modularity 38 | q = find_modularity( r ); 39 | fprintf( 1, 'MATLAB: modularity scores:\n' ); 40 | catch 41 | cleanup(filename) 42 | error('Unable to find modularity score in the stderr: %s.\nCheck that the correct path to the Louvain code is specified.', r); 43 | end 44 | 45 | 46 | % find number of lvevls 47 | command = [ps 'hierarchy ' filename '.tree' ]; 48 | fprintf(1, '%s\n', command ); 49 | [~,r] = system( command ); 50 | fprintf(1, '\n' ); 51 | 52 | r = strtok(r, 10); 53 | r = regexprep( r, 'Number of levels: ', '' ); 54 | num_levels = str2double( r )-1; 55 | 56 | fprintf( 1, 'MATLAB: max level is %d\n', num_levels ); 57 | 58 | % import levels 59 | for level = 1:num_levels 60 | fprintf( 1, 'MATLAB: importing level %d\n', level ); 61 | command = [ps 'hierarchy ' filename '.tree -l ' num2str( level ) ' > ' filename '.tmp' ]; 62 | fprintf(1, '%s\n', command ); 63 | system( command ); 64 | hierarchy_output = load( [filename '.tmp'] ); 65 | c{iter,level} = hierarchy_output(:,2) + 1; 66 | Q{iter,level} = q(level); 67 | end 68 | waitbar(iter/numiters, hWaitbar); 69 | end 70 | close(hWaitbar); 71 | % find best partition 72 | maxmod = 0; 73 | for i = 1:numel(Q) 74 | if Q{i} > maxmod 75 | maxmod = Q{i}; 76 | [I,J] = ind2sub( size(Q), i ); 77 | end 78 | end 79 | bestpartition = c{I,J}; 80 | bestpartitionhierarchy = c(I,:); 81 | % delete temporary files 82 | cleanup(filename) 83 | 84 | %------------------------- 85 | function Q = find_modularity( r ) 86 | % Q = find_modularity( r ) 87 | % convert the text output into modularity score of each iteration 88 | signature = ' modularity increased from %f to %f'; 89 | idx = 0; 90 | while( ~isempty( r ) ) 91 | % read a line and match it to the signature 92 | [token, r] = strtok( r, char( 10 ) ); 93 | a = sscanf( token, signature ); 94 | 95 | if( ~isempty( a ) ) 96 | % signature matched copy new modularity 97 | idx = idx + 1; 98 | Q( idx ) = a( 2 ); 99 | end 100 | end 101 | %------------------------- 102 | function cleanup(filename) 103 | files{1} = dir([filename '*.tmp']); 104 | files{2} = dir([filename '*.tree']); 105 | files{3} = dir([filename '*.weights']); 106 | files{4} = dir([filename '*.bin']); 107 | for i = 1:4 108 | for j = 1:length(files{i}) 109 | delete( files{i}(j).name ) 110 | end 111 | end 112 | 113 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/LouvainfromBin_Windows.m: -------------------------------------------------------------------------------- 1 | function [c,Q,bestpartition,bestpartitionhierarchy] = LouvainfromBin_Windows( filename, numiters ) 2 | % LOUVAINFROMBIN_WINDOWS 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %the path to louvain in each histoCAT app 11 | %[curr_path, ~, ~] = fileparts(pwd);%mfilename('fullpath') 12 | disp('In windows..'); 13 | path = which('LouvainfromBin_Windows'); 14 | curr_path = fileparts(path); 15 | curr_path = [curr_path filesep]; 16 | ps = [curr_path 'Louvain_d' filesep]; 17 | 18 | 19 | filename = strrep( filename, '.bin', '' ); 20 | % begin 21 | fprintf(1, 'MATLAB: calling convert:\n'); 22 | command = [ps 'convert.exe -i ' filename '.bin -o ' filename '_graph.bin -w ' filename '_graph.weights' ]; 23 | fprintf(1,'%s\n', command ); 24 | system( command ); 25 | hWaitbar = waitbar(0,'Running Phenograph, Please wait...'); 26 | % run community detection 27 | for iter = 1:numiters 28 | 29 | fprintf(1,'MATLAB: running community detection, ITERATION %i\n', iter ); 30 | command = [ps 'community.exe ' filename '_graph.bin -l -1 -v -w ' filename '_graph.weights > ' filename '.tree']; 31 | fprintf( 1, '%s\n', command ); 32 | [~,r] = system( command ); 33 | fprintf(1, '\n'); 34 | try 35 | % find each iteration's modularity 36 | q = find_modularity( r ); 37 | fprintf( 1, 'MATLAB: modularity scores:\n' ); 38 | catch 39 | cleanup(filename) 40 | error('Unable to find modularity score in the stderr: %s.\nCheck that the correct path to the Louvain code is specified.', r); 41 | end 42 | 43 | 44 | % find number of lvevls 45 | command = [ps 'hierarchy.exe ' filename '.tree' ]; 46 | fprintf(1, '%s\n', command ); 47 | [~,r] = system( command ); 48 | fprintf(1, '\n' ); 49 | 50 | r = strtok(r, 10); 51 | r = regexprep( r, 'Number of levels: ', '' ); 52 | num_levels = str2double( r )-1; 53 | 54 | fprintf( 1, 'MATLAB: max level is %d\n', num_levels ); 55 | 56 | % import levels 57 | for level = 1:num_levels 58 | fprintf( 1, 'MATLAB: importing level %d\n', level ); 59 | command = [ps 'hierarchy.exe ' filename '.tree -l ' num2str( level ) ' > ' filename '.tmp' ]; 60 | fprintf(1, '%s\n', command ); 61 | system( command ); 62 | hierarchy_output = load( [filename '.tmp'] ); 63 | c{iter,level} = hierarchy_output(:,2) + 1; 64 | Q{iter,level} = q(level); 65 | end 66 | waitbar(iter/numiters, hWaitbar); 67 | 68 | end 69 | close(hWaitbar); 70 | put('Q',Q) 71 | % find best partition 72 | maxmod = 0; 73 | for i = 1:numel(Q) 74 | if Q{i} > maxmod 75 | maxmod = Q{i}; 76 | [I,J] = ind2sub( size(Q), i ); 77 | end 78 | end 79 | bestpartition = c{I,J}; 80 | bestpartitionhierarchy = c(I,:); 81 | % delete temporary files 82 | cleanup(filename) 83 | 84 | %------------------------- 85 | function Q = find_modularity( r ) 86 | % Q = find_modularity( r ) 87 | % convert the text output into modularity score of each iteration 88 | signature = ' modularity increased from %f to %f'; 89 | idx = 0; 90 | while( ~isempty( r ) ) 91 | % read a line and match it to the signature 92 | [token, r] = strtok( r, char( 10 ) ); 93 | a = sscanf( token, signature ); 94 | 95 | if( ~isempty( a ) ) 96 | % signature matched copy new modularity 97 | idx = idx + 1; 98 | Q( idx ) = a( 2 ); 99 | end 100 | end 101 | %------------------------- 102 | function cleanup(filename) 103 | files{1} = dir([filename '*.tmp']); 104 | files{2} = dir([filename '*.tree']); 105 | files{3} = dir([filename '*.weights']); 106 | files{4} = dir([filename '*.bin']); 107 | for i = 1:4 108 | for j = 1:length(files{i}) 109 | delete( files{i}(j).name ) 110 | end 111 | end 112 | 113 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/LouvainfromBin_ubuntu.m: -------------------------------------------------------------------------------- 1 | function [c,Q,bestpartition,bestpartitionhierarchy] = LouvainfromBin( filename, numiters ) 2 | % LOUVAINFROMBIN 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %the path to louvain in each histoCAT app 11 | [curr_path, ~, ~] = fileparts(mfilename('fullpath')); 12 | curr_path = [curr_path filesep]; 13 | ps = [curr_path 'Louvain_d' filesep 'ubuntu' filesep]; 14 | 15 | filename = strrep( filename, '.bin', '' ); 16 | % begin 17 | fprintf(1, 'MATLAB: calling convert:\n'); 18 | command = [ps 'convert -i ' filename '.bin -o ' filename '_graph.bin -w ' filename '_graph.weights' ]; 19 | fprintf(1,'%s\n', command ); 20 | system( command ); 21 | hWaitbar = waitbar(0,'Running Phenograph, Please wait...'); 22 | % run community detection 23 | for iter = 1:numiters 24 | 25 | fprintf(1,'MATLAB: running community detection, ITERATION %i\n', iter ); 26 | command = [ps 'community ' filename '_graph.bin -l -1 -v -w ' filename '_graph.weights > ' filename '.tree']; 27 | fprintf( 1, '%s\n', command ); 28 | [~,r] = system( command ); 29 | fprintf(1, '\n'); 30 | try 31 | % find each iteration's modularity 32 | q = find_modularity( r ); 33 | fprintf( 1, 'MATLAB: modularity scores:\n' ); 34 | catch 35 | cleanup(filename) 36 | error('Unable to find modularity score in the stderr: %s.\nCheck that the correct path to the Louvain code is specified.', r); 37 | end 38 | 39 | 40 | % find number of lvevls 41 | command = [ps 'hierarchy ' filename '.tree' ]; 42 | fprintf(1, '%s\n', command ); 43 | [~,r] = system( command ); 44 | fprintf(1, '\n' ); 45 | 46 | r = strtok(r, 10); 47 | r = regexprep( r, 'Number of levels: ', '' ); 48 | num_levels = str2double( r )-1; 49 | 50 | fprintf( 1, 'MATLAB: max level is %d\n', num_levels ); 51 | 52 | % import levels 53 | for level = 1:num_levels 54 | fprintf( 1, 'MATLAB: importing level %d\n', level ); 55 | command = [ps 'hierarchy ' filename '.tree -l ' num2str( level ) ' > ' filename '.tmp' ]; 56 | fprintf(1, '%s\n', command ); 57 | system( command ); 58 | hierarchy_output = load( [filename '.tmp'] ); 59 | c{iter,level} = hierarchy_output(:,2) + 1; 60 | Q{iter,level} = q(level); 61 | end 62 | waitbar(iter/numiters, hWaitbar); 63 | end 64 | close(hWaitbar); 65 | % find best partition 66 | maxmod = 0; 67 | for i = 1:numel(Q) 68 | if Q{i} > maxmod 69 | maxmod = Q{i}; 70 | [I,J] = ind2sub( size(Q), i ); 71 | end 72 | end 73 | bestpartition = c{I,J}; 74 | bestpartitionhierarchy = c(I,:); 75 | % delete temporary files 76 | cleanup(filename) 77 | 78 | %------------------------- 79 | function Q = find_modularity( r ) 80 | % Q = find_modularity( r ) 81 | % convert the text output into modularity score of each iteration 82 | signature = ' modularity increased from %f to %f'; 83 | idx = 0; 84 | while( ~isempty( r ) ) 85 | % read a line and match it to the signature 86 | [token, r] = strtok( r, char( 10 ) ); 87 | a = sscanf( token, signature ); 88 | 89 | if( ~isempty( a ) ) 90 | % signature matched copy new modularity 91 | idx = idx + 1; 92 | Q( idx ) = a( 2 ); 93 | end 94 | end 95 | %------------------------- 96 | function cleanup(filename) 97 | files{1} = dir([filename '*.tmp']); 98 | files{2} = dir([filename '*.tree']); 99 | files{3} = dir([filename '*.weights']); 100 | files{4} = dir([filename '*.bin']); 101 | for i = 1:4 102 | for j = 1:length(files{i}) 103 | delete( files{i}(j).name ) 104 | end 105 | end 106 | 107 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/Run_Phenograph_Callback.m: -------------------------------------------------------------------------------- 1 | function Run_Phenograph_Callback 2 | % RUN_PHENOGRAPH_CALLBACK Run Phenograph once button (callback) selected 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %retrieve gui data 11 | handles = gethand; 12 | selected_gates = get(handles.list_samples,'Value'); 13 | gates = retr('gates'); 14 | sessionData = retr('sessionData'); 15 | gate_context = retr('gateContext'); 16 | 17 | %set_seed if want to reproduce 18 | rng(2); 19 | 20 | %data = sessionData(gate_context, selected_channels); 21 | [ selectedset ] = Find_selectedchannels; 22 | data = selectedset; 23 | %normalize 24 | percentile = 99; 25 | data = mynormalize(data, percentile); 26 | 27 | % Run Phenograph 28 | near_neighbors_cell = inputdlg('Nearst Neighbors','Nearst Neighbors',1,{'30'}); 29 | if isempty(near_neighbors_cell) == 1 30 | return; 31 | end 32 | 33 | % Random seed yes or no 34 | random_seed = questdlg('Random seed - Yes or No?','Random seed - Yes or No?',{'Yes','No'}); 35 | 36 | near_neighbors = str2num(near_neighbors_cell{:}); 37 | [labels,~,~] = phenograph(data, near_neighbors,'random_seed',random_seed); 38 | 39 | %remove fixed seed for name generation 40 | rng('shuffle'); 41 | %added to create appropriate name for Phenograph 42 | newPhenograph_name = int2str(randi(10000000000));%horzcat(cell2mat(gates{selected_gates(1),3}((selected_channels)))); 43 | disp('assigning random number for current Phenograph'); 44 | new_channel_name = {sprintf('Phenograph%s',newPhenograph_name)}; 45 | 46 | %create new session data 47 | opt_gates = selected_gates; 48 | opt_gate_context = gate_context; 49 | new_data = labels; 50 | [sessionData,gates] = addChannels(new_channel_name, new_data, opt_gate_context,opt_gates, gates, sessionData); 51 | [ pheno_clusters ] = parse_Phenographclusters( sessionData,gates ); 52 | custom_gatesfolder = retr('custom_gatesfolder'); 53 | 54 | % %write tsne channels to file for user's reference 55 | % if exist(fullfile(custom_gatesfolder,'tSNEinfo.txt')) ~= 0 56 | % fileID = fopen(fullfile(custom_gatesfolder,'tSNEinfo.txt'),'a'); 57 | % 58 | % else 59 | % fileID = fopen(fullfile(custom_gatesfolder,'tSNEinfo.txt'),'w'); 60 | % end 61 | % tsne_channels = horzcat(cell2mat(gates{selected_gates(1),3}((selected_channels)))); 62 | % fprintf(fileID,'\ntSNE_%s:%s\n',newbhSNE_name,tsne_channels); 63 | % fclose(fileID); 64 | 65 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/WindowsAccessBridge-64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/WindowsAccessBridge-64.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/atmfd.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/atmfd.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/atmlib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/atmlib.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/concrt140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/concrt140.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/dciman32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/dciman32.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/dcomp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/dcomp.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/fontsub.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/fontsub.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/java.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/java.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/javaw.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/javaw.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/javaws.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/javaws.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/knn2jaccard.m: -------------------------------------------------------------------------------- 1 | function G = knn2jaccard( IDX ) 2 | % IN: 3 | % IDX is a n x k matrix 4 | % row i contains the indices of i's k nearest neighbors (in descending order of similarity) 5 | % e.g. IDX = knnsearch(data,data,'k',k+1); IDX(:,1)=[]; 6 | % OUT: 7 | % G is the lower triangle (excluding diagonal) of the resulting adjacency matrix 8 | [n,k] = size(IDX); 9 | I = nan(1, k*n ); 10 | J = I; 11 | S = I; 12 | row = 1; 13 | pctdone = 10; 14 | ticker = round(n/10); 15 | t = tic; 16 | for ii = 1:n 17 | 18 | pt_neighbs = IDX(ii,:); 19 | n_of_n = IDX(pt_neighbs,:); 20 | shared_neighbors = sum(ismember(n_of_n, pt_neighbs),2); 21 | % intersection and union sum to k 22 | weights = shared_neighbors ./ (2*k-shared_neighbors); % Jaccard coefficient 23 | idx = row:row+k-1; 24 | I(idx) = repmat(ii,1,k); 25 | J(idx) = pt_neighbs; 26 | S(idx) = weights; 27 | row = row+k; 28 | if ~mod(ii,ticker) && ii>1 29 | fprintf(1,'%i percent complete: %.2f s\n',... 30 | pctdone, toc(t) ); 31 | pctdone = pctdone + 10; 32 | end 33 | 34 | end 35 | fprintf(1,'Finished Jaccard graph in %.2f s\n', toc(t)); 36 | % Produce sparse lower triangle of symmetrized graph 37 | G = sparse(I,J,S,n,n); 38 | init_edge_num = nnz(G); 39 | clear I J S IDX 40 | u = triu(G,1); 41 | v = tril(G,-1); 42 | % G = v .* u'; % product zeros-out non-reciprocal edges 43 | G = v + u'; 44 | fprintf(1,'Edge number pruned from %g to %g\n', init_edge_num, nnz(G)); 45 | fprintf(1, 'Sparsity: %g\n',nnz(G)/numel(G)); 46 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/lpk.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/lpk.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/phenograph.m: -------------------------------------------------------------------------------- 1 | % PhenoGraph: Robust graph-based phenotype discovery 2 | % ----------------------------------------------------------------------- 3 | % [labels,communities,G] = phenograph( data, k, varargin ) 4 | % 5 | % INPUT: 6 | % data - n x d matrix of n single cells 7 | % k - number of neighbors for graph construction 8 | % Options: 9 | % 'distance', distance - string input for knnsearch 10 | % 'G', graph 11 | % 'IDX', IDX 12 | % 'graphtype', 'jaccard' or 'knn' 13 | % 'random_seed', 'yes' or 'no' 14 | % OUTPUT: 15 | % labels - n x 1 vector of cluster assignments 16 | % G - n x n sparse matrix representation of the (lower triangle) 17 | % of the Jaccard graph used for community detection 18 | % ----------------------------------------------------------------------- 19 | function [labels,communities,G,uniqueID] = phenograph( data, k, varargin) 20 | 21 | distance = 'euclidean'; 22 | graphtype = 'jaccard'; 23 | if nargin >2 24 | for i = 1:2:length(varargin) 25 | switch varargin{i} 26 | case 'G' 27 | G = varargin{i+1}; 28 | case 'IDX' 29 | IDX = varargin{i+1}; 30 | case 'distance' 31 | distance = varargin{i+1}; 32 | case 'graphtype' 33 | graphtype = varargin{i+1}; 34 | case 'random_seed' 35 | random_seed = varargin{i+1}; 36 | end 37 | end 38 | end 39 | Jaccard = strcmpi( 'jaccard', graphtype ); 40 | 41 | if ~exist('IDX','var') && ~exist('G','var') 42 | % Nearest neighbors 43 | fprintf(1,'Finding %i nearest neighbors...\n',k); 44 | [IDX,D] = knnsearch(data,data,'k',k+1,'distance',distance); 45 | IDX(:,1) = []; D(:,1) = []; 46 | end 47 | 48 | if ~exist('G','var') && Jaccard 49 | % Jaccard graph 50 | fprintf(1,'Building Jaccard Graph...\n'); 51 | G = knn2jaccard(IDX); 52 | end 53 | 54 | if ~exist('G','var') && ~Jaccard 55 | % knn graph 56 | fprintf(1,'Building knn graph...\n'); 57 | G = idx2knn(IDX,D); 58 | end 59 | 60 | if any(isinf(nonzeros(G))) 61 | [~,j] = find(isinf(G)); 62 | display(unique(j)); 63 | error('Graph contains infinite weights. Check your data for identical points'); 64 | end 65 | 66 | % Write graph to file 67 | custom_gates = retr('custom_gatesfolder'); 68 | Graph2Binary(G,fullfile(custom_gates,'G')); 69 | 70 | % Run Louvain on file for multiple iterations 71 | niter = 20; 72 | if ispc == 1 73 | [c,Q,labels,communities] = LouvainfromBin_Windows(fullfile(custom_gates,'G.bin'),niter); 74 | elseif ismac 75 | [c,Q,labels,communities] = LouvainfromBin(fullfile(custom_gates,'G.bin'),niter,random_seed); 76 | elseif isunix 77 | [c,Q,labels,communities] = LouvainfromBin_ubuntu(fullfile(custom_gates,'G.bin'),niter); 78 | end 79 | 80 | llim = max([ceil(length(labels)./1e4) 1]); 81 | labels = sortlabels(labels,llim); 82 | 83 | % %generate unique id 84 | % uniqueID = genarateID; 85 | 86 | function c = sortlabels( c, cutoff ) 87 | % c = sortlabels( c, cutoff ) 88 | % Rearrange classlabels in c so the first class is the largest, etc. 89 | % if c is a cell array, perform iteratively on each cell 90 | % if cutoff is provided, entries in c belonging to classes with size < 91 | % cutoff are assigned to class 0. 92 | 93 | if nargin < 2 94 | cutoff = 0; 95 | end 96 | 97 | if iscell( c ) 98 | for idx = 1:length(c) 99 | c{idx} = sortlabs( c{idx}, cutoff ); 100 | end 101 | 102 | else % c is a single unsorted labels vector 103 | 104 | c = sortlabs( c, cutoff ); 105 | 106 | end 107 | 108 | function sl = sortlabs( labs, cutoff ) 109 | 110 | i = 1; 111 | classSize = arrayfun(@(x) sum(labs==x), 1:max(labs)); 112 | sl = zeros(size(labs)); 113 | remove = sort( classSize <= cutoff, 'ascend'); 114 | [~,ix] = sort(classSize,'descend'); 115 | ix(remove) = []; 116 | for assignment = ix 117 | sl( labs == assignment ) = i; 118 | i = i+1; 119 | end 120 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/PhenoGraph/vcruntime140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/PhenoGraph/vcruntime140.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/b2r/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, LoveUltraman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Laurens van der Maaten (Delft University of Technology) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. All advertising materials mentioning features or use of this software 12 | must display the following acknowledgement: 13 | This product includes software developed by the Delft University of Technology. 14 | 4. Neither the name of the Delft University of Technology nor the names of 15 | its contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY LAURENS VAN DER MAATEN ''AS IS'' AND ANY EXPRESS 19 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 21 | EVENT SHALL LAURENS VAN DER MAATEN BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 26 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 27 | OF SUCH DAMAGE. -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/bh_tsne_linux32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/bh_tsne_linux32 -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/bh_tsne_linux64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/bh_tsne_linux64 -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/bh_tsne_mac64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/bh_tsne_mac64 -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/bh_tsne_win32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/bh_tsne_win32.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/bh_tsne_win64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/bh_tsne_win64.exe -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/libgcc_s_sjlj-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/libgcc_s_sjlj-1.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/bh_tsne/libstdc++-6.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/3rdParty/bh_tsne/libstdc++-6.dll -------------------------------------------------------------------------------- /histoCAT/3rdParty/cm_and_cb_utilities/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2014, Carlos Adrian Vargas Aguilera 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/save_sessiondata.m: -------------------------------------------------------------------------------- 1 | function save_sessiondata 2 | %SAVE_SESSIONDATA function to save the session data (clicking on the save button) 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | handles=gethand; 11 | gates = retr('gates'); 12 | sessionData = retr('sessionData'); 13 | sessiondata_index = retr('sessiondata_index'); 14 | allids = retr('allids'); 15 | global Fcs_Interest_all 16 | global Sample_Set_arranged 17 | global HashID 18 | global Mask_all 19 | Tiff_name = retr('Tiff_name'); 20 | Tiff_all = retr('Tiff_all'); 21 | expansionfeature_value = handles.pixelexpansion_dropdown.Value; 22 | expansionfeature_range = handles.pixelexpansion_dropdown.String; 23 | notNan = retr('notNan'); 24 | 25 | 26 | if (isempty(sessionData)) 27 | uiwait(msgbox('The session is empty.','Warning!','modal')); 28 | return; 29 | end 30 | 31 | [filename,pathname,~] = uiputfile('*.mat','Save Session'); 32 | 33 | if isequal(filename,0) || isequal(pathname,0) 34 | return; 35 | end 36 | 37 | save([pathname filename], 'sessionData','gates','sessiondata_index','allids','Fcs_Interest_all','Sample_Set_arranged','HashID','Mask_all','Tiff_name','Tiff_all','expansionfeature_value','expansionfeature_range','notNan','-v7.3'); 38 | 39 | 40 | end 41 | 42 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/tSNE/Run_tsne_Callback.m: -------------------------------------------------------------------------------- 1 | function Run_tsne_Callback 2 | % RUN_TSNE_CALLBACK Runs tSNE and returns the sessionData matrix with the added channels for which tSNE was run 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | % fast tsne is only implemented for 2 dims. 11 | ndims = 2; 12 | 13 | %retrieve gui data 14 | handles = gethand; 15 | selected_gates = get(handles.list_samples,'Value'); 16 | selected_channels = get(handles.list_channels,'Value'); 17 | gates = retr('gates'); 18 | sessionData = retr('sessionData'); 19 | gate_context = retr('gateContext'); 20 | custom_gatesfolder = retr('custom_gatesfolder'); 21 | %%%%%%%%%%%%%%%%%%%%%%%%% 22 | 23 | if numel(selected_channels) <=1 24 | msgbox('Please select atleast two or more channels to run tSNE'); 25 | return; 26 | end 27 | 28 | MAX_TSNE = 1000000; 29 | 30 | if (numel(gate_context) > MAX_TSNE) 31 | %setStatus(sprintf('Cannot run tSNE locally on more than %g points. Please subsample first.', MAX_TSNE)); 32 | return; 33 | end 34 | 35 | msg = 'BH-SNE started. Refer to Command window or std-o for progress.'; 36 | hwaitbar = waitbar(0,msg); 37 | 38 | 39 | tic; 40 | %%Get the data from the correct channel columns 41 | [ selectedset ] = Find_selectedchannels; 42 | data = selectedset; 43 | %normalize 44 | percentile = 99; 45 | data = mynormalize(data, percentile); 46 | 47 | 48 | try 49 | map = fast_tsne(data, 110); 50 | catch 51 | msgbox(... 52 | ['tSNE Failed: Common causes are \n' ... 53 | 'a) illegal histoCAT installation path - spaces in path.\n' ... 54 | 'b) illegal histoCAT installation path - no writing persmissions in folder.\n' ... 55 | 'c) perplexity too high caused by insufficient number of points.'],... 56 | 'Error','error'); 57 | return; 58 | end 59 | 60 | disp(sprintf('map generated in %g m', toc/60)); 61 | 62 | 63 | %undo seed for names 64 | rng('shuffle'); 65 | %added to create appropriate names and not bhSNE1 bhSNE2(creates confusion) 66 | newbhSNE_name = int2str(randi(10000000000));%horzcat(cell2mat(gates{selected_gates(1),3}((selected_channels)))); 67 | disp('assigning random number for current tSNE'); 68 | new_channel_names = cell(1, ndims); 69 | 70 | %%Store the new names for the tsne channels 71 | for i=1:numel(new_channel_names) 72 | new_channel_names{i} = sprintf('tSNE%s_%g',newbhSNE_name,i); 73 | end 74 | 75 | %%Prepare the inputs for adding channels to the listbox and sessionData 76 | opt_gates = selected_gates; 77 | opt_gate_context = gate_context; 78 | new_data = map; 79 | %%Function call to add the new channels 80 | [ sessionData,gates ] = addChannels(new_channel_names, new_data, opt_gate_context,opt_gates, gates, sessionData); 81 | 82 | waitbar(1,hwaitbar, 'Done.'); 83 | 84 | close(hwaitbar); 85 | 86 | %write tsne channels to file for user's reference 87 | if exist(fullfile(custom_gatesfolder,'tSNEinfo.txt')) ~= 0 88 | fileID = fopen(fullfile(custom_gatesfolder,'tSNEinfo.txt'),'a'); 89 | 90 | else 91 | fileID = fopen(fullfile(custom_gatesfolder,'tSNEinfo.txt'),'w'); 92 | end 93 | tsne_channels = horzcat(cell2mat(gates{selected_gates(1),3}((selected_channels)))); 94 | fprintf(fileID,'\ntSNE_%s:%s\n',newbhSNE_name,tsne_channels); 95 | fclose(fileID); 96 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 97 | 98 | end 99 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/tSNE/addChannels.m: -------------------------------------------------------------------------------- 1 | function [sessionData,gates] = addChannels(new_channel_names, new_data, opt_gate_context,opt_gates, gates, sessionData) 2 | % ADDCHANNELS Once t-SNE/Normalization etc. is run this function is will add the newly created channels to the sessionData 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Input: 8 | % new_channel_names --> Cell array of strings with names for the new channels 9 | % new_data --> matrix with new data to add 10 | % opt_gate_context --> gate context 11 | % opt_gates --> selected gate 12 | % gates --> all gates 13 | % sessionData --> full session data 14 | % 15 | % Output: 16 | % sessionData --> Updated session data 17 | % gates --> updated gates 18 | % 19 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 20 | % Denis Schapiro - Bodenmiller Group - UZH 21 | 22 | if (exist('opt_gate_context','var')) 23 | gate_context = opt_gate_context; 24 | else 25 | gate_context = retr('gateContext'); 26 | end 27 | 28 | if (exist('opt_gates','var')) 29 | selected_gates = opt_gates; 30 | elseif isempty(opt_gates) 31 | selected_gates = 1:size(gates, 1); 32 | end 33 | 34 | % add necessary channels to the selected gates 35 | defined_channels = cellfun(@(x)numel(x), gates(selected_gates, 3), 'uniformoutput', true); 36 | undef_channel_ind = max(defined_channels)+1; 37 | 38 | if (size(sessionData,2)-undef_channel_ind >= 0) && ... 39 | any(~any(sessionData(gate_context, undef_channel_ind:end))) 40 | 41 | % find a streak the same width of new_data of empty columns 42 | d = diff([false any(sessionData(gate_context, undef_channel_ind:end)) == 0 ones(1, size(new_data, 2)) false]); 43 | p = find(d==1); 44 | m = find(d==-1); 45 | lr = find(m-p>=size(new_data, 2)); 46 | last_def_channel = undef_channel_ind - 1 + (p(lr(1)) - 1); 47 | else 48 | last_def_channel = size(sessionData,2); 49 | end 50 | 51 | for i=selected_gates 52 | 53 | % add new channel names to gate 54 | channel_names = gates{i, 3}; 55 | if (last_def_channel-numel(channel_names) > 0) 56 | % add blank\placeholder channel names 57 | for j=numel(channel_names)+1:last_def_channel 58 | channel_names{j} = strcat('empty_channel',int2str(j)); 59 | end 60 | end 61 | channel_names(end+1:end+numel(new_channel_names)) = new_channel_names; 62 | gates{i, 3} = channel_names; 63 | 64 | 65 | end 66 | 67 | n_new_columns = size(new_data, 2) - (size(sessionData,2) - last_def_channel); 68 | 69 | % extend session data 70 | if (n_new_columns > 0) 71 | new_columns = zeros(size(sessionData, 1), n_new_columns); 72 | sessionData = [sessionData new_columns]; 73 | end 74 | 75 | % set new data to session 76 | sessionData(gate_context, last_def_channel+1:last_def_channel+size(new_data, 2)) = new_data; 77 | 78 | %update gui variables 79 | put('sessionData',sessionData); 80 | put('gates',gates); 81 | list_samples_Callback; 82 | 83 | 84 | 85 | end 86 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/tSNE/mynormalize.m: -------------------------------------------------------------------------------- 1 | function data = mynormalize(data, percentile) 2 | % MYNORMALIZE Normalize data according to a specified percentile 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Input: 8 | % data --> data to be normalized 9 | % percentile --> percentile selected for normalization 10 | % 11 | % Output: data --> normalized data 12 | % 13 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 14 | % Denis Schapiro - Bodenmiller Group - UZH 15 | 16 | fprintf('Normalizing according to the %gth percentile...', percentile); 17 | data = data-repmat(prctile(data, 100-percentile, 1), size(data,1),1); 18 | data = data./repmat(prctile((data), percentile, 1),size(data,1),1); 19 | 20 | data(data > 1) = 1; 21 | data(data < 0) = 0; 22 | data(isinf(data)) = 0; 23 | end 24 | 25 | 26 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/tSNE/read_data.m: -------------------------------------------------------------------------------- 1 | function [X, landmarks, costs] = read_data 2 | % READ_DATA Reads the result file from the fast t-SNE implementation 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | h = fopen('result.dat','rb'); 11 | n = fread(h, 1, 'integer*4'); 12 | d = fread(h, 1, 'integer*4'); 13 | X = fread(h, n*d , 'double'); 14 | landmarks = fread(h, n, 'integer*4'); 15 | landmarks = landmarks + 1; 16 | costs = fread(h, n, 'double'); % this vector contains only zeros 17 | X = reshape(X, [d n])'; 18 | fclose(h); 19 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_modified/tSNE/write_data.m: -------------------------------------------------------------------------------- 1 | function write_data(X, theta, perplexity) 2 | % WRITE_DATA Writes the datafile for the fast t-SNE implementation 3 | % 4 | % This function is modified from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | [n, d] = size(X); 11 | h = fopen('data.dat', 'wb'); 12 | fwrite(h, n, 'integer*4'); 13 | fwrite(h, d, 'integer*4'); 14 | fwrite(h, theta, 'double'); 15 | fwrite(h, perplexity, 'double'); 16 | fwrite(h, X', 'double'); 17 | fclose(h); 18 | end 19 | 20 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/dplot.m: -------------------------------------------------------------------------------- 1 | function hLine = dplot(data, varargin) 2 | % dplot(data, varargin) 3 | % Produces up to 12 distinct line color/style combinations using ksdensity 4 | % PARAMS 5 | % @data: nx1 vector 6 | % @kernelwidth: value in the range of 0.01 to 1, 'default' uses automatic 7 | % selection by ksdensity function 8 | % @linewidth: if no value or 'default' is entered, default is 2. 9 | % @'colors', 'bluegrey': changes ColorOrder to Blue, Grey 10 | % @'colors', 'fourcolors': Blue, cyan, magenta, green 11 | % @'colors', colormatrix: enter n x 3 RGB colormatrix. 12 | 13 | %defaults 14 | linewidth = 2; 15 | 16 | 17 | for i = 1:2:length(varargin) 18 | switch varargin{i} 19 | 20 | case 'kernelwidth' 21 | kernelwidth = varargin{i+1}; 22 | 23 | case 'linewidth' 24 | linewidth = varargin{i+1}; 25 | 26 | case 'colors' 27 | if strmatch(varargin{i+1}, 'bluegrey') 28 | colormat = [0 0 1; .5 .5 .5]; 29 | elseif strmatch(varargin{i+1}, 'fourcolors') 30 | colormat = [0 0 1; 0 1 1; 1 0 1; 0 .8 .2]; 31 | else 32 | colormat = varargin{i+1}; 33 | end 34 | 35 | set(gcf, 'DefaultAxesColorOrder', colormat ) 36 | freezeColors; 37 | end 38 | end 39 | 40 | 41 | if ~exist('linewidth','var') || strcmpi(linewidth,'default') 42 | linewidth = 2; 43 | end 44 | 45 | %set(gcf, 'DefaultAxesLineStyleOrder',{'-','--',':'}) 46 | %blue and grey: 47 | %set(0, 'DefaultAxesColorOrder', [0 0 1; .5 .5 .5]) 48 | %blue, cyan, magenta, green: 49 | hold all 50 | 51 | if ~exist('kernelwidth','var') || strcmpi(kernelwidth,'default') 52 | [f,xi] = ksdensity(data,'npoints',200); 53 | else 54 | [f,xi] = ksdensity(data,'npoints',200,'width',kernelwidth); 55 | end 56 | hLine = plot(xi,f,'LineWidth',linewidth); 57 | 58 | 59 | 60 | % %code below uses kde from file exchange 61 | % [~,f,xi,~] = kde(data); 62 | % plot(xi,f,'LineWidth',linewidth) 63 | % %following required for kde function which can result in Y lowerlimit < 0 64 | % %YL = get(gca,'ylim'); 65 | % %set(gca, 'ylim',[0 YL(2)]); -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/getIntIndices.m: -------------------------------------------------------------------------------- 1 | function intIndices=getIntIndices 2 | % GETINTINDICES Get integer indices for gates 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | handles = gethand; 11 | gates = retr('gates'); 12 | selIntGates = get(handles.list_samples,'Value'); 13 | 14 | intIndices = []; 15 | 16 | for i=selIntGates 17 | intIndices = union(intIndices, gates{i, 2}); 18 | end 19 | 20 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/getSelectedIndices.m: -------------------------------------------------------------------------------- 1 | function [indices,channels] = getSelectedIndices(selected_gates, gates) 2 | % GETSELECTEDINDICES Gets the indices of the selected gates, and combines all channels of selected gates and displays the common among them in the listbox. 3 | %When an individual sample is selected, it only displays those that have 4 | %data(or non-zeros) and don't display neighbour columns 5 | % 6 | % This function is modified from CYT (Dana Pe'er Lab) 7 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 8 | % 9 | % Input: 10 | % selected_gates --> selected gates in the GUI 11 | % gates --> all gates 12 | % 13 | % Output: 14 | % indices --> indices of selected gates 15 | % channels --> channels selected 16 | % 17 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 18 | % Denis Schapiro - Bodenmiller Group - UZH 19 | 20 | %Retrieve 21 | sessionData = retr('sessionData'); 22 | 23 | %extract specific gate or merge multiple gates according to selection 24 | if (numel(selected_gates) == 1) 25 | indices = gates{selected_gates, 2}; 26 | %incase its a tiff 27 | if isempty(indices) == 1 28 | channels = gates{selected_gates, 3}; 29 | else 30 | getthoseNtzeros = find(~all(sessionData(indices,1:length(gates{selected_gates,3})) == 0,1)); 31 | channels = gates{selected_gates, 3}(getthoseNtzeros); 32 | getNtneighbrs = find(~strncmp('neighbour',channels,9)); 33 | if ~isempty(getNtneighbrs) 34 | channels = channels(getNtneighbrs); 35 | end 36 | end 37 | else 38 | indices = []; 39 | if (~isempty(selected_gates)) 40 | channels = gates{selected_gates(1),3}; %gates{selected_gates(1),3}; 41 | else 42 | channels = []; 43 | end 44 | 45 | for i=selected_gates 46 | curidices = gates{i, 2}; 47 | %incase its a tiff 48 | if isempty(curidices) == 1 49 | channels = intersect(gates{i,3},channels,'stable'); 50 | getNtneighbrs = find(~strncmp('neighbour',channels,9)); 51 | if ~isempty(getNtneighbrs) 52 | channels = channels(getNtneighbrs); 53 | end 54 | else 55 | getthoseNtzeros = find(~all(sessionData(curidices,1:length(gates{i,3})) == 0,1)); 56 | indices = union(gates{i, 2}, indices); 57 | channels = intersect(gates{i,3}(getthoseNtzeros),channels,'stable'); 58 | getNtneighbrs = find(~strncmp('neighbour',channels,9)); 59 | if ~isempty(getNtneighbrs) 60 | channels = channels(getNtneighbrs); 61 | end 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/get_channelnames_from_header.m: -------------------------------------------------------------------------------- 1 | function channel_names=get_channelnames_from_header(fcshdr) 2 | % GET_CHANNELNAMES_FROM_HEADER Get the channel names from header 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Input: fcshdr --> header output from fca_fcsread 8 | % 9 | % Output: channel_names --> channel names 10 | % 11 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 12 | % Denis Schapiro - Bodenmiller Group - UZH 13 | 14 | 15 | channel_names1 = {fcshdr.par.name}; 16 | channel_names2 = {fcshdr.par.name2}; 17 | if (strcmp(channel_names1,channel_names2)==0) 18 | channel_names = combineNames(channel_names1,channel_names2); 19 | else 20 | channel_names=channel_names2; %channel_names2 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/gethand.m: -------------------------------------------------------------------------------- 1 | function handles=gethand 2 | % GETHAND Get handles from GUI 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | selectgui=getappdata(0,'histoCATgui'); 11 | handles=guihandles(selectgui); 12 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/myplotclr.m: -------------------------------------------------------------------------------- 1 | function myplotclr(x,y,z,v,marker, map, clim, draw_grid,ax) 2 | %FUNCTION PLOTC(X,Y,V,'MARKER') plots the values of v colour coded 3 | % at the positions specified by x and y, and v (z-axis) in a 3-D axis 4 | % system. A colourbar is added on the right side of the figure. 5 | % 6 | % The colorbar strectches from the minimum value of v to its 7 | % maximum in 9 steps (10 values). 8 | % 9 | % The last argument is optional to define the marker being used. The 10 | % default is a point. To use a different marker (such as circles, ...) send 11 | % its symbol to the function (which must be enclosed in '; see example). 12 | % 13 | % The plot is actually a 3D plot but the orientation of the axis is set 14 | % such that it appears to be a plane 2D plot. However, you can toggle 15 | % between 2D and 3D view either by using the command 'view(3)' (for 3D 16 | % view) or 'view(2)' (for 2D), or by interactively rotating the axis 17 | % system. 18 | % 19 | % Example: 20 | % Define three vectors 21 | % x=1:10;y=1:10;p=randn(10,1); 22 | % plotc(x,y,p) 23 | % 24 | % x=randn(100,1); 25 | % y=2*x+randn(100,1); 26 | % p=randn(100,1); 27 | % plotc(x,y,p,'d') 28 | % view(3) 29 | % 30 | % Uli Theune, University of Alberta, 2004 31 | % modified by Stephanie Contardo, British OCeanographic Data Centre, 2006 32 | % modified by Michelle Tadmor, Columbia University, 2013 33 | % 34 | 35 | 36 | if nargin <4 37 | marker='.'; 38 | keep_bg = 0; 39 | else 40 | keep_bg = 0; 41 | end 42 | 43 | if (nargin <5) 44 | map=colormap; 45 | end 46 | 47 | if (nargin <6) 48 | miv=min(v); 49 | mav=max(v); 50 | draw_grid = false; 51 | else 52 | miv = clim(1); 53 | mav = clim(2); 54 | end 55 | 56 | clrstep = (mav-miv)/size(map,1) ; 57 | % Plot the points 58 | 59 | % plot3([],[],[],marker,'color',map(1,:),'markerfacecolor',map(1,:)); 60 | % hold on; 61 | 62 | % plot points not in caxis 63 | if (miv>=min(v) || mavmav; 69 | plot3(x(iv),y(iv),z(iv),marker,'color',map(end,:),'markerfacecolor',map(end,:),'Tag','Areaplot') 70 | 71 | end 72 | 73 | 74 | for nc=1:size(map,1) 75 | iv = find(v>miv+(nc-1)*clrstep & v<=miv+nc*clrstep) ; 76 | plot3(x(iv),y(iv),z(iv),marker,'color',map(nc,:),'markerfacecolor',map(nc,:)) 77 | 78 | if (nc==1) 79 | hold on; 80 | end 81 | end 82 | hold off 83 | 84 | % Re-format the colorbar 85 | 86 | h = colorbar(ax); 87 | 88 | set(h,'ylim',[1 length(map)]); 89 | 90 | yal=linspace(1,length(map),10); 91 | set(h,'ytick',yal); 92 | 93 | % Create the yticklabels 94 | ytl=linspace(miv,mav,10); 95 | s=char(10,4); 96 | for i=1:10 97 | if min(abs(ytl)) >= 0.001 98 | B=sprintf('%-4.3f',ytl(i)); 99 | else 100 | B=sprintf('%-3.1E',ytl(i)); 101 | end 102 | s(i,1:length(B))=B; 103 | end 104 | set(h,'yticklabel',s); 105 | if draw_grid 106 | grid on; 107 | else 108 | grid off; 109 | end 110 | view(2); 111 | freezeColors; 112 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/put.m: -------------------------------------------------------------------------------- 1 | function put(name, what) 2 | % PUT Updates GUI data 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Input: 8 | % name --> name for gui app data variable 9 | % what --> data 10 | % 11 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 12 | % Denis Schapiro - Bodenmiller Group - UZH 13 | 14 | selectgui=getappdata(0,'histoCATgui'); 15 | setappdata(selectgui, name, what); 16 | 17 | listener = retr([name '_listener']); 18 | if ~isempty(listener) 19 | listener(); 20 | end 21 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/remove_repeating_strings.m: -------------------------------------------------------------------------------- 1 | function result = remove_repeating_strings(strings) 2 | % REMOVE_REPEATING_STRINGS 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | if isempty(strings) 10 | return; 11 | end 12 | 13 | if numel(strings) == 1 14 | result = strings; 15 | return; 16 | end 17 | 18 | str = strings{1}; 19 | for i=1:numel(str) 20 | TF = strncmpi(str(1:i),strings,i); 21 | if ~isempty(find(TF==0)) 22 | break; 23 | end 24 | end 25 | 26 | 27 | result = strings; 28 | 29 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/cyt_functions_unchanged/retr.m: -------------------------------------------------------------------------------- 1 | function var = retr(name) 2 | % RETR returns saved variable or empty matrix if the variable is not found 3 | % 4 | % This function is from CYT (Dana Pe'er Lab) 5 | % https://www.c2b2.columbia.edu/danapeerlab/html/cyt-download.html 6 | % 7 | % Input: name --> name for gui app data variable 8 | % 9 | % Output: var --> variable selected 10 | % 11 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 12 | % Denis Schapiro - Bodenmiller Group - UZH 13 | 14 | selectgui=getappdata(0,'histoCATgui'); 15 | var=getappdata(selectgui, name); 16 | end 17 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/fca_fcs/fca_writefcs.m: -------------------------------------------------------------------------------- 1 | function fca_writefcs(filename, data, marker_names,channel_names) 2 | % fca_writefcs(filename, data, marker_names,channel_names) 3 | 4 | if size(data,2)~= length(marker_names) % put the data matrix back to what flow people are familiar with, thin tall matrix 5 | if size(data,1)== length(marker_names) 6 | data = data.'; 7 | else 8 | error('data size and marker_names length do not match!!') 9 | end 10 | end 11 | 12 | fcsheader_main=['\$BEGINANALYSIS\0\$ENDANALYSIS\0\$BEGINSTEXT\0\$ENDSTEXT\0\$NEXTDATA\0\']; 13 | fcsheader_main = [fcsheader_main,'$TOT\',num2str(size(data,1)),'\']; % number of cells/events 14 | fcsheader_main = [fcsheader_main,'$PAR\',num2str(size(data,2)),'\']; % number of channels 15 | fcsheader_main = [fcsheader_main,'FCSversion\3\']; % i'm pretending this is a fcs v3 format 16 | fcsheader_main = [fcsheader_main,'CREATOR\PengQiu FCS writer\']; 17 | fcsheader_main = [fcsheader_main,'$COM\PengQiu FCS writer\']; 18 | fcsheader_main = [fcsheader_main,'FILENAME\',filename,'\']; 19 | fcsheader_main = [fcsheader_main,'GUID\1.fcs\ORIGINALGUID\1.fcs\']; % don't know what this means 20 | fcsheader_main = [fcsheader_main,'$BYTEORD\4,3,2,1\']; % big-endian ordering -- rfinck added 'b' to fwrite to correspond 21 | fcsheader_main = [fcsheader_main,'$DATATYPE\F\']; % don't know what this means 22 | fcsheader_main = [fcsheader_main,'$MODE\L\']; % don't know what this means 23 | for i=1:length(marker_names) 24 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'B\',num2str(32),'\']; 25 | if exist('channel_names') 26 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'N\',channel_names{i},'\']; 27 | else 28 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'N\',marker_names{i},'\']; 29 | end 30 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'S\',marker_names{i},'\']; 31 | % fcsheader_main = [fcsheader_main,'$P',num2str(i),'R\',num2str(ceil(max(data(i,:)))),'\']; 32 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'R\',num2str(ceil(max(data(:,i)))),'\']; 33 | fcsheader_main = [fcsheader_main,'$P',num2str(i),'E\','0,0','\']; 34 | end 35 | 36 | fid = fopen(filename,'w','b'); 37 | HeaderStart = 100; 38 | HeaderStop = HeaderStart + length(fcsheader_main)+100-1; 39 | DataStart = HeaderStop; 40 | DataEnd = DataStart+prod(size(data))*4; 41 | 42 | %testing if header is too long to be supported by fcs format 43 | if (numel(num2str(HeaderStop)) > 4) 44 | %uiwait(msgbox('Unfortunately fcs file format supports up to 9,999 total fcs header characters, you either have to many channels or your channel names are too long\n','error')); 45 | failedfcs = 1; 46 | put('failedfcs',failedfcs); 47 | end 48 | 49 | fcsheader_1stline = sprintf('FCS3.0 %3d %4d %4d%8d%8d%8d',HeaderStart,HeaderStop,DataStart,DataEnd,0,0); 50 | fcsheader_main = [fcsheader_main,'$BEGINDATA\',num2str(DataStart),'\']; 51 | fcsheader_main = [fcsheader_main,'$ENDDATA\',num2str(DataEnd),'\']; 52 | entire_header = [fcsheader_1stline, repmat(char(32),1,HeaderStart-length(fcsheader_1stline)),fcsheader_main]; 53 | entire_header = [entire_header, repmat(char(32),1,HeaderStop-length(entire_header))]; 54 | fwrite(fid,entire_header,'char'); 55 | fwrite(fid,data.','float32','b'); 56 | fclose(fid); 57 | 58 | return 59 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/fca_fcs/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Laszlo Balkay 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/freezeColors/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, John Iversen 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/getAllFiles.m: -------------------------------------------------------------------------------- 1 | function fileList = getAllFiles(dirName) 2 | % GETALLFILES Get all files in a folder 3 | % 4 | % we thank gnovice from 5 | % http://stackoverflow.com/questions/2652630/how-to-get-all-files-under-a-specific-directory-in-matlab 6 | % to share this getAllFiles.m function 7 | % 8 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 9 | % Denis Schapiro - Bodenmiller Group - UZH 10 | 11 | dirData = dir(dirName); %# Get the data for the current directory 12 | dirIndex = [dirData.isdir]; %# Find the index for directories 13 | fileList = {dirData(~dirIndex).name}'; %'# Get a list of the files 14 | if ~isempty(fileList) 15 | fileList = cellfun(@(x) fullfile(dirName,x),... %# Prepend path to files 16 | fileList,'UniformOutput',false); 17 | end 18 | subDirs = {dirData(dirIndex).name}; %# Get a list of the subdirectories 19 | validIndex = ~ismember(subDirs,{'.','..'}); %# Find index of subdirectories 20 | %# that are not '.' or '..' 21 | for iDir = find(validIndex) %# Loop over valid subdirectories 22 | nextDir = fullfile(dirName,subDirs{iDir}); %# Get the subdirectory path 23 | fileList = [fileList; getAllFiles(nextDir)]; %# Recursively call getAllFiles 24 | end 25 | 26 | end -------------------------------------------------------------------------------- /histoCAT/3rdParty/getGitInfo/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Andrew 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/parfor_progressbar/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Daniel Terry 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | * Neither the name of the Cornell University nor the names 14 | of its contributors may be used to endorse or promote products derived 15 | from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/selectdata/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, John D'Errico 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/uipickfiles/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2007, Douglas M. Schwarz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/3rdParty/uisplitpane/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Yair Altman 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/Heatmap_slider_tSNE.m: -------------------------------------------------------------------------------- 1 | function Heatmap_slider_tSNE() 2 | % HEATMAP_SLIDER_TSNE: Enables slider for percentile cut-off of heatmap 3 | % overlays on analysis side of GUI and updates it. 4 | % 5 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 6 | % Denis Schapiro - Bodenmiller Group - UZH 7 | 8 | %Get previous slider value and set the bar of the slider to it 9 | global currentsliderValue_tSNE; 10 | 11 | %Get GUI handles 12 | handles = gethand; 13 | 14 | %Delete any existing java wrapper 15 | delete(handles.figure1.Children.findobj('Units','pixels')); 16 | 17 | %Create slider component and place it 18 | sliderJava = javax.swing.JSlider; 19 | [~, sliderContainer] = javacomponent(sliderJava,[300,30,50,270],handles.figure1); 20 | set(sliderContainer,'Units','normalized','position',[0.7616236162361624,0.025899280575539568,0.12398523985239851,0.05323741007194244]); 21 | 22 | %Set major and minor ticks and initialize to previous slider value 23 | if ~(isempty(currentsliderValue_tSNE) == 1) 24 | set(sliderJava, 'Value',currentsliderValue_tSNE, 'Orientation',sliderJava.HORIZONTAL,'MinorTickSpacing',2.5,'MajorTickSpacing',10, 'PaintLabels',true,'PaintTicks',true); 25 | else 26 | set(sliderJava, 'Value',100, 'Orientation',sliderJava.HORIZONTAL,'MinorTickSpacing',2.5,'MajorTickSpacing',10, 'PaintLabels',true,'PaintTicks',true); 27 | end 28 | 29 | %Set min and max values, labels and make visible 30 | sliderJava.setMinimum(0) 31 | sliderJava.setMaximum(100); 32 | sliderJava.setPaintLabels(true); 33 | set(sliderContainer,'Visible','on'); 34 | 35 | %Set slider callback 36 | cmpsliderJava = handle(sliderJava, 'CallbackProperties'); 37 | set(cmpsliderJava, 'StateChangedCallback', {@sliderChangedCallbackHeatmap_tSNE}); 38 | 39 | 40 | end 41 | 42 | 43 | %For slider changes 44 | %After changing value of slider in GUI, click on Visualize-Button again in 45 | %order for change to be visible on the image 46 | function sliderChangedCallbackHeatmap_tSNE(src,~, Arg1) 47 | 48 | %Store the value of the slider in a global variable so the 49 | %any function can access it 50 | global currentsliderValue_tSNE; 51 | handles = gethand; 52 | currentsliderValue_tSNE = src.getValue; 53 | 54 | %Textbox displaying at what value the slider currently is 55 | sliderValue = num2str(currentsliderValue_tSNE); 56 | store_valtext = strcat('cut-off is at',{' '},sliderValue,'%'); 57 | txtbox = uicontrol('Style','text',... 58 | 'Units','normalized','Position',[0.897,0.043,0.049,0.033],... 59 | 'String',store_valtext,'Parent',handles.figure1); 60 | end 61 | 62 | 63 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/RegressionLine_ScatterPlot.m: -------------------------------------------------------------------------------- 1 | 2 | function RegressionLine_ScatterPlot(hObject, eventdata, handles) 3 | % REGRESSIONLINE_SCATTERPLOT: Produces scatterplot with linear regressionline 4 | % and correlation coefficient in GUI. Only for one gate at the time and 2 dimensional plots. 5 | % 6 | % hObject: handle to scatter_plot (see GCBO) 7 | % eventdata: reserved - to be defined in a future version of MATLAB 8 | % handles: structure with handles and user data (see GUIDATA) 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Call scatter plot function 14 | scatter_plot_Callback; 15 | 16 | %Retrieve x and y values saved by scatterplot function 17 | vX = retr('vX'); 18 | vY = retr('vY'); 19 | 20 | %Get GUI handles 21 | handles = gethand; 22 | 23 | %Get index of currently selected channels 24 | selectedChannels = get(handles.list_channels,'Value'); 25 | 26 | %If more than 2 channels are selected (3 dimensional plot), no regressionline is displayed 27 | if length(selectedChannels)>2 28 | msgbox('Regression line is only displayed for 2D plots.'); 29 | return; 30 | end 31 | 32 | %Get index of selected gates 33 | selectedGates = retr('selected_gates_plotted'); 34 | 35 | %If more than one gate is selected, no regressionline is displayed 36 | if length(selectedGates)>1 37 | msgbox('Regression line is only displayed for one gate at the time.'); 38 | return; 39 | end 40 | 41 | %calculate person's correlation coefficient and p-values 42 | [R,P] = corrcoef(vX,vY); 43 | 44 | %adding R-value and LS line to plot 45 | intercept = (sum(vY)*sum(vX.^2)-sum(vX)*sum(vX.*vY))/(length(vX)*sum(vX.^2)-(sum(vX)^2)); 46 | slope = (length(vX)*sum(vX.*vY)-sum(vX)*sum(vY))/(length(vX)*sum(vX.^2)-(sum(vX)^2)); 47 | refline(slope,intercept); %is exactly the same as lsline 48 | 49 | %Define position of R-value on plot 50 | ylim=get(gca,'ylim'); 51 | xlim=get(gca,'xlim'); 52 | xval = 0.8*(xlim(2)); 53 | yval = 0.8*(ylim(2)); 54 | text(xval,yval,['R=' num2str(R(1,2))]); 55 | 56 | end -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/analyze_options_Callback.m: -------------------------------------------------------------------------------- 1 | function analyze_options_Callback(hObject, eventdata, handles) 2 | % ANALYZE_OPTIONS_CALLBACK: Executes on any change in the analyze options 3 | % drop down menu. 4 | % 5 | % hObject: handle to scatter_plot (see GCBO) 6 | % eventdata: reserved - to be defined in a future version of MATLAB 7 | % handles: structure with handles and user data (see GUIDATA) 8 | % 9 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 10 | % Denis Schapiro - Bodenmiller Group - UZH 11 | 12 | 13 | %Disable all other toolbar options 14 | zoom off; 15 | pan off; 16 | rotate3d off; 17 | datacursormode off; 18 | 19 | %Get GUI handles 20 | handles = gethand; 21 | 22 | %Set gating variable to zero 23 | gatedontiff = 0; 24 | put('gatedontiff',gatedontiff); 25 | 26 | %If RGB is selected on visualization side, reset the option since channels would otherwise be RGB in list_channels 27 | if strcmp(handles.visualize_options.String{handles.visualize_options.Value},'Apply RGBCMY on selected samples') == 1 28 | set(handles.visualize_options,'Value',1); 29 | end 30 | 31 | %If scatter plot option is selected 32 | if strcmp(handles.analyze_options.String{handles.analyze_options.Value},'Scatter') == 1 33 | %Make the checkbox for the regression line visible 34 | set(handles.Regressionline,'Visible','on'); 35 | else 36 | %Hide checkbox otherwise 37 | set(handles.Regressionline,'Visible','off'); 38 | end 39 | 40 | %If heatmap option is selected 41 | if strcmp(handles.analyze_options.String{handles.analyze_options.Value},'Heatmap') == 1 42 | %make the checkbox for the b2r appear 43 | set(handles.b2r,'Visible','on'); 44 | %make the checkbox for the median appear 45 | set(handles.median,'Visible','on'); 46 | else 47 | %Hide checkboxes otherwise 48 | set(handles.b2r,'Visible','off'); 49 | set(handles.median,'Visible','off'); 50 | end 51 | 52 | %Updates the heatmap channels; 53 | list_samples_Callback; 54 | 55 | end 56 | 57 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/b2r_checkbox_callback.m: -------------------------------------------------------------------------------- 1 | function b2r_checkbox_callback(hObject, eventdata, handles) 2 | % B2R_CHECKBOX_CALLBACK: Callback for checking and unchecking 3 | % the b2r checkbox. The heatmap function is called to display the 4 | % heatmap with or without the b2r settings when the box is checked or unchecked respectively. 5 | % 6 | % hObject: handle to scatter_plot (see GCBO) 7 | % eventdata: reserved - to be defined in a future version of MATLAB 8 | % handles: structure with handles and user data (see GUIDATA) 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Switch off external gui tools 14 | zoom off; 15 | pan off; 16 | rotate3d off; 17 | datacursormode off; 18 | 19 | %Retrieve GUI handles 20 | handles = gethand; 21 | 22 | %Call heatmap function everythime the checkbox is changed 23 | if handles.b2r.Value == 1 24 | heatmap_of_selected; 25 | else handles.b2r.Value == 0 26 | heatmap_of_selected; 27 | 28 | end -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/histmean.m: -------------------------------------------------------------------------------- 1 | function [meanchannel_gates] = histmean( selectedGates,channel ) 2 | % HISTMEAN: Returns the mean of the selected channel across all the selected gates. 3 | % 4 | % Input: 5 | % selectedGates --> currently selected gates 6 | % channel --> currently selected channel 7 | % 8 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 9 | % Denis Schapiro - Bodenmiller Group - UZH 10 | 11 | %Retrieve GUI variables 12 | sessionData = retr('sessionData'); 13 | gates = retr('gates'); 14 | 15 | %Store the indices of the gates in sessionData 16 | intIndices = getIntIndices; 17 | 18 | %Clear/initializing variables 19 | ntotal_count = 0; 20 | store_channelvalues = cell(numel(selectedGates),1); 21 | 22 | %Loop through the selected gates 23 | for ngates = selectedGates 24 | 25 | %Get the current gate's indices 26 | currGate = gates{ngates, 2}; 27 | 28 | %Check what is common in both the current gate and all the selected 29 | %gates (intIndices) 30 | if ~isempty(intIndices) 31 | currGate = intersect(intIndices, currGate); 32 | end 33 | 34 | %Store the corresponding channel data and their size 35 | store_channelvalues{ngates,1} = sessionData(currGate, channel); 36 | total(ngates) = size(store_channelvalues{ngates,1},1); 37 | ntotal_count = ntotal_count + total(ngates); 38 | 39 | end 40 | 41 | %If channelvalues are empty, store empty 42 | store_channelvalues(cellfun(@isempty,store_channelvalues)) = []; 43 | 44 | %Calculate the mean of selected channel's aggregated gate columns 45 | meanchannel_gates = mean(cell2mat(store_channelvalues)); 46 | 47 | %Store variable 48 | put('store_channelvalues',store_channelvalues); 49 | 50 | end 51 | 52 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/kmeans_callback.m: -------------------------------------------------------------------------------- 1 | function [] = kmeans_callback() 2 | %KMEANS_CALLBACK: Runs kmeans on selected data and returns to sessionData 3 | 4 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 5 | % Denis Schapiro - Bodenmiller Group - UZH 6 | 7 | %Retrieve GUI data 8 | handles = gethand; 9 | selected_gates = get(handles.list_samples,'Value'); 10 | gates = retr('gates'); 11 | sessionData = retr('sessionData'); 12 | gate_context = retr('gateContext'); 13 | 14 | %Get the data from the correct channel columns 15 | [selectedset] = Find_selectedchannels; 16 | data_to_kmeans = selectedset; 17 | 18 | %Ask the user for amount clusters and interactions 19 | answers = inputdlg({'Number of clusters:','iterations'},'k-means',1,{'20','100'}); 20 | amount_clusters = str2double(answers(1)) 21 | interations = str2double(answers(2)) 22 | 23 | %Run k-means 24 | new_data_to_add = kmeans(data_to_kmeans,amount_clusters,'Replicates', interations) 25 | 26 | %Assign random number for k-means and afterwards the name 27 | newbhSNE_name = int2str(randi(10000000000)); 28 | disp('assigning random number for current k-means'); 29 | new_channel_names_to_add = cell(1, 1); 30 | new_channel_names_to_add{1} = sprintf('k_mean_k_%g_it_%g_%s',amount_clusters,interations,newbhSNE_name); 31 | 32 | %Prepare the inputs for adding channels to the listbox and sessionData 33 | opt_gates = selected_gates; 34 | opt_gate_context = gate_context; 35 | 36 | %Function call to add the new channels 37 | [sessionData,gates] = addChannels(new_channel_names_to_add, new_data_to_add, opt_gate_context,opt_gates, gates, sessionData); 38 | 39 | end 40 | 41 | 42 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/median_checkbox_callback.m: -------------------------------------------------------------------------------- 1 | function median_checkbox_callback(hObject, eventdata, handles) 2 | % MEDIAN_CHECKBOX_CALLBACK: Callback for checking and unchecking the median 3 | % checkbox. The heatmap_of_selected function is called to display the 4 | % heatmap with the new settings everytime the box is checked/unchecked. 5 | % 6 | % hObject: handle to scatter_plot (see GCBO) 7 | % eventdata: reserved - to be defined in a future version of MATLAB 8 | % handles: structure with handles and user data (see GUIDATA) 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | 14 | %Switch off external gui tools 15 | zoom off; 16 | pan off; 17 | rotate3d off; 18 | datacursormode off; 19 | 20 | %Get GUI handles 21 | handles = gethand; 22 | 23 | if handles.median.Value == 1 24 | %Call heatmap function 25 | heatmap_of_selected; 26 | else handles.median.Value == 0 27 | %Call heatmap function 28 | heatmap_of_selected; 29 | end 30 | 31 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/pca_callback.m: -------------------------------------------------------------------------------- 1 | function [] = pca_callback() 2 | % PCA_CALLBACK: Runs PCA on selected data and returns to sessionData 3 | 4 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 5 | % Denis Schapiro - Bodenmiller Group - UZH 6 | 7 | %PCA similar to tSNE for 2 dimensions 8 | ndims = 2; 9 | 10 | %Retrieve GUI data 11 | handles = gethand; 12 | selected_gates = get(handles.list_samples,'Value'); 13 | selected_channels = get(handles.list_channels,'Value'); 14 | gates = retr('gates'); 15 | sessionData = retr('sessionData'); 16 | gate_context = retr('gateContext'); 17 | custom_gatesfolder = retr('custom_gatesfolder'); 18 | 19 | %Check if enough channels were selected to run PCA 20 | if numel(selected_channels) <=1 21 | msgbox('Please select atleast two or more channels to run PCA'); 22 | return; 23 | end 24 | 25 | %Get the data from the correct channel columns 26 | [selectedset] = Find_selectedchannels; 27 | data_for_PCA = selectedset; 28 | 29 | %Run PCA 30 | [coef, scores, latent] = pca(data_for_PCA,'NumComponents',ndims); 31 | new_data_to_add = scores; 32 | 33 | %Assign random number for k-means and afterwards the name 34 | PCA_name = int2str(randi(10000000000)); 35 | disp('assigning random number for current PCA'); 36 | new_channel_names_to_add = cell(1, ndims); 37 | 38 | %Store the new names for the PCA channels 39 | for i=1:numel(new_channel_names_to_add) 40 | new_channel_names_to_add{i} = sprintf('PCA%s_%g',PCA_name,i); 41 | end 42 | 43 | %Prepare the inputs for adding channels to the listbox and sessionData 44 | opt_gates = selected_gates; 45 | opt_gate_context = gate_context; 46 | 47 | %Function call to add the new channels 48 | [sessionData,gates] = addChannels(new_channel_names_to_add, new_data_to_add, opt_gate_context,opt_gates, gates, sessionData); 49 | 50 | end 51 | 52 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/percentile_cutoff_tSNE.m: -------------------------------------------------------------------------------- 1 | function [vColor] = percentile_cutoff_tSNE(vColor,handles, percent ) 2 | % PERCENTILE_CUTOFF_TSNE: Function to cut off certain percentile of intensities for 3 | % plotScatter_Channels color overlay. Sets intensities above the cut-off down to the 4 | % value of the cut-off. 5 | % 6 | % Input: 7 | % vColor --> color intensities before cut-off 8 | % handles --> structure with handles and user data (see GUIDATA) 9 | % percent --> percentage to cut off set by slider (if slider is set to 1, the 10 | % values above the 99th percentile will be set down to the value of the 11 | % 99th percentile) 12 | % 13 | % Output: vColor --> color intensities after cut-off 14 | % 15 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 16 | % Denis Schapiro - Bodenmiller Group - UZH 17 | 18 | %If slider is at zero there is no cut-off 19 | if percent == 0 20 | disp('no cut-off'); 21 | else 22 | 23 | %Get value of percentile corresponding to given cut-off 24 | percentile = prctile(vColor, percent); 25 | 26 | %Find values above given percentile and set them down to value of 27 | %percentile 28 | for i=1:length(vColor) 29 | if vColor(i) > percentile 30 | vColor(i) = percentile; 31 | end 32 | end 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /histoCAT/GUI/Analyse_Data/regressionline_checkbox_callback.m: -------------------------------------------------------------------------------- 1 | function regressionline_checkbox_callback(hObject, eventdata, handles) 2 | % REGRESSIONLINE_CHECKBOX_CALLBACK: Callback for checking and unchecking 3 | % the regressionline checkbox. The scatterplot function is called to display the 4 | % scatterplot with or without the regressionline when the box is checked or unchecked respectively. 5 | % 6 | % hObject: handle to scatter_plot (see GCBO) 7 | % eventdata: reserved - to be defined in a future version of MATLAB 8 | % handles: structure with handles and user data (see GUIDATA) 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Switch off external GUI tools 14 | zoom off; 15 | pan off; 16 | rotate3d off; 17 | datacursormode off; 18 | 19 | %Get GUI handles 20 | handles = gethand; 21 | 22 | if handles.Regressionline.Value == 1 23 | %Call scatter plot with regressionline 24 | RegressionLine_ScatterPlot; 25 | else handles.Regressionline.Value == 0 26 | %Call scatter plot without regressionline 27 | scatter_plot_Callback; 28 | end 29 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/Find_selectedchannels.m: -------------------------------------------------------------------------------- 1 | function [ selectedset ] = Find_selectedchannels 2 | %FIND_SELECTEDCHANNELS: To find the selected channels for each sample irrespective of 3 | %how they are selected. This resolves the problem when channels are 4 | %selected for normalize or tSNE. 5 | % 6 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 7 | % Denis Schapiro - Bodenmiller Group - UZH 8 | 9 | %Retrieve GUI handles 10 | handles = gethand; 11 | 12 | %Retrieve Variables 13 | gates = retr('gates'); 14 | selected_samples = get(handles.list_samples,'Value'); 15 | selected_channels = get(handles.list_channels,'Value'); 16 | sessionData = retr('sessionData'); 17 | channels = get(handles.list_channels,'String'); 18 | 19 | %Initialize 20 | selectedset = []; 21 | 22 | %Loop through selected gates 23 | for i = selected_samples 24 | 25 | %Get the value of the selected channel from the selected gate 26 | [~,curidxval,channelval] = intersect(channels(selected_channels),gates{i,3},'stable'); 27 | 28 | %Store gate index 29 | gateindex = gates{i,2}; 30 | 31 | create_zeros = zeros(numel(gateindex),numel(channels(selected_channels))); 32 | create_zeros(:,curidxval) = sessionData(gateindex,channelval); 33 | 34 | %Vertcat the sessionData information for the gate index (rows in sessionData) and gate channels 35 | selectedset = vertcat(selectedset,create_zeros); 36 | 37 | end 38 | 39 | 40 | end 41 | 42 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/Merging_samples.m: -------------------------------------------------------------------------------- 1 | function [ merged_data ] = Merging_samples( Sample_Set_arranged,Fcs_Interest_all,HashID ) 2 | % MERGING_SAMPLES: Gets called when 'Merge samples' from the prepare samples 3 | % drop down menu is executed. This function will merge the selected samples 4 | % into one gate, save the new gate as fcs-file to the custom gates folder and import 5 | % it into the sessionData/ the samples listbox. 6 | % 7 | % Input: 8 | % Sample_Set_arranged --> paths to all sample folders in session (historical) 9 | % Fcs_Interest_all --> all individual images as tables with their single-cell information in fcs 10 | % format 11 | % HashID --> Unique folder IDs 12 | % 13 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 14 | % Denis Schapiro - Bodenmiller Group - UZH 15 | 16 | %Get GUI handles 17 | handles = gethand; 18 | 19 | %Retrieve GUI variables 20 | sessionData = retr('sessionData'); 21 | sessiondata_index = retr('sessiondata_index'); 22 | selected_gates = get(handles.list_samples,'Value'); 23 | gates = retr('gates'); 24 | custom_gatesfolder = retr('custom_gatesfolder'); 25 | 26 | %Initialize variable 27 | merged_data = []; 28 | 29 | %Get the union of the variable names (channels) of the selected gates, in the 30 | %same order as in the original gates 31 | variablesmax = unique([gates{selected_gates,3}],'stable'); 32 | 33 | %Loop through the selected gates 34 | for ms=selected_gates 35 | 36 | %If data of the currently selected gate is found 37 | if isempty(sessiondata_index{ms}{1}) ~= 1 38 | 39 | %Initialize matrix of zeros to the size needed 40 | currentdata = zeros(numel(sessiondata_index{ms}{1}(1):sessiondata_index{ms}{1}(2)),numel(variablesmax)); 41 | 42 | %Find the indices of the variable names in the sessionData 43 | [~,findgateidx] = ismember(variablesmax,gates{ms,3}); 44 | findgateidx(findgateidx == 0) = []; 45 | findvaridx = find(ismember(variablesmax,gates{ms,3})); 46 | 47 | %If the variable names were found in the sessionData 48 | if isempty(findgateidx) ~= 1 49 | 50 | %Store the data in those respective columns corresponding to the variablenames union 51 | currentdata(:,findvaridx) = sessionData(sessiondata_index{ms}{1}(1):sessiondata_index{ms}{1}(2),findgateidx); 52 | end 53 | 54 | %Concatenate the data of all selected gates vertically into merged_data 55 | merged_data = vertcat(merged_data,currentdata); 56 | end 57 | 58 | end 59 | 60 | %Update GUI data 61 | put('merged_data',merged_data); 62 | put('variablesmax',variablesmax); 63 | 64 | %If the merged data is not empty 65 | if isempty(merged_data) ~= 1 66 | 67 | %Store the merged data as fcs-file in the custom gates folder 68 | pathmerged = custom_gatesfolder; 69 | namefcs = inputdlg('Give a name for the merged samples'); 70 | filemerged = strcat(char(namefcs{:}),'.fcs'); 71 | 72 | %If the filename is valid 73 | if strcmp(filemerged,'.fcs') ~= 1 74 | 75 | %Write out the fcs-file 76 | [filename_merged] = writefcs_merged(filemerged,pathmerged,merged_data); 77 | 78 | %If no file has been stored, return 79 | if isempty(filename_merged) == 1 80 | return; 81 | 82 | %If fcs-file was stored, import it as new gate 83 | else 84 | import_gatedarea( filename_merged ); 85 | end 86 | 87 | else 88 | return; 89 | end 90 | 91 | %Inform user that gates cannot be merged if merged_data was empty and 92 | %return 93 | else 94 | disp('Cannot merge tiffs'); 95 | return; 96 | end 97 | 98 | end 99 | 100 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/Pixelexpansion_callback.m: -------------------------------------------------------------------------------- 1 | function Pixelexpansion_callback(hObject, eventdata, handles) 2 | % PIXELEXPANSION_CALLBACK: Executes on selection 3 | % change in pixelexpansion_dropdown. 4 | % 5 | % hObject: handle to pixelexpansion_dropdown 6 | % eventdata: reserved - to be defined in a future version of MATLAB 7 | % handles: structure with handles and user data (see GUIDATA) 8 | % 9 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 10 | % Denis Schapiro - Bodenmiller Group - UZH 11 | 12 | %Get GUI handles 13 | handles = gethand; 14 | 15 | %Check which number was selected and store it in pixelexpansion variable 16 | 17 | pixelexpansion = handles.pixelexpansion_dropdown.String(handles.pixelexpansion_dropdown.Value); 18 | put('pixelexpansion',pixelexpansion); 19 | 20 | 21 | end -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/Selection_save_questions.m: -------------------------------------------------------------------------------- 1 | function Selection_save_questions( Sample_Set_arranged,Fcs_Interest_all,HashID ) 2 | % SELECTION_SAVE_QUESTIONS: Question will be asked to the user whether to 3 | % save gated area and import data as new gate. If saved, the fcs of the 4 | % gate will automatically get imported to the UI listbox. 5 | % 6 | % Input: 7 | % Sample_Set_arrange --> file paths to all samples in session 8 | % Fcs_Interest_all --> singe-cell data in fcs format for each image in session 9 | % HashID --> hashes of all image names, as they appear in the first column 10 | % of the sessionData (ImageID), corresponding to the loading order of the images 11 | % 12 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 13 | % Denis Schapiro - Bodenmiller Group - UZH 14 | 15 | %Get GUI handles 16 | handles = gethand; 17 | 18 | %Retrieve variables 19 | gates = retr('gates'); 20 | selected_gates = get(handles.list_samples,'Value'); 21 | end_max = max(cellfun(@length,gates([selected_gates],3))); 22 | allids = retr('allids'); 23 | gatedontiff = retr('gatedontiff'); 24 | vxyid = retr('vxyid'); 25 | 26 | %Function call to get the index of the selected gates in Sample set order. 27 | [ ~, ~, ~,sample_orderIDX ] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates, allids); 28 | 29 | if isempty(vxyid) ~= 1 30 | sample_orderIDX = sample_orderIDX(vxyid); 31 | end 32 | 33 | %Find the maximum amount of channels of the selected samples 34 | fcs = cellfun(@(x) size(x,2),Fcs_Interest_all([sample_orderIDX],1),'UniformOutput',false); 35 | idx_fcs = find(~cellfun('isempty',fcs)); 36 | end_of_newfcs = max([fcs{idx_fcs}]); 37 | 38 | if end_max > end_of_newfcs && gatedontiff == 0 39 | end_fcs = end_max; 40 | else 41 | %Question to user whether to save the gated cells 42 | quest_custchannel = questdlg('Do you want to save the gate?',... 43 | 'Save Gate',... 44 | 'Yes','No','Cancel','Cancel'); 45 | if strcmp(quest_custchannel,'Yes') == 1 46 | end_fcs = end_max; 47 | else 48 | return; 49 | end 50 | end 51 | 52 | %Store size of current session 53 | put('end_fcs',end_fcs); 54 | 55 | %If user selected to import gated cells 56 | if isempty(end_fcs) ~= 1 57 | 58 | %Retrieve the folder to store the custom gates in 59 | pathgate = retr('custom_gatesfolder'); 60 | %Ask user to give the new gate a name 61 | namefcs = inputdlg('Give a name for the gate'); 62 | %Add fcs ending to name of new gate 63 | filegate = strcat(char(namefcs{:}),'.fcs'); 64 | 65 | %If the user gave a valid name (no empty string) 66 | if strcmp(filegate,'.fcs') ~= 1 67 | 68 | %Write out fcs file of new gate to custom gates folder 69 | [filename_gatedarea] = writefcs_gate(filegate,pathgate); 70 | 71 | %If a file has been written out to an fcs-file 72 | if isempty(filename_gatedarea) ~= 1 73 | %Import it as new gate 74 | import_gatedarea(filename_gatedarea); 75 | else 76 | return; 77 | end 78 | else 79 | return; 80 | end 81 | end 82 | 83 | end 84 | 85 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/Set_listVisualSamples.m: -------------------------------------------------------------------------------- 1 | function Set_listVisualSamples( handles,allids,selected_gates,Sample_Set_arranged,HashID ) 2 | % SET_LISTVISUALSAMPLES: Executed when visualize option is set. Displays 3 | % the source images from which a gate's cells stem, if the currently 4 | % selected gate's cells are from multiple images. Updates the list_visual 5 | % box(subsamples/source_images list). 6 | % 7 | % Input: 8 | % handles --> GUI handles 9 | % allids --> contains a list of the unique imageIDs (first column of sessionData) 10 | % for each gate in the session 11 | % selected_gates --> gates from list_samples box that have been selected by 12 | % user 13 | % Sample_Set_arrange --> file paths to all samples in session in the order 14 | % they appear in GUI 15 | % HashID --> hashes of all image names representing the imageIDs in the 16 | % first column of sessionData (same order as Sample_Set_arranged) 17 | % 18 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 19 | % Denis Schapiro - Bodenmiller Group - UZH 20 | 21 | %Check which selected gates contain cells from more than just one imageid 22 | foundlengthgrt = find(cellfun('length',allids([selected_gates])) > 1); 23 | 24 | %If any are found 25 | if isempty(foundlengthgrt) ~= 1 26 | 27 | %Get their original imageids and gate names 28 | [ ~, gate_names_pre, ~ ,~] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates(foundlengthgrt), allids); 29 | 30 | %Find idexes of unique ones 31 | [~, idxs, ~] = unique(gate_names_pre); 32 | 33 | %Store in the list_visual listbox (subsample list) 34 | set(handles.list_visual,'String',['None' gate_names_pre(sort(idxs))]); 35 | 36 | %Allow only upto 10 selections simultaneously 37 | set(handles.list_visual,'Min',1,'Max',10); 38 | set(handles.list_visual,'Value',1); 39 | 40 | %If the cells of the selected gates only came from the one imageID each 41 | %(the imageID of that gate) 42 | else 43 | 44 | %Set list_visual box to null string 45 | set(handles.list_visual,'String',''); 46 | set(handles.list_visual,'Value',1); 47 | 48 | end 49 | 50 | end 51 | 52 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/ZScore_Normalize.m: -------------------------------------------------------------------------------- 1 | function ZScore_Normalize() 2 | % ZSCORE_NORMALIZE: Normalizes data using the ZScore. 3 | % Each selected channel is treated individually but across all selected sample. 4 | % 5 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 6 | % Denis Schapiro - Bodenmiller Group - UZH 7 | 8 | %Get GUI hanldes 9 | handles = gethand; 10 | 11 | %Get selected channels and gates 12 | selected_gates = get(handles.list_samples,'Value'); 13 | selected_channels = get(handles.list_channels,'Value'); 14 | 15 | %Retrieve variables 16 | gates = retr('gates'); 17 | sessionData = retr('sessionData'); 18 | gate_context = retr('gateContext'); 19 | 20 | %Get all raw data for the selected gates and channels 21 | [data_raw] = Find_selectedchannels; 22 | if isempty(data_raw) == 1 23 | disp('No single cell data available for selected sample'); 24 | return; 25 | end 26 | 27 | %Normalize the data using ZScore individually for each channel 28 | data_ZScore = zscore(data_raw); 29 | 30 | %Generate new channel names for normalized data 31 | new_channel_names = strcat('ZScoreNorm_',handles.list_channels.String(selected_channels)); 32 | 33 | %Add normalized channels to list_channels box 34 | addChannels(new_channel_names,data_ZScore, gate_context,selected_gates, gates, sessionData); 35 | 36 | end 37 | 38 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/list_channels_Callback.m: -------------------------------------------------------------------------------- 1 | function list_channels_Callback(hObject, eventdata, handles) 2 | % LIST_CHANNELS_CALLBACK: Callback for channel box. Executes on selection 3 | % change in list_channels. 4 | % 5 | % hObject: handle to listbox1 (see GCBO) 6 | % eventdata: reserved - to be defined in a future version of MATLAB 7 | % handles: structure with handles and user data (see GUIDATA) 8 | % Hints: contents = cellstr(get(hObject,'String')) returns contents 9 | % contents{get(hObject,'Value')} returns selected item from listbox1 10 | % 11 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 12 | % Denis Schapiro - Bodenmiller Group - UZH 13 | 14 | 15 | %Get GUI handles 16 | handles = gethand; 17 | 18 | %Function call to callback of samples box 19 | list_samples_Callback; 20 | 21 | %Pass control back to GUI 22 | uicontrol(handles.list_channels); 23 | 24 | end 25 | 26 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/list_samples_Callback.m: -------------------------------------------------------------------------------- 1 | function list_samples_Callback(hObject, eventdata, handles) 2 | % LIST_SAMPLES_CALLBACK: Executes on selection change in list_samples. 3 | % 4 | % hObject: handle to lstGates (see GCBO) 5 | % eventdata: reserved - to be defined in a future version of MATLAB 6 | % handles: structure with handles and user data (see GUIDATA) 7 | % Hints: contents = cellstr(get(hObject,'String')) returns contents 8 | % contents{get(hObject,'Value')} returns selected item from listbox1 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Get GUI handles 14 | handles = gethand; 15 | 16 | %Retrieve variables 17 | gates = retr('gates'); 18 | allids = retr('allids'); 19 | global HashID; 20 | global Sample_Set_arranged; 21 | selected_gates = get(handles.list_samples,'Value'); 22 | 23 | %If there are no gates in session, return 24 | if (size(gates, 1) == 0) 25 | return; 26 | end 27 | 28 | %If no gate is selected, then the context is all the data available in the session. 29 | if isempty(selected_gates) 30 | selected_gates = 1:size(gates, 1); 31 | end 32 | 33 | %Store gate indices (in sessionData matrix) and channel names of the selected gates 34 | [gate_indices, channel_names] = getSelectedIndices(selected_gates, gates); 35 | 36 | %Preserve selection 37 | selected_channels = get(handles.list_channels, 'Value'); 38 | selected_channels(selected_channels > numel(channel_names)) = []; 39 | set(handles.list_channels, 'Value', selected_channels); 40 | 41 | %Set list_channels to channels names in selected gates 42 | set(handles.list_channels, 'String', channel_names); 43 | 44 | %Set the heatmap listbox to channel names in selected gates 45 | set(handles.list_heatmap,'String',['None' channel_names]); 46 | set(handles.list_heatmap,'Min',1,'Max',100); 47 | set(handles.list_heatmap,'Value',1); 48 | 49 | %If user wants to visualize single channel or RGBCMY 50 | if strcmp(handles.visualize_options.String{handles.visualize_options.Value},... 51 | 'Highlight sample on Tiff images') == 1 || strcmp(handles.visualize_options.String{handles.visualize_options.Value},... 52 | 'Apply RGBCMY on selected samples') == 1 || strcmp(handles.visualize_options.String{handles.visualize_options.Value},... 53 | 'Heatmap channel on selected samples') == 1 || strcmp(handles.visualize_options.String{handles.visualize_options.Value},... 54 | 'Highlight excluding selected sample') == 1 55 | 56 | %Check which selected gates came from more than just one imageID 57 | foundlengthgrt = find(cellfun('length',allids([selected_gates])) > 1); 58 | 59 | %If they are from more than one image, display the original image names 60 | %in list subsamples box 61 | if isempty(foundlengthgrt) ~= 1 62 | 63 | %Get their gate names 64 | allids = retr('allids'); 65 | [ ~, gate_names_pre, ~,~ ] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates,allids); 66 | 67 | %Allow only upto 10 selections 68 | set(handles.list_visual,'String',['None' gate_names_pre]); 69 | set(handles.list_visual,'Min',1,'Max',10); 70 | set(handles.list_visual,'Value',1); 71 | 72 | %If the selected gates only came from current imageID 73 | else 74 | 75 | %Get gate name of current image 76 | [ ~, gate_names_pre, ~,~ ] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates,allids); 77 | 78 | %Set it to null string 79 | set(handles.list_visual,'String',['None' gate_names_pre]); 80 | set(handles.list_visual,'Value',1); 81 | 82 | end 83 | 84 | else 85 | %List subsample box stays empty 86 | set(handles.list_visual,'String',''); 87 | set(handles.list_visual,'Value',1); 88 | end 89 | 90 | 91 | %Save new gate context 92 | put('gateContext', gate_indices); 93 | 94 | %Save new channel names 95 | put('list_channels', channel_names); 96 | 97 | %Pass control back to GUI 98 | uicontrol(handles.list_samples); 99 | 100 | end 101 | 102 | 103 | -------------------------------------------------------------------------------- /histoCAT/GUI/Listboxes/preparesample_button_Callback.m: -------------------------------------------------------------------------------- 1 | function preparesample_button_Callback(hObject, eventdata, handles) 2 | % PREPARESAMPLE_BUTTON_CALLBACK: Executed when Prepare button is clicked. 3 | % 4 | % hObject: handle to preparesample_button (see GCBO) 5 | % eventdata: reserved - to be defined in a future version of MATLAB 6 | % handles: structure with handles and user data (see GUIDATA) 7 | % 8 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 9 | % Denis Schapiro - Bodenmiller Group - UZH 10 | 11 | %Disable external GUI functions 12 | zoom off; 13 | pan off; 14 | rotate3d off; 15 | datacursormode off; 16 | 17 | %Set the listbox 18 | list_samples_Callback; 19 | 20 | %Get GUI handles and variables 21 | handles = gethand; 22 | global Sample_Set_arranged; 23 | global Fcs_Interest_all; 24 | global HashID; 25 | 26 | %If import neighbors option is selected 27 | Logic_Neighbrs = strcmp(handles.preparesample_options.String{handles.preparesample_options.Value},... 28 | 'Import Neighbors'); 29 | if Logic_Neighbrs == 1 30 | %Function call to import neighbors of selected samples 31 | import_neighbrs( Sample_Set_arranged,Fcs_Interest_all,HashID ); 32 | end 33 | 34 | %If merge samples is selected 35 | Logic_Merge = strcmp(handles.preparesample_options.String{handles.preparesample_options.Value},... 36 | 'Merge Samples'); 37 | if Logic_Merge == 1 38 | %Function call to merge selected samples into one gate 39 | Merging_samples( Sample_Set_arranged,Fcs_Interest_all,HashID ); 40 | end 41 | 42 | %If normalize channels option is selected 43 | Logic_Normalize = strcmp(handles.preparesample_options.String{handles.preparesample_options.Value},... 44 | 'Normalization'); 45 | if Logic_Normalize 46 | %Function call to Z-score normalize the selected channels for the 47 | %selected samples 48 | ZScore_Normalize; 49 | end 50 | 51 | %If neighborhood analysis option is selected 52 | Logic_Neighbrhood = strcmp(handles.preparesample_options.String{handles.preparesample_options.Value},... 53 | 'Neighborhood Analysis'); 54 | if Logic_Neighbrhood 55 | %Function call to run neighborhood analysis on the selected samples 56 | Neighborhood_callback; 57 | end 58 | 59 | %If custom clustering option is selected 60 | Logic_customClusters = strcmp(handles.preparesample_options.String{handles.preparesample_options.Value},... 61 | 'Custom Clustering'); 62 | if Logic_customClusters 63 | %Function call to generate custom clustering based on selected samples 64 | custom_clusters; 65 | end 66 | 67 | 68 | end 69 | 70 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/Remove_channels_Callback.m: -------------------------------------------------------------------------------- 1 | function Remove_channels_Callback 2 | % REMOVE_CHANNELS_CALLBACK: For the selected gates the selected channels will be 3 | % removed ONLY if they are costum made. If the user selects any of the 4 | % original sample channels and wants to delete them, he will be told that 5 | % this is not possible, since it would destroy the session. 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %Retrieve global variables 11 | global Fcs_Interest_all; 12 | global Sample_Set_arranged; 13 | global HashID; 14 | 15 | %Get GUI handles 16 | handles = gethand; 17 | 18 | %Retrieve GUI variables 19 | selected_channels = get(handles.list_channels, 'Value'); 20 | selected_gates = get(handles.list_samples,'Value'); 21 | gates = retr('gates'); 22 | sessiondata_index = retr('sessiondata_index'); 23 | sessionData = retr('sessionData'); 24 | allids = retr('allids'); 25 | chan_string = get(handles.list_channels,'String'); 26 | 27 | %If no channels were selected 28 | if isempty(selected_channels) == 1 29 | 30 | %If samples exist and no channels were selected, prompt user to select 31 | %them first 32 | if isempty(gates) ~= 1 33 | msgbox('Please select a channel first'); 34 | 35 | %If there are no samples in the session, ask user to load them first 36 | else 37 | msgbox('Please load samples first'); 38 | end 39 | 40 | %If channels were selected, get the channel name of the selected channel 41 | else 42 | chan_todelete = chan_string(selected_channels); 43 | end 44 | 45 | %Function call to get sample order and the indices of the selected gates 46 | [ ~, ~, ~ ,sample_orderIDX] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates, allids); 47 | 48 | %Start count and initialize 49 | count = 1; 50 | com_del = []; 51 | 52 | %Loop through selected gates 53 | for j = selected_gates 54 | 55 | %Get the original channels of the samples -> deleting these is 56 | %not allowed 57 | original_names = Fcs_Interest_all{sample_orderIDX(count)}.Properties.VariableNames; 58 | 59 | %Get the indices of the channels to delete 60 | ntorg_idx = find(~ismember(chan_todelete,original_names)); 61 | 62 | %If all selected channels are members of the original list, then dont 63 | %delete and prompt user 64 | if isempty(ntorg_idx) == 1 65 | com_del = [com_del ntorg_idx]; 66 | warning('Cannot delete constant channels over all samples'); 67 | 68 | else 69 | com_del = 0; 70 | %Check where the channels to delete exist in the gates list 71 | todel_fromgates = find(ismember(gates{j,3},chan_todelete(ntorg_idx))); 72 | 73 | %Delete these channels for the current gate 74 | gates{j,3}(todel_fromgates) = []; 75 | 76 | %Fill up the corresponding column with zeros in sessionData for only this gate 77 | sessionData(sessiondata_index{j}{1}(1):sessiondata_index{j}{1}(2),todel_fromgates) = 0; 78 | end 79 | end 80 | 81 | %If all selected channels were original channels, nothing was deleted 82 | if isempty(com_del) == 1 83 | msgbox('Cannot delete constant channels over all samples'); 84 | end 85 | 86 | %Update GUI variables 87 | put('gates',gates); 88 | put('sessionData',sessionData); 89 | 90 | %Update list box 91 | list_samples_Callback; 92 | 93 | end 94 | 95 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/Remove_gates_Callback.m: -------------------------------------------------------------------------------- 1 | function Remove_gates_Callback 2 | % REMOVE_GATES_CALLBACK: Removes the selected gates from the session. 3 | % 4 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 5 | % Denis Schapiro - Bodenmiller Group - UZH 6 | 7 | %Get GUI handles 8 | handles = gethand; 9 | 10 | %Retrieve GUI variables 11 | gates = retr('gates'); 12 | hplots_gates = retr('hplots_gates'); 13 | hplots = retr('hplots'); 14 | tabmaster_histonetiff = retr('tabmaster_histonetiff'); 15 | hist_plot = retr('hist_plot'); 16 | 17 | %If only originally loaded gates are selected 18 | if isempty(get(handles.list_samples, 'Value')) ~= 1 19 | 20 | %Get indices from samples listbox 21 | org_gates = get(handles.list_samples,'Value'); 22 | 23 | %If all gates are removed, display nothing in list_channels box 24 | if size(org_gates,2) == size(gates,1) 25 | set(handles.list_samples,'String',''); 26 | set(handles.list_visual,'String',''); 27 | set(handles.list_heatmap,'String',''); 28 | set(handles.list_channels,'String',''); 29 | set(handles.list_channels,'Value',1); 30 | 31 | %Switch off all the GUI features, which are not necessary before loading samples 32 | set(handles.analyze_button,'Enable','off'); 33 | set(handles.visualize_button,'Enable','off'); 34 | set(handles.preparesample_button,'Enable','off'); 35 | set(handles.remove_options,'Enable','off'); 36 | set(handles.areaxy_onoff,'Visible','off'); 37 | set(handles.mask_onoff,'Visible','off'); 38 | set(handles.areaxy_onoff,'Callback',@areaxy_checkbox_Callback); 39 | 40 | %Remove plots if there are any 41 | delete(handles.panel_plots.Children); 42 | 43 | %Remove tiff-image tabs ifthere are any 44 | if isempty(tabmaster_histonetiff) ~= 1 45 | tabmaster_histonetiff.delete; 46 | handles.panel_tiff_images.Children.delete 47 | end 48 | 49 | end 50 | 51 | %Function call to remove gates from all involved variables 52 | removegates_commonfunction(org_gates); 53 | 54 | %If no gates were selected, prompt user 55 | else 56 | uiwait(msgbox('No gates selected')); 57 | return; 58 | 59 | end 60 | 61 | %Retrieve the gates 62 | gates = retr('gates'); 63 | 64 | %If there are gates 65 | if (~isempty(gates)) 66 | 67 | %Update GUI handles. 68 | set(handles.list_samples,'String',gates(:, 1)); 69 | set(handles.list_samples,'Value',1); 70 | 71 | %Update list boxes 72 | list_samples_Callback; 73 | 74 | end 75 | 76 | end 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/clear_plots.m: -------------------------------------------------------------------------------- 1 | function clear_plots 2 | % CLEAR_PLOTS: Clears all current plots on the right side of the GUI 3 | % 4 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 5 | % Denis Schapiro - Bodenmiller Group - UZH 6 | 7 | %Get GUI handles 8 | handles = gethand; 9 | 10 | %If there is a plot, delete it 11 | if isempty(handles.panel_plots.Children) ~= 1 12 | delete(handles.panel_plots.Children) 13 | else 14 | uiwait(msgbox('Nothing to clear')); 15 | end 16 | 17 | end 18 | 19 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/clear_tiffs.m: -------------------------------------------------------------------------------- 1 | function clear_tiffs 2 | % CLEAR_PLOTS: Clears all current tiff-images from the left side of the GUI 3 | % 4 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 5 | % Denis Schapiro - Bodenmiller Group - UZH 6 | 7 | %Get GUI handles 8 | handles = gethand; 9 | 10 | %Retrieve tabs 11 | tabmaster_histonetiff = retr('tabmaster_histonetiff'); 12 | 13 | %If there are tabs open delete them 14 | if isempty(tabmaster_histonetiff) ~= 1 15 | handles.panel_tiff_images.Children.delete; 16 | else 17 | return; 18 | end 19 | 20 | end 21 | 22 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/clearall_gateselections.m: -------------------------------------------------------------------------------- 1 | function clearall_gateselections 2 | % CLEARALL_GATESELECTION: Clears all gated selections of cells on the image 3 | % or plot 4 | % 5 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 6 | % Denis Schapiro - Bodenmiller Group - UZH 7 | 8 | %Retrieve selections 9 | add_selections = retr('add_selections'); 10 | 11 | %If there was a selection, delete it 12 | if isempty(add_selections) ~= 1 13 | for j = 1:length(add_selections); 14 | delete(add_selections{j}); 15 | end 16 | clear add_selections; 17 | else 18 | uiwait(msgbox('Nothing to clear')); 19 | end -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/remove_options_Callback.m: -------------------------------------------------------------------------------- 1 | function remove_options_Callback(hObject, eventdata, handles) 2 | % REMOVE_OPTIONS_CALLBACK: Executed when remove button is clicked. A selection of 3 | % options will appear for remove possibilities (gates, channels, plots,...) 4 | % 5 | % hObject: handle to figure (see GCBO) 6 | % eventdata: reserved - to be defined in a future version of MATLAB 7 | % handles: structure with handles and user data (see GUIDATA) 8 | % 9 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 10 | % Denis Schapiro - Bodenmiller Group - UZH 11 | 12 | %Get GUI handles 13 | handles = gethand; 14 | 15 | %Disable external GUI functions 16 | zoom off; 17 | pan off; 18 | rotate3d off; 19 | datacursormode off; 20 | 21 | %List of remove options 22 | list = {'Clear gate selections','Gates','Channels','Gate coordinates','Clear plots','Clear All Tiff images'}; 23 | 24 | %Open list dialogue for user to choose option 25 | [remove_elements,ok] = listdlg('PromptString','Remove/Clear options',... 26 | 'SelectionMode','multiple',... 27 | 'ListString',list,... 28 | 'ListSize', [180 100]); 29 | 30 | %If 'Clear gate selection' is selected, clear selection from samples 31 | %listbox 32 | if remove_elements == 1 33 | Scatter = 0; 34 | put('Scatter',Scatter); 35 | set(handles.list_samples,'Value',[]); 36 | 37 | %If removes gates is selected, function call to remove the selected gates 38 | elseif remove_elements == 2 39 | Remove_gates_Callback; 40 | 41 | %If removes channels is selected, function call to remove selected channels 42 | elseif remove_elements == 3 43 | Remove_channels_Callback; 44 | 45 | %If removes gate coordinates is selected, function call to remove gated 46 | %selection of cells 47 | elseif remove_elements == 4 48 | clearall_gateselections; 49 | 50 | %If remove plots is selected, remove all plots (right side of GUI) 51 | elseif remove_elements == 5 52 | clear_plots; 53 | 54 | %If remove Tiff images is selected, remove all tiff visualizations (left 55 | %side of GUI) 56 | elseif remove_elements == 6 57 | clear_tiffs; 58 | 59 | else 60 | return; 61 | end 62 | 63 | end 64 | 65 | -------------------------------------------------------------------------------- /histoCAT/GUI/Remove_button_options/removegates_commonfunction.m: -------------------------------------------------------------------------------- 1 | function removegates_commonfunction(remGates) 2 | % REMOVEGATES_COMMONFUNCTION: Updates all involved variables during gate removal 3 | % 4 | % Input: 5 | % remGates --> indices of gates to be removed 6 | % 7 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 8 | % Denis Schapiro - Bodenmiller Group - UZH 9 | 10 | %Retrieve GUI Variables 11 | gates = retr('gates'); 12 | allids = retr('allids'); 13 | sessionData = retr('sessionData'); 14 | sessiondata_index = retr('sessiondata_index'); 15 | 16 | %Remove the selected gates from gates and allids variables 17 | gates(remGates, :) = []; 18 | allids(:,remGates) = []; 19 | allids(cellfun(@isempty,allids)) = []; 20 | sessiondata_index(remGates) = []; 21 | 22 | %Use the sessiondata_index to clear the data of the removed gates also from 23 | %sessionData: 24 | 25 | %Initialize new variables 26 | newdata = []; 27 | 28 | %Loop through sessiondata_index 29 | for numidx = 1:numel(sessiondata_index) 30 | 31 | %If current index is empty, continue to next 32 | if isempty(sessiondata_index{numidx}{:}) == 1 33 | continue; 34 | end 35 | 36 | %Get the current index and add the corresponding data to newdata 37 | currInd = size(newdata,1); 38 | data = sessionData(sessiondata_index{numidx}{1}(1):sessiondata_index{numidx}{1}(2),:); 39 | newdata = vertcat(newdata,sessionData(sessiondata_index{numidx}{1}(1):sessiondata_index{numidx}{1}(2),:)); 40 | 41 | %Updating session_index 42 | session_index{1,numidx} = {[currInd+1,currInd+size(data,1)]}; 43 | 44 | %Updating gate indices 45 | gates{numidx,2} = currInd+1:currInd+size(data,1); 46 | end 47 | 48 | try 49 | if isempty(session_index) == 1 50 | session_index = []; 51 | end 52 | catch 53 | session_index = []; 54 | end 55 | 56 | %Update GUI variables 57 | put('sessionData',newdata); 58 | put('sessiondata_index',session_index); 59 | put('gates', gates); 60 | put('allids',allids); 61 | 62 | end 63 | 64 | -------------------------------------------------------------------------------- /histoCAT/GUI/Save_button_options/SavePlot.m: -------------------------------------------------------------------------------- 1 | function SavePlot(hObject, eventdata, handles) 2 | % SAVEPLOT: Opens currently displayed plot (right side of the GUI) in a new 3 | % window and saves it to user defined folder 4 | % 5 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 6 | % Denis Schapiro - Bodenmiller Group - UZH 7 | 8 | %Retrieve GUI variables 9 | handles = gethand; 10 | plots = handles.panel_plots; 11 | 12 | %If there is no plot 13 | if isempty(plots.Children) == 1 14 | msgbox('No plot found'); 15 | return; 16 | end 17 | 18 | %Open figure 19 | currentplot=figure; 20 | 21 | %Copy the current plot to figure 22 | copyobj(plots.Children,currentplot); 23 | 24 | %Ask user for the folder to save it in 25 | [filename,path]=uiputfile('*.jpeg','Save Plot'); 26 | 27 | %If no path found 28 | if path==0 29 | return; 30 | end 31 | 32 | %Save the figure as jpeg 33 | saveas(currentplot,fullfile(path,filename)); 34 | 35 | %Close the current figure 36 | close(currentplot); 37 | 38 | end 39 | 40 | -------------------------------------------------------------------------------- /histoCAT/GUI/Save_button_options/Savetiff_fig.m: -------------------------------------------------------------------------------- 1 | function Savetiff_fig(hObject, eventdata, handles) 2 | % SAVETIFF_FIG: Opens currently displayed tiff image (left side of the GUI) in a new 3 | % window and saves it to user defined folder 4 | % 5 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 6 | % Denis Schapiro - Bodenmiller Group - UZH 7 | 8 | %Retrieve Variables of displayed images 9 | tabmaster_histonetiff = retr('tabmaster_histonetiff'); 10 | all_tabs = get(tabmaster_histonetiff.Children.findobj('type','axes')); 11 | 12 | %If there is no image displayed, return 13 | if isempty(tabmaster_histonetiff) == 1 14 | msgbox('No figure found'); 15 | return; 16 | end 17 | 18 | if length(all_tabs) > 1 19 | %Ask user about batch saving 20 | batch = questdlg('Save current image or save all tabs?','Batch save?','Current image','All tabs','Current image'); 21 | else 22 | batch = 'Current image'; 23 | end 24 | 25 | %If the user only wants to save the current image 26 | if strcmp(batch,'Current image') 27 | 28 | %Open new figure 29 | currentfig=figure; 30 | 31 | %Get only the image in the currently selected tab 32 | tab = tabmaster_histonetiff.SelectedTab; 33 | 34 | %Copy the tiff image to the figure 35 | copyobj(tab.Children,currentfig); 36 | 37 | %Ask user for the folder to save it in 38 | [filename,path]=uiputfile('*.jpeg','Save Tiff'); 39 | 40 | %If no path found 41 | if path==0 42 | return; 43 | end 44 | 45 | %Save the figure as jpeg 46 | saveas(currentfig,fullfile(path,filename)); 47 | 48 | %Close the current figure 49 | close(currentfig); 50 | 51 | %If the user selects to save all curently opened image tabs 52 | else 53 | 54 | %Loop through open tabs 55 | for i=1:size(all_tabs,1) 56 | 57 | %Open new figure 58 | currentfig=figure; 59 | 60 | %Get only the image in the current tab of iteration 61 | tab = get(all_tabs(i,:).Parent); 62 | 63 | %Copy the tiff image to the figure 64 | copyobj(tab.Children,currentfig); 65 | 66 | if ~exist('filename','var') 67 | %Ask user for the folder to save it in 68 | [filename,path]=uiputfile('*.jpeg','Save Tiff'); 69 | end 70 | 71 | %If no path found 72 | if path==0 73 | return; 74 | end 75 | 76 | %Save the figure as jpeg 77 | saveas(currentfig,fullfile(path,strcat(tab.Title,'_',filename))); 78 | 79 | %Close the current figure 80 | close(currentfig); 81 | end 82 | end 83 | 84 | 85 | end 86 | 87 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/Heatmap_slider.m: -------------------------------------------------------------------------------- 1 | function Heatmap_slider(labelimg) 2 | % HEATMAP_SLIDER: Enables slider for the user to adjust the percentile 3 | % cut-off for the heatmap_images_overlay. 4 | % 5 | % Input: 6 | % labelimg --> selected channel for which the slider will adjust the 7 | % intensities 8 | % 9 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 10 | % Denis Schapiro - Bodenmiller Group - UZH 11 | 12 | %Get previous slider value to initialize the current slider value 13 | %(since the variable is global it will be applied even if you switch to a different 14 | %image) 15 | global currentsliderValue; 16 | 17 | %Get GUI handles 18 | handles = gethand; 19 | 20 | %Delete any existing java wrapper 21 | delete(handles.figure1.Children.findobj('Units','pixels')) 22 | 23 | %Create slider component 24 | sliderJava = javax.swing.JSlider; 25 | [~, sliderContainer] = javacomponent(sliderJava,[300,30,50,270],handles.figure1); 26 | set(sliderContainer,'Units','normalized','position',[0.2206642066420664,0.020143884892086333,0.1719557195571956,0.07625899280575539]); 27 | 28 | %Set major/ minor ticks and min/ max value and initialize to previous 29 | %settings 30 | if ~(isempty(currentsliderValue) == 1) 31 | set(sliderJava, 'Value',currentsliderValue, 'Orientation',sliderJava.HORIZONTAL,'MinorTickSpacing',2.5,'MajorTickSpacing',10, 'PaintLabels',true,'PaintTicks',true); 32 | else 33 | set(sliderJava, 'Value',100, 'Orientation',sliderJava.HORIZONTAL,'MinorTickSpacing',2.5,'MajorTickSpacing',10, 'PaintLabels',true,'PaintTicks',true); 34 | end 35 | 36 | sliderJava.setMinimum(0) 37 | sliderJava.setMaximum(100); 38 | sliderJava.setPaintLabels(true); 39 | set(sliderContainer,'Visible','on'); 40 | 41 | %Set up slider callback 42 | cmpsliderJava = handle(sliderJava, 'CallbackProperties'); 43 | set(cmpsliderJava, 'StateChangedCallback', {@sliderChangedCallbackHeatmap,labelimg}); 44 | 45 | end 46 | 47 | 48 | 49 | function sliderChangedCallbackHeatmap(src,~, Arg1) 50 | % SLIDERCHANGECALLBACKHEATMAP: Gets called whenever the slider value is 51 | % changed by the user. In order for the cut-off to be applied to the image, the 52 | % 'Visualize' button has to be pressed. 53 | 54 | %Store the value of the slider in a global variable so the 55 | %heatmap_images_overlay function can access it for any image that is 56 | %displayed 57 | global currentsliderValue; 58 | handles = gethand; 59 | currentsliderValue = src.getValue; 60 | 61 | %Set textbox to display clearly at what value the slider currently is 62 | sliderValue = num2str(currentsliderValue); 63 | store_valtext = strcat('cut-off is at',{' '},sliderValue,'%'); 64 | txtbox = uicontrol('Style','text',... 65 | 'Units','normalized','Position',[0.38671586715867157,0.06330935251798561,0.07011070110701106,0.021582733812949645],... 66 | 'String',store_valtext,'Parent',handles.figure1); 67 | 68 | end 69 | 70 | 71 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/ScaleTiff_Intensity.m: -------------------------------------------------------------------------------- 1 | function ScaleTiff_Intensity( Alltiffsmat,sliderintensityScale,RGBColourChkboxindex,noise_checkbox ) 2 | % SCALETIFF_INTENSITY: Adjusts color intensity of selected colors (tiff-images) based on 3 | % the slider value set by the user. 4 | % 5 | % Input: 6 | % Alltiffsmat --> tiff-matrices of each channel (color) of the currently displayed 7 | % image 8 | % sliderintensityScale --> slider value set by user 9 | % RGBColourChkboxindex --> index of checked box (altered color) 10 | % noise_checkbox --> handle to the noise checkbox 11 | % 12 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 13 | % Denis Schapiro - Bodenmiller Group - UZH 14 | 15 | %Retrieve GUI variables 16 | tabmaster_histonetiff = retr('tabmaster_histonetiff'); 17 | 18 | %Store the colormap based on the number of selected gates 19 | %in order: 'r','g','b','c','m','y' 20 | colorstouse = [[1 0 0];[0 1 0];[0 0 1];[0 1 1];[1 0 1];[1 1 0]]; 21 | 22 | %Apply to all open tabs 23 | for tb=1:numel(tabmaster_histonetiff.Children) 24 | 25 | %Apply for each checked color 26 | for clrcode = RGBColourChkboxindex' 27 | 28 | %Delete the rgbimage that was create as part of visualize function 29 | %for the current channel 30 | delete(tabmaster_histonetiff.Children(tb).Children.findobj('type','axes').Children.findobj('tag',strcat('rgbimage',int2str(clrcode)))) 31 | 32 | %Store the matrix of the current channel's tiff-image 33 | tiffimage_read = Alltiffsmat{1,tb}{clrcode}; 34 | 35 | %Convert it from uint16 to double 36 | scale_tiff = im2double(tiffimage_read) ./ 65535; 37 | 38 | %Multiply the mat2gray version of the double image with the slider value 39 | %(this image will be used for the alphadata of the image) 40 | scale_tiffslider = mat2gray(scale_tiff) * sliderintensityScale; 41 | 42 | %Check if noise cancellation is requested 43 | if noise_checkbox.Value == 0 44 | 45 | %If no noise cancellation is requested convert the image to RGB 46 | %directly 47 | [ rgb_Image ] = make_rgb( tiffimage_read,colorstouse,clrcode); 48 | 49 | else 50 | 51 | %If noise cancellation is checked, use the Matlab medfilt2 function 52 | %to obtain a median based filtered matrix of the image. 53 | [ rgb_Image ] = make_rgb( medfilt2(tiffimage_read),colorstouse,clrcode); 54 | end 55 | 56 | %Set the focus to the current axes and hold on to it 57 | axes(tabmaster_histonetiff.Children(tb).Children.findobj('type','axes')); 58 | hold on; 59 | 60 | %Display the rgb image 61 | imagesh = imshow(rgb_Image);freezeColors;hold on; 62 | 63 | %Tag image 64 | set(imagesh,'Tag',strcat('rgbimage',int2str(clrcode))); 65 | hold off; 66 | 67 | %Freeze colors 68 | freezeColors; 69 | 70 | %Set the alphadata (intensity) of the RGB image to the adjusted 71 | %grayimage from above 72 | set(imagesh,'AlphaData',scale_tiffslider);freezeColors; 73 | 74 | hold off; 75 | 76 | end 77 | 78 | end 79 | 80 | 81 | end 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/choosetiffs_overlay_Callback.m: -------------------------------------------------------------------------------- 1 | function [imageids,gate_names_pre, SGsof_imageids_open,sample_orderIDX ] = choosetiffs_overlay_Callback(hObject, eventdata, handles) 2 | % CHOOSETIFFS_OVERLAY_CALLBACK: This function is called when any of the visualize 3 | % options (excpet for gating) are selected. It takes the selected gates and 4 | % the selected channels and finds them in the entire SampleSet (which contains 5 | % all samples loaded in the current session). This SampleSet is only erased when 6 | % the user closes the session. 7 | % 8 | % hObject: handle to figure (see GCBO) 9 | % eventdata: reserved - to be defined in a future version of MATLAB 10 | % handles: structure with handles and user data (see GUIDATA) 11 | % 12 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 13 | % Denis Schapiro - Bodenmiller Group - UZH 14 | 15 | %Initialize variables 16 | put('SGsof_imageids_open',{}); 17 | put('save_index',[]); 18 | put('gate_names',{}); 19 | 20 | %Get GUI handles and global variables 21 | handles = gethand; 22 | global Sample_Set_arranged; 23 | global HashID; 24 | selected_gates = get(handles.list_samples,'Value'); 25 | allids = retr('allids'); 26 | 27 | %Function call to get the imageIDs, gate names and indices of the selected gates 28 | [imageids, gate_names_pre, SGsof_imageids_open,sample_orderIDX ] = getimageids_of_selectedgates(... 29 | Sample_Set_arranged,HashID,selected_gates, allids); 30 | 31 | %Store the gate names in a new variable 32 | gate_names = gate_names_pre; 33 | 34 | %Update gui variables 35 | put('gate_names',gate_names); 36 | put('SGsof_imageids_open',SGsof_imageids_open); 37 | put('imageids',imageids); 38 | put('sample_orderIDX',sample_orderIDX); 39 | 40 | end 41 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/fuse_images.m: -------------------------------------------------------------------------------- 1 | function [ tiff_matrix ] = fuse_images(tabchild,imh) 2 | % FUSE_IMAGES: If more than one tiff (channel) is selected, fuse the 3 | % images into one displaying the different channel's pixel intensities in different 4 | % colors. 5 | % 6 | % tabchild --> the current tab created for the sample by the 7 | % overlay_maskandchannels function 8 | % imh --> the loop/gatenames number to keep in sequence 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Get GUI variables 14 | handles = gethand; 15 | tab_axes = retr('tab_axes1'); 16 | 17 | %Delete javawrapper classes 18 | delete(tabchild.Children.findobj('Units','pixels')); 19 | 20 | %Retrieve global variables 21 | global Mask_all 22 | 23 | %Function call to get the index and the tiff name of the selected channels 24 | [sel_channels,tiff_matrix] = Comparetiffnames_tolistchannels(Mask_all); 25 | 26 | %Store the colormap based on the number of selected channels 27 | %in order: 'r','g','b','c','m','y' 28 | colorstouse = [[1 0 0];[0 1 0];[0 0 1];[0 1 1];[1 0 1];[1 1 0]]; 29 | 30 | %If no axes found, create one 31 | if isempty(tab_axes) == 1 32 | handles.panel_tiff_images; 33 | tab_axes = subplot(1,1,1,'Parent',tabchild); 34 | put('tab_axes1',tab_axes); 35 | end 36 | 37 | %We can only visualize 6 colors - Show error 38 | if length(tiff_matrix{1,imh})<=6 39 | 40 | %Loop through the selected tiffs (channels) 41 | for k=1:length(tiff_matrix{1,imh}) 42 | 43 | %Scale image 44 | tiffimage_read = mat2gray(tiff_matrix{1,imh}{k}); 45 | 46 | %Focus on axes 47 | handles.panel_tiff_images; 48 | axes(tab_axes); 49 | hold on; 50 | 51 | %If it is the first image, set background as the BWimage 52 | if k == 1 53 | blackim = imshow(tiffimage_read); 54 | set(blackim,'Tag','firstgrayimage'); 55 | hold on; 56 | end 57 | 58 | %Function call to convert image to RGB 59 | [rgb_Image] = make_rgb( tiffimage_read,colorstouse,k); 60 | hold on; 61 | 62 | %Display RGB image 63 | imagesh = imshow(rgb_Image);freezeColors; 64 | hold on; 65 | 66 | %Tag image 67 | set(imagesh,'Tag',strcat('rgbimage',int2str(k))); 68 | hold off; 69 | 70 | %Freeze colors 71 | freezeColors; 72 | 73 | %Adjust the intensity of the cell colors if multiple channels are 74 | %selected 75 | if length(tiff_matrix{1,imh}) ~= 1 76 | disp('Applying contrast to image to display all markers') 77 | intensemask = imadjust(tiffimage_read); 78 | else 79 | intensemask = tiffimage_read; 80 | end 81 | 82 | %Set the alphadata of the RGB image to the adjusted grayimage 83 | set(imagesh,'AlphaData',intensemask); 84 | freezeColors; 85 | 86 | hold off; 87 | 88 | end 89 | 90 | else 91 | %Show error if more than 6 markers 92 | errordlg('Please select maximum 6 channels simultaneously'); 93 | end 94 | 95 | %If multiple channels are selected 96 | if numel(sel_channels) > 1 97 | 98 | %Set up legend of which color correspond to which channel 99 | string_channels = retr('list_channels'); 100 | La = line(ones(numel(sel_channels)),ones(numel(sel_channels)),'LineWidth',2,'Parent',tabchild.Children.findobj('Type','axes')); 101 | set(La,{'color'},mat2cell(colorstouse(1:numel(sel_channels),:),ones(1,numel(sel_channels)),3)); freezeColors; 102 | hla=legend(La,cellfun(@(n)(num2str(n)), string_channels(sel_channels), 'UniformOutput', false)); 103 | 104 | %Define the location of the legend 105 | set(hla, 'Location','South'); 106 | set(hla,'FontSize',8,'Interpreter','none'); 107 | 108 | end 109 | 110 | end 111 | 112 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/getimageids_of_selectedgates.m: -------------------------------------------------------------------------------- 1 | function [ imageids, gate_names_pre, SGsof_imageids_open,sample_orderIDX ] = getimageids_of_selectedgates(Sample_Set_arranged,HashID,selected_gates, allids) 2 | % GETIMAGEIDS_OF_SELECTEDGATES: Extract the imageids, gate names and 3 | % indices of the selected gates. 4 | % 5 | % Input: 6 | % Sample_Set_arranged --> all samples loaded into the current session (Even if 7 | % a sample was removed from the listbox, this will still retain the information 8 | % and will only be deleted when session is closed.) 9 | % selected_gates --> current selection of gates by user 10 | % allids --> the HashIDs of all samples (All imageIDs irrespective of whether 11 | % they contain single-cell information or not are saved into allids.) 12 | % Output: 13 | % imageids --> the HashIDs corresponding to the currently selected gates 14 | % gate_names_pre --> all names of the samples corresponding to the imageids 15 | % SGsof_imageids_open --> the indices of the selected gates in the samples listbox 16 | % sample_orderIDX --> the indices of the selected gates in the whole SampleSet (This index corresponds to the order in which all singlecell info, 17 | % masks and tiffs are stored.) 18 | % 19 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 20 | % Denis Schapiro - Bodenmiller Group - UZH 21 | 22 | 23 | %Initialize variables 24 | count = 1; 25 | SGsof_imageids_open = []; 26 | imageid_entr = {}; 27 | 28 | %Get the ID for each selected gate from allids 29 | for j= selected_gates 30 | imageid_entr{count} = unique([allids{j}],'stable'); 31 | SGsof_imageids_open = [SGsof_imageids_open repmat(j,1,numel(imageid_entr{count}))]; 32 | count = count+1; 33 | end 34 | 35 | %Store the unique imageids sequentially 36 | imageids = unique([imageid_entr{:}],'stable'); 37 | 38 | %Convert the full hashes into decimals for comparison 39 | alldhextodecHashes = cellfun(@(x) hex2dec(x),HashID,'UniformOutput',false); 40 | 41 | %Compare the decimal hashes with the imageids list retrieved to see which sample name/hashID 42 | %appears in it 43 | [ax,idx_name] = ismember(imageids,[alldhextodecHashes{:}]); 44 | 45 | %Get the sample name corresponding to the imageids 46 | [~,gate_names_pre] = cellfun(@fileparts,Sample_Set_arranged(idx_name),'UniformOutput',false); 47 | 48 | %Store the selected gates' indices and the index of a match of imageids and 49 | %hashID 50 | SGsof_imageids_open = selected_gates; 51 | sample_orderIDX = idx_name; 52 | 53 | end 54 | 55 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/heatmap_images_overlay.m: -------------------------------------------------------------------------------- 1 | function heatmap_images_overlay( labelimg, labelvec, valuevec, axis ,handles ) 2 | % HEATMAP_IMAGES_OVERLAY: This function gets called to overlay the tiff-image 3 | % with a heatmap of the single-cell intensities of the selected channel. 4 | % It maps the intensity values to the cell labels and assigns colors. 5 | % 6 | % Input: 7 | % labelimg --> single-cell mask where the pixels of each individual cell 8 | % are labelled with the corresponding cell number 9 | % labelvec --> vector of single-cell labels 10 | % valuevec --> vector of intensity values corresponding to the single cells 11 | % axis --> handle to current axis 12 | % handles --> handle to GUI variables 13 | % 14 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 15 | % Denis Schapiro - Bodenmiller Group - UZH 16 | 17 | %Initialize amount of colors 18 | ncols =100; 19 | 20 | %Retrieve current percentile cut-off slider value 21 | global currentsliderValue; 22 | perc = currentsliderValue; 23 | 24 | %If a percentile cut-off has been set 25 | if ~(isempty(perc) == 1) 26 | 27 | %Function call to cut off the values above a given percentile 28 | %(outliers) 29 | valuevec = percentile_cutoff(labelvec, valuevec, handles, perc); 30 | 31 | end 32 | 33 | %Sort the label vector and the value vector according to the same order 34 | [labelvec, ord] = sort(labelvec); 35 | valuevec = valuevec(ord); 36 | 37 | %Normalize the value vector 38 | maxval = max(valuevec); 39 | minval = min(valuevec); 40 | res_valuevec = (valuevec-minval)/(maxval-minval); 41 | 42 | %If there are no values found, return 43 | if isnan(res_valuevec) == 1 44 | disp('No Data found to visualize'); 45 | return; 46 | end 47 | 48 | %Make a 'full vector' in case some cell labels were missing 49 | full_valuevec = zeros(max(labelimg(:)),1); 50 | full_valuevec(labelvec) = res_valuevec; 51 | full_valuevec = (full_valuevec-min(full_valuevec(:))) ./ (max(full_valuevec(:)-min(full_valuevec(:)))); 52 | 53 | %Define the color map 54 | colmap = jet(ncols+1); 55 | 56 | %Assign the colors to the values 57 | full_valuevec = round(full_valuevec*ncols)+1; 58 | colmap_lab = colmap(full_valuevec,:); 59 | 60 | %Remove labels that are not in the labelvector from the image mask 61 | labelimg(~ismember(labelimg, labelvec)) = 0; 62 | 63 | %Apply the colormap 64 | rgb_img = label2rgb(labelimg, colmap_lab, [0,0,0]); 65 | 66 | %Set focus on axis and hold on to it 67 | axes(axis); 68 | hold on; 69 | 70 | %Display image 71 | intenseim = imshow(rgb_img); 72 | hold on; 73 | 74 | %Set colorbar 75 | colormap(axis,colmap); 76 | cbr = colorbar(axis); 77 | cbr.Location = 'SouthOutside'; 78 | hold on; 79 | 80 | %Set labels, lims and ticks 81 | drawnow; 82 | lims = get(cbr,'Limits'); 83 | yval = linspace(lims(1), lims(2),11); 84 | set(cbr,'ytick',yval); 85 | ylab=linspace(minval,maxval,11); 86 | ylab =round(ylab, 2, 'significant'); 87 | set(cbr,'YTickLabel',ylab); 88 | freezeColors; 89 | 90 | %Set position of colorbar 91 | cbr.Position = [0.1542 0.022 0.7274 0.0200]; 92 | 93 | %Tag the image 94 | set(intenseim,'Tag','rgbimage1'); 95 | 96 | end 97 | 98 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/make_rgb.m: -------------------------------------------------------------------------------- 1 | function [rgb_Image] = make_rgb(mask,colorstouse,loopnum) 2 | % MAKE_RGB: Sets the RGBCMY color for each selected channel(tiff) of the 3 | % current sample. 4 | % 5 | % Input: 6 | % mask --> input mask to be colored 7 | % colorstouse --> colormap generated by jet for the number of 8 | % selected channels 9 | % loopnum --> count of loop through the selected gates 10 | % 11 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 12 | % Denis Schapiro - Bodenmiller Group - UZH 13 | 14 | 15 | %Create an RGB image from the mask 16 | forothercolors = cat(3,double(mask),double(mask),double(mask)); 17 | 18 | %Store it in another variable 19 | currentcells_color = forothercolors; 20 | 21 | %Assign the third dimension RGB based on each row of the jet colors 22 | currentcells_color(:,:,1) = colorstouse(loopnum,1); 23 | currentcells_color(:,:,2) = colorstouse(loopnum,2); 24 | currentcells_color(:,:,3) = colorstouse(loopnum,3); 25 | 26 | %Store this RGB image 27 | rgb_Image = currentcells_color; 28 | 29 | end 30 | 31 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/percentile_cutoff.m: -------------------------------------------------------------------------------- 1 | function [valuevec] = percentile_cutoff(labelvec, valuevec, handles, percent ) 2 | % PERCENTILE_CUTOFF_TSNE: Function to cut off certain percentile of intensities for 3 | % heatmap_images_overlay. Sets intensities above the cut-off down to the 4 | % value of the cut-off. 5 | % 6 | % Input: 7 | % labelvec --> vector of single-cell labels 8 | % valuevec --> vector of intensity values corresponding to the single cells 9 | % handles --> handle to GUI variables 10 | % percent --> percentage to cut off set by slider (if slider is set to 1, the 11 | % values above the 99th percentile will be set down to the value of the 12 | % 99th percentile) 13 | % 14 | % Output: 15 | % valuevec --> new vector of values with the values above the given 16 | % percentile set down to the value of the percentile 17 | % 18 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 19 | % Denis Schapiro - Bodenmiller Group - UZH 20 | 21 | %Sort the cell label vector and sort the value vector corresponding to the 22 | %same order 23 | [~, ord] = sort(labelvec); 24 | valuevec = valuevec(ord); 25 | 26 | %If the slider is set to zero, there will be no cut-off 27 | if percent == 0 28 | disp('no cut-off'); 29 | 30 | %If the slider is set to anything but zero, cut the corresponding 31 | %percentage off 32 | else 33 | 34 | %Get value of percentile corresponding to given cut-off 35 | percentile = prctile(valuevec, percent); 36 | 37 | %Find values above given percentile and set them down to value of 38 | %percentile 39 | for i=1:length(valuevec) 40 | if valuevec(i) > percentile 41 | valuevec(i) = percentile; 42 | end 43 | end 44 | 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/Overlay_Tiffs/plotAreaXY.m: -------------------------------------------------------------------------------- 1 | function plotAreaXY(tabchild,imh,imageids,sample_orderIDX) 2 | % PLOTAREAXY: This function plots the single-cell centroids once for each 3 | % selected gate and stores them as part of the image tab. 4 | % 5 | % Input: 6 | % tabchild --> handle to image tab 7 | % imh --> current number of selected sample (this function is part of a 8 | % loop through all selected samples) 9 | % imageids --> image IDs of all selected samples 10 | % sample_orderIDX --> indices of currently selected samples in the session/ 11 | % list box 12 | % 13 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 14 | % Denis Schapiro - Bodenmiller Group - UZH 15 | 16 | %Get GUI handles and global variables 17 | handles = gethand; 18 | global Mask_all 19 | 20 | %Initialize variable 21 | vColor = []; 22 | 23 | %Centroids get plotted only once for each selected gate (imh -> count) 24 | %by function call to regionprops 25 | areaXY = struct2cell(regionprops(Mask_all(sample_orderIDX(imh)).Image,'Centroid')); 26 | 27 | %If no centroids were found, there is no single-cell information 28 | if isempty(areaXY) == 1 29 | 30 | vX_olay = []; 31 | disp('Sample not segmented yet...'); 32 | put('tab_axes1',[]); 33 | put('vX_olay',vX_olay); 34 | return; 35 | 36 | %If centroids were found, extract x and y variables for plotting 37 | else 38 | vX_olay = cellfun(@(x) double(x(:,1)),areaXY)'; 39 | vY_olay = cellfun(@(x) x(:,2),areaXY)'; 40 | vColor = [vColor; ones(size(areaXY,2), 1)*1]; 41 | vZ_olay = vColor; 42 | 43 | %Update and store the variables 44 | put('vX_olay',vX_olay); 45 | put('vY_olay',vY_olay); 46 | end 47 | 48 | %Set the color for the dots to be plotted 49 | clr = distinguishable_colors(numel(imageids)); 50 | 51 | %Create dummy third dimension 52 | vColor_discrete = vColor; 53 | colors = unique(vColor)'; 54 | for ci=1:numel(colors); 55 | vColor_discrete(vColor==colors(ci)) = ci; 56 | end 57 | 58 | %Plot on the tiff images panel 59 | handles.panel_tiff_images; 60 | 61 | %Create axes to plot on 62 | tab_axes1 = subplot(1,1,1,'Parent',tabchild); 63 | 64 | %Function call 'myplotclr' to plot centroids 65 | myplotclr(vX_olay, vY_olay, vZ_olay, vColor_discrete, '.', clr, [min(vColor_discrete), max(vColor_discrete)], false,tab_axes1);%(imh,:) 66 | freezeColors; 67 | 68 | %Switch off colorbar 69 | colorbar(tab_axes1,'off'); 70 | hold on; 71 | 72 | %Update variable 73 | put('tab_axes1',tab_axes1); 74 | 75 | end 76 | 77 | -------------------------------------------------------------------------------- /histoCAT/GUI/Visualize_Images/areaxy_checkbox_Callback.m: -------------------------------------------------------------------------------- 1 | function areaxy_checkbox_Callback(hObject, eventdata, handles) 2 | % AREAXY_CHECKBOX_CALLBACK: This function is executed when the areaxy on/off 3 | % checkbox is checked or unchecked. Checking the box displayes the 4 | % centroids of the individual cells on the current image tab. 5 | % 6 | % hObject: handle to figure 7 | % eventdata: reserved - to be defined in a future version of MATLAB 8 | % handles: structure with handles and user data (see GUIDATA) 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | %Switch off external GUI tools 14 | zoom off; 15 | pan off; 16 | rotate3d off; 17 | datacursormode off; 18 | 19 | %Retrieve GUI handles/variables 20 | tabmaster_histonetiff = retr('tabmaster_histonetiff'); 21 | handles = gethand; 22 | 23 | %If the user unchecks the checkbox 24 | if handles.areaxy_onoff.Value == 0 25 | 26 | %Get the previously stored line type with the tag 'Areaplot' 27 | %(it was stored in the the plotAreaXY function) 28 | foundline = tabmaster_histonetiff.SelectedTab.Children.findobj('type','axes').findobj('Tag','Areaplot'); 29 | 30 | %If the line type was found, switch its visibility off 31 | if isempty(foundline) ~= 1 32 | set(foundline,'Visible','off'); 33 | 34 | %If the line type was not found, there is no segmentation/ single-cell information 35 | else 36 | disp('No single-cell information was found'); 37 | end 38 | 39 | %If the ckeckbox is checked 40 | else 41 | 42 | %Get the previously stored line type with the tag 'Areaplot' 43 | %(it was stored in the plotAreaXY function) 44 | foundline = tabmaster_histonetiff.SelectedTab.Children.findobj('type','axes').findobj('Tag','Areaplot'); 45 | 46 | %If the line type was found, switch its visibility on 47 | if isempty(foundline) ~= 1 48 | set(foundline,'Visible','on'); 49 | 50 | %If the line type was not found, there is no segmentation/ single-cell information 51 | else 52 | disp('No single-cell information was found'); 53 | end 54 | 55 | end 56 | 57 | end 58 | 59 | -------------------------------------------------------------------------------- /histoCAT/GUI/Write_fcs_options/writefcs_gate.m: -------------------------------------------------------------------------------- 1 | function [filename_gatedarea] = writefcs_gate(filegate,pathgate) 2 | % WRITEFCS_GATE: Write out fcs-file of the selected area during manual 3 | % gating. 4 | % 5 | % Input: 6 | % filegate --> user-defined file name with fcs ending 7 | % pathgate --> path to custom gates folder, which is where the fcs-file 8 | % will be saved 9 | % 10 | % Output: 11 | % filename_gatedarea --> full file path to fcs-file that has been written 12 | % 13 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 14 | % Denis Schapiro - Bodenmiller Group - UZH 15 | 16 | %Disable extrenal GUI functions 17 | zoom off; 18 | pan off; 19 | handles = gethand; 20 | 21 | %Retrieve variables 22 | gates = retr('gates'); 23 | area_selected = retr('area_selected'); 24 | selected_gates = get(handles.list_samples,'Value'); 25 | 26 | %Get all channel names of each selected gate 27 | allnames = cellfun(@(x) gates{x,3}, num2cell(selected_gates),'UniformOutput',false); 28 | %Find neighbor columns for each selected gate 29 | neigh_cols = cellfun(@(x) strncmp(x,'neighbour',9),allnames,'UniformOutput',false); 30 | %Get the amount of neighbor columns each selected gate contains 31 | amount_neighbours = cellfun(@(x) sum(x), neigh_cols); 32 | %Get the index of the selected gate containing the most neighbor columns 33 | max_idx = find(amount_neighbours == max(amount_neighbours)); 34 | 35 | %Get the channel names of the selected gate with the most neighbor columns 36 | %and get the corresponding columns form the selected area data 37 | varnames = gates{selected_gates(max_idx),3}; 38 | area_selected =area_selected(:,1:length(varnames)); 39 | 40 | %Write fcs-file with single cell data of selected area and corresponding 41 | %channel names 42 | fcs_gatetable = array2table(area_selected,'VariableNames',strrep(varnames,'-','_')); 43 | fca_writefcs(char(fullfile(pathgate,filegate)),area_selected,fcs_gatetable.Properties.VariableNames,fcs_gatetable.Properties.VariableNames); 44 | 45 | %Return the file path to the fcs-file 46 | filename_gatedarea = char(fullfile(pathgate,filegate)); 47 | 48 | end 49 | 50 | -------------------------------------------------------------------------------- /histoCAT/GUI/Write_fcs_options/writefcs_merged.m: -------------------------------------------------------------------------------- 1 | function [filename_merged] = writefcs_merged(filemerged,pathmerged,merged_data) 2 | % WRITEFCS_MERGED: Write out fcs-file after merging multiple gates into 3 | % one. 4 | % 5 | % Input: 6 | % filemerged --> user-defined file name with fcs ending 7 | % pathmerged --> path to custom gates folder, which is where the fcs-file 8 | % will be saved 9 | % merged_data --> matrix of merged single-cell data of multiple gates 10 | % 11 | % Output: 12 | % filename_merged --> full file path to fcs-file that has been written 13 | % 14 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 15 | % Denis Schapiro - Bodenmiller Group - UZH 16 | 17 | %Switch off external GUI functions 18 | zoom off; 19 | pan off; 20 | 21 | %Retrieve variables 22 | variablesmax = retr('variablesmax'); 23 | 24 | %Put merged data with variable names into table 25 | fcs_gatetable = array2table(merged_data,'VariableNames',variablesmax); 26 | %Write fcs-file 27 | fca_writefcs(char(fullfile(pathmerged,filemerged)),merged_data,fcs_gatetable.Properties.VariableNames,fcs_gatetable.Properties.VariableNames); 28 | 29 | %Return the path to the fcs-file 30 | filename_merged = char(fullfile(pathmerged,filemerged)); 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /histoCAT/GUI/Write_fcs_options/writefcs_neighbors.m: -------------------------------------------------------------------------------- 1 | function [filename_ngate] = writefcs_neighbors(fileneighb,pathneighb,data_neighbrfile,max_varnames) 2 | % WRITEFCS_NEIGHBORS: Write out fcs-file of the neighbors of a certain cell 3 | % population to be imported later. 4 | % 5 | % Input: 6 | % fileneighb --> user-defined file name with fcs ending 7 | % pathneighb --> path to custom gates folder, which is where the fcs-file 8 | % will be saved 9 | % data_neighbrfile --> matrix of merged single-cell data of multiple gates 10 | % max_varnames --> Channel names of selected gate with the largest amount 11 | % of channels 12 | % 13 | % Output: 14 | % filename_ngate --> full file path to fcs-file that has been written 15 | % 16 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 17 | % Denis Schapiro - Bodenmiller Group - UZH 18 | 19 | %Switch off external GUI functions 20 | zoom off; 21 | pan off; 22 | rotate3d off; 23 | datacursormode off; 24 | 25 | %Create fcs-file for neighbors gate 26 | fcs_gatetable = array2table(data_neighbrfile,'VariableNames',max_varnames); 27 | fca_writefcs(char(fullfile(pathneighb,fileneighb)),data_neighbrfile,fcs_gatetable.Properties.VariableNames,fcs_gatetable.Properties.VariableNames); 28 | 29 | %Return path to fcs-file 30 | filename_ngate = char(fullfile(pathneighb,fileneighb)); 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /histoCAT/Loading_New/DataProcessing/DataProcessing_Master.m: -------------------------------------------------------------------------------- 1 | function [Fcs_Interest_all] = DataProcessing_Master(Mask_all,Tiff_all,Tiff_name,HashID,Fcs_Interest_all,expansionpixels,varargin) 2 | % DATAPROCESSING_MASTER: Main function for processing the data 3 | % This function processes all tiff files using the mask 4 | % to extract single cell information for each channel. Additionally, we 5 | % can expand the cell to get the extracellular information 6 | % ('Nano'-Environment) and their neighbors. 7 | % 8 | % Input variables: 9 | % Mask_all --> segmentation masks of all samples 10 | % Tiff_all --> tiff matrices of all samples (images / channels) 11 | % Tiff_name --> tiff names of all samples (image / channel names) 12 | % HashID --> Unique folder IDs (!!!GLOBAL!!!) 13 | % fcs_Boolean --> 1 creates fcs files, 0 no fcs files are generated 14 | % 15 | % Output variables; 16 | % Fcs_Interest_all --> data in fcs format (first column: ImageID, second 17 | % column: CellID, third column: marker1, etc.) 18 | % 19 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 20 | % Denis Schapiro - Bodenmiller Group - UZH 21 | 22 | % Get all single cell information from a TIFF file using the mask 23 | 24 | % If a pixelexpansion has already been set by the user, pass it to the function and don't ask again 25 | % (This can be used for UnitTest) 26 | if exist('expansionpixels') == 1 27 | [Fcs_Interest_all] = Process_SingleCell_Tiff_Mask(Tiff_all,Tiff_name,Mask_all,Fcs_Interest_all,HashID,expansionpixels); 28 | else 29 | [Fcs_Interest_all] = Process_SingleCell_Tiff_Mask(Tiff_all,Tiff_name,Mask_all,Fcs_Interest_all,HashID); 30 | end 31 | 32 | end 33 | 34 | -------------------------------------------------------------------------------- /histoCAT/Loading_New/DataProcessing/NeighbourID.m: -------------------------------------------------------------------------------- 1 | function [ neighbour_CellId_table,removerows ] = NeighbourID(cellarray_neighbourids,expansionpixels) 2 | % NEIGHBOURID: Function to get the CellIds of the neighbors of each cell at a certain pixelexpansion, in a table. 3 | % 4 | % Input variables: 5 | % cellarray_neighbourids --> cellIDs of neighboring cells at current 6 | % pixelexpansion 7 | % expansionpixels --> current pixelexpansion of 1:6 from loop in NeighbrCells_histoCATsinglecells 8 | % 9 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 10 | % Denis Schapiro - Bodenmiller Group - UZH 11 | 12 | %Initialize 13 | count = 1; 14 | removerws = {}; 15 | 16 | %Construct matrix of neighboring cellIDs 17 | for i=1:length(cellarray_neighbourids) 18 | try 19 | length_neighbrid = length(cellarray_neighbourids{i,1}); 20 | neighbour_CellId(i,1:length_neighbrid) = cellarray_neighbourids{i,1}; 21 | catch 22 | %In unlikely case of missing cellIDs 23 | removerws{count} = i; 24 | count = count + 1; 25 | end 26 | end 27 | 28 | %In unlikely case of missing cellIDs 29 | if isempty([removerws{:}]) ~= 1 30 | removerows = [removerws{:}]; 31 | neighbour_CellId(removerows,:) = []; 32 | else 33 | removerows = []; 34 | end 35 | 36 | %Make column names for table 37 | neighbour_names = strcat({strcat('neighbour_',num2str(expansionpixels),'_CellId')},... 38 | int2str((1:size(neighbour_CellId,2)).')).'; 39 | neighbour_names_include = strrep(neighbour_names,' ',''); 40 | 41 | %Convert matrix to table 42 | if isempty(neighbour_CellId) == 1 43 | neighbour_CellId = zeros(size(neighbour_CellId,1),1); 44 | neighbour_CellId_table = array2table(neighbour_CellId,'VariableNames',neighbour_names_include); 45 | else 46 | neighbour_CellId_table = array2table(neighbour_CellId,'VariableNames',neighbour_names_include); 47 | end 48 | 49 | end 50 | 51 | 52 | -------------------------------------------------------------------------------- /histoCAT/Loading_New/Load_Functions/Load_MatrixDB.m: -------------------------------------------------------------------------------- 1 | function [Sample_Set_arranged,Mask_all,Tiff_all,Tiff_name] = Load_MatrixDB(samplefolders,Sample_Set_arranged,Mask_all) 2 | % LOAD_MATRIXDB: Main function for loading tiffs and mask data 3 | % 4 | % Input variable: 5 | % samplefolders --> paths to the selected sample folders 6 | % Sample_Set_arranged --> paths to all sample folders in session (historical) 7 | % Mask_all --> segmentation masks of all samples (matrices) 8 | % 9 | % Output variables: 10 | % Sample_Set_arranged --> paths to all sample folders in session (historical) 11 | % Mask_all --> segmentation masks of all samples (matrices) 12 | % Tiff_all --> tiff matrices of all samples (images / channels) 13 | % Tiff_name --> tiff names of all samples (image / channel names) 14 | % 15 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 16 | % Denis Schapiro - Bodenmiller Group - UZH 17 | 18 | %If not stored before, add the sample folders to Sample_Set_arranged 19 | [Sample_Set_arranged]= unique([Sample_Set_arranged samplefolders],'stable'); 20 | 21 | %Display update 22 | disp('Samples arranged..Loading Masks,Tiffs of all Samples..'); 23 | hWaitbar = waitbar(0,'Loading all files from Database. This may take a while...'); 24 | 25 | %Loop through all the samples in DB 26 | for i=1:size(Sample_Set_arranged,2) 27 | 28 | %Load all mask from the TMA 29 | [Mask_all] = Load_mask(Sample_Set_arranged,Mask_all,i); 30 | 31 | %Load all tiff files and names for each image 32 | [Tiff_all,Tiff_name] = Load_tiff(Sample_Set_arranged,i); 33 | 34 | %Update waitbar 35 | waitbar(i/size(Sample_Set_arranged,2), hWaitbar); 36 | end 37 | 38 | close(hWaitbar); 39 | 40 | end 41 | 42 | -------------------------------------------------------------------------------- /histoCAT/Loading_New/Load_Functions/Load_SampleFolders.m: -------------------------------------------------------------------------------- 1 | function [ samplefolders,fcsfiles_path,HashID ] = Load_SampleFolders(HashID,samplefolders,varargin) 2 | % LOAD_SAMPLEFOLDERS: Main function for loading folders 3 | % The selected folders should contain all *.tiff files for each image (and a mask if exists) 4 | % 5 | % Input variables: 6 | % HashID --> Unique folder IDs 7 | % samplefolders --> paths to the selected sample folders 8 | % 9 | % Output variables: 10 | % samplefolders --> paths to the selected sample folders 11 | % fcsfiles_path --> if there are fcs-files: path to fcs-files, empty string 12 | % otherwise 13 | % HashID --> Unique folder IDs 14 | % 15 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 16 | % Denis Schapiro - Bodenmiller Group - UZH 17 | 18 | %For UnitTest 19 | if nargin == 1 20 | %Select sample folders 21 | samplefolders = uipickfiles('Prompt','Select folders containing tiffs with/without segmentation mask'); 22 | end 23 | 24 | %Make sure user selected folders containing each samples and not individual 25 | %files 26 | check_dir = cellfun(@isdir, samplefolders); 27 | found_notDir = find(check_dir == 0); 28 | if ~isempty(found_notDir) 29 | errordlg('The tiff images (and segmentation mask) of each acquisition have to be in a single folder. Please select acquisition folders and not individual files! Please see manual for further information.'); 30 | return; 31 | end 32 | 33 | %Initiate cell if it's not already one 34 | if iscell(samplefolders) ~= 1 35 | samplefolders = []; 36 | fcsfiles_path = []; 37 | return; 38 | end 39 | 40 | %Get the fileparts 41 | [path,name,ext] = cellfun(@fileparts,samplefolders,'UniformOutput',false); 42 | 43 | %Get the position of the samples (each sample is stored in a separate folder) 44 | find_dir = find(cellfun(@isdir,samplefolders)); 45 | fcsfiles_path(find_dir) = {['']}; 46 | 47 | %Store HashIDs as unique identifiers like imageids 48 | fullHash = cellfun(@DataHash,samplefolders,'UniformOutput',false); 49 | 50 | %If HashID not already present add new, else concatenate to existing 51 | if isempty(HashID) == 1 52 | HashID = cellfun(@(x) x(1:5),fullHash,'UniformOutput',false); 53 | else 54 | concatHashes = cellfun(@(x) x(1:5),fullHash,'UniformOutput',false); 55 | HashID = unique([HashID concatHashes],'stable'); 56 | end 57 | 58 | end 59 | 60 | 61 | -------------------------------------------------------------------------------- /histoCAT/Loading_New/Load_Functions/Load_tiff.m: -------------------------------------------------------------------------------- 1 | function [Tiff_all,Tiff_name] = Load_tiff(Sample_Set_arranged,i) 2 | % LOAD_TIFF: Load all tiffs for each image. This function checks in the path if there are any tiffs. If found, it 3 | % reads them into matrices. If not, it is stored as empty. 4 | % 5 | % Input variables: 6 | % Sample_Set_arranged --> paths all sample folders in session (historical) 7 | % i --> loop variable for Sample_Set_arranged folder number 8 | % 9 | % Output variables: 10 | % Tiff_all --> cell storing all tiff files (as matrices) for each sample 11 | % Tiff_name --> contains all the tiff names to later load as channel names 12 | % 13 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 14 | % Denis Schapiro - Bodenmiller Group - UZH 15 | 16 | %Retrieve GUI variables 17 | Tiff_all = retr('Tiff_all'); 18 | Tiff_name = retr('Tiff_name'); 19 | 20 | %If sample present in list 21 | if cellfun(@isempty,Sample_Set_arranged(i)) == 0 22 | 23 | %Get all the files in the sample folder 24 | fileList = getAllFiles(char(Sample_Set_arranged(i))); 25 | 26 | %Extract tiffs (besides the one representing a mask) 27 | tiff_position = find(~cellfun('isempty',regexp(fileList,'(? all possible combinations of clusters 7 | % Phenograph_Neighor_Matrix --> matrix with all phenograph clusters and the 8 | % corresponding neighbors 9 | % Phenograph_Vector --> Phenograph cluster for each cell 10 | % Neighbor_Matrix --> matrix with all neighbor ID's 11 | % 12 | % Output: 13 | % combos_all_histcount --> histcount for the individual combinations 14 | % 15 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 16 | % Denis Schapiro - Bodenmiller Group - UZH 17 | 18 | for i=1:size(combos_all,1) 19 | 20 | % Test for the different interactions 21 | Find_cluster_in_neighbormatrix = find(combos_all(i,1)==Phenograph_Neighor_Matrix); 22 | [row_cluster_matrix,~] = ind2sub(size(Phenograph_Neighor_Matrix),Find_cluster_in_neighbormatrix); 23 | Find_Cluster_in_PhenoVector = find(combos_all(i,2)==Phenograph_Vector); 24 | 25 | % Find intersect between row_cluster_matrix and Find_Cluster_in_PhenoVector 26 | Intersect_combos_all = intersect(row_cluster_matrix,Find_Cluster_in_PhenoVector); 27 | % Get the histocount 28 | Get_unique_rows = unique(Intersect_combos_all); 29 | 30 | % Include interaction information 31 | combos_all_histcount(i,1:2) = combos_all(i,1:2); 32 | % Check if empty 33 | if isempty(Get_unique_rows)==1 34 | combos_all_histcount(i,3) = 0; 35 | else 36 | 37 | %For patch detection 38 | intersectNeighbours = Phenograph_Neighor_Matrix(Intersect_combos_all,:); 39 | eachLogic = ismember(intersectNeighbours, combos_all(i,1)); 40 | eachCount = sum(eachLogic,2); 41 | atLeastX = eachCount > patch_det; 42 | 43 | % Count all interactions divided by the amount of interacting cells 44 | combos_all_histcount(i,3) = sum(eachCount)/length(Intersect_combos_all); 45 | if isnan(combos_all_histcount(i,3)) 46 | combos_all_histcount(i,3) = 0; 47 | end 48 | end 49 | end 50 | 51 | end 52 | 53 | 54 | -------------------------------------------------------------------------------- /histoCAT/Neighborhood_New/Check_if_equal_and_replace.m: -------------------------------------------------------------------------------- 1 | function [Tested_Clustering_Index] = Check_if_equal_and_replace(Clustering_Index) 2 | %CHECK_IF_EQUAL_AND_REPLACE Tests if the individual clustering methods are 3 | % present across the samples selected for neighborhood analysis 4 | % Detailed explanation goes here 5 | 6 | % Check if empty 7 | Cluster_available = cellfun(@isempty,Clustering_Index); 8 | % Check if equal 9 | if range(Cluster_available) == 0 10 | Tested_Clustering_Index = Clustering_Index; 11 | else 12 | Tested_Clustering_Index = []; 13 | end 14 | 15 | end 16 | 17 | -------------------------------------------------------------------------------- /histoCAT/Neighborhood_New/Neighborhood_Individual_Image.m: -------------------------------------------------------------------------------- 1 | function [pValue_higher,pValue_lower,real_data_mean,combos_all] = Neighborhood_Individual_Image(permutations,... 2 | selectedall_gates,gates,sessionData,image_num,expansion_name,Phenograph_index_selected,patch_det) 3 | % NEIGHBORHOOD_INDIVIDUAL_IMAGE Calculates the pValues for left/right tailed permutation test 4 | % 5 | % Input: 6 | % permutations --> Amount of permutations 7 | % selectedall_gates --> gates selected in the GUI 8 | % gates --> all gates 9 | % sessionData --> all session data 10 | % image_num --> image number 11 | % expansion_name --> pixel expansion value for regexp 12 | % Phenograph_index_selected --> Which PhenoGraph name selected 13 | % 14 | % Output: 15 | % pValue_higher,pValue_lower --> pValues for right/left tailed permutation test 16 | % real_data_mean --> mean interactions for the real data set 17 | % Phenograph_index --> Which PhenoGraph name selected 18 | % 19 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 20 | % Denis Schapiro - Bodenmiller Group - UZH 21 | 22 | %change default interpreter from tex to none 23 | set(gca,'TickLabelInterpreter','none') 24 | % Get neighbor index for each image 25 | neigb_index = cellfun(@(x) find(~cellfun('isempty',regexp(x,expansion_name))),... 26 | gates(selectedall_gates,3),'UniformOutput',false); 27 | % % Get phenograph index for each image 28 | % Phenograph_index = cellfun(@(x) find(~cellfun('isempty',regexp(x,'Phenograph'))),... 29 | % gates(selectedall_gates,3),'UniformOutput',false); 30 | 31 | % Generate a matrix for only CellID, Neighbors and Phenograph 32 | % We added +1 to use the index also for cells which have zero neighbors 33 | Neighbor_Matrix = sessionData(gates{selectedall_gates(image_num),2},[neigb_index{image_num,1}]); 34 | Neighbor_Matrix_index = Neighbor_Matrix+1; 35 | Phenograph_Vector = sessionData(gates{image_num,2},Phenograph_index_selected{image_num}); 36 | Phenograph_Vector_index =[0;Phenograph_Vector]; 37 | 38 | % Replace all neighbors with corresponding cell type 39 | Phenograph_Neighor_Matrix = Phenograph_Vector_index(Neighbor_Matrix_index); 40 | 41 | % Calculate all possible interactions 42 | Available_Labels = unique(Phenograph_Vector); 43 | combos_oneside = nchoosek(Available_Labels,2); 44 | combos_all = [combos_oneside;fliplr(combos_oneside);[Available_Labels,Available_Labels]]; 45 | 46 | combos_all_histcount = [combos_all,zeros(size(combos_all,1),1)]; 47 | 48 | 49 | % Run through all combos_all_histcount 50 | [combos_all_histcount_real] = Calculate_STDandMean(combos_all,Phenograph_Neighor_Matrix,... 51 | Phenograph_Vector,Neighbor_Matrix,patch_det); 52 | 53 | for p=1:permutations 54 | combos_all_histcount_Perm_single = [];Phenograph_Vector_perm = []; 55 | Phenograph_Vector_index_perm = []; 56 | % Generate matrix for permutation 57 | Phenograph_Vector_perm = Phenograph_Vector(randperm(length(Phenograph_Vector))); 58 | Phenograph_Vector_index_perm = [0;Phenograph_Vector_perm]; 59 | % Replace all neighbors with corresponding cell type 60 | Phenograph_Neighor_Matrix_perm = Phenograph_Vector_index_perm(Neighbor_Matrix_index); 61 | % Run through all combos_all_histcount 62 | [combos_all_histcount_Perm_single] = Calculate_STDandMean(combos_all,Phenograph_Neighor_Matrix_perm,... 63 | Phenograph_Vector_perm,Neighbor_Matrix,patch_det); 64 | combos_all_histcount_Perm(:,p+2) = combos_all_histcount_Perm_single(:,3); 65 | end 66 | 67 | % Calculate p-values 68 | % Get real data and permutated data 69 | real_data_mean = combos_all_histcount_real(:,3); 70 | perm_data_mean = combos_all_histcount_Perm(:,3:end); 71 | % Calculate amount higher or lower than mean (logic matrix) 72 | % What is the likelihood realdata is higher than random? 73 | Higher_perm_test=repmat(real_data_mean,1,size(perm_data_mean,2))<=perm_data_mean; 74 | % What is the likelihood realdata is lower than random? 75 | Lower_perm_test=repmat(real_data_mean,1,size(perm_data_mean,2))>=perm_data_mean; 76 | % Calculate sum of lower and higherstat 77 | Amount_higher = sum(Higher_perm_test,2); 78 | Amount_lower = sum(Lower_perm_test,2); 79 | % Calculate actuall pValues 80 | pValue_higher = (Amount_higher+1)/(permutations+1); 81 | pValue_lower = (Amount_lower+1)/(permutations+1); 82 | 83 | end -------------------------------------------------------------------------------- /histoCAT/Neighborhood_New/Neighborhood_callback.m: -------------------------------------------------------------------------------- 1 | function Neighborhood_callback(hObject, eventdata, handles) 2 | % NEIGHBORHOOD_CALLBACK Callback for the neighorhood function from GUI 3 | % 4 | % Input: 5 | % Global variables: 6 | % Fcs_Interest_all --> all data in the fcs file structure 7 | % Sample_Set_arranged --> samples arranged based on names (numbers) 8 | % HashID --> individual HashID for each image 9 | % 10 | % Histology Topography Cytometry Analysis Toolbox (histoCAT) 11 | % Denis Schapiro - Bodenmiller Group - UZH 12 | 13 | % Get handles 14 | handles = gethand; 15 | selectedall_gates = get(handles.list_samples,'Value'); 16 | global Fcs_Interest_all; 17 | global Sample_Set_arranged; 18 | global HashID; 19 | gates = retr('gates'); 20 | sessionData = retr('sessionData'); 21 | custom_gatesfolder = retr('custom_gatesfolder'); 22 | 23 | gates_cut = gates(selectedall_gates,:); 24 | select_gates_cut = 1:size(gates_cut,1); 25 | 26 | % User input for neighborhood analysis 27 | pixelexpansion_dropdown = retr('pixelexpansion'); 28 | answers = inputdlg({'Amount of permutations:','Significance cut-off: (min. 1/amount of permutations)','Special cluster (Individual Output)','Extra information (Legend for Individual Output)','Specify the amount of pixel expansion to look for cell neighbors:','Percentage cut-off for present interactions (0-1)','If you want to run patch detection: enter minimum amount of neighbors the patch has to include'},'Neighborhood Analysis',1,{'999','0.05','7','Grade1',pixelexpansion_dropdown,'0.1','\'}); 29 | 30 | % Extract user input 31 | % Amount permutations 32 | perm = answers(1); 33 | perm = str2double(perm); 34 | % Significants cut-off for pValue 35 | alpha = answers(2); 36 | alpha = str2double(alpha); 37 | % Cluster number which should be highlighted and annotated 38 | Special_clusters_name = answers(3); 39 | Special_clusters_name = cell2mat(Special_clusters_name); 40 | % Name/Annotation for the special/highlighted cluster 41 | Extra_information = answers(4); 42 | Extra_information = cell2mat(Extra_information); 43 | % Pixel expansion - when is a cell a neighbor 44 | Pixel_expansion = answers(5); 45 | Pixel_expansion = str2double(Pixel_expansion); 46 | % Cut off for how many images need to be included in a significant cluster 47 | % (0-1) --> Example 0.1 --> 10% of all images include the cluster 48 | cut_off_percent = answers(6); 49 | cut_off_percent = str2double(cut_off_percent); 50 | %Patch detection 51 | patch_det = answers(7); 52 | if strcmp(patch_det,'\') 53 | patch_det = 0; 54 | else 55 | %Minus one because it is later used as the number the interactions have 56 | %to be higher than, so if user enters 1 -> it will be 0 and hence the 57 | %regular neighborhood analysis, if user enters 2 -> the interaction has 58 | %to be with more than 1 neighbor 59 | patch_det = str2double(patch_det)-1; 60 | end 61 | 62 | 63 | % If batch mode - each pixel expansion can be tested 64 | if isnan(Pixel_expansion) 65 | 66 | for pixel = 1:6 67 | Neighborhood_Master(perm,pixel,alpha,gates_cut,select_gates_cut,... 68 | sessionData,custom_gatesfolder,Special_clusters_name,Extra_information,cut_off_percent,patch_det); 69 | disp('Done') 70 | disp(pixel) 71 | end 72 | else 73 | Neighborhood_Master(perm,Pixel_expansion,alpha,gates_cut,select_gates_cut,... 74 | sessionData,custom_gatesfolder,Special_clusters_name,Extra_information,cut_off_percent,patch_det); 75 | disp('Done') 76 | disp(Pixel_expansion) 77 | end 78 | 79 | end 80 | 81 | -------------------------------------------------------------------------------- /histoCAT/SpotDetection/3rd_Party/3rd_Party_Licenses/license_CellProfiler.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchapiroLabor/histoCAT/fe4c92ba1a0cb915a8f35c0466b8b6e3c012cff9/histoCAT/SpotDetection/3rd_Party/3rd_Party_Licenses/license_CellProfiler.txt -------------------------------------------------------------------------------- /histoCAT/SpotDetection/3rd_Party/CellProfiler_unmodified/FilterImageCP3D.m: -------------------------------------------------------------------------------- 1 | function FilteredImage = FilterImageCP3D(rImage,Filter) 2 | % Support function for ObjByFilter. (See help there for more information). 3 | % 4 | % Pad image to reduce border artifact. Note that comment in original 5 | % IdentifyPrimLoG2 says "to fix border artifact". However this is not fully 6 | % true as TS/NB observed when looking at xy distribution of spot centroids. 7 | % There still is a bias in spot detection against the pixels at the very 8 | % border, potentially because 'replicate' pixels are not Gaussian. Raj et 9 | % al. 2009 did not use padding. In most scenarios, cells directly at the 10 | % border (and thus the pixels next to the image border) are discarded 11 | % 12 | % Authors: 13 | % Nico Battich 14 | % Thomas Stoeger 15 | % Lucas Pelkmans 16 | % 17 | % Battich et al., 2013. 18 | % Website: http://www.imls.uzh.ch/research/pelkmans.html 19 | % ************************************************************************* 20 | 21 | padsize = ceil(max(size(Filter))./2); 22 | FilteredImage = padarray(rImage,[padsize padsize],'replicate'); 23 | 24 | % Perform Filtering 25 | FilteredImage = imfilter(FilteredImage,Filter,'replicate'); 26 | % Remove Border 27 | FilteredImage = FilteredImage(padsize+1:end-padsize,padsize+1:end-padsize,:); 28 | 29 | 30 | end -------------------------------------------------------------------------------- /histoCAT/SpotDetection/3rd_Party/CellProfiler_unmodified/RescaleImageCP3D.m: -------------------------------------------------------------------------------- 1 | function RescaledImage = RescaleImageCP3D(Image,limQuant,RescaleThr,numDownsampling) 2 | % Support function for ObjByFilter. (See help there for more information). 3 | % Put into separate function to have constincy among multiple module. 4 | % Will generate RESCALEDIMAGE from IMAGE according to given constraints 5 | % LIMQUANT and RESCALETHR. NUMDOWNSAMPLING is factor used for downsampling 6 | % to increase speed. It does not affect RESCALEDIMAGE. 7 | % 8 | % Authors: 9 | % Nico Battich 10 | % Thomas Stoeger 11 | % Lucas Pelkmans 12 | % 13 | % Battich et al., 2013. 14 | % Website: http://www.imls.uzh.ch/research/pelkmans.html 15 | % ************************************************************************* 16 | 17 | % Obtain Minimal and maximal intensity of image; 18 | [minRescInt maxRescInt] = getImageIntensityExtremaCP3D(Image,limQuant(1), limQuant(2), numDownsampling); 19 | % Ensure that minimal and maximal intensity do not exceed input boundaries 20 | % note that this will prevent that intensities of very dim imags are 21 | % amplified so that false-positive objects are identified 22 | minRescInt = max(minRescInt,RescaleThr(1)); % Minimum of lower boundary 23 | minRescInt = min(minRescInt,RescaleThr(2)); % Maximum of lower boundary 24 | maxRescInt = max(maxRescInt,RescaleThr(3)); % Minimum of higher boundary 25 | maxRescInt = min(maxRescInt,RescaleThr(4)); % Maximum of higher boundary 26 | 27 | % Rescale image 28 | RescaledImage = -(Image-minRescInt)./(maxRescInt-minRescInt); % note that here rescaling is not normalized to max of 100%=1 as in initial Identifyprimlog2 29 | 30 | 31 | end -------------------------------------------------------------------------------- /histoCAT/SpotDetection/3rd_Party/CellProfiler_unmodified/getImageIntensityExtremaCP3D.m: -------------------------------------------------------------------------------- 1 | function [minIntensity, maxIntensity] = getImageIntensityExtremaCP3D(Image,minQuantile, maxQuantile, downsamplingFactor,varargin) 2 | % getImageIntensityExtremaCP3D(Image,minQuantile, maxQuantile, 3 | % downsamplingFactor,Illmean,IllStd) 4 | % 5 | % obtains minimum and maximum of an image. Note that minimum and maximum 6 | % are given by the quantile, e.g. minQuantile of 0 is the real minimum of the 7 | % image, wheareas 0.01 would discard the lowest 1%. 8 | % 9 | % 10 | % IMAGE can either be a matrix with the 2D or 3D image or a path to a 2D 11 | % image 12 | % 13 | % To speed up processing of large images (such as sCMOS 10megapixel iamges), 14 | % DOWNSAMPLINGFACTOR of higher than 1 can downsample the image prior to quantile 15 | % 16 | % If the optional input arguments ILLMEAN and ILLSTD are provided at the 17 | % end of the input, illumination correction will be performed with the MEAN 18 | % and STD provided for illumination correction. 19 | % 20 | % 21 | % Authors: 22 | % Nico Battich 23 | % Thomas Stoeger 24 | % Lucas Pelkmans 25 | % 26 | % Battich et al., 2013. 27 | % Website: http://www.imls.uzh.ch/research/pelkmans.html 28 | 29 | % Preprocess input 30 | 31 | downsamplingFactor = ceil(downsamplingFactor); % make downsampling factor integer 32 | 33 | if nargin== 6 % see if illumination correction should be performed. 34 | if ~any([isempty(varargin{1}),isempty(varargin{2})]) 35 | bnDoIlluminationCorrection = true; 36 | IllMean = varargin{1}; 37 | IllStd = varargin{2}; 38 | else 39 | bnDoIlluminationCorrection = false; 40 | end 41 | else 42 | bnDoIlluminationCorrection = false; 43 | end 44 | 45 | % Load Data 46 | if isnumeric(Image) 47 | OrigImage = Image; 48 | elseif ischar(Image); 49 | if any(fileattrib(Image)) 50 | try 51 | OrigImage = imread(Image); 52 | catch notLoaded 53 | error(['Could not load Image with file path/name ' Image '.']) 54 | end 55 | else 56 | error(['Could not find file with file path/name ' Image '.']) 57 | end 58 | else 59 | error('Could not identify format of input Image') 60 | end 61 | 62 | % Downsample by choosing discrete rows/columns. Note that this will prevent 63 | % masking of small intensity peaks (such as RNA spots) below sampling 64 | % scale (which might occur with classical image downsampling involving 65 | % interpolation). Also use discrete steps of rows instead of randomly 66 | % chosen subset of image for reproducibility (assumption that there 67 | % is no repetitive pattern of the intensities) 68 | rowIndices= 1:downsamplingFactor:size(OrigImage,1); 69 | columnIndices = 1:downsamplingFactor:size(OrigImage,2); 70 | 71 | 72 | ImagesDS = OrigImage(rowIndices,columnIndices,:); 73 | 74 | if bnDoIlluminationCorrection == true % if requested, do illumination correction 75 | % downsample template for illumantion correction 76 | IllMeanDS = IllMean(rowIndices,columnIndices); 77 | IllStdDS = IllStd(rowIndices,columnIndices); 78 | switch size(ImagesDS,3) 79 | case 1 % in case of 2D image use Nico's function for illum correction 80 | ImagesDS = IllumCorrect(ImagesDS,IllMeanDS,IllStdDS,1); 81 | otherwise % otherwise use implementation supporting 3D 82 | ImagesDS = applyNBBSIllumCorrCP3D(ImagesDS,IllMeanDS,IllStdDS); 83 | end 84 | end 85 | 86 | if ~isempty(minQuantile) 87 | minIntensity = quantile(ImagesDS(:),minQuantile); 88 | else 89 | minIntensity = NaN; 90 | end 91 | 92 | if ~isempty(maxQuantile) 93 | maxIntensity = quantile(ImagesDS(:),maxQuantile); 94 | else 95 | maxIntensity = NaN; 96 | end 97 | 98 | end -------------------------------------------------------------------------------- /histoCAT/SpotDetection/3rd_Party/CellProfiler_unmodified/inputVectorsForEvalCP3D.m: -------------------------------------------------------------------------------- 1 | function [bnIsAllowed evalStr] = inputVectorsForEvalCP3D(Str,varargin) 2 | % - Formats CP input such that it can be used to make a vector; 3 | % - Ensures that input does not contain potentially harmful code 4 | % [bnIsAllowed evalStr] = inputVectorsForEvalCP3D(Str,varargin) 5 | % checks string, which should be eval'ed, for absence of characters of 6 | % whitelist. optional second input argument can be TRUE/FALSE to indicate 7 | % whether NaN should be allowed - default is FALSE. 8 | % 9 | % BNISALLOWED is TRUE or FALSE and indicates whether string is allowed 10 | % EVALSTRING is (reformatted> add [ and ]) STR to evaluate. In case of non 11 | % allowed STR, EVALSTRING will be empty 12 | % 13 | % Authors: 14 | % Nico Battich 15 | % Thomas Stoeger 16 | % Lucas Pelkmans 17 | % 18 | % Battich et al., 2013. 19 | % Website: http://www.imls.uzh.ch/research/pelkmans.html 20 | % ************************************************************************* 21 | 22 | switch nargin 23 | case 1 24 | bnAllowNaN = false; 25 | bnOutputBrackets = true; 26 | case 2 27 | bnAllowNaN = varargin{1}; 28 | bnOutputBrackets = true; 29 | case 3 30 | bnAllowNaN = varargin{1}; 31 | bnOutputBrackets = varargin{2}; 32 | otherwise 33 | error('Number of input arguments not correct'); 34 | end 35 | 36 | allowedChar = ismember(Str,'0123456789.,:[] '); 37 | if bnAllowNaN == true; 38 | NaNStart = strfind(Str,'NaN'); 39 | if any(NaNStart) 40 | allowedChar(NaNStart)= true; 41 | allowedChar(NaNStart+1)= true; 42 | allowedChar(NaNStart+2)= true; 43 | end 44 | end 45 | 46 | if any(~allowedChar) == true 47 | bnIsAllowed = false; 48 | evalStr = []; % report empty string to eval so that bad code does not get accidentally eval'ed 49 | else 50 | bnIsAllowed = true; 51 | evalStr = Str; 52 | if bnOutputBrackets == true 53 | if evalStr(1) ~= '[' % reformat: add square brackets 54 | evalStr = ['[' evalStr]; 55 | end 56 | if evalStr(end) ~= ']' 57 | evalStr = [evalStr ']']; 58 | end 59 | end 60 | end 61 | 62 | end -------------------------------------------------------------------------------- /histoCAT/antiquated_functions/struct2array.m: -------------------------------------------------------------------------------- 1 | function a = struct2array(s) 2 | %STRUCT2ARRAY Convert structure with doubles to an array. 3 | 4 | % Author(s): R. Losada 5 | % Copyright 1988-2013 The MathWorks, Inc. 6 | 7 | narginchk(1,1); 8 | 9 | % Convert structure to cell 10 | c = struct2cell(s); 11 | 12 | % Construct an array 13 | a = [c{:}]; 14 | 15 | -------------------------------------------------------------------------------- /histoCAT_version.txt: -------------------------------------------------------------------------------- 1 | 1.77 2 | --------------------------------------------------------------------------------