<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.2 20190208//EN" "http://jats.nlm.nih.gov/publishing/1.2/JATS-journalpublishing1.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" article-type="methods-article" dtd-version="1.2" xml:lang="en">
    <front>
        <journal-meta>
            <journal-id journal-id-type="pmc">F1000Research</journal-id>
            <journal-title-group>
                <journal-title>F1000Research</journal-title>
            </journal-title-group>
            <issn pub-type="epub">2046-1402</issn>
            <publisher>
                <publisher-name>F1000 Research Limited</publisher-name>
                <publisher-loc>London, UK</publisher-loc>
            </publisher>
        </journal-meta>
        <article-meta>
            <article-id pub-id-type="doi">10.12688/f1000research.11622.2</article-id>
            <article-categories>
                <subj-group subj-group-type="heading">
                    <subject>Method Article</subject>
                </subj-group>
                <subj-group>
                    <subject>Articles</subject>
                    <subj-group>
                        <subject>Bioinformatics</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Biomacromolecule-Ligand Interactions</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Cell Signaling</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Cell Signaling &amp; Trafficking Structures</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Chemical Biology of the Cell</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Membranes &amp; Sorting</subject>
                    </subj-group>
                    <subj-group>
                        <subject>Nuclear Structure &amp; Function</subject>
                    </subj-group>
                </subj-group>
            </article-categories>
            <title-group>
                <article-title>CyTOF workflow: differential discovery in high-throughput high-dimensional cytometry datasets</article-title>
                <fn-group content-type="pub-status">
                    <fn>
                        <p>[version 2; peer review: 2 approved]</p>
                    </fn>
                </fn-group>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Nowicka</surname>
                        <given-names>Malgorzata</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Formal Analysis</role>
                    <role content-type="http://credit.niso.org/">Investigation</role>
                    <role content-type="http://credit.niso.org/">Methodology</role>
                    <role content-type="http://credit.niso.org/">Software</role>
                    <role content-type="http://credit.niso.org/">Visualization</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Original Draft Preparation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a1">1</xref>
                    <xref ref-type="aff" rid="a2">2</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Krieg</surname>
                        <given-names>Carsten</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Investigation</role>
                    <role content-type="http://credit.niso.org/">Validation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a3">3</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Weber</surname>
                        <given-names>Lukas M.</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Formal Analysis</role>
                    <role content-type="http://credit.niso.org/">Methodology</role>
                    <role content-type="http://credit.niso.org/">Software</role>
                    <role content-type="http://credit.niso.org/">Visualization</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-3282-1730</uri>
                    <xref ref-type="aff" rid="a1">1</xref>
                    <xref ref-type="aff" rid="a2">2</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Hartmann</surname>
                        <given-names>Felix J.</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Methodology</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-4174-2276</uri>
                    <xref ref-type="aff" rid="a3">3</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Guglietta</surname>
                        <given-names>Silvia</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Validation</role>
                    <xref ref-type="aff" rid="a4">4</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Becher</surname>
                        <given-names>Burkhard</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Investigation</role>
                    <role content-type="http://credit.niso.org/">Supervision</role>
                    <xref ref-type="aff" rid="a3">3</xref>
                </contrib>
                <contrib contrib-type="author" corresp="no">
                    <name>
                        <surname>Levesque</surname>
                        <given-names>Mitchell P.</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Investigation</role>
                    <role content-type="http://credit.niso.org/">Resources</role>
                    <role content-type="http://credit.niso.org/">Supervision</role>
                    <role content-type="http://credit.niso.org/">Validation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <xref ref-type="aff" rid="a5">5</xref>
                </contrib>
                <contrib contrib-type="author" corresp="yes">
                    <name>
                        <surname>Robinson</surname>
                        <given-names>Mark D.</given-names>
                    </name>
                    <role content-type="http://credit.niso.org/">Conceptualization</role>
                    <role content-type="http://credit.niso.org/">Formal Analysis</role>
                    <role content-type="http://credit.niso.org/">Investigation</role>
                    <role content-type="http://credit.niso.org/">Methodology</role>
                    <role content-type="http://credit.niso.org/">Project Administration</role>
                    <role content-type="http://credit.niso.org/">Software</role>
                    <role content-type="http://credit.niso.org/">Supervision</role>
                    <role content-type="http://credit.niso.org/">Visualization</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Original Draft Preparation</role>
                    <role content-type="http://credit.niso.org/">Writing &#x2013; Review &amp; Editing</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-3048-5518</uri>
                    <xref ref-type="corresp" rid="c1">a</xref>
                    <xref ref-type="aff" rid="a1">1</xref>
                    <xref ref-type="aff" rid="a2">2</xref>
                </contrib>
                <aff id="a1">
                    <label>1</label>SIB Swiss Institute of Bioinformatics, University of Zurich, Zurich, 8057, Switzerland</aff>
                <aff id="a2">
                    <label>2</label>Institute for Molecular Life Sciences, University of Zurich, Zurich, 8057, Switzerland</aff>
                <aff id="a3">
                    <label>3</label>Institute of Experimental Immunology, University of Zurich, Zurich, 8057, Switzerland</aff>
                <aff id="a4">
                    <label>4</label>Department of Experimental Oncology, European Institute of Oncology, Via Adamello 16, Milan, I-20139, Italy</aff>
                <aff id="a5">
                    <label>5</label>Department of Dermatology, University Hospital Zurich, Zurich, CH-8091, Switzerland</aff>
            </contrib-group>
            <author-notes>
                <corresp id="c1">
                    <label>a</label>
                    <email xlink:href="mailto:mark.robinson@imls.uzh.ch">mark.robinson@imls.uzh.ch</email>
                </corresp>
                <fn fn-type="con">
                    <p>MN and MDR designed and ran analyses. MN drafted the manuscript with input from MDR. CK and SG performed experiments, analyzed data and gave feedback on clinical applications. CK performed the cluster merging. FJH and LMW contributed code and ideas for the analyses. MPL interpreted data and provided clinical perspective. BB gave feedback on the manuscript and the bioinformatics. All authors read and approved the final manuscript and have agreed to the content.</p>
                </fn>
                <fn fn-type="conflict">
                    <p>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>14</day>
                <month>11</month>
                <year>2017</year>
            </pub-date>
            <pub-date pub-type="collection">
                <year>2017</year>
            </pub-date>
            <volume>6</volume>
            <elocation-id>748</elocation-id>
            <history>
                <date date-type="accepted">
                    <day>19</day>
                    <month>6</month>
                    <year>2026</year>
                </date>
            </history>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2017 Nowicka M et al.</copyright-statement>
                <copyright-year>2017</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access article distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <self-uri content-type="pdf" xlink:href="https://f1000research.com/articles/6-748/pdf"/>
            <abstract>
                <p>High dimensional mass and flow cytometry (HDCyto) experiments have become a method of choice for high throughput interrogation and characterization of cell populations. Here, we present an R-based pipeline for differential analyses of HDCyto data, largely based on Bioconductor packages. We computationally define cell populations using FlowSOM clustering, and facilitate an optional but reproducible strategy for manual merging of algorithm-generated clusters. Our workflow offers different analysis paths, including association of cell type abundance with a phenotype or changes in signaling markers within specific subpopulations, or differential analyses of aggregated signals. Importantly, the differential analyses we show are based on regression frameworks where the HDCyto data is the response; thus, we are able to model arbitrary experimental designs, such as those with batch effects, paired designs and so on. In particular, we apply generalized linear mixed models to analyses of cell population abundance or cell-population-specific analyses of signaling markers, allowing overdispersion in cell count or aggregated signals across samples to be appropriately modeled. To support the formal statistical analyses, we encourage exploratory data analysis at every step, including quality control (e.g. multi-dimensional scaling plots), reporting of clustering results (dimensionality reduction, heatmaps with dendrograms) and differential analyses (e.g. plots of aggregated signals).</p>
            </abstract>
            <kwd-group kwd-group-type="author">
                <kwd>CyTOF</kwd>
                <kwd>flow cytometry</kwd>
                <kwd>differential analysis</kwd>
            </kwd-group>
            <funding-group>
                <award-group id="fund-1">
                    <funding-source>Swiss Institute of Bioinformatics</funding-source>
                </award-group>
                <funding-statement>MN acknowledges the funding from a Swiss Institute of Bioinformatics (SIB) Fellowship.</funding-statement>
                <funding-statement>
                    <italic>The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.</italic>
                </funding-statement>
            </funding-group>
        </article-meta>
        <notes>
            <sec sec-type="version-changes">
                <label>Revised</label>
                <title>Amendments from Version 1</title>
                <p>In version 2 of the workflow, we have added a section called "Obtaining higher resolution" where we describe strategies for deeper clustering analysis. We have fixed and added missing references, extended the discussion section. We have proposed additional visualizations of clusters and extended some of the figure captions. To improve speed, the density of marker signals across clusters was changed to ridgeline plots (geom_density_ridges) instead of densities (geom_density). &#x00a0;Furthermore, heatmaps of the identity marker clustering are now supplemented with a barplot highlighting the frequency of the cluster. In total, two new figures were added: one to highlight the usage of the 'ComplexHeatmap' package (in the context of subpopulation-specific identity and functional marker signal) and another that corresponds with the new&#x00a0;"Obtaining higher resolution" Section.</p>
            </sec>
        </notes>
    </front>
    <body>
        <sec sec-type="intro">
            <title>Introduction</title>
            <p>Flow cytometry and the more recently introduced CyTOF (cytometry by time-of-flight mass spectrometry or mass cytometry) are high-throughput technologies that measure protein abundance on the surface or within cells. In flow cytometry, antibodies are labeled with fluorescent dyes and fluorescence intensity is measured using lasers and photodetectors. CyTOF utilizes antibodies tagged with metal isotopes from the lanthanide series, which have favorable chemistry and do not occur in biological systems; abundances per cell are recorded with a time-of-flight mass spectrometer. In either case, fluorescence intensities (flow cytometry) or ion counts (mass cytometry) are assumed to be proportional to the expression level of the antibody-targeted antigens of interest.</p>
            <p>Due to the differences in acquisition, further distinct characteristics should be noted. Conventional fluorophorebased flow cytometry is non-destructive and can be used to sort cells for further analysis. However, because of the spectral overlap between fluorophores, 
                <italic toggle="yes">compensation</italic> of the data needs to be performed (
                <xref ref-type="bibr" rid="ref-34">Roederer, 2001</xref>), which also limits the number of parameters that can be measured simultaneously. Thus, standard flow cytometry experiments measure 6&#x2013;12 parameters with modern systems measuring up to 20 channels (
                <xref ref-type="bibr" rid="ref-27">Mahnke &amp; Roederer, 2007</xref>), while new developments (e.g. BD FACSymphony) promise to increase this capacity towards 50. Moreover, flow cytometry offers the highest throughput with tens of thousands of cells measured per second at relatively low operating costs per sample.</p>
            <p>By using rare metal isotopes in CyTOF, cell autofluorescence can be avoided and spectral overlap is drastically reduced. However, the sensitivity of mass spectrometry results in the measurement of metal impurities and oxide formations, which need to be carefully considered in antibody panel design (e.g. through antibody concentrations and coupling of antibodies to neighboring metals). Leipold 
                <italic toggle="yes">et al.</italic> recently commented that 
                <italic toggle="yes">minimal spillover does not equal no spillover</italic> (
                <xref ref-type="bibr" rid="ref-20">Leipold, 2015</xref>). Nonetheless, CyTOF offers a high dimension of parameters measured per cell, with current panels using ~40 parameters and the promise of up to 100. Throughput of CyTOF is lower, at the rate of hundreds of cells per second, and cells are destroyed during ionization.</p>
            <p>The ability of flow cytometry and mass cytometry to analyze individual cells at high-throughput scales has resulted in a wide range of biological and medical applications. For example, immunophenotyping assays are used to detect and quantify cell populations of interest, to uncover new cell populations and compare abundance of cell populations between different conditions, for example between patient groups (
                <xref ref-type="bibr" rid="ref-39">van Unen 
                    <italic toggle="yes">et al.</italic>, 2016</xref>). Thus, it can be used as a biomarker discovery tool.</p>
            <p>Various methodological approaches aim for biomarker discovery (
                <xref ref-type="bibr" rid="ref-35">Saeys 
                    <italic toggle="yes">et al.</italic>, 2016</xref>). A common strategy, which we will refer to through this workflow as the &#x201c;classic&#x201d; approach, is to first identify cell populations of interest by manual gating or automated clustering (
                <xref ref-type="bibr" rid="ref-17">Hartmann 
                    <italic toggle="yes">et al.</italic>, 2016</xref>; 
                <xref ref-type="bibr" rid="ref-30">Pejoski 
                    <italic toggle="yes">et al.</italic>, 2016</xref>). Second, using statistical tests, one can determine which of the cell subpopulations or protein markers are associated with a phenotype (e.g. clinical outcome) of interest. Typically, cell subpopulation abundance expressed as cluster cell counts or median marker expression would be used in the statistical model to relate to the sample-level phenotype.</p>
            <p>Importantly, there are many alternatives to what we propose below, and several new methods are emerging. For instance, 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>) tackles the differential discovery problem by strong over-clustering of the cells, and by building a hierarchy of clusters from very specific to general ones. Using model selection and regularization techniques, clusters and markers that associate with the outcome are identified. A new machine learning approach, 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-3">Arvaniti &amp; Claassen, 2017</xref>), learns the representation of clusters that are associated with the considered phenotype by means of convolutional neural networks, which makes it particularly applicable to detecting discriminating rare cell populations. However, there are tradeoffs to consider. 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> performs feature selection but does not provide significance levels, such as p-values, for the strength of associations. Due to its computational requirements, 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> can not be run on entire mass cytometry datasets and one typically must analyze a subset of the data. The &#x201c;filters&#x201d; from 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic> may identify one or more cell subsets that distinguish experimental groups, while these groups may not necessarily correspond to any of the canonical cell types, since they are learned with a data-driven approach.</p>
            <p>A noticeable distinction between the machine-learning approaches and our classical regression approach is how the model is designed. 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic> model the patient response as a function of the measured HDCyto values, whereas the classical approach models the HDCyto data itself as the response, thus putting the distributional assumptions on the experimental HDCyto data. This carries the distinct advantage that covariates (e.g. age, gender, batch) can be included, together with finding associations of the phenotype to the predictors of interest (e.g. cell type abundance). Specifically, neither 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> nor 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic> are able to directly account for complex designs, such as paired experiments or presence of batches.</p>
            <p>Within the classical approach, hybrid methods are certainly possible, where discovery of interesting cell populations is done with one algorithm, and quantifications or signal aggregations are modeled in standard regression frameworks. For instance, 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic> provides p-values from a t-test or Mann-Whitney U-test conducted on the frequencies of previously detected cell populations. The models we propose below are flexible extensions of this strategy.</p>
            <p>Step by step, this workflow presents differential discovery analyses assembled from a suite of tools and methods that, in our view, lead to a higher level of flexibility and robust, statistically-supported and interpretable results. Cell population identification is conducted by means of unsupervised clustering using the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> and 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ConsensusClusterPlus">
                    <italic toggle="yes">ConsensusClusterPlus</italic>
                </ext-link> packages, which together were among the best performing clustering approaches for high-dimensional cytometry data (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>). Notably, 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> scales easily to millions of cells and thus no subsetting of the data is required.</p>
            <p>To be able to analyze arbitrary experimental designs (e.g. batch effects, paired experiments, etc.), we show how to conduct the differential analysis of cell population abundances using the generalized linear mixed models (GLMM) and of marker intensities using linear models (LM) and linear mixed models (LMM). Model fitting is performed with 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=lme4">
                    <italic toggle="yes">lme4</italic>
                </ext-link> and 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=stats">
                    <italic toggle="yes">stats</italic>
                </ext-link> packages, and hypothesis testing with the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=multcomp">
                    <italic toggle="yes">multcomp</italic>
                </ext-link> package.</p>
            <p>We use the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=ggplot2">
                    <italic toggle="yes">ggplot2</italic>
                </ext-link> package as our graphical engine. Notably, we propose a suite of useful visual representations of HDCyto data characteristics, such as an MDS (multidimensional scaling) plot of aggregated signal for exploring sample similarities. The obtained cell populations are visualized using dimension reduction techniques (e.g. t-SNE via the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=Rtsne">
                    <italic toggle="yes">Rtsne</italic>
                </ext-link> package) and heatmaps (via the 
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=pheatmap">
                    <italic toggle="yes">pheatmap</italic>
                </ext-link> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ComplexHeatmap">ComplexHeatmap</ext-link>
                </italic> packages) to represent characteristics of the annotated cell populations and identified biomarkers.</p>
            <p>The workflow is intentionally not fully automatic. First, we strongly advocate for exploratory data analysis to get an understanding of data characteristics before formal statistical modeling. Second, the workflow involves an optional step where the user can manually merge and annotate clusters (see 
                <xref ref-type="other" rid="S5">Cluster merging and annotation</xref> section) but in a way that is easily reproducible. The CyTOF data used here (see 
                <xref ref-type="other" rid="S1">Data description</xref> section) is already preprocessed; i.e. the normalization and de-barcoding, as well as removal of doublets, debris and dead cells, were already performed. To see how such an analysis could be performed, please see the 
                <xref ref-type="other" rid="S2">Data preprocessing</xref> section.</p>
            <p>Notably, this workflow is equally applicable to flow or mass cytometry datasets, for which the preprocessing steps have already been performed. In addition, the workflow is modular and can be adapted as new algorithms or new knowledge about how to best use existing tools comes to light. Alternative clustering algorithms such as the popular PhenoGraph algorithm (
                <xref ref-type="bibr" rid="ref-21">Levine 
                    <italic toggle="yes">et al.</italic>, 2015</xref>) (e.g. via the 
                <ext-link ext-link-type="uri" xlink:href="https://github.com/JinmiaoChenLab/Rphenograph">
                    <italic toggle="yes">Rphenograph</italic>
                </ext-link> package), dimensionality reduction techniques, such as diffusion maps (
                <xref ref-type="bibr" rid="ref-15">Haghverdi 
                    <italic toggle="yes">et al.</italic>, 2015</xref>) via the 
                <italic toggle="yes">destiny</italic> package (
                <xref ref-type="bibr" rid="ref-2">Angerer 
                    <italic toggle="yes">et al.</italic>, 2016</xref>), and SIMLR (
                <xref ref-type="bibr" rid="ref-40">Wang 
                    <italic toggle="yes">et al.</italic>, 2017</xref>) via the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/SIMLR">
                    <italic toggle="yes">SIMLR</italic>
                </ext-link> package could be inserted to the workflow.</p>
        </sec>
        <sec id="S1">
            <title>Data description</title>
            <p>We use a subset of CyTOF data originating from Bodenmiller 
                <italic toggle="yes">et al.</italic> (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>) that was also used in the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> paper (
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>). In the original study, peripheral blood mononuclear cells (PBMCs) in unstimulated and after 11 different stimulation conditions were measured for 8 healthy donors. For each sample, expression of 10 cell surface markers and 14 signaling markers was recorded. We perform our analysis on samples from the reference and one stimulated condition where cell were crosslinked for 30 minutes with B cell receptor/Fc receptor known as BCR/FcR-XL, resulting in 16 samples in total (8 patients, unstimulated and stimulated for each).</p>
            <p>The original data is available from the 
                <ext-link ext-link-type="uri" xlink:href="http://reports.cytobank.org/105/v2">Cytobank report</ext-link>. The subset used here can be downloaded from the 
                <ext-link ext-link-type="uri" xlink:href="https://community.cytobank.org/cytobank/experiments/15713/">Citrus Cytobank repository</ext-link> (files with 
                <monospace>_BCR-XL.fcs</monospace> or 
                <monospace>_Reference.fcs</monospace> endings) or from our web server (see 
                <xref ref-type="other" rid="S3">Data import</xref> section).</p>
            <p>In both the Bodenmiller 
                <italic toggle="yes">et al.</italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> manuscripts, the 10 lineage markers were used to identify cell subpopulations. These were then investigated for differences between reference and stimulated cell subpopulations separately for each of the 14 functional markers. The same strategy is used in this workflow; 10 lineage markers are used for cell clustering and 14 functional markers are tested for differential expression between the reference and BCR/FcR-XL stimulation. Even though differential analysis of cell abundance was not in the scope of the Bodenmiller 
                <italic toggle="yes">et al.</italic> experiment, we present it here to highlight the generality of the discovery.</p>
        </sec>
        <sec id="S2">
            <title>Data preprocessing</title>
            <p>Conventional flow cytometers and mass cytometers produce .fcs files that can be manually analyzed using programs such as FlowJo [TriStar] or Cytobank (
                <xref ref-type="bibr" rid="ref-19">Kotecha 
                    <italic toggle="yes">et al.</italic>, 2001</xref>), or using the R/Bioconductor packages, such as 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/flowWorkspace">flowWorkspace</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-11">Finak &amp; Jiang, 2011</xref>) and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/openCyto">openCyto</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-12">Finak 
                    <italic toggle="yes">et al.</italic>, 2014</xref>). During this initial analysis step, dead cells are removed, compensation is checked and with simple two dimensional scatter plots (e.g. marker intensity versus time), marker expression patterns are checked. Often, modern experiments are barcoded in order to remove analytical biases due to individual sample variation or acquisition time. Preprocessing steps including normalization using bead standards (
                <xref ref-type="bibr" rid="ref-14">Finck 
                    <italic toggle="yes">et al.</italic>, 2013</xref>), de-barcoding (
                <xref ref-type="bibr" rid="ref-45">Zunder 
                    <italic toggle="yes">et al.</italic>, 2015</xref>) and compensation can be completed with the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/CATALYST">CATALYST</ext-link>
                </italic> package (
                <xref ref-type="bibr" rid="ref-9">Chevrier 
                    <italic toggle="yes">et al.</italic>, 2017</xref>), which also provides a 
                <ext-link ext-link-type="uri" xlink:href="https://catalyst-project.github.io/">Shiny app</ext-link> for the interactive analysis. Of course, preprocessing steps can occur using custom scripts within R or outside of R (e.g. 
                <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/bead-normalization/releases/latest">Normalizer</ext-link> (
                <xref ref-type="bibr" rid="ref-14">Finck 
                    <italic toggle="yes">et al.</italic>, 2013</xref>)).</p>
        </sec>
        <sec id="S3">
            <title>Data import</title>
            <p>We recommend as standard practice to keep an independent record of all samples collected, with additional information about the experimental condition, including sample or patient identifiers, processing batch and so on. That is, we recommend having a trail of metadata for each experiment. In our example, the metadata file, PBMC8_metadata.xlsx, can be downloaded from the  
                <ext-link ext-link-type="uri" xlink:href="http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow/">Robinson Lab server</ext-link> with the 
                <monospace>download.file</monospace> function. For the workflow, the user should place it in the current working directory (
                <monospace>getwd()</monospace>). Here, we load it into R with the 
                <monospace>read_excel</monospace> function from the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=readxl">readxl</ext-link>
                </italic> package and save it into a variable called 
                <monospace>md</monospace>, but other file types and interfaces to read them in are also possible.</p>
            <p>The data frame 
                <monospace>md</monospace> contains the following columns:</p>
            <list list-type="bullet">
                <list-item>
                    <p>
                        <monospace>file_name</monospace> with names of the .fcs files corresponding to the reference (suffix &#x201c;Reference&#x201d;) and BCR/FcR-XL stimulation (suffix &#x201c;BCR-XL&#x201d;) samples,</p>
                </list-item>
                <list-item>
                    <p>
                        <monospace>sample_id</monospace> with shorter unique names for each sample containing information about conditions and patient IDs,</p>
                </list-item>
                <list-item>
                    <p>
                        <monospace>condition</monospace> describes whether samples originate from the reference (
                        <monospace>Ref</monospace>) or stimulated (
                        <monospace>BCRXL</monospace>) condition,</p>
                </list-item>
                <list-item>
                    <p>
                        <monospace>patient_id</monospace> defines the IDs of patients.</p>
                </list-item>
            </list>
            <p>The 
                <monospace>sample_id</monospace> variable is used as row names in metadata and will be used all over the workflow to label the samples. It is important to carefully check whether variables are of the desired type (factor, numeric, character), since input methods may convert columns into different data types. For the statistical modeling, we want to make the condition variable a factor with the reference (
                <monospace>Ref</monospace>) samples being the reference level, where the order of factor levels can be defined with the 
                <monospace>levels</monospace> parameter of the 
                <monospace>factor</monospace> function. We also specify colors for the different conditions in a variable 
                <monospace>color_conditions</monospace>.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(readxl)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">url &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow"</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">metadata_filename &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"PBMC8_metadata.xlsx"</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">download.file</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(url,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"/"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, metadata_filename)</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">destfile =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">metadata_filename,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">mode =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"wb"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
md &lt;- 
                    <styled-content style="font-size:15px;color:#214A87;">read_excel</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(metadata_filename)</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">## Make sure condition variables are factors with the right levels</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels = c</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;">"Ref"</styled-content>, 
                    <styled-content style="font-size:15px;color:#4F9905;">"BCRXL"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">head</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(md))</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">##                            file_name sample_id condition patient_id</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 1    PBMC8_30min_patient1_BCR-XL.fcs    BCRXL1     BCRXL   Patient1</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 2 PBMC8_30min_patient1_Reference.fcs      Ref1       Ref   Patient1</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 3    PBMC8_30min_patient2_BCR-XL.fcs    BCRXL2     BCRXL   Patient2</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 4 PBMC8_30min_patient2_Reference.fcs      Ref2       Ref   Patient2</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 5    PBMC8_30min_patient3_BCR-XL.fcs    BCRXL3     BCRXL   Patient3</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">## 6 PBMC8_30min_patient3_Reference.fcs      Ref3       Ref   Patient3</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">## Define colors for conditions</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">color_conditions &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">c</styled-content>(
                    <styled-content style="font-size:15px;color:#4F9905;">"#6A3D9A"</styled-content>, 
                    <styled-content style="font-size:15px;color:#4F9905;">"#FF7F00"</styled-content>)

                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(color_conditions) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>(md
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition)</styled-content>
                </preformat>
            </p>
            <p>The .fcs files listed in the metadata can be downloaded manually from the 
                <ext-link ext-link-type="uri" xlink:href="https://community.cytobank.org/cytobank/experiments/15713/download_files">Citrus Cytobank repository</ext-link> or automatically from the 
                <ext-link ext-link-type="uri" xlink:href="http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow/">Robinson Lab server</ext-link> where they are saved in a compressed archive file, PBMC8_fcs_files.zip.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">fcs_filename &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"PBMC8_fcs_files.zip"</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">download.file</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(url,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"/"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, fcs_filename),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">destfile =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">fcs_filename,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">mode =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"wb"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">unzip</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs_filename)</styled-content>
                </preformat>
            </p>
            <p>To load the content of the .fcs files into R, we use the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/flowCore">
                    <italic toggle="yes">flowCore</italic>
                </ext-link> package (
                <xref ref-type="bibr" rid="ref-16">Hahne 
                    <italic toggle="yes">et al.</italic>, 2009</xref>). Using 
                <monospace>read.flowSet</monospace>, we read in all files into a 
                <monospace>flowSet</monospace> object, which is a general container for HDCyto data. Importantly, 
                <monospace>read.flowSet</monospace> and the underlying 
                <monospace>read.FCS</monospace> functions, by default, may transform the marker intensities and remove cells with extreme positive values. We keep these options off to be sure that we control the exact preprocessing steps.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(flowCore)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">fcs_raw &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">read.flowSet</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">file_name,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">transformation =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>,
  
                    <styled-content style="font-size:15px;color:#214A87;">truncate_max_range</styled-content> = 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">fcs_raw</styled-content>
                </preformat>
            </p>
            <p>In our example, information about the panel is also available in a file called PBMC8_panel.xlsx, and can be downloaded from the 
                <ext-link ext-link-type="uri" xlink:href="http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow/">Robinson Lab server</ext-link> and loaded into a variable called 
                <monospace>panel</monospace>. It contains columns for 
                <monospace>Isotope</monospace> and 
                <monospace>Metal</monospace> that define the atomic mass number and the symbol of the chemical element conjugated to the antibody, respectively, and 
                <monospace>Antigen</monospace>, which specifies the protein marker that was targeted; two additional columns specify whether a channel belongs to the lineage or surface type of marker.</p>
            <p>The isotope, metal and antigen information that the instrument receives is also stored in the 
                <monospace>flowFrame</monospace> (container for one sample) or 
                <monospace>flowSet</monospace> (container for multiple samples) objects. You can type 
                <monospace>fcs_raw[[1]]</monospace> to see the first 
                <monospace>flowFrame</monospace>, which contains a table with columns 
                <monospace>name</monospace> and 
                <monospace>desc</monospace>. Their content can be accessed with functions 
                <monospace>pData(parameters())</monospace>, which is identical for all the 
                <monospace>flowFrame</monospace> objects in the 
                <monospace>flowSet</monospace>. The variable 
                <monospace>name</monospace> corresponds to the column names in the 
                <monospace>flowSet</monospace> object, you can type in R 
                <monospace>colnames(fcs_raw)</monospace>.</p>
            <p>It should be checked that elements from 
                <monospace>panel</monospace> can be matched to their corresponding entries in the 
                <monospace>flowSet</monospace> object to make the analysis less prone to subsetting mistakes. Here, for example, the entries in 
                <monospace>panel$Antigen</monospace> have their exact equivalents in the 
                <monospace>desc</monospace> columns of the 
                <monospace>flowFrame</monospace> objects. In the following analysis, we will often use marker IDs as column names in the tables containing expression values. As a cautionary note, during object conversion from one type to another (e.g. in the creation of data.frame from a matrix), some characters (e.g. dashes) in the dimension names are replaced with dots, which may cause problems in matching. To avoid this problem, we replace all the dashes with underscores. Also, we define two variables that indicate the lineage and functional markers.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">panel_filename &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"PBMC8_panel.xlsx"</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">download.file</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(url,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"/"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, panel_filename),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">destfile = </styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">panel_filename,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">mode =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"wb"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">panel &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">read_excel</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(panel_filename)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">head</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(panel))</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">##   Metal Isotope Antigen Lineage Functional
## 1    Cd 110:114     CD3       1          0
## 2    In     115    CD45       1          0
## 3    La     139     BC1       0          0
## 4    Pr     141     BC2       0          0
## 5    Nd     142   pNFkB       0          1
## 6    Nd     144    pp38       0          1
</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;"># Replace problematic characters</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Antigen &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">gsub</styled-content>(
                    <styled-content style="font-size:15px;color:#4F9905;">"-"</styled-content>, 
                    <styled-content style="font-size:15px;color:#4F9905;">"_"</styled-content>, 
                    <styled-content style="font-size:15px;color:#000000;">panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Antigen)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">panel_fcs &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">pData</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">parameters</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs_raw[[</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">]]))</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">head</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(panel_fcs)</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">##               name        desc   range  minRange maxRange
## $P1           Time        Time 2377271   0.00000  2377270
## $P2    Cell_length Cell_length      66   0.00000       65
## $P3 CD3(110:114)Dd         CD3    1212 -13.66756     1211
## $P4  CD45(In115)Dd        CD45    2654   0.00000     2653
## $P5   BC1(La139)Dd         BC1   13357   0.00000    13356
## $P6   BC2(Pr141)Dd         BC2      39 -66.97583       38</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;"># Replace problematic characters</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">panel_fcs</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">desc &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">gsub</styled-content>(
                    <styled-content style="font-size:15px;color:#4F9905;">"-"</styled-content>, 
                    <styled-content style="font-size:15px;color:#4F9905;">"_"</styled-content>, 
                    <styled-content style="font-size:15px;color:#000000;">panel_fcs</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">desc)</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;"># Lineage markers</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">(lineage_markers &lt;- panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Antigen[panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Lineage</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">==</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">])</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">##  [1] "CD3"    "CD45"    "CD4"    "CD20"    "CD33"    "CD123"    "CD14"
##  [8] "IgM"    "HLA_DR"  "CD7"</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;"># Functional markers</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">(functional_markers &lt;- panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Antigen[panel</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Functional</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">==</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">])</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">##  [1] "pNFkB"  "pp38"   "pStat5" "pAkt"   "pStat1" "pSHP2"  "pZap70"
##  [8] "pStat3" "pSlp76" "pBtk"   "pPlcg2" "pErk"   "pLat"   "pS6"</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;"># Spot checks</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(lineage_markers</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%in%</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">panel_fcs</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">desc)</styled-content>
</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">## [1] TRUE</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(functional_markers</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%in%</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">panel_fcs</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">desc)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">## [1] TRUE</styled-content>
                </preformat>
            </p>
        </sec>
        <sec>
            <title>Data transformation</title>
            <p>Usually, the raw marker intensities read by a cytometer have strongly skewed distributions with varying ranges of expression, thus making it difficult to distinguish between the negative and positive cell populations. It is common practice to transform CyTOF marker intensities using, for example, arcsinh (hyperbolic inverse sine) with cofactor 5 (
                <xref ref-type="bibr" rid="ref-5">Bendall 
                    <italic toggle="yes">et al.</italic>, 2011</xref> Figure S2; 
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>) to make the distributions more symmetric and to map them to a comparable range of expression, which is important for clustering. A cofactor of 150 has been promoted for flow cytometry, but users are free to implement alternative transformations, some of which are available from the 
                <monospace>transform</monospace> function of the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/flowCore">
                    <italic toggle="yes">flowCore</italic>
                </ext-link> package. In the following step, we include only those channels that correspond to the lineage and functional markers. We also rename the columns in the 
                <monospace>flowSet</monospace> to the antigen names from 
                <monospace>panel$desc</monospace>.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;">## arcsinh transformation and column subsetting</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">fcs &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fsApply</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs_raw,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cofactor=</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">){</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x) &lt;- panel_fcs</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">desc
  expr &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">exprs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x)
  expr &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">asinh</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr[,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(lineage_markers, functional_markers)]</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;"> /</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cofactor)</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">exprs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x) &lt;- expr
  x
})
fcs</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">## A flowSet with 16 experiments.
##
##   column names:
##   CD3 CD45 CD4 CD20 CD33 CD123 CD14 IgM HLA_DR CD7 pNFkB pp38 pStat5 pAkt pStat1 pSHP2 pZap70 pStat3 pSlp76 pBtk pPlcg2 pErk pLat pS6</styled-content>
                </preformat>
            </p>
            <p>For some of the further analysis, it is more convenient for us to work using a matrix (called 
                <monospace>expr</monospace>) that contains marker expression for cells from all samples. We create such a matrix with the 
                <monospace>fsApply</monospace> function that extracts the expression matrices (function 
                <monospace>exprs</monospace>) from each element of the 
                <monospace>flowSet</monospace> object, and by default, concatenates them into one matrix.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;">## Extract expression</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">expr &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fsApply</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs, exprs)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">dim</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr)

## [1] 172791       24</styled-content>
                </preformat>
            </p>
            <p>As the ranges of marker intensities can vary substantially, we apply another transformation that scales expression of all markers to values between 0 and 1 using low (e.g. 1%) and high (e.g. 99%) percentiles as the boundary. This additional transformation of the arcsinh-transformed data can sometimes give better representation of relative differences in marker expression between annotated cell populations, however, it is only used here for visualization.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(matrixStats)
rng &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colQuantiles</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">probs = c</styled-content>(
                    <styled-content style="font-size:15px;color:#0000B1;">0.01</styled-content>, 
                    <styled-content style="font-size:15px;color:#0000B1;">0.99</styled-content>))

                    <styled-content style="font-size:15px;color:#000000;">expr01 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">t</styled-content>((
                    <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">
                        <styled-content style="font-size:15px;color:#000000;">rng[,</styled-content>
                    </styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>]) 
                    <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">(rng[,</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>] 
                    <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">rng[,</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">]))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">expr01[expr01</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>] &lt;- 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">expr01[expr01</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">&gt;</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>] &lt;- 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
</preformat>
            </p>
        </sec>
        <sec>
            <title>Diagnostic plots</title>
            <p>We propose some quick checks to verify whether the data we analyze globally represents what we expect; for example, whether samples that are replicates of one condition are more similar and are distinct from samples from another condition. Another important check is to verify that marker expression distributions do not have any abnormalities such as having different ranges or distinct distributions for a subset of the samples. This could highlight problems with the sample collection or HDCyto acquisition, or batch effects that were unexpected. Depending on the situation, one can then consider removing problematic markers or samples from further analysis; in the case of batch effects, a covariate column could be added to the metadata table and used below in the statistical analyses.</p>
            <p>The step below generates a plot with per-sample marker expression distributions, colored by condition (see 
                <xref ref-type="fig" rid="f1">Figure 1</xref>). Here, we can already see distinguishing markers, such as pNFkB and CD20, between stimulated and unstimulated conditions.</p>
            <fig fig-type="figure" id="f1" orientation="portrait" position="float">
                <label>Figure 1. </label>
                <caption>
                    <title>Per-sample smoothed densities of marker expression (arcsinh-transformed) of 10 lineage markers and 14 functional markers in the PBMC dataset.</title>
                    <p>Two conditions: unstimulated (Ref) and stimulated with BCR/FcR-XL (BCRXL) for each of the 8 healthy donors are presented and colored by experimental condition.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure1.gif"/>
            </fig>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;">## Generate sample IDs corresponding to each cell in the 'expr' matrix</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">sample_ids &lt;- </styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">rep</styled-content>(md
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>sample_id, 
                    <styled-content style="font-size:15px;color:#214A87;">fsApply</styled-content>(fcs_raw, nrow))


                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>(ggplot2)

                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>(reshape2)

ggdf &lt;- 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">sample_id =</styled-content> sample_ids, expr)
ggdf &lt;- 
                    <styled-content style="font-size:15px;color:#214A87;">melt</styled-content>(ggdf, 
                    <styled-content style="font-size:15px;color:#214A87;">id.var =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"sample_id"</styled-content>,
  
                    <styled-content style="font-size:15px;color:#214A87;">value.name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"expression"</styled-content>, variable.name = 
                    <styled-content style="font-size:15px;color:#4F9905;">"antigen"</styled-content>)
mm &lt;- 
                    <styled-content style="font-size:15px;color:#214A87;">match</styled-content>(ggdf
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>sample_id, md
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>sample_id)
ggdf
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>condition &lt;- md
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>condition[mm]


                    <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>(ggdf, 
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> expression, 
                    <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> condition,
  
                    <styled-content style="font-size:15px;color:#214A87;">group =</styled-content> sample_id)) 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">geom_density</styled-content>() 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">facet_wrap</styled-content>(
                    <styled-content style="font-size:15px;color:#CF5C00;">~</styled-content> antigen, 
                    <styled-content style="font-size:15px;color:#214A87;">nrow =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">4</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">scales =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"free"</styled-content>) 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>() 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">axis.text.x = element_text</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">angle =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">90</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">hjust =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>),
    
                    <styled-content style="font-size:15px;color:#214A87;">strip.text = element_text</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>), 
                    <styled-content style="font-size:15px;color:#214A87;">axis.text = element_text</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>)) 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> color_conditions)</preformat>
            </p>
            <p>Another spot check is the number of cells per sample (see 
                <xref ref-type="fig" rid="f2">Figure 2</xref>). This plot can be used as a guide together with other readouts to identify samples where not enough cells were assayed.</p>
            <fig fig-type="figure" id="f2" orientation="portrait" position="float">
                <label>Figure 2. </label>
                <caption>
                    <title>Barplot showing the number of cells measured for each sample in the PBMC dataset.</title>
                    <p>Bars are colored by experimental condition: unstimulated (Ref) and stimulated with BCR/FcR-XL (BCRXL). Numbers in the names on the x-axis indicate patient IDs. Numbers on top of the bars indicate the cell counts.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure2.gif"/>
            </fig>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">cell_table &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(sample_ids)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">ggdf &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">sample_id = names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_table),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">cell_counts = as.numeric</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_table))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition &lt;- md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition[mm]</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggdf,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">sample_id,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_counts,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">condition))</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">geom_bar</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">stat =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"identity"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">geom_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">label =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_counts),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hjust=</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">vjust=</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">2.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">axis.text.x = element_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">angle =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">90</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">vjust =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hjust =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">scale_fill_manual</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_conditions,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">drop =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">scale_x_discrete</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">drop =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                </preformat>
            </p>
            <sec>
                <title>MDS plot</title>
                <p>In transcriptomics applications, one of the most utilized exploratory plots is the multi-dimensional scaling (MDS) plot or a principal component analysis (PCA) plot. Such plots show similarities between samples measured in an unsupervised way and give a sense of how much differential expression can be detected before conducting any formal tests. An MDS plot can be generated with the 
                    <monospace>plotMDS</monospace> function from the 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/limma">limma</ext-link>
                    </italic> package. In transcriptomics, distances between samples are calculated based on the expression of the top varying genes. We propose a similar plot for HDCyto data using median marker expression over all cells to calculate dissimilarities between samples (other aggregations are also possible, and one could reduce the number of top varying markers to include in the calculation). Ideally, samples should cluster well within the same condition, although this depends on the magnitude of the difference between experimental conditions. With this diagnostic, one can identify the outlier samples and eliminate them if the circumstances warrant it. In our MDS plot on median marker expression values (see 
                    <xref ref-type="fig" rid="f3">Figure 3</xref>), we can see that the first dimension (MDS1) separates the unstimulated and stimulated samples reasonably well. The second dimension (MDS2) represents, to some degree, differences between patients. Most of the samples that originate from the same patient are placed at a similar point along the y-axis, for example, samples from patients 7, 5, and 8 are at the top of the plot, samples from patient 4 are located at the bottom of the plot. This also indicates that the marker expression of individual patients is driving similarity and perhaps should be formally accounted for in the downstream statistical modeling.</p>
                <fig fig-type="figure" id="f3" orientation="portrait" position="float">
                    <label>Figure 3. </label>
                    <caption>
                        <title>MDS plot for the unstimulated (Ref) and stimulated with BCR/FcR-XL (BCRXL) samples obtained for each of the 8 healthy donors in the PBMC dataset.</title>
                        <p>Calculations are based on the median (arcsinh-transformed) marker expression of 10 lineage markers and 14 functional markers across all cells measured for each sample. Distances between samples in the plot approximate the typical change in medians. Numbers in the label names indicate patient IDs.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure3.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dplyr)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;"># Get the median marker expression per sample</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_tbl &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">sample_id =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_ids, expr)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(sample_id)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_tbl[,</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">])</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>(expr_median_sample) &lt;- expr_median_sample_tbl
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(limma)</styled-content>
mds &lt;- 
                        <styled-content style="font-size:15px;color:#214A87;">plotMDS</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">plot =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggrepel)</styled-content>
ggdf &lt;- 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">MDS1 =</styled-content> mds
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">x,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">MDS2 =</styled-content> mds
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">y,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">sample_id = colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample))</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>condition &lt;- md
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm]</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">= MDS1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">MDS2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>, 
                        <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0.8</styled-content>) 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_label_repel</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">label =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_id))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  coord_fixed</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content>
                    </preformat>
                </p>
                <p>In contrast to genomic applications, the number of variables measured for each sample is much lower in HDCyto data. In the former, thousands of genes are surveyed, whereas in the latter, ~20&#x2013;50 antigens are typically targeted. Similar to the MDS plot above, a heatmap of the same data also gives insight into the structure of the data. The heatmap shows median marker intensities with clustered columns (samples) and rows (markers). We have used hierarchical clustering with average linkage and euclidean distance, but also Ward&#x2019;s linkage could be used (
                    <xref ref-type="bibr" rid="ref-7">Bruggner 
                        <italic toggle="yes">et al.</italic>, 2014</xref>), and in CyTOF applications, a cosine distance shows good performance (
                    <xref ref-type="bibr" rid="ref-4">Bendall 
                        <italic toggle="yes">et al.</italic>, 2014</xref>). In this plot, we can see which markers drive the observed clustering of samples (see 
                    <xref ref-type="fig" rid="f4">Figure 4</xref>).</p>
                <fig fig-type="figure" id="f4" orientation="portrait" position="float">
                    <label>Figure 4. </label>
                    <caption>
                        <title>Heatmap of the median (arcsinh-transformed) marker expression of 10 lineage markers and 14 functional markers across all cells measured for each sample in the PBMC dataset.</title>
                        <p>Color-coded with yellow for lower expression and blue for higher expression. The numbers in the heatmap represent the actual expression values. Dendrograms present clustering of samples (columns) and markers (rows) which is based on hierarchical clustering with Euclidean distance metric and average linkage. The two conditions: unstimulated (Ref) and stimulated with BCR/FcR-XL (BCRXL) for each of the 8 healthy donors are presented with a bar colored by experimental condition on top of the heatmap. Numbers in the column label names indicate patient IDs.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure4.gif"/>
                </fig>
                <p>As with the MDS plot, the dendrogram separates the reference and stimulated samples very well. Also, similar groupings of patients within experimental conditions are observed (patients 1-2, 5-7-8 and 3-4 are together in both conditions).</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(RColorBrewer)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pheatmap)</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;"># Column annotation for the heatmap</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample), md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">annotation_col &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">condition =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">row.names = colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample))</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">annotation_colors &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">condition =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;"># Colors for the heatmap</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">color &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colorRampPalette</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">brewer.pal</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">n =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">9</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"YlGnBu"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">pheatmap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">display_numbers =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">number_color =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"black"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">fontsize_number =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">annotation_col =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">annotation_col,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">annotation_colors =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">annotation_colors,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">clustering_method =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"average"</styled-content>)</preformat>
                </p>
            </sec>
        </sec>
        <sec>
            <title>Marker ranking based on the non-redundancy score</title>
            <p>In this step, we identify the ability of markers to explain the variance observed in each sample. In particular, we calculate the PCA-based non-redundancy score (NRS) (
                <xref ref-type="bibr" rid="ref-21">Levine 
                    <italic toggle="yes">et al.</italic>, 2015</xref>). Markers with higher score explain a larger portion of variability present in a given sample.</p>
            <p>The average NRS can be used to select a subset of markers that are non-redundant in each sample but at the same time capture the overall diversity between samples. Such a subset of markers can be then used for cell population identification analysis (i.e. clustering). We note that there is no precise rule on how to choose the right cutoff for marker inclusion, but one of the approaches is to select a suitable number of the top-scoring markers. The number can be chosen by analyzing the plot with the NR scores (see 
                <xref ref-type="fig" rid="f5">Figure 5</xref>), where the markers are sorted by the decreasing average NRS. Based on the prior biological knowledge, one can refine the marker selection and drop out markers that are not likely to distinguish cell populations of interest, even if they have high scores, and add in markers with low scores but known to be important in discerning cell subgroups (
                <xref ref-type="bibr" rid="ref-21">Levine 
                    <italic toggle="yes">et al.</italic>, 2015</xref>). Thus, the NRS analysis serves more as a guide to marker selection and is not meant as a hardcoded rule.</p>
            <fig fig-type="figure" id="f5" orientation="portrait" position="float">
                <label>Figure 5. </label>
                <caption>
                    <title>Non-redundancy scores for each of the 10 lineage markers and all samples in the PBMC dataset.</title>
                    <p>The full points represent the per-sample NR scores (colored by experimental conditions), while empty black circles indicate the mean NR scores from all the samples. Markers on the x-axis are sorted according to the decreasing average NRS.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure5.gif"/>
            </fig>
            <p>In the dataset considered here (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>; 
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>) we want to use all the 10 lineage markers, so there is no explicit need to restrict the set of cell surface markers, and the NRS serve as another quality control step. There may be other situations where this feature selection step would be of interest, for example, in panel design (
                <xref ref-type="bibr" rid="ref-21">Levine 
                    <italic toggle="yes">et al.</italic>, 2015</xref>).</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;">## Define a function that calculates the NRS per sample</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">NRS &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">ncomp =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000CF;">3</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">){</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">pr &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">prcomp</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">center =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">scale. =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">score &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rowSums</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">outer</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">rep</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">ncol</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(x)),</styled-content>
    
                    <styled-content style="font-size:15px;color:#000000;">pr</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sdev[</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">ncomp]</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">^</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">*</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">abs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(pr</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">rotation[,</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">ncomp]))</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(score)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">## Calculate the score</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">nrs_sample &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fsApply</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs[, lineage_markers], NRS,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">use.exprs =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs_sample) &lt;- md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">nrs &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colMeans</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs_sample,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">na.rm =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">## Plot the NRS for ordered markers</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">lineage_markers_ord &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">sort</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">decreasing =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">nrs_sample &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs_sample)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">nrs_sample</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs_sample)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">ggdf &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">melt</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(nrs_sample,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">id.var =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"sample_id"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">value.name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"nrs"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">variable.name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"antigen"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  

                    <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">antigen &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">lineage_markers_ord)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition &lt;- md</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">condition[mm]</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggdf,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">nrs))</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">condition),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.9</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">position = position_jitter</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">width =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.3</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">height =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">geom_boxplot</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">outlier.color =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NA</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NA</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">stat_summary</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fun.y =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"mean"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">geom =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"point"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">shape =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">21</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"white"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">axis.text.x = element_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">angle =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">90</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">vjust =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hjust =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content>
                </preformat>
            </p>
        </sec>
        <sec>
            <title>Cell population identification with FlowSOM and ConsensusClusterPlus</title>
            <p>Cell population identification typically has been carried out by manual gating, a method based on visual inspection of a series of two-dimensional scatterplots. At each step, a subset of cells, either positive or negative for the two visualized markers, is selected and further stratified in the subsequent iterations until populations of interest across a range of marker combinations are captured. However, manual gating has drawbacks, such as subjectivity, bias toward well-known cell types, and inefficiency when analyzing large datasets, which also contribute to a lack of reproducibility (
                <xref ref-type="bibr" rid="ref-35">Saeys 
                    <italic toggle="yes">et al.</italic>, 2016</xref>).</p>
            <p>Considerable effort has been made to improve and automate cell population identification, such as unsupervised clustering (
                <xref ref-type="bibr" rid="ref-1">Aghaeepour 
                    <italic toggle="yes">et al.</italic>, 2013</xref>). However, not all methods scale well in terms of performance and speed from the lower dimensionality flow cytometry data to the higher dimensionality mass cytometry data (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>), since clustering in higher dimensions can suffer the &#x201c;curse of dimensionality&#x201d;.</p>
            <p>Beside the mathematical and algorithmic challenges of clustering, cell population identification may be difficult due to the chemical and biological aspects of the cytometry experiment itself. Therefore, caution should be taken when designing panels aimed at detecting rare cell populations by assigning higher sensitivity metals to rare markers. The right choice of a marker panel used for clustering can also be important. It should include all markers that are relevant for cell type identification.</p>
            <p>In this workflow, we conduct cell clustering with 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> (
                <xref ref-type="bibr" rid="ref-38">Van Gassen 
                    <italic toggle="yes">et al.</italic>, 2015</xref>) and 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ConsensusClusterPlus">
                    <italic toggle="yes">ConsensusClusterPlus</italic>
                </ext-link> (
                <xref ref-type="bibr" rid="ref-43">Wilkerson &amp; Hayes, 2010</xref>), which appeared amongst the fastest and best performing clustering approaches in a recent study of HDCyto datasets (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>). This ensemble showed strong performance in detecting both high and low frequency cell populations and is one of the fastest methods to run, which enables its interactive usage. We use a slight modification of the original workflow presented in the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> vignette, which we find more flexible. In particular, we directly call the 
                <monospace>ConsensusClusterPlus</monospace> function that is embedded in 
                <monospace>metaClustering_consensus</monospace>. Thus, we are able to access all the functionality of the 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/release/bioc/html/ConsensusClusterPlus">
                    <italic toggle="yes">ConsensusClusterPlus</italic>
                </ext-link> package to identify the number of clusters.</p>
            <p>The 
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> workflow consists of three main steps. First, a self-organizing map (SOM) is built using the 
                <monospace>BuildSOM</monospace> function, where cells are assigned according to their similarities to 100 (by default) grid points (or, so-called codebook vectors or codes) of the SOM. The building of a minimal spanning tree, which is mainly used for graphical representation of the clusters, is skipped in this pipeline. And finally, 
                <italic toggle="yes">metaclustering</italic> of the SOM codes, is performed directly with the 
                <monospace>ConsensusClusterPlus</monospace> function. Additionally, we add an optional round of manual expert-based merging of the metaclusters and allow this to be done in a reproducible fashion.</p>
            <p>
				
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                    <italic toggle="yes">FlowSOM</italic>
                </ext-link> output can be sensitive to random starts (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>). To make results reproducible, one must specify the seed for the random number generation in R using function 
                <monospace>set.seed.</monospace> It is also advisable to rerun analyses with multiple random seeds, for two reasons. First, one can see how robust the detected clusters are, and second, when the goal is to find smaller cell populations, it may happen that, in some runs, random starting points do not represent rare cell populations, as the chance of selecting starting cells from them is low and they are merged into a larger cluster.</p>
            <p>It is important to point out that we cluster all cells from all samples together. This strategy is beneficial, since we directly obtain cluster assignment for each cell, we label cell populations only once and the mapping of cell types between samples is automatically consistent. For a list of alternative approaches and their advantages and disadvantages, please refer to the 
                <xref ref-type="other" rid="D1">Discussion</xref> section, where we consider: clustering per sample, clustering of data from different measurement batches and down-sampling in case of widely varying numbers of cells per sample.</p>
            <p>In our analysis, cell populations are identified using only the 10 lineage markers as defined in the 
                <monospace>BuildSOM</monospace> function with the 
                <monospace>colsToUse</monospace> argument.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(FlowSOM)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">fsom &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">ReadInput</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fcs,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">transform =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">scale =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">set.seed</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1234</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">som &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">BuildSOM</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(fsom,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colsToUse =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">lineage_markers)</styled-content>

                    <styled-content style="font-size:15px;color:#8F5903;">## Get the cell clustering into 100 SOM codes</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">cell_clustering_som &lt;- som</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">map</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">mapping[,</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">]</styled-content>
                </preformat>
            </p>
            <p>Automatic approaches for selecting the number of clusters in HDCyto data do not always succeed (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>). In general, we therefore recommend some level of over-clustering, and if desired, manual merging of clusters. Such a hierarchical approach is especially suited when the goal is to detect smaller cell populations.</p>
            <p>The SPADE analysis performed by Bodenmiller 
                <italic toggle="yes">et al.</italic> (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>) identified 6 main cell types (T-cells, monocytes, dendritic cells, B-cells, NK cells and surface- cells) that were further stratified into 14 more specific subpopulations (CD4+ T-cells, CD8+ T-cells, CD14+ HLA-DR high monocytes, CD14+ HLA-DR med monocytes, CD14+ HLA-DR low monocytes, CD14- HLA-DR high monocytes, CD14- HLA-DR med monocytes, CD14- HLA-DR low monocytes, dendritic cells, IgM+ B-cells, IgM- B-cells, NK cells, surface- CD14+ cells and surface- CD14- cells). In our analysis, we are interested in identifying the 6 main PBMC populations, including: CD4+ T-cells, CD8+ T-cells, monocytes, dendritic cells, NK cells and B-cells. Following the concept of over-clustering we perform the metaclustering of the (by default) 100 SOM codes into more than expected number of groups. For example, stratification into 20 groups should give enough resolution to detect these main clusters. We can explore the clustering in a wide variety of visualizations: t-SNE plots, heatmaps and a plot generated by 
                <monospace>ConsensusClusterPlus</monospace> called &#x201c;delta area&#x201d;.</p>
            <p>When the interest is in studying more specific subpopulations at higher detail, one can follow a strategy of reclustering as described in the 
                <xref ref-type="other" rid="S4">Obtaining higher resolution</xref> section, where we propose to repeat the workflow (clustering and differential analyses) after gating out a selected cell type (e.g. one of the large populations).</p>
            <p>We call 
                <monospace>ConsensusClusterPlus</monospace> with maximum number of clusters 
                <monospace>maxK = 20</monospace> and other clustering parameters set to the values as in the 
                <monospace>metaClustering_consensus</monospace> function from the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">FlowSOM</ext-link>
                </italic> package. Again, to ensure that the analyses are reproducible, we define the random seed.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;">## Metaclustering into 20 clusters with ConsensusClusterPlus</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ConsensusClusterPlus)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">codes &lt;- som</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">map</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">codes</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">plot_outdir &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"consensus_plots"</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">nmc &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">20</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">mc &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">ConsensusClusterPlus</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(codes),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">maxK =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">nmc,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">reps =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">pItem =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.9</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">pFeature =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">title =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">plot_outdir,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">plot =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"png"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">clusterAlg =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"hc"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">innerLinkage =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"average"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">finalLinkage =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"average"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">distance =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"euclidean"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">seed =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1234</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">## Get cluster ids for each cell</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">code_clustering1 &lt;- mc[[nmc]]</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">consensusClass</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">cell_clustering1 &lt;- code_clustering1[cell_clustering_som]</styled-content>
                </preformat>
            </p>
            <p>We can then investigate characteristics of identified clusters with heatmaps that illustrate median marker expression in each cluster (see 
                <xref ref-type="fig" rid="f6">Figure 6</xref>). As the range of marker expression can vary substantially from marker to marker, we use the 0-1 transformed data (
                <monospace>expr01</monospace>) for some visualizations. However, to stay consistent with 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">FlowSOM</ext-link>
                </italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ConsensusClusterPlus">ConsensusClusterPlus</ext-link>
                </italic>, we use the (arcsinh-transformed) unscaled data (
                <monospace>expr</monospace>) to generate the dendrogram of the hierarchical structure of metaclusters.</p>
            <fig fig-type="figure" id="f6" orientation="portrait" position="float">
                <label>Figure 6. </label>
                <caption>
                    <title>Heatmap of the median marker intensities of the 10 lineage markers across the 20 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus (PBMC data).</title>
                    <p>The color in the heatmap represents the median of the arcsinh, 0-1 transformed marker expression calculated over cells from all the samples, varying from blue for lower expression to red for higher expression. The numbers indicate the actual expression values. The dendrogram on the left represents the hierarchical similarity between the 20 metaclusters (metric: Euclidean distance; linkage: average). Each cluster has a unique color assigned (bar on the left) which is identical in other visualizations of these 20 clusters (e.g. Figure t-SNE map in 10) facilitating the figure interpretation. Values in the brackets next to the cluster numbers indicate the relative size of clusters.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure6.gif"/>
            </fig>
            <p>Instead of using only medians, which do not give a full representation of cluster specifics, one can plot the entire marker expression distribution in each cluster (see 
                <xref ref-type="fig" rid="f7">Figure 7</xref>). Such a plot gives more detailed profile of each cluster, but represents an increase in the amount of information to interpret. Heatmaps give the overall overview of clusters, are quicker and easier to interpret, and together with the dendrogram can be a good basis for further cluster merging (see 
                <xref ref-type="other" rid="S5">Cluster merging and annotation</xref> section).</p>
            <fig fig-type="figure" id="f7" orientation="portrait" position="float">
                <label>Figure 7. </label>
                <caption>
                    <title>Distributions of marker intensities (arcsinh-transformed) of the 10 lineage markers in the 20 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus (PBMC data).</title>
                    <p>Red densities represent marker expression for cells in a given cluster. Green densities are calculated over all the cells and serve as a reference.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure7.gif"/>
            </fig>
            <p>Since we will use the heatmap and density plots again later on in this workflow, in code chunks below, we create wrapper functions that generate these two types of plots.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#8F5903;"># Define cluster colors (here there are 30 colors)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">color_clusters &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">c</styled-content>(
                    <styled-content style="font-size:15px;color:#4F9905;">"#DC050C"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#FB8072"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#1965B0"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#7BAFDE"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#882E72"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#4F9905;">"#B17BA6"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#FF7F00"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#FDB462"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#E7298A"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#E78AC3"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#4F9905;">"#33A02C"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#B2DF8A"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#55A1B1"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#8DD3C7"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#A6761D"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#4F9905;">"#E6AB02"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#7570B3"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#BEAED4"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#666666"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#999999"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#4F9905;">"#aa8282"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#d4b7b7"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#8600bf"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#ba5ce3"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#808000"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#4F9905;">"#aeae5c"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#1e90ff"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#00bfff"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#56ff0d"</styled-content>, 
                    <styled-content style="font-size:15px;color:#4F9905;">"#ffff00"</styled-content>)</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">plot_clustering_heatmap_wrapper &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr, expr01,</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering, color_clusters,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_merging =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">){</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate the median expression</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr_median &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr01_median &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate cluster frequencies</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">clustering_table &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">clustering_prop &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">round</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(clustering_table</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">sum</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(clustering_table)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">*</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Sort the cell clusters with hierarchical clustering</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">d &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">dist</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_median[,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr)],</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"euclidean"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hclust</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(d,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"average"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

  
                    <styled-content style="font-size:15px;color:#000000;">expr_heat &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">as.matrix</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median[,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01)])</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_heat) &lt;- expr01_median</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering</styled-content>
  
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Colors for the heatmap</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">color_heat &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colorRampPalette</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">rev</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">brewer.pal</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">n =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">9</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">
                        <styled-content style="font-size:15px;color:#4F9905;">"RdYlBu"</styled-content>
                    </styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)))(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">legend_breaks = </styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">seq</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">from =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">to =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">by =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">labels_row &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">" ("</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, clustering_prop ,</styled-content>
    
                    <styled-content style="font-size:15px;color:#4F9905;">"%)"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
     
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Annotation for the original clusters</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">annotation_row &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">Cluster = factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering))</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_heat)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">color_clusters1 &lt;- color_clusters[</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">nlevels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster)]</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(color_clusters1) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">annotation_colors &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">list</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">Cluster =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_clusters1)</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Annotation for the merged clusters</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">
                        <styled-content style="font-size:15px;color:#214A87;">if</styled-content>(</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">is.null</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging)){</styled-content>
    
                    <styled-content style="font-size:15px;color:#000000;">cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster)</styled-content>
    
                    <styled-content style="font-size:15px;color:#000000;">annotation_row</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster_merging &lt;- cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster</styled-content>
    
                    <styled-content style="font-size:15px;color:#000000;">color_clusters2 &lt;- color_clusters[</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">nlevels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster)]</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(color_clusters2) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster)</styled-content>
    
                    <styled-content style="font-size:15px;color:#000000;">annotation_colors</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster_merging &lt;- color_clusters2</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>

  
                    <styled-content style="font-size:15px;color:#214A87;">pheatmap</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_heat,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_heat,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_cols =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">cluster_rows =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">labels_row =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">labels_row,</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">display_numbers =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">number_color =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"black"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">8</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fontsize_number =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">6</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>  
                    <styled-content style="font-size:15px;color:#214A87;">legend_breaks =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">legend_breaks,</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">annotation_row =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">annotation_row,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">annotation_colors =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">annotation_colors)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">expr[, lineage_markers_ord],</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering1,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> color_clusters)</preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggridges)</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">plot_clustering_distr_wrapper &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr, cell_clustering){</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate the median expression</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr_median &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Sort the cell clusters with hierarchical clustering</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">d &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">dist</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_median[,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr)],</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">
                        <styled-content style="font-size:15px;color:#4F9905;">"euclidean"</styled-content>
                    </styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
 
                    <styled-content style="font-size:15px;color:#000000;"> cluster_rows &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hclust</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(d,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "average"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate cluster frequencies</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">freq_clust &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">freq_clust &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">round</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(freq_clust)</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">sum</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(freq_clust)</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">*</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF;"> 2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)
 cell_clustering &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">labels = paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering),</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "  ("</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, freq_clust,</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "%)"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;">### Data organized per cluster</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">melt</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">cluster =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering, expr),</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">id.vars =</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "cluster"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">value.name =</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "expression"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">variable.name =</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;"> "antigen"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">antigen &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggd</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels = colnames</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">reference &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"no"</styled-content>
  
                    <styled-content style="font-size:15px;color:#8F5903;">### The reference data</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd_bg &lt;- ggd</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd_bg</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cluster &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"reference"</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd_bg</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">reference &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"yes"</styled-content>
 
  
                    <styled-content style="font-size:15px;color:#000000;">ggd_plot &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rbind</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggd, ggd_bg)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ggd_plot</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cluster &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ggd_plot</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cluster,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">levels = c</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)[</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">rev</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_rows</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">order)],</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"reference"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

  
                    <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">geom_density_ridges</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">data =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ggd_plot,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">expression,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cluster,</styled-content>
     
                    <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">reference,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">reference),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.3</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">facet_wrap</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">~</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;"> scales = </styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;">"free_x"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">nrow =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;"> +</styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">theme_ridges</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">()</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;"> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
                    </styled-content>
   
                    <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">axis.text = element_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">size = </styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>  
     
                    <styled-content style="font-size:15px;color:#214A87;">strip.text = element_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">size = </styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">legend.position =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"none"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">plot_clustering_distr_wrapper</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">expr = </styled-content>
                    <styled-content style="font-size:15px;color:#000000;">expr[, lineage_markers_ord],</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering = </styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering1)</styled-content>
                </preformat>
            </p>
            <p>In addition to investigating expression of the lineage markers, we can also have a look at expression of the functional markers. We propose a heatmap that depicts median expression of functional markers in each sample (see 
                <xref ref-type="fig" rid="f8">Figure 8</xref>) so the potential differential expression can be investigated already at this data exploration step before the formal testing is done. In order to plot all the heatmaps in one panel, we use the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ComplexHeatmap">ComplexHeatmap</ext-link>
                </italic> package. Again, we created a wrapper function that does all the plotting and can be reused through the workflow.</p>
            <fig fig-type="figure" id="f8" orientation="portrait" position="float">
                <label>Figure 8. </label>
                <caption>
                    <title>Heatmap of the median marker intensities of the 10 lineage markers and one signaling marker (pS6) across the 20 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus (PBMC data).</title>
                    <p>This plot was generated using ComplexHeatmaps. The left panel presents a heatmap analogous to the one in 
                        <xref ref-type="fig" rid="f6">Figure 6</xref>, additionally, it contains a barplot along the rows (clusters) which represents the relative sizes of clusters. Heatmap on the right represents the median of the arcsinh, 0-1 transformed marker expression for a signaling marker pS6 calculated over cells in each sample (columns) individually.</p>
                </caption>
                <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure8.gif"/>
            </fig>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(ComplexHeatmap)</styled-content>


                    <styled-content style="font-size:15px;color:#000000;">plot_clustering_heatmap_wrapper2 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr, expr01,</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">lineage_markers,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">functional_markers =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>, 
                    <styled-content style="font-size:15px;color:#214A87;">sample_ids =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering, color_clusters,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_merging =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">plot_cluster_annotation =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">){</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate the median expression of lineage markers</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr_median &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr[, lineage_markers],</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr01_median &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01[, lineage_markers],</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>(
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Calculate cluster frequencies</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">clustering_table &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cell_clustering))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">clustering_prop &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">round</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(clustering_table</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">sum</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(clustering_table)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">*</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Sort the cell clusters with hierarchical clustering</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">d &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">dist</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_median[, lineage_markers],</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"euclidean"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">hclust</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(d,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"average"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>

  
                    <styled-content style="font-size:15px;color:#000000;">expr_heat &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">as.matrix</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median[, lineage_markers])</styled-content>

  
                    <styled-content style="font-size:15px;color:#8F5903;"># Median expression of functional markers in each sample per cluster</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster_tbl &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01[, functional_markers,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">drop =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">],</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">sample_id =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">sample_ids,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(sample_id, cluster)</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>
  
  
                    <styled-content style="font-size:15px;color:#8F5903;"># Colors for the heatmap</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">color_heat &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">colorRampPalette</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">rev</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">brewer.pal</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">n =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">9</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"RdYlBu"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)))(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">legend_breaks =</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">seq</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">from =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">to =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">by =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">labels_row &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">" ("</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">, clustering_prop ,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"%)"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
  

                    <styled-content style="font-size:15px;color:#8F5903;">### Annotation for the original clusters</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">annotation_row1 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">Cluster = factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr01_median</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">cell_clustering))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">color_clusters1 &lt;- color_clusters[</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">nlevels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster)]</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(color_clusters1) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster)</styled-content>



                    <styled-content style="font-size:15px;color:#8F5903;">### Annotation for the merged clusters</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">is.null</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging)){</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster, cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">original_cluster)</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">annotation_row2 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">Cluster_merging =</styled-content>
      
                    <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">new_cluster[mm]))</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">color_clusters2 &lt;- color_clusters[</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">nlevels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row2</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster_merging)]</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(color_clusters2) &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">levels</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row2</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">Cluster_merging)</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>



                    <styled-content style="font-size:15px;color:#8F5903;">### Heatmap annotation for the original clusters</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ha1 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">Heatmap</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row1,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"Cluster"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_clusters1,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_columns =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">cluster_rows =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">row_dend_reorder =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">show_row_names =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">width = unit</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"cm"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">rect_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"grey"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                    <styled-content style="font-size:15px;color:#8F5903;">### Heatmap annotation for the merged clusters</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">is.null</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging)){</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">ha2 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">Heatmap</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(annotation_row2,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"Cluster \nmerging"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_clusters2,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_columns =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">cluster_rows =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">row_dend_reorder =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">show_row_names =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">width = unit</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">0.5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"cm"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">rect_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"grey"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>

                    <styled-content style="font-size:15px;color:#8F5903;">### Cluster names and sizes - text</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ha_text &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rowAnnotation</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">text = row_anno_text</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(labels_row,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">6</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">)),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">width = max_text_width</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(labels_row))</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">### Cluster sizes - barplot</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ha_bar &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">rowAnnotation</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#4F9905;">"Frequency (%)"</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">=</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">row_anno_barplot</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">clustering_prop,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">border =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">axis =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">axis_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#696969"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"#696969"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">bar_width =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0.9</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">width = unit</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">0.7</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"cm"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">show_annotation_name =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">annotation_name_rot =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">annotation_name_offset = unit</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"mm"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">annotation_name_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                    <styled-content style="font-size:15px;color:#8F5903;">### Heatmap for the lineage markers</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">ht1 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">Heatmap</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(expr_heat,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"Expr"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">column_title =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"Lineage markers"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">color_heat,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_columns =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">cluster_rows =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">cluster_rows,</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">row_dend_reorder =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">heatmap_legend_param = list</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">at =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">legend_breaks,</styled-content>
    
                    <styled-content style="font-size:15px;color:#214A87;">labels =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">legend_breaks,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">color_bar =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"continuous"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">show_row_names =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">row_dend_width = unit</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"cm"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">rect_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">col =</styled-content> 
                    <styled-content style="font-size:15px;color:#4F9905;">"grey"</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">column_names_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">8</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">))</styled-content>


                    <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(plot_cluster_annotation){</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">draw_out &lt;- ha1</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">else</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">{</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">draw_out &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">is.null</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(cluster_merging)){</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">draw_out &lt;- draw_out</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ha2</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ht1</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ha_bar</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ha_text</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">else</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">{</styled-content>
  
                    <styled-content style="font-size:15px;color:#000000;">draw_out &lt;- draw_out</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ht1</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ha_bar</styled-content> 
                    <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                    <styled-content style="font-size:15px;color:#000000;">ha_text</styled-content>

                    <styled-content style="font-size:15px;color:#000000;">}</styled-content>


                    <styled-content style="font-size:15px;color:#8F5903;">### Heatmaps for the signaling markers</styled-content>

                    <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">is.null</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(functional_markers)){</styled-content>
  
                    <styled-content style="font-size:15px;color:#214A87;">for</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(i</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87;">in</styled-content> 
                    <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                    <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                    <styled-content style="font-size:15px;color:#214A87;">length</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">(functional_markers)){</styled-content>
    
                    <styled-content style="font-size:15px;color:#8F5903;">## Rearange so the rows represent clusters</styled-content>
    
                    <styled-content style="font-size:15px;">expr_heat_fun &lt;- </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">as.matrix</styled-content>
                    <styled-content style="font-size:15px;">(</styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">dcast</styled-content>
                    <styled-content style="font-size:15px;">(expr_median_sample_cluster_tbl[,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     c</styled-content>
                    <styled-content style="font-size:15px;">(</styled-content>
                    <styled-content style="color:#4F9905;font-size:15px;">"sample_id"</styled-content>
                    <styled-content style="font-size:15px;">, </styled-content>
                    <styled-content style="color:#4F9905;font-size:15px;">"cluster"</styled-content>
                    <styled-content style="font-size:15px;">,</styled-content> 
                    <styled-content style="font-size:15px;">functional_markers[i])],</styled-content>

                    <styled-content style="font-size:15px;">     cluster</styled-content> 
                    <styled-content style="color:#CF5C00;font-size:15px;">~</styled-content>
                    <styled-content style="font-size:15px;"> sample_id, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">value.var = </styled-content>
                    <styled-content style="font-size:15px;">functional_markers[i])[, </styled-content>
                    <styled-content style="color:#CF5C00;font-size:15px;">-</styled-content>
                    <styled-content style="color:#0000CF;font-size:15px;">1</styled-content>])

                    <styled-content style="font-size:15px;">   draw_out &lt;- draw_out </styled-content>
                    <styled-content style="color:#CF5C00;font-size:15px;">+ </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">Heatmap</styled-content>
                    <styled-content style="font-size:15px;">(expr_heat_fun,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     column_title = </styled-content>
                    <styled-content style="font-size:15px;">functional_markers[i], </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">col = </styled-content>
                    <styled-content style="font-size:15px;">color_heat,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     cluster_columns = </styled-content>
                    <styled-content style="color:#8F5903;font-size:15px;">FALSE</styled-content>
                    <styled-content style="font-size:15px;">, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">cluster_rows = </styled-content>
                    <styled-content style="font-size:15px;">cluster_rows,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     row_dend_reorder = </styled-content>
                    <styled-content style="color:#8F5903;font-size:15px;">FALSE</styled-content>
                    <styled-content style="font-size:15px;">, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">show_heatmap_legend = </styled-content>
                    <styled-content style="color:#8F5903;font-size:15px;">FALSE</styled-content>
                    <styled-content style="font-size:15px;">,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     show_row_names = </styled-content>
                    <styled-content style="color:#8F5903;font-size:15px;">FALSE</styled-content>
                    <styled-content style="font-size:15px;">, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">rect_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;">(</styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">col =</styled-content> 
                    <styled-content style="color:#4F9905;font-size:15px;">"grey"</styled-content>
                    <styled-content style="font-size:15px;">),</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">     column_names_gp = gpar</styled-content>
                    <styled-content style="font-size:15px;">(</styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">fontsize =</styled-content> 
                    <styled-content style="color:#0000CF;font-size:15px;">8</styled-content>
                    <styled-content style="font-size:15px;">))
  }
 }</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;"> draw</styled-content>
                    <styled-content style="font-size:15px;">(draw_out, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">row_dend_side = </styled-content>
                    <styled-content style="color:#4F9905;font-size:15px;">"left"</styled-content>
                    <styled-content style="font-size:15px;">)</styled-content>

                    <styled-content style="font-size:15px;">}</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">plot_clustering_heatmap_wrapper2</styled-content>
                    <styled-content style="font-size:15px;">(</styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">expr = </styled-content>
                    <styled-content style="font-size:15px;">expr, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">expr01 = </styled-content>
                    <styled-content style="font-size:15px;">expr01,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">  lineage_markers = </styled-content>
                    <styled-content style="font-size:15px;">lineage_markers, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">functional_markers = </styled-content>
                    <styled-content style="color:#4F9905;font-size:15px;">"pS6"</styled-content>,

                    <styled-content style="color:#214A87;font-size:15px;">  sample_ids = </styled-content>
                    <styled-content style="font-size:15px;">sample_ids, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">cell_clustering = </styled-content>
                    <styled-content style="font-size:15px;">cell_clustering1,</styled-content>

                    <styled-content style="color:#214A87;font-size:15px;">  color_clusters = </styled-content>
                    <styled-content style="font-size:15px;">color_clusters, </styled-content>
                    <styled-content style="color:#214A87;font-size:15px;">cluster_merging = </styled-content>
                    <styled-content style="color:#8F5903;font-size:15px;">NULL</styled-content>
                    <styled-content style="font-size:15px;">)</styled-content>
                </preformat>
            </p>
            <sec>
                <title>Visual representation with t-SNE</title>
                <p>One of the most popular plots for representing single cell data are t-SNE plots, where each cell is represented in a lower, usually two-dimensional, space computed using t-stochastic neighbor embedding (t-SNE) (
                    <xref ref-type="bibr" rid="ref-37">Van Der Maaten &amp; Hinton, 2008</xref>). More generally, dimensionality reduction techniques represent the similarity of points in 2 or 3 dimensions, such that similar objects in high dimensional space are also similar in lower dimensional space. Mathematically, there are a myriad of ways to define this similarity. For example, principal components analysis (PCA) uses linear combinations of the original features to find orthogonal dimensions that show the highest levels of variability; the top 2 or 3 principal components can then be visualized.</p>
                <p>Nevertheless, there are few notes of caution when using t-SNE or any other dimensionality reduction technique. Since they are based on preserving similarities between cells, those that are similar in the original space will be close in the 2D/3D representation, but the opposite does not always hold. In our experience, t-SNE with default parameters for HDCyto data is often suitable; for more guidance on the specifics of t-SNE, see 
                    <ext-link ext-link-type="uri" xlink:href="http://distill.pub/2016/misread-tsne/">How to Use t-SNE Effectively</ext-link> (
                    <xref ref-type="bibr" rid="ref-41">Wattenberg 
                        <italic toggle="yes">et al.</italic>, 2016</xref>). Due to the stochastic nature of t-SNE optimization, rerunning the method will result in different lower dimensional projections, thus it is advisable to run it a few times to identify the common trends and get a feeling about the variability of the results. As with other methods, to be sure that the analysis is reproducible, the user can define the random seed.</p>
                <p>t-SNE is a method that requires significant computational time to process the data even for tens of thousands of cells. CyTOF datasets are usually much larger and thus to keep running times reasonable, one may use a subset of cells; for example, here we use 2000 cells from each sample. The t-SNE map below is colored according to the expression level of the CD4 marker, highlighting that the CD4+ T-cells are placed to the left side of the plot (see 
                    <xref ref-type="fig" rid="f9">Figure 9</xref>). In this way, one can use a collection of markers to highlight where cell types of interest are located on the 
                    <italic toggle="yes">map</italic>.</p>
                <fig fig-type="figure" id="f9" orientation="portrait" position="float">
                    <label>Figure 9. </label>
                    <caption>
                        <title>t-SNE plot based on the arcsinh-transformed expression of the 10 lineage markers in the cells from the PBMC dataset.</title>
                        <p>t-SNE was run with no PCA step, perplexity equal to 30 and 1000 iterations. From each of the 16 samples, 2000 cells were randomly selected. Cells are colored according to the expression level of the CD4 marker.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure9.gif"/>
                </fig>
                <p>Instead of t-SNE, one could also use other dimension reduction techniques, such as PCA, diffusion maps, SIMLR (
                    <xref ref-type="bibr" rid="ref-40">Wang 
                        <italic toggle="yes">et al.</italic>, 2017</xref>) or isomaps, some of which are conveniently available via the 
                    <monospace>cytof_dimReduction</monospace> function from the 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/cytofkit">cytofkit</ext-link>
                    </italic> package (
                    <xref ref-type="bibr" rid="ref-8">Chen 
                        <italic toggle="yes">et al.</italic>, 2016</xref>). To speed up the t-SNE analysis, one could use a multicore version that is available via the 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="https://github.com/RGLab/Rtsne.multicore">Rtsne.multicore</ext-link>
                    </italic> package. Alternative algorithms, such as 
                    <monospace>largeVis</monospace> (
                    <xref ref-type="bibr" rid="ref-36">Tang 
                        <italic toggle="yes">et al.</italic>, 2016</xref>) (available via the 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="https://github.com/elbamos/largeVis">largeVis</ext-link>
                    </italic> package), can be used for dimensionality reduction of very large datasets without downsampling. Alternatively, the dimensionality reduction can be performed on the 
                    <italic toggle="yes">codes</italic> of the SOM, at a resolution (size of the SOM) specified by the user (see 
                    <xref ref-type="fig" rid="f13">Figure 13</xref>).</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Find and skip duplicates</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">dups &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">which</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">!</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">duplicated</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr[, lineage_markers]))</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;">## Data subsampling: create indices by sample</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">inds &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">split</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">length</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(sample_ids), sample_ids)</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;">## How many cells to downsample per-sample</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">tsne_ncells &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">pmin</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(sample_ids),</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2000</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;">## Get subsampled indices</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">set.seed</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">1234</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">tsne_inds &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">lapply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(inds),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(i){</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">s &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">sample</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(inds[[i]], tsne_ncells[i],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">replace =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">intersect</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(s, dups)
})</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">tsne_inds &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">unlist</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(tsne_inds)

tsne_expr &lt;- expr[tsne_inds, lineage_markers]</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Run t-SNE</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(Rtsne)</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">set.seed</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">1234</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">tsne_out &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">Rtsne</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(tsne_expr,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">check_duplicates =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">pca =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Plot t-SNE colored by CD4 expression</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">dr &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">tSNE1 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tsne_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">Y[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">tSNE2 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tsne_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">Y[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],
  expr[tsne_inds, lineage_markers])</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">CD4)) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_gradientn</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"CD4"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">colours = colorRampPalette</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">rev</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">brewer.pal</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">n =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">11</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">name =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"Spectral"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)))(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">50</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>
                    </preformat>
                </p>
                <p>We can color the cells by cluster. Ideally, cells of the same color should be close to each other (see 
                    <xref ref-type="fig" rid="f10">Figure 10</xref>). When the plots are further stratified by sample (see 
                    <xref ref-type="fig" rid="f11">Figure 11</xref>), we can verify whether similar cell populations are present in all replicates, which can help in identifying outlying samples. Optionally, stratification can be done by condition (see 
                    <xref ref-type="fig" rid="f12">Figure 12</xref>). With such a spot-check plot, we can inspect whether differences in cell abundance are strong between conditions, and we can visualize and identify distinguishing clusters before applying formal statistical testing. A similar approach of data exploration was proposed in studies of treatment-specific differences of polyfunctional antigen-specific T-cells (
                    <xref ref-type="bibr" rid="ref-24">Lin 
                        <italic toggle="yes">et al.</italic>, 2015</xref>).</p>
                <fig fig-type="figure" id="f10" orientation="portrait" position="float">
                    <label>Figure 10. </label>
                    <caption>
                        <title>t-SNE plot based on the arcsinh-transformed expression of the 10 lineage markers in the cells from the PBMC dataset.</title>
                        <p>From each of the 16 samples, 2000 cells were randomly selected. Cells are colored according to the 20 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure10.gif"/>
                </fig>
                <fig fig-type="figure" id="f11" orientation="portrait" position="float">
                    <label>Figure 11. </label>
                    <caption>
                        <title>t-SNE plot as in the 
                            <xref ref-type="fig" rid="f10">Figure 10</xref>, but stratified by sample.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure11.gif"/>
                </fig>
                <fig fig-type="figure" id="f12" orientation="portrait" position="float">
                    <label>Figure 12. </label>
                    <caption>
                        <title>t-SNE plot as in the 
                            <xref ref-type="fig" rid="f10">Figure 10</xref>, but stratified by condition.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure12.gif"/>
                </fig>
                <fig fig-type="figure" id="f13" orientation="portrait" position="float">
                    <label>Figure 13. </label>
                    <caption>
                        <p>The 100 SOM codes in the PBMC dataset colored according to the metaclustering with ConsensusClusterPlus into 20 cell populations presented after the dimension reduction with (
                            <bold>A</bold>) t-SNE and (
                            <bold>B</bold>) PCA. The SOM codes represent characteristics of the 100 (by default) clusters generated in the first step of the FlowSOM pipeline. The size of the points corresponds to the number of cells that were assigned to a given code.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure13.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id &lt;- sample_ids[tsne_inds]
mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)
dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition &lt;- md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm]
dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cell_clustering1[tsne_inds],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">nmc)</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;">## Plot t-SNE colored by clusters</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ncol =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggp</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Facet per sample</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">~</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Facet per condition</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">~</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition)</styled-content>
                    </preformat>
                </p>
                <p>The SOM codes represent characteristics of the 100 (by default) clusters generated in the first step of the 
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                        <italic toggle="yes">FlowSOM</italic>
                    </ext-link> pipeline. Their visualization can also be helpful in understanding the cell population structure and determining the number of clusters. Ultimately, the metaclustering step uses the codes and not the original cells. We treat the codes as new representative cells and apply the t-SNE dimension reduction to visualize them in 2D (see 
                    <xref ref-type="fig" rid="f13">Figure 13</xref>). The size of the points corresponds to the number of cells that were assigned to a given code. The points are colored according to the results of metaclustering. Since we have only 100 data points, the t-SNE analysis is fast.</p>
                <p>As there are multiple ways to mathematically define similarity in high dimensional space, it is always good practice visualizing projections from other methods to see how consistent the observed patterns are. For instance, we also represent the 
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                        <italic toggle="yes">FlowSOM</italic>
                    </ext-link> codes via the first two principal components (see 
                    <xref ref-type="fig" rid="f13">Figure 13</xref>).</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Get code sizes; sometimes not all the codes have mapped cells so they will have size 0</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">code_sizes &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(som</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">map</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">mapping[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">nrow</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(codes)))
code_sizes &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(code_sizes)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Run t-SNE on codes</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">set.seed</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">1234</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)
tsne_out &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">Rtsne</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(codes,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">perplexity =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">5</styled-content>, 
                        <styled-content style="font-size:15px;color:#214A87;">pca =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Run PCA on codes</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">pca_out &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">prcomp</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(codes,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">center =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">scale. =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">codes_dr &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">tSNE1 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tsne_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">Y[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">tSNE2 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tsne_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">Y[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">PCA1 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">pca_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">x[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">PCA2 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">pca_out</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">x[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">])
codes_dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">code_clustering1 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(code_clustering1)
codes_dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">size &lt;- code_sizes</styled-content>


                        <styled-content style="font-size:15px;color:#8F5903;">## Plot t-SNE on codes</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">gg_tsne_codes &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(codes_dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">code_clustering1, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">size))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.9</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters</styled-content>) 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ncol =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Plot PCA on codes</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">gg_pca_codes &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(codes_dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">PCA1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">PCA2,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">code_clustering1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">size))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.9</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ncol =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>  
  
                        <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">legend.position =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"right"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">legend.box =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"vertical"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>


                        <styled-content style="font-size:15px;color:#214A87;">library</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cowplot)</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">legend &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">get_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(gg_tsne_codes)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">ggdraw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">draw_plot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(gg_tsne_codes</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">legend.position =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"none"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">draw_plot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(gg_pca_codes</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">legend.position =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"none"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">draw_plot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(legend, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">draw_plot_label</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"A"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"B"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">""</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">7</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, .</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">15</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
</preformat>
                </p>
                <p>Using heatmaps, we can also visualize median marker expression in the 100 SOM codes as in 
                    <xref ref-type="fig" rid="f14">Figure 14</xref>. Of note, the clustering presented with the dendrogram does not completely agree with the clustering depicted by the 20 colors because the first one is based on the hierarchical clustering with average linkage and Euclidean distance, while the second one results from the consensus clustering.</p>
                <fig fig-type="figure" id="f14" orientation="portrait" position="float">
                    <label>Figure 14. </label>
                    <caption>
                        <title>Heatmap of the median marker intensities of the 10 lineage markers (left panel) and one signaling marker pS6 (right panel) across the 100 SOM codes in the PBMC dataset.</title>
                        <p>The color in the heatmap represents the median of the arcsinh, 0-1 transformed marker expression calculated over cells from all the samples, for the lineage markers, and over cells in each sample individually, for the signaling marker. The heat varies from blue for lower expression to red for higher expression. The dendrogram on the left represents the hierarchical similarity between the 100 codes (metric: Euclidean distance; linkage: average). The annotation bar on the left is colored according to the code metaclustering with ConsensusClusterPlus into 20 cell populations. The relative size of the codes is presented with the barplot along the rows and in the brackets next to the cluster numbers.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure14.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">lineage_markers =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">lineage_markers,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">functional_markers =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"pS6"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">sample_ids =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_ids,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering_som,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters = rep</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(color_clusters,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">length.out =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">cluster_merging = data.frame</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">original_cluster =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">100</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
   
                        <styled-content style="font-size:15px;color:#214A87;">new_cluster =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">code_clustering1),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">plot_cluster_annotation =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
</preformat>
                </p>
            </sec>
            <sec id="S5">
                <title>Cluster merging and annotation</title>
                <p>In our experience, manual merging of clusters leads to slightly different results compared to an algorithm with a specified number of clusters. In order to detect somewhat rare populations, some level of over-clustering is necessary so that the more subtle populations become separated from the main populations. In addition, merging can always follow an over-clustering step, but splitting of existing clusters is not generally feasible. In our setup, over-clustering is also useful when the interest is identifying the &#x201c;natural&#x201d; number of clusters present in the data. In addition to the t-SNE plots, one could investigate the delta area plot from the 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ConsensusClusterPlus">ConsensusClusterPlus</ext-link>
                    </italic> package and the hierarchical clustering dendrogram of the over-clustered subpopulations, as shown in 
                    <xref ref-type="fig" rid="f16">Figure 16</xref> and 
                    <xref ref-type="fig" rid="f18">Figure 18</xref>, respectively.</p>
                <p>In our example, we expect around 6 specific cell types, and we have performed 
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">
                        <italic toggle="yes">FlowSOM</italic>
                    </ext-link> clustering into 20 groups as a reasonable over-estimate. After analyzing the heatmaps (
                    <xref ref-type="fig" rid="f6">Figure 6</xref>) and t-SNE plots (
                    <xref ref-type="fig" rid="f10">Figure 10</xref>), we can clearly see that stratification of the data into 20 clusters may be too strong. In the t-SNE map, many clusters are placed very close to each other, indicating that they could be merged together. The same can be deduced from the heatmaps, highlighting that marker expression patterns for some neighboring clusters are very similar. Cluster merging and annotating is somewhat manual, based partially on visual inspection of t-SNE plots and heatmaps and thus, benefits from expert knowledge of the cell types.</p>
                <p>
                    <bold>
                        <italic toggle="yes">Manual cluster merging and annotating based on heatmaps.</italic>
                    </bold> In our experience, the main reference for manual merging of clusters is the heatmap of marker characteristics across metaclusters (e.g. 
                    <xref ref-type="fig" rid="f6">Figure 6</xref>), with dendrograms showing the hierarchy of similarities. Such plots aggregate information over many cells and thus show average marker expression for each cluster. Together with dimensionality reduction, these plots give good insight into the relationships between clusters and the marker levels within each cluster. Given expert knowledge of the cell types and markers, it is then left to the researcher to decide how exactly to merge clusters (e.g. with higher weight given to some markers).</p>
                <p>The dendrogram highlights the similarity between the metaclusters and can be used explicitly for the merging. However, there are reasons why we would not always follow the dendrogram exactly. In general, when it comes to clustering, blindly following the hierarchy of codes will lead to identification of populations of similar cells, but it does not necessarily mean that they are of biological interest. The distances between metaclusters are calculated across all the markers, and it may be that some markers carry higher weight for certain cell types. In addition, different linkage methods may lead to different hierarchy, especially when clusters are not fully distinct. Another aspect to consider in cluster merging is the cluster size, represented in the parentheses next to the cluster label in our plots. If the cluster size is very small, but the cluster seems relevant and distinct, one can keep it as separate. However, if it is small and different from the neighboring clustering only in a somewhat unimportant marker, it could be merged. And, if some of the metaclusters do not represent any specific cell types, they could be dropped out of the downstream analysis instead of being merged. However, in case an automated solution for cluster merging is truly needed, one could use the 
                    <monospace>cutree()</monospace> function applied to the dendrogram.</p>
                <p>Based on the seed that was set, cluster merging of the 20 metaclusters is defined in the PBMC8_cluster_merging1.xlsx file on the 
                    <ext-link ext-link-type="uri" xlink:href="http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow/">Robinson Lab server</ext-link> with the IDs of the original clusters and new cluster names, and we save it as a 
                    <monospace>cluster_merging1</monospace> data frame. The expert has annotated 8 cell populations: CD8 T-cells, CD4 T-cells, B-cells IgM-, B-cells IgM+, NK cells, dendritic cells (DCs), monocytes and surface negative cells; monocytes could be further subdivided based on HLA-DR into high, medium and low subtypes.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1_filename &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"PBMC8_cluster_merging1.xlsx"</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">download.file</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(url,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"/"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, cluster_merging1_filename),</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">destfile =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1_filename,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">mode =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"wb"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">read_excel</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging1_filename)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging1)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##      original_cluster  new_cluster
## 1                   1 B-cells IgM+
## 2                   2     surface-
## 3                   3     NK cells
## 4                   4  CD8 T-cells
## 5                   5 B-cells IgM-
## 6                   6    monocytes
## 7                   7    monocytes
## 8                   8  CD8 T-cells
## 9                   9  CD8 T-cells
## 10                 10    monocytes
## 11                 11    monocytes
## 12                 12  CD4 T-cells
## 13                 13           DC
## 14                 14  CD8 T-cells
## 15                 15  CD4 T-cells
## 16                 16           DC
## 17                 17  CD4 T-cells
## 18                 18  CD4 T-cells
## 19                 19  CD4 T-cells
## 20                 20  CD4 T-cells</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Convert to factor with merged clusters in desired order</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">levels_clusters_merged &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"B-cells IgM+"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"B-cells IgM-"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"CD4 T-cells"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                        <styled-content style="font-size:15px;color:#4F9905;">"CD8 T-cells"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"DC"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"NK cells"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"monocytes"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"surface-"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">levels_clusters_merged)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## New clustering1m</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cell_clustering1,</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">original_cluster)
cell_clustering1m &lt;- cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster[mm]</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(code_clustering1, cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">original_cluster)
code_clustering1m &lt;- cluster_merging1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster[mm]</styled-content>
                    </preformat>
                </p>
                <p>We update the t-SNE plot with the new annotated cell populations, 
                    <xref ref-type="fig" rid="f15">Figure 15</xref>.</p>
                <fig fig-type="figure" id="f15" orientation="portrait" position="float">
                    <label>Figure 15. </label>
                    <caption>
                        <title>t-SNE plot for the PBMC dataset, where cells are colored according to the manual merging of the 20 cell populations, obtained with FlowSOM, into 8 PBMC populations.</title>
                        <p>As in 
                            <xref ref-type="fig" rid="f10">Figure 10</xref>, t-SNE analysis uses the arcsinh-transformed expression of the 10 lineage markers in 2000 randomly selected cells from each of the 16 samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure15.gif"/>
                </fig>
                <fig fig-type="figure" id="f16" orientation="portrait" position="float">
                    <label>Figure 16. </label>
                    <caption>
                        <title>Heatmap as in 
                            <xref ref-type="fig" rid="f6">Figure 6</xref>, where the additional color bar on the left indicates how the 20 metaclusters, obtained with FlowSOM, are merged into the 8 PBMC populations.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure16.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1m &lt;- cell_clustering1m[tsne_inds]</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1m))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)))</styled-content>
                    </preformat>
                </p>
                <p>One of the useful representations of merging is a heatmap of median marker expression in each of the original clusters, which are labeled according to the proposed merging, 
                    <xref ref-type="fig" rid="f16">Figure 16</xref>.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content>
                        <styled-content style="font-size:15px;color:#000000;"> expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cluster_merging =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging1)</styled-content>
                    </preformat>
                </p>
                <p>To get a final summary of the annotated cell types, one can plot a heatmap of median marker expression, calculated based on the cells in each of the annotated populations, 
                    <xref ref-type="fig" rid="f17">Figure 17</xref>.</p>
                <fig fig-type="figure" id="f17" orientation="portrait" position="float">
                    <label>Figure 17. </label>
                    <caption>
                        <title>Heatmap of the median marker intensities of the 10 lineage markers in the 8 PBMC cell populations obtained by manual merging of the 20 metaclusters generated by FlowSOM.</title>
                        <p>As in 
                            <xref ref-type="fig" rid="f6">Figure 6</xref>, the heat represents the median of arcsinh and 0-1 transformed marker expression calculated over cells from all the samples. The dendrogram on the left represents the hierarchical similarity between the 8 populations calculated using Euclidean distance and average linkage. Values in the brackets indicate the relative size of each of the cell populations across all the samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure17.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content>
                        <styled-content style="font-size:15px;color:#000000;"> expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1m,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content>
                    </preformat>
                </p>
                <p>
                    <bold>
                        <italic toggle="yes">Reducing the number of clusters in ConsensusClusterPlus.</italic>
                    </bold> The 
                    <italic toggle="yes">
                        <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/ConsensusClusterPlus">ConsensusClusterPlus</ext-link>
                    </italic> package provides visualizations that can help to understand the metaclustering process and the characteristics of the analyzed data. For example, the delta area plot (see 
                    <xref ref-type="fig" rid="f18">Figure 18</xref>) highlights the amount of extra cluster stability gained when clustering into k groups as compared to k-1 groups (from k=2 to k=20). It can be expected that high stability of clusters can be reached when clustering into the number of groups that best fits the data. Thus, using the delta area plot could help finding the &#x201c;natural&#x201d; number of clusters present in the data, which would correspond to the value of k where there is no appreciable increase in stability. This strategy can be referred as the &#x201c;elbow criterion&#x201d;. For more details about the meaning of this plot, the user can refer to the original description of the consensus clustering method (
                    <xref ref-type="bibr" rid="ref-29">Monti 
                        <italic toggle="yes">et al.</italic>, 2003</xref>).</p>
                <fig fig-type="figure" id="f18" orientation="portrait" position="float">
                    <label>Figure 18. </label>
                    <caption>
                        <title>The delta area plot generated in the metaclustering step by the ConsensusClusterPlus function.</title>
                        <p>The delta area score (y-axis) indicates the relative increase in cluster stability obtained when clustering the 100 SOM codes generated by FlowSOM into k groups (x-axis).</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure18.gif"/>
                </fig>
                <p>The elbow criterion is quite subjective since the &#x201c;appreciable&#x201d; increase is not defined exactly. For example, in the delta plot below, we could say that the last point before plateau is for k=6, or for k=5, or for k=3, depending on our perception of sufficient decrease of the delta area score. Moreover, the exact point where a plateau is reached may vary for runs with different random seeds, the drop may not always be so sharp and and the function is not guaranteed to be decreasing. It is advisable to investigate more of those plots and the resulting t-SNE and heatmaps before drawing any conclusions about the final number of &#x201c;natural&#x201d; clusters.</p>
                <p>Manual merging of up to 20 clusters can be laborious. To simplify this task, one could reduce the strength of over-clustering and allow the metaclustering method to do a part of the merging, which then can be completed manually. Analyzing the delta plot from the right side, we can see how much we can reduce the strength of over-clustering while still obtaining stable clusters. In parallel, one should check the heatmaps to see whether the less stringent stratification is able to capture cell populations of interest.</p>
                <p>As an example, we chose to reduce the strength of metaclustering to 12 groups.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Get cluster ids for each cell</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">nmc2 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">12</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">code_clustering2 &lt;- mc[[nmc2]]</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">consensusClass
cell_clustering2 &lt;- code_clustering2[som</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">map</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">mapping[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]]</styled-content>
                    </preformat>
                </p>
                <p>In the t-SNE plot (see 
                    <xref ref-type="fig" rid="f19">Figure 19</xref>), we can see that many small clusters obtained when stratifying data into 20 groups are now merged together, which should simplify the new cluster annotation.</p>
                <fig fig-type="figure" id="f19" orientation="portrait" position="float">
                    <label>Figure 19. </label>
                    <caption>
                        <title>t-SNE plot for the PBMC dataset, where cells are colored according to the 12 cell populations obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus.</title>
                        <p>As in 
                            <xref ref-type="fig" rid="f10">Figure 10</xref>, t-SNE analysis uses the arcsinh-transformed expression of the 10 lineage markers in 2000 randomly selected cells from each of the 16 samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure19.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2 &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cell_clustering2[tsne_inds], </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">nmc2)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>, 
                        <styled-content style="font-size:15px;color:#214A87;">ncol =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content>
                    </preformat>
                </p>
                <p>Over-clustering into as few as 12 groups still allows us to identify the same 8 cell populations as when merging 20 clusters (see 
                    <xref ref-type="fig" rid="f20">Figure 20</xref>&#x2013;
                    <xref ref-type="fig" rid="f23">Figure 23</xref>), but it is simpler to define since fewer profiles need to be manually scanned. The expert-based merging is saved in the PBMC8_cluster_merging2.xlsx file on the 
                    <ext-link ext-link-type="uri" xlink:href="http://imlspenticton.uzh.ch/robinson_lab/cytofWorkflow/">Robinson Lab server</ext-link>.</p>
                <fig fig-type="figure" id="f20" orientation="portrait" position="float">
                    <label>Figure 20. </label>
                    <caption>
                        <title>Heatmap of the median marker intensities of the 10 lineage markers in the 12 metaclusters obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus (PBMC data).</title>
                        <p>As in 
                            <xref ref-type="fig" rid="f6">Figure 6</xref>, the heat represents the median of arcsinh and 0-1 transformed marker expression calculated over cells from all the samples. The dendrogram on the left represents the hierarchical similarity between the 12 clusters calculated using Euclidean distance and average linkage. Values in the brackets indicate the relative size of each cluster across all the samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure20.gif"/>
                </fig>
                <fig fig-type="figure" id="f21" orientation="portrait" position="float">
                    <label>Figure 21. </label>
                    <caption>
                        <title>t-SNE plot for the PBMC dataset, where cells are colored according to the manual merging of the 12 metaclusters, obtained with FlowSOM, into 8 PBMC populations.</title>
                        <p>As in 
                            <xref ref-type="fig" rid="f10">Figure 10</xref>, t-SNE analysis uses the arcsinh-transformed expression of the 10 lineage markers in 2000 randomly selected cells from each of the 16 samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure21.gif"/>
                </fig>
                <fig fig-type="figure" id="f22" orientation="portrait" position="float">
                    <label>Figure 22. </label>
                    <caption>
                        <title>Heatmap as in 
                            <xref ref-type="fig" rid="f20">Figure 20</xref>, where the additional color bar on the left indicates how the 12 metaclusters, obtained with FlowSOM, are merged into the 8 PBMC populations.</title>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure22.gif"/>
                </fig>
                <fig fig-type="figure" id="f23" orientation="portrait" position="float">
                    <label>Figure 23. </label>
                    <caption>
                        <title>Heatmap of the median marker intensities of the 10 lineage markers in the 8 PBMC cell populations obtained by manual merging of the 12 metaclusters generated by FlowSOM.</title>
                        <p>The heat represents the median of arcsinh and 0-1 transformed marker expression calculated over cells from all the samples. The dendrogram on the left represents the hierarchical similarity between the 8 populations calculated using Euclidean distance and average linkage. Values in the brackets indicate the relative size of each of the cell populations across all the samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure23.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging2_filename &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"PBMC8_cluster_merging2.xlsx"</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">download.file</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(url,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"/"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, cluster_merging2_filename),</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">destfile =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging2_filename,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">mode =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"wb"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">cluster_merging2 &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">read_excel</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging2_filename)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging2)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##    original_cluster  new_cluster
## 1                 1 B-cells IgM+
## 2                 2     surface-
## 3                 3     NK cells
## 4                 4  CD8 T-cells
## 5                 5 B-cells IgM-
## 6                 6    monocytes
## 7                 7  CD8 T-cells
## 8                 8  CD8 T-cells
## 9                 9    monocytes
## 10               10  CD4 T-cells
## 11               11           DC
## 12               12  CD4 T-cells</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Convert to factor with merged clusters in correct order</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">cluster_merging2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cluster_merging2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">levels_clusters_merged)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## New clustering2m</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(cell_clustering2, cluster_merging2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">original_cluster)
cell_clustering2m &lt;- cluster_merging2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">new_cluster[mm]</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">dr</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2m &lt;- cell_clustering2m[tsne_inds]
gg_tsne_cl2m &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2m))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)))
gg_tsne_cl2m</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cluster_merging =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster_merging2)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#214A87;">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering2m,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_clusters)</styled-content>
                    </preformat>
                </p>
                <p>
                    <bold>
                        <italic toggle="yes">Comparison of automated and manual merging.</italic>
                    </bold> The manual merging of 20 (or 12) clusters by an expert resulted in identification of 8 cell populations. To highlight the impact of manual merging versus algorithm-defined subpopulations, we compare to the results of an automated cluster merging that is set to stratify the data also into 8 clusters. We extract the result from the 
                    <monospace>ConsensusClusterPlus</monospace> output. Out of interest, we can see which clusters are split by tabulating the cell labels.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Get cluster ids for each cell</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">nmc3 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">8</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">code_clustering3 &lt;- mc[[nmc3]]</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">consensusClass
cell_clustering3 &lt;- code_clustering3[som</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">map</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">mapping[,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]]</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#8F5903"># tabular comparison of cell_clustering3 and cell_clustering2m</styled-content>

                        <styled-content style="font-size:15px;color:#214FAB">table</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214FAB">algorithm=</styled-content>
                        <styled-content style="font-size:15px;color:#000000">cell_clustering3,</styled-content> 
                        <styled-content style="font-size:15px;color:#214FAB">manual=</styled-content>
                        <styled-content style="font-size:15px;color:#000000">cell_clustering2m)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">##	    manual</styled-content>

                        <styled-content style="font-size:15px;color:#000000">## algorithm B-cells IgM+ B-cells IgM- CD4 T-cells CD8 T-cells   DC NK cells</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   1	     6651	     0	         0	     0	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   2	        0	     0	         0	     0	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   3	        0	     0	         0	 32112	  0    24518</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   4	        0	  3265	         0	     0	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   5	        0	     0	         0	     0	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   6	        0	     0	      2603	 19038	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   7	        0	     0	     60287	     0	  0	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   8	        0	     0	         0	     0 1980	   0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	    manual</styled-content>

                        <styled-content style="font-size:15px;color:#000000">## algorithm monocytes surface-</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   1	     0	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   2	     0	   3901</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   3	     0	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   4	     0	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   5	 18436	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   6	     0	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   7	     0	      0</styled-content>

                        <styled-content style="font-size:15px;color:#000000">##	   8	     0	      0</styled-content>
                    </preformat>
                </p>
                <p>In the t-SNE map (see 
                    <xref ref-type="fig" rid="f24">Figure 24</xref>), we can see that part of the new cell populations (cluster 7, 1 and 4, 2, 5 and 8) overlap substantially with populations obtained by the means of manual merging (CD4 T-cells, B-cells, surface-, monocytes and DC). However, cells that belong to clusters 3 and 6 are subdivided in a different manner according to the manual merging. Cluster 3 consists of CD8 T-cells and NK cells, and the latter cannot be identified anymore based on the heatmap corresponding to clustering into 8 groups (see 
                    <xref ref-type="fig" rid="f25">Figure 25</xref>).</p>
                <fig fig-type="figure" id="f24" orientation="portrait" position="float">
                    <label>Figure 24. </label>
                    <caption>
                        <p>t-SNE plots with cells colored according to (
                            <bold>A</bold>) the expert merging of 12 metaclusters obtained with FlowSOM into 8 PBMC populations; and (
                            <bold>B</bold>) the 8 automatically detected with FlowSOM metaclusters.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure24.gif"/>
                </fig>
                <fig fig-type="figure" id="f25" orientation="portrait" position="float">
                    <label>Figure 25. </label>
                    <caption>
                        <title>Heatmap of the median marker intensities of the 10 lineage markers in the 8 metaclusters obtained with FlowSOM after the metaclustering step with ConsensusClusterPlus (PBMC data).</title>
                        <p>The heat represents the median of arcsinh and 0-1 transformed marker expression calculated over cells from all the samples. The dendrogram on the left represents the hierarchical similarity between the 8 clusters calculated using Euclidean distance and average linkage. Values in the brackets indicate the relative size of each cluster across all the samples.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure25.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">dr</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">cell_clustering3 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(cell_clustering3[tsne_inds],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">1</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">:</styled-content>
                        <styled-content style="font-size:15px;color:#000000">nmc3)</styled-content>

                        <styled-content style="font-size:15px;color:#000000">gg_tsne_cl3 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(dr,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">tSNE1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">tSNE2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">cell_clustering3))</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000">()</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">color_clusters)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">color = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">4</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)))</styled-content>
  

                        <styled-content style="font-size:15px;color:#214A87">plot_grid</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(gg_tsne_cl2m, gg_tsne_cl3,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">ncol =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">labels = c</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#659C0D">"A"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"B"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">))</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#214A87">plot_clustering_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">expr =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">expr[, lineage_markers_ord],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">expr01 =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">expr01[, lineage_markers_ord],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">cell_clustering =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">cell_clustering3,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">color_clusters =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">color_clusters)</styled-content>
                    </preformat>
                </p>
                <p>The example above highlights the difference between automatic clustering and manual merging of algorithm-generated clusters in the search for biologically meaningful cell populations. Automated and manual merging may give different weight to marker importance and thus result in different populations being detected. However, in our view, the manual merging done here in a reproducible fashion results in a more biologically meaningful cell stratification.</p>
            </sec>
        </sec>
        <sec>
            <title>Differential analysis</title>
            <p>For the dataset used in this workflow (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>; 
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>), we perform three types of analyses that aim to identify subsets of PBMCs and signaling markers that respond to BCR/FcR-XL stimulation, by comparing stimulated samples to unstimulated samples. We first describe the differential abundance of the defined cell populations, followed by differential analysis of marker expression within each cluster. Finally, differential analysis of the overall aggregated marker expression could also be of interest.</p>
            <p>The PBMC subset analyzed in this workflow originates from a paired experiment, where samples from 8 patients were treated with 12 different stimulation conditions for 30 minutes, together with unstimulated reference samples (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>). This is a natural example where one would choose a mixed model to model the response (abundance or marker signal), and patients would be treated as a random effect. In this way, one can formally account for within-patient variability, observed to be quite strong in the MDS plot (see 
                <xref ref-type="other" rid="S4">MDS plot</xref> section), and this should give a gain in power to detect differences between conditions.</p>
            <p>We use the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=stats">stats</ext-link>
                </italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=lme4">lme4</ext-link>
                </italic> packages to fit the fixed and mixed models, respectively, and the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org/package=multcomp">multcomp</ext-link>
                </italic> package for hypothesis testing. In all differential analyses here, we want to test for differences between the reference (
                <monospace>Ref</monospace>) and BCR/FcR-XL treatment (
                <monospace>BCRXL</monospace>). The fixed model formula is straightforward: 
                <monospace>~ condition</monospace>, where 
                <monospace>condition</monospace> indicates the treatment group. The corresponding full model design matrix consists of the intercept and dummy variable indicating the treated samples. In the presence of batches, one can include them in the model by using a formula 
                <monospace>~ condition + batch</monospace>, or if they affect the treatment, a formula with interactions 
                <monospace>~ condition * batch</monospace>.</p>
            <p>For testing, we use the general linear hypotheses function 
                <monospace>glht</monospace>, which allows testing of arbitrary hypotheses using t-tests. The 
                <monospace>linfct</monospace> parameter specifies the linear hypotheses to be tested. It should be a matrix where each row corresponds to one comparison (contrast), and the number of columns must be the same as in the design matrix. In our analysis, the contrast matrix indicates that the regression coefficient corresponding to 
                <monospace>conditionBCRXL</monospace> is tested to be equal to zero; i.e. we test the null hypothesis that there is no effect of the BCR/FcR-XL treatment. The result of the test is a p-value, which indicates the probability of observing an as strong (or stronger) difference between the two conditions assuming the null hypothesis is true.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                    <styled-content style="font-size:15px;color:#214A87">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(lme4)</styled-content>

                    <styled-content style="font-size:15px;color:#214A87">library</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(multcomp)</styled-content>

                    <styled-content style="font-size:15px;color:#8F5903;">## Model formula without random effects</styled-content>

                    <styled-content style="font-size:15px;color:#214A87">model.matrix</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(</styled-content> 
                    <styled-content style="font-size:15px;color:#D05C3E">&#x223c;</styled-content> 
                    <styled-content style="font-size:15px;color:#000000">condition,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">data =</styled-content> 
                    <styled-content style="font-size:15px;color:#000000">md)</styled-content>
                </preformat>
            </p>
            <p>Testing is performed on each cluster and marker separately, resulting in 8 tests for differential abundance (one for each merged population), 14 tests for overall differential marker expression analysis and 8 &#x00d7; 14 tests for differential marker expression within-populations. Thus, to account for the multiple testing correction, we apply the Benjamini &amp; Hochberg adjustment to each of them using an FDR cutoff of 5%.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                    <styled-content style="font-size:15px;color:#000000">##    (Intercept) conditionBCRXL</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 1		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 2		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 3		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 4		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 5		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 6		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 7		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 8		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 9		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 10		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 11		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 12		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 13		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 14		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 15		1	       1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## 16		1	       0</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## attr(,"assign")</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## [1] 0 1</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## attr(,"contrasts")</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## attr(,"contrasts")$condition</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## [1] "contr.treatment"</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                    <styled-content style="font-size:15px;color:#8F5903;">## Create contrasts</styled-content>

                    <styled-content style="font-size:15px;color:#000000">contrast_names &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">c</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(</styled-content>
                    <styled-content style="font-size:15px;color:#659C0D">"BCRXLvsRef"</styled-content>
                    <styled-content style="font-size:15px;color:#000000">)</styled-content>

                    <styled-content style="font-size:15px;color:#000000">k1 &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">c</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(</styled-content>
                    <styled-content style="font-size:15px;color:#0000CF">0</styled-content>
                    <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                    <styled-content style="font-size:15px;color:#0000CF">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000">)</styled-content>

                    <styled-content style="font-size:15px;color:#000000">K &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">matrix</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(k1,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">nrow =</styled-content> 
                    <styled-content style="font-size:15px;color:#0000CF">1</styled-content>
                    <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">byrow =</styled-content> 
                    <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                    <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                    <styled-content style="font-size:15px;color:#214A87">dimnames = list</styled-content>
                    <styled-content style="font-size:15px;color:#000000">(contrast_names))</styled-content>

                    <styled-content style="font-size:15px;color:#000000">K</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                    <styled-content style="font-size:15px;color:#000000">## 	       [,1] [,2]</styled-content>

                    <styled-content style="font-size:15px;color:#000000">## BCRXLvsRef     0    1</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                    <styled-content style="font-size:15px;color:#000000">FDR_cutoff &lt;-</styled-content> 
                    <styled-content style="font-size:15px;color:#0000CF">0.05</styled-content>
                </preformat>
            </p>
            <sec>
                <title>Differential cell population abundance</title>
                <p>Differential analysis of cell population abundance compares the proportions of cell types across experimental conditions and aims to highlight populations that are present at different ratios. First, we calculate two tables: one that contains cell counts for each sample and population and one with the corresponding proportions of cell types by sample. The proportions are used only for plotting, since the statistical modeling takes the cell counts by cluster and sample as input.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">counts_table &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">table</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(cell_clustering1m, sample_ids)</styled-content>

                        <styled-content style="font-size:15px;color:#000000">props_table &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(counts_table)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">/</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">colSums</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(counts_table))</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">*</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">100</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">counts &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">as.data.frame.matrix</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(counts_table)</styled-content>

                        <styled-content style="font-size:15px;color:#000000">props &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">as.data.frame.matrix</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(props_table)</styled-content>
                    </preformat>
                </p>
                <p>For each sample, we plot its PBMC cell type composition represented with colored bars, where the size of a given stripe reflects the proportion of the corresponding cell type in a given sample (see 
                    <xref ref-type="fig" rid="f26">Figure 26</xref>).</p>
                <fig fig-type="figure" id="f26" orientation="portrait" position="float">
                    <label>Figure 26. </label>
                    <caption>
                        <title>Relative abundance of the 8 PBMC populations in each sample (x-axis), in the PBMC dataset, represented with a barplot.</title>
                        <p>The 8 cell populations are a result of manual merging of the 20 FlowSOM metaclusters.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure26.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">ggdf &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">melt</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">cluster =</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(props), props),</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">id.vars =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"cluster"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">value.name =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"proportion"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">variable.name =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"sample_id"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cluster &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cluster,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">levels =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">levels_clusters_merged)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Add condition info</styled-content>

                        <styled-content style="font-size:15px;color:#000000">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">sample_id, md</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#000000">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">condition &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(md</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">condition[mm])</styled-content>


                        <styled-content style="font-size:15px;color:#214A87">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(ggdf,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">sample_id,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">proportion,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">fill =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">cluster))</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">geom_bar</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">stat =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"identity"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">scales =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"free_x"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000">()</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">axis.text.x =</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">element_text</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">angle =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">90</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">hjust =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000">))</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">scale_fill_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">color_clusters)</styled-content>
                    </preformat>
                </p>
                <p>It may be quite hard to see the differences in cluster abundances in the plot above, especially for clusters with very low frequency. And, since boxplots cannot represent multimodal distributions, we show boxplots with jittered points of the sample-level cluster proportions overlaid (see 
                    <xref ref-type="fig" rid="f27">Figure 27</xref>). The y-axes are scaled to the range of data plotted for each cluster, to better visualize the differences in frequency of lower abundance clusters. For this experiment, it may be interesting to additionally depict the patient information. We do this by plotting a different point shape for each patient. Indeed, we can see that often the direction of abundance changes between the two conditions are concordant among the patients.</p>
                <fig fig-type="figure" id="f27" orientation="portrait" position="float">
                    <label>Figure 27. </label>
                    <caption>
                        <title>Relative abundance of the 8 PBMC populations in each sample, in the PBMC dataset, represented with boxplots.</title>
                        <p>Values for the two conditions are indicated with different colors: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) samples. Values for each patient are indicated with different shape. The 8 cell populations are a result of manual merging of the 20 FlowSOM metaclusters.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure27.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">

                        <styled-content style="font-size:15px;color:#000000">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">patient_id &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(md</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000">patient_id[mm])</styled-content>


                        <styled-content style="font-size:15px;color:#214A87">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(ggdf)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">geom_boxplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">proportion,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87">fill =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">position = position_dodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">0.5,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87">outlier.color =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">NA</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">proportion,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">condition,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87">shape =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">patient_id),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">0.8,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">position = position_jitterdodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000">())</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#D05C3E">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">cluster,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">scales =</styled-content> 
                        <styled-content style="font-size:15px;color:#659C0D">"free"</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">nrow =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">axis.text.x = element_blank</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">axis.ticks.x = element_blank</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(),</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">axis.title.x = element_blank</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87">strip.text = element_text</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">6</styled-content>
                        <styled-content style="font-size:15px;color:#000000">))</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">scale_fill_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#D05C3E">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87">scale_shape_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87">values = c</styled-content>
                        <styled-content style="font-size:15px;color:#000000">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF">16</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">17</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">8</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">3</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">12</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000">))</styled-content>
                    </preformat>
                </p>
                <p>As our goal is to compare proportions, one could take these values, transform them (e.g. logit) and use them as a dependent variable in a linear model. However, this approach does not take into account the uncertainty of proportion estimates, which is higher when ratios are calculated for samples with lower total cell counts. A distribution that naturally accounts for such uncertainty is the binomial distribution (i.e. logistic regression), which takes the cell counts as input (relative to the total for each sample). Nevertheless, as in the genomic data analysis, the pure logistic regression is not able to capture the overdispersion that is present in HDCyto data. A natural extension to model the extra variation is the generalized linear mixed model (GLMM), where the random effect is defined by the sample ID (
                    <xref ref-type="bibr" rid="ref-18">Jia 
                        <italic toggle="yes">et al.</italic>, 2014</xref>; 
                    <xref ref-type="bibr" rid="ref-44">Zhao 
                        <italic toggle="yes">et al.</italic>, 2013</xref>). Additionally, in our example the patient pairing could be accounted in the model by incorporating a random intercept for each patient. Thus, we present two GLMMs. Both of them comprise a random effect defined by the sample ID to model the overdispersion in proportions. The second model includes a random effect defined by the patient ID to account for the experiment pairing.</p>
                <p>In our model, the blocking variable is patient ID 
                    <italic toggle="yes">i</italic> = 1, ..., 
                    <italic toggle="yes">n</italic>, where 
                    <italic toggle="yes">n</italic> = 8. For each patient, there are 
                    <italic toggle="yes">n
                        <sub>i</sub>
                    </italic> samples measured, and 
                    <italic toggle="yes">j</italic> = 1, ..., 
                    <italic toggle="yes">n
                        <sub>i</sub>
                    </italic> indicates the sample ID. Here, 
                    <italic toggle="yes">n
                        <sub>i</sub>
                    </italic> = 2 for all 
                    <italic toggle="yes">i</italic> (one from reference and one from BCR/FcR-XL stimulated).</p>
                <p>We assume that for a given cell population, the cell counts 
                    <italic toggle="yes">Y
                        <sub>ij</sub>
                    </italic> follow a binomial distribution 
                    <italic toggle="yes">Y
                        <sub>ij</sub> &#x223c; Bin</italic>(
                    <italic toggle="yes">m
                        <sub>ij</sub>
                    </italic>, 
                    <italic toggle="yes">&#x03c0;
                        <sub>ij</sub>
                    </italic>), where 
                    <italic toggle="yes">m
                        <sub>ij</sub>
                    </italic> is a total number of cells in a sample corresponding to patient 
                    <italic toggle="yes">i</italic> and condition 
                    <italic toggle="yes">j</italic>. The generalized linear mixed model with observation-level random effects 
                    <italic toggle="yes">&#x03be;
                        <sub>ij</sub>
                    </italic> is defined as follows:
				
                    <disp-formula id="e1">
                        <mml:math display="block" id="math1">
                            <mml:mrow>
                                <mml:mi>E</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:msub>
                                    <mml:mi>Y</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>|</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>=</mml:mo>
                                <mml:mi>l</mml:mi>
                                <mml:mi>o</mml:mi>
                                <mml:mi>g</mml:mi>
                                <mml:mi>i</mml:mi>
                                <mml:msup>
                                    <mml:mi>t</mml:mi>
                                    <mml:mrow>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>1</mml:mn>
                                    </mml:mrow>
                                </mml:msup>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>x</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>,</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>where 
                    <inline-formula>
                        <mml:math display="inline" id="math2">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:mn>0</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>&#x03c3;</mml:mi>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mn>2</mml:mn>
                                </mml:msubsup>
                                <mml:mo stretchy="false">)</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula> and 
                    <italic toggle="yes">x
                        <sub>ij</sub>
                    </italic> corresponds to the 
                    <monospace>conditionBCRXL</monospace> column in the design matrix and indicates whether a sample 
                    <italic toggle="yes">ij</italic> belongs to the reference (
                    <italic toggle="yes">x
                        <sub>ij</sub>
                    </italic> = 0) or treated condition (
                    <italic toggle="yes">x
                        <sub>ij</sub>
                    </italic> = 1). Since 
                    <italic toggle="yes">E</italic>(
                    <italic toggle="yes">Y
                        <sub>ij</sub>|&#x03b2;</italic>
                    <sub>0</sub>, 
                    <italic toggle="yes">&#x03b2;</italic>
                    <sub>1</sub>, 
                    <italic toggle="yes">&#x03be;
                        <sub>ij</sub>
                    </italic> ) = 
                    <italic toggle="yes">&#x03c0;
                        <sub>ij</sub>
                    </italic>, the above formula can be written as follows: 
                    <disp-formula id="e2">
                        <mml:math display="block" id="math3">
                            <mml:mrow>
                                <mml:mi>l</mml:mi>
                                <mml:mi>o</mml:mi>
                                <mml:mi>g</mml:mi>
                                <mml:mi>i</mml:mi>
                                <mml:mi>t</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03c0;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>=</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>x</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>The generalized linear mixed model that furthermore accounts for the patient pairing incorporates additionally a random intercept for each patient 
                    <italic toggle="yes">i</italic>: 
                    <disp-formula id="e3">
                        <mml:math display="block" id="math4">
                            <mml:mrow>
                                <mml:mi>E</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:msub>
                                    <mml:mi>Y</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>|</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>=</mml:mo>
                                <mml:mi>l</mml:mi>
                                <mml:mi>o</mml:mi>
                                <mml:mi>g</mml:mi>
                                <mml:mi>i</mml:mi>
                                <mml:msup>
                                    <mml:mi>t</mml:mi>
                                    <mml:mrow>
                                        <mml:mo>&#x2212;</mml:mo>
                                        <mml:mn>1</mml:mn>
                                    </mml:mrow>
                                </mml:msup>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>x</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03be;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>,</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula> where 
                    <inline-formula>
                        <mml:math display="inline" id="math5">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:mn>0</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>&#x03c3;</mml:mi>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mn>2</mml:mn>
                                </mml:msubsup>
                                <mml:mo stretchy="false">)</mml:mo>
                                <mml:mo>.</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">formula_glmer_binomial1 &lt;- y</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">total</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">|</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)
formula_glmer_binomial2 &lt;- y</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">total</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">|</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id) + (</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">|</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>
                    </preformat>
                </p>
                <p>The wrapper function below takes as input a data frame with cell counts (each row is a population, each column is a sample), the metadata table, and the formula, and performs the differential analysis specified with contrast 
                    <monospace>K</monospace> for each population separately, returning a table with non-adjusted and adjusted p-values.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">differential_abundance_wrapper &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts, md, formula, K){</styled-content>
  
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit the GLMM for each cluster separately</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">ntot &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colSums</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts)
  fit_binomial &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">lapply</styled-content>(
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">nrow</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(i){</styled-content>
  
    
                        <styled-content style="font-size:15px;color:#000000;">data_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">y</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">=</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts[i, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id]),</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">total</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">= ntot[md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id], md)</styled-content>

    
                        <styled-content style="font-size:15px;color:#000000;">fit_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">glmer</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(formula,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">weights</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">= total,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">family</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">= binomial,</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">data = </styled-content>
                        <styled-content style="font-size:15px;color:#000000">data_tmp)</styled-content>

    
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit contrasts one by one</styled-content>
    
                        <styled-content style="font-size:15px;color:#000000">out &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>(K, 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>, 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(k){
      contr_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">glht</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(fit_tmp,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">linfct = matrix</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(k,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))
      summ_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">summary</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(contr_tmp)
      pval &lt;- summ_tmp</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">test</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">pvalues</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pval)
    })</styled-content>
     
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(out)
  })</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">pvals &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">do.call</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(rbind, fit_binomial)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>(
                        <styled-content style="font-size:15px;color:#4F9905;">"pval_"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, contrast_names)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts)</styled-content>
  
                        <styled-content style="font-size:15px;color:#8F5903;">## Adjust the p-values</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">adjp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, p.adjust,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">method</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">=</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"BH"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(adjp) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, contrast_names)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">pvals</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">= pvals,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">adjp =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">adjp))
}</styled-content>
                    </preformat>
                </p>
                <p>We fit both of the GLMMs specified above. We can see that accounting for the patient pairing increases the sensitivity to detect differentially abundant cell populations.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">da_out1 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_abundance_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content>
   
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_glmer_binomial1,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(da_out1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE               5
## TRUE                3</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">da_out2 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_abundance_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_glmer_binomial2,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(da_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE               2
## TRUE                6</styled-content>
                    </preformat>
                </p>
                <p>An output table containing the observed cell population proportions in each sample and p-values can be assembled (and optionally written to a file).</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">da_output2 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">cluster = rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(props), props,
  da_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">pvals, da_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">row.names =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">print</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">head</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(da_output2),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">digits =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##        cluster BCRXL1 BCRXL2 BCRXL3 BCRXL4 BCRXL5 BCRXL6 BCRXL7 BCRXL8
## 1 B-cells IgM+   3.95   1.43    4.1    3.8    3.9    4.0    2.6    2.7
## 2 B-cells IgM-   1.09   1.01    2.0    1.1    1.5    1.2    2.1    1.7
## 3  CD4 T-cells  26.81  35.78   32.3   31.8   36.7   44.1   26.8   31.5
## 4  CD8 T-cells  46.05  40.87   26.5   25.9   28.2   24.6   34.3   39.7
## 5           DC   0.18   0.83    1.5    1.4    2.1    1.4    1.2    1.2
## 6     NK cells  15.64  11.69   16.6   18.3   12.6    6.8   25.5   12.9
##    Ref1 Ref2 Ref3 Ref4 Ref5  Ref6  Ref7  Ref8 pval_BCRXLvsRef
## 1  4.82  2.8  8.3  4.7  4.4  5.68  4.34  3.82         3.5e-08
## 2  1.90  1.3  3.3  1.4  2.5  2.34  2.79  2.19         2.2e-11
## 3 44.72 49.1 39.7 32.4 38.4 47.33 28.16 36.94         1.9e-03
## 4 23.66 23.8 15.5 17.6 26.0 25.31 33.49 34.21         1.2e-03
## 5  0.22  0.9  1.2  1.2  1.6  0.86  0.93  0.89         7.1e-05
## 6 14.31  9.7 15.1 14.5 10.2  6.67 22.54 10.99         4.5e-13
##   adjp_BCRXLvsRef
## 1         9.2e-08
## 2         8.8e-11
## 3         2.5e-03
## 4         1.9e-03
## 5         1.4e-04
## 6         3.6e-12</styled-content>
                    </preformat>
                </p>
                <p>We use a heatmap to report the differential cell populations (see 
                    <xref ref-type="fig" rid="f28">Figure 28</xref>). Proportions are first scaled with the arcsine-square-root transformation (as an alternative to logit that does not return NAs when ratios are equal to zero or one). Then, Z-score normalization is applied to each population to better highlight the relative differences between compared conditions. We created two wrapper functions: 
                    <monospace>normalization_wrapper</monospace> performs the normalization of submitted expression 
                    <monospace>expr</monospace> to mean 0 and standard deviation 1, and 
                    <monospace>plot_differential_heatmap_wrapper</monospace> generates a heatmap of submitted expression 
                    <monospace>expr_norm</monospace>, where samples are grouped by 
                    <monospace>condition</monospace>, indicated with a color bar on top of the plot. Additionally, labels of clusters contain the adjusted p-values in parenthesis.</p>
                <fig fig-type="figure" id="f28" orientation="portrait" position="float">
                    <label>Figure 28. </label>
                    <caption>
                        <title>Normalized proportions of PBMC cell populations that are significantly differentially abundant between BCR/FcR-XL stimulated and unstimulated condition.</title>
                        <p>The heat represents arcsine-square-root transformed cell frequencies that were subsequently normalized per cluster (rows) to mean of zero and standard deviation of one. The color of the heat varies from blue indicating relative under-representation to orange indicating relative over-representation. Bar at the top of the heatmap indicates the condition the samples (columns) belong to: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) condition. Numbers in the brackets next to the cluster names indicate adjusted p-values. Shown are only the significant clusters for which adjusted p-values &lt; 0.05. Clusters are sorted according to the significance so that a cluster on the top shows the most significant abundance changes between the two conditions.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure28.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">normalization_wrapper &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">th =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2.5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">){</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">expr_norm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(x){
   sdx &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">sd</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">na.rm =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">if</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(sdx</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">==</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">){
     x &lt;- (x</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">mean</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">na.rm =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))
    }</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">else</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">{
     x &lt;- (x</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">mean</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(x,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">na.rm =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">TRUE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sdx
    }
    x[x</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&gt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">th] &lt;- th
    x[x</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt; -</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">th] &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">th</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(x)
  })
  expr_norm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_norm)
}</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">plot_differential_heatmap_wrapper &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>(expr_norm, sign_adjp,
  condition, color_conditions, 
                        <styled-content style="font-size:15px;color:#214A87;">th =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2.5</styled-content>){
  
                        <styled-content style="font-size:15px;color:#8F5903;">## Order samples by condition</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">oo &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">order</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(condition)
  condition &lt;- condition[oo]
  expr_norm &lt;- expr_norm[, oo, drop =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>]

  
                        <styled-content style="font-size:15px;color:#8F5903;">## Create the row labels with adj p-values and other objects for pheatmap</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">labels_row &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_norm),</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">" ("</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
     
                        <styled-content style="font-size:15px;color:#214A87;">sprintf</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"%.02e"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, sign_adjp),</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">")"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)
  labels_col &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_norm)
  annotation_col &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">condition = factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(condition))</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(annotation_col) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_norm) 
  annotation_colors &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">condition =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)
  color &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colorRampPalette</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"#87CEFA"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#56B4E9"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#56B4E9"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#0072B2"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
     
                        <styled-content style="font-size:15px;color:#4F9905;">"#000000"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#D55E00"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#E69F00"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#E69F00"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"#FFD700"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">100</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">breaks =</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">seq</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">from =</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">th,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">to =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">th,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">length.out =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">101</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">legend_breaks = </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">seq</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">from =</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">-</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">round</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(th),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">to = round</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(th),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">by =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">gaps_col &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">as.numeric</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">table</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(annotation_col</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition))</styled-content>

  
                        <styled-content style="font-size:15px;color:#214A87;">pheatmap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_norm,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">breaks =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">breaks,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">legend_breaks =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">legend_breaks,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cluster_cols =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cluster_rows =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">labels_col =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">labels_col,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">labels_row =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">labels_row,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">gaps_col =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">gaps_col,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">annotation_col =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">annotation_col,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">annotation_colors =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">annotation_colors,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">fontsize =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)
}
</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Apply the arcsine-square-root transformation to the proportions</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">asin_table &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">asin</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">sqrt</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">((</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">t</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts_table)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">/</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">colSums</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts_table)))))</styled-content> 

                        <styled-content style="font-size:15px;color:#000000;">asin &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">as.data.frame.matrix</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(asin_table)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Get significant clusters and sort them by significance</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_clusters &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">which</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">sort</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(da_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">])</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff))
## Get the adjusted p-values for the significant clusters
sign_adjp &lt;- da_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[sign_clusters ,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, drop=</styled-content>
                        <styled-content style="font-size:15px;color:#8F5903;">FALSE</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Normalize the transformed proportions to mean = 0 and sd = 1</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">asin_norm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">normalization_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(asin[sign_clusters, ])</styled-content>
                    </preformat>
</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>(
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(asin_norm),</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">plot_differential_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_norm =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">asin_norm,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">sign_adjp =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sign_adjp,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">condition =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm],</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color_conditions =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content>
                    </preformat>
</p>
            </sec>
            <sec>
                <title>Differential analysis of marker expression stratified by cell population</title>
                <p>For this part of the analysis, we calculate the median expression of the 14 signaling markers in each cell population (merged cluster) and sample. These will be used as the response variable 
                    <italic toggle="yes">Y
                        <sub>ij</sub>
                    </italic> in the linear model (LM) or linear mixed model (LMM), for which we assume that the median marker expression follows a Gaussian distribution (on the already arcsinh-transformed scale). The linear model is formulated as follows: 
                    <disp-formula id="e4">
                        <mml:math display="block" id="math6">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>Y</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>x</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03f5;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>where 
                    <italic toggle="yes">&#x2208;
                        <sub>ij</sub> &#x223c; N</italic>(0, 
                    <italic toggle="yes">&#x03c3;</italic>
                    <sup>2</sup>), and the mixed model includes a random intercept for each patient: 
                    <disp-formula id="e5">
                        <mml:math display="block" id="math7">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>Y</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>=</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>0</mml:mn>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b2;</mml:mi>
                                    <mml:mn>1</mml:mn>
                                </mml:msub>
                                <mml:msub>
                                    <mml:mi>x</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>+</mml:mo>
                                <mml:msub>
                                    <mml:mi>&#x03f5;</mml:mi>
                                    <mml:mrow>
                                        <mml:mi>i</mml:mi>
                                        <mml:mi>j</mml:mi>
                                    </mml:mrow>
                                </mml:msub>
                                <mml:mo>,</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </disp-formula>
                </p>
                <p>where 
                    <inline-formula>
                        <mml:math display="inline" id="math8">
                            <mml:mrow>
                                <mml:msub>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mi>i</mml:mi>
                                </mml:msub>
                                <mml:mo>&#x223c;</mml:mo>
                                <mml:mi>N</mml:mi>
                                <mml:mo stretchy="false">(</mml:mo>
                                <mml:mn>0</mml:mn>
                                <mml:mo>,</mml:mo>
                                <mml:msubsup>
                                    <mml:mi>&#x03c3;</mml:mi>
                                    <mml:mi>&#x03b3;</mml:mi>
                                    <mml:mn>2</mml:mn>
                                </mml:msubsup>
                                <mml:mo stretchy="false">)</mml:mo>
                            </mml:mrow>
                        </mml:math>
                    </inline-formula>. In the current experiment, we have an intercept (basal level) and a single covariate, 
                    <italic toggle="yes">x
                        <sub>ij</sub>
                    </italic>, which is represented as a binary (stimulated/unstimulated) variable. For more complicated designs or batch effects, additional columns of a design matrix can be used.</p>
                <p>One drawback of summarizing the protein marker intensity with a median over cells is that all the other characteristics of the distribution, such as bimodality, skewness and variance, are ignored. On the other hand, it results in a simple, easy to interpret approach, which in many cases will be able to detect interesting changes. Another issue that arises from using a summary statistic is the level of uncertainty, which increases as the number of cells used to calculate it decreases. In the statistical modeling, this problem could be partially handled by assigning observation weights (number of cells) to each cluster and sample (parameter 
                    <monospace>weights</monospace> in the 
                    <monospace>lm</monospace> and 
                    <monospace>lmer</monospace> functions). However, since each cluster is tested separately, these weights do not account for the differences in size between clusters.</p>
                <p>There might be instances of small cell populations for which no cells are observed in some samples or where the number of cells is very low. For clusters absent from a sample (e.g. due to biological variance or insufficient sampling), NAs are introduced because no median expression can be calculated; in the case of few cells, the median may be quite variable. Thus, we apply a filter to remove samples that have fewer than 5 cells. We also remove cases where marker expression is equal to zero in all the samples, as this leads to an error during model fitting.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Get median marker expression per sample and cluster</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster_tbl &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr[, functional_markers],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">sample_id =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_ids,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">cluster =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cell_clustering1m)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">group_by</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(sample_id, cluster)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">%&gt;%</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">summarize_all</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">funs</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(median))</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Melt</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster_melt &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">melt</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster_tbl,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">id.vars = c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"sample_id"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"cluster"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">value.name =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"median_expression"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">variable.name =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"antigen"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Rearange so the rows represent clusters and markers</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">dcast</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster_melt,
  cluster</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">antigen</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sample_id,</styled-content>  
                        <styled-content style="font-size:15px;color:#214A87;">value.var =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"median_expression"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cluster,</styled-content>
  
                        <styled-content style="font-size:15px;color:#4F9905;">"_"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, expr_median_sample_cluster</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">antigen)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Eliminate clusters with low frequency</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">clusters_keep &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">which</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">((</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">rowSums</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(counts</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">==</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)))
keepLF &lt;- expr_median_sample_cluster</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cluster</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">%in%</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">clusters_keep</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster &lt;- expr_median_sample_cluster[keepLF, ]</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Eliminate cases with zero expression in all samples</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">keep0 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">rowSums</styled-content>(expr_median_sample_cluster[, md
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>sample_id]) 
                        <styled-content style="font-size:15px;color:#CF5C00;">&gt;</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster &lt;- expr_median_sample_cluster[keep0, ]</styled-content>
                    </preformat>
                </p>
                <p>It is helpful to plot the median expression of all the markers in each cluster for each sample colored by condition, to get a rough image of how strong the differences might be (see 
                    <xref ref-type="fig" rid="f29">Figure 29</xref>). We do this by combining boxplots and jitter.</p>
                <fig fig-type="figure" id="f29" orientation="portrait" position="float">
                    <label>Figure 29. </label>
                    <caption>
                        <title>Median (arcsinh-transformed) expression of 14 signaling markers (x-axis) across the 8 identified PBMC cell populations (individual panels).</title>
                        <p>Values for the two conditions are indicated with different colors: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) samples. Values for each patient are indicated with different shape. The 8 cell populations are a result of manual merging of the 20 FlowSOM metaclusters.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure29.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">ggdf &lt;- expr_median_sample_cluster_melt[expr_median_sample_cluster_melt</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">cluster</styled-content>
  
                        <styled-content style="font-size:15px;color:#CF5C00;">%in%</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">clusters_keep, ]</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Add info about samples</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)
ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm])
ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id[mm])</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_boxplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">median_expression,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">fill =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition),</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">position = position_dodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">outlier.color =</styled-content> 
                        <styled-content style="font-size:15px;color:#8F5903;">NA</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">antigen,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">y =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">median_expression,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">color =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition,</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">shape =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">patient_id),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">alpha =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">position = position_jitterdodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(),</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.7</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">cluster,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">scales =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"free_y"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">ncol=</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">axis.text.x = element_text</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">angle =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">90</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">vjust =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0.5</styled-content>, 
                        <styled-content style="font-size:15px;color:#214A87;">hjust =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_fill_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_shape_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values = c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">16</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">17</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">3</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">12</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">guides</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">shape = guide_legend</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">override.aes = list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">size =</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)))</styled-content>
                    </preformat>
                </p>
                <p>We created a wrapper function 
                    <monospace>differential_expression_wrapper</monospace> that performs the differential analysis of marker expression. The user needs to specify a data frame 
                    <monospace>expr_median</monospace> with marker expression, where each column corresponds to a sample and each row to a cluster/marker combination. One can choose between fitting a regular linear model 
                    <monospace>model = "lm"</monospace> or a linear mixed model 
                    <monospace>model = "lmer"</monospace>. The 
                    <monospace>formula</monospace> parameter must be adjusted adequately to the model choice. The wrapper function returns the non-adjusted and adjusted p-values for each of the specified contrasts 
                    <monospace>K</monospace> for each cluster/marker combination.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">differential_expression_wrapper &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median, md,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">model =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"lmer"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, formula, K){</styled-content>
  
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit LMM or LM for each marker separately</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">fit_gaussian &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">lapply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">:</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">nrow</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(i){</styled-content>
    
                        <styled-content style="font-size:15px;color:#000000;">data_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">y = as.numeric</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median[i, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id]), md)</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">switch</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(model,</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">lmer =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">{</styled-content>
        
                        <styled-content style="font-size:15px;color:#000000;">fit_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">lmer</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(formula,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">data_tmp)</styled-content>
      
                        <styled-content style="font-size:15px;color:#000000;">},</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">lm =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">{</styled-content>
        
                        <styled-content style="font-size:15px;color:#000000;">fit_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">lm</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(formula,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">data_tmp)</styled-content>
      
                        <styled-content style="font-size:15px;color:#000000;">})</styled-content>
    
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit contrasts one by one</styled-content>
    
                        <styled-content style="font-size:15px;color:#000000;">out &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(K,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">function</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(k){</styled-content>
      
                        <styled-content style="font-size:15px;color:#000000;">contr_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">glht</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(fit_tmp,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">linfct = matrix</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(k,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>
      
                        <styled-content style="font-size:15px;color:#000000;">summ_tmp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">summary</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(contr_tmp)</styled-content>
      
                        <styled-content style="font-size:15px;color:#000000;">pval &lt;- summ_tmp</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">test</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">pvalues</styled-content>
      
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pval)</styled-content>
    
                        <styled-content style="font-size:15px;color:#000000;">})</styled-content>
    
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(out)</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">})</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">pvals &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">do.call</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(rbind, fit_gaussian)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"pval_"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, contrast_names)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">rownames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median)</styled-content>
  
                        <styled-content style="font-size:15px;color:#8F5903;">## Adjust the p-values</styled-content>
  
                        <styled-content style="font-size:15px;color:#000000;">adjp &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(pvals,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, p.adjust,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">method =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"BH"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(adjp) &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">paste0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, contrast_names)</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">return</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">list</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">pvals =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">pvals,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">adjp =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">adjp))</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">}</styled-content>
                    </preformat>
                </p>
                <p>To present how accounting for the within patient variability with the mixed model increases sensitivity, we
also fit a regular linear model. The linear mixed model has a random intercept for each patient.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">formula_lm &lt;- y</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">formula_lmer &lt;- y</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">condition</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">|</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id)</styled-content>
                    </preformat>
                </p>
                <p>By accounting for the patient effect, we detect almost twice as many cases of differential signaling compared
to the regular linear model.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">de_out1 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_expression_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_median =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">model =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"lm"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_lm,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out1</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE              51
## TRUE               42</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">de_out2 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_expression_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_median =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">model =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"lmer"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_lmer,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE              23
## TRUE               70</styled-content>
                    </preformat>
                </p>
                <p>One can assemble together an output table with the information about median marker expression in each
cluster and sample, and the obtained p-values.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">de_output2 &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster,</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">  de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">pvals, de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">row.names = </styled-content>
                        <styled-content style="font-size:15px;color:#8F5903;">NULL</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">print</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">head</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_output2), </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">digits = </styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##        cluster antigen BCRXL1 BCRXL2 BCRXL3 BCRXL4 BCRXL5 BCRXL6 BCRXL7
## 1 B-cells IgM+   pNFkB  1.179  0.880  0.808   1.47  1.361  1.725  1.436
## 2 B-cells IgM+    pp38  0.109 -0.012  0.044   0.24 -0.046  0.083 -0.039
## 3 B-cells IgM+    pAkt  3.247  2.960  2.951   3.26  2.382  3.184  2.762
## 4 B-cells IgM+  pStat1  0.343  0.126  0.242   0.33 -0.010  0.616 -0.050
## 5 B-cells IgM+  pZap70  0.317  0.287  0.351   0.40  0.132  0.604  0.267
## 6 B-cells IgM+  pStat3 -0.047 -0.059  0.451   0.35 -0.058 -0.026  0.534
##    BCRXL8    Ref1   Ref2    Ref3    Ref4   Ref5   Ref6   Ref7   Ref8
## 1  1.5747  1.9639  1.869  1.7726  2.1833  1.861  1.953  1.915  1.979
## 2 -0.0055  0.8891  1.113  0.8534  0.6424  0.126  0.210  0.128  0.126
## 3  3.1439  2.3195  2.310  2.2688  3.0858  1.729  2.024  2.145  2.603
## 4  0.3795 -0.0058  0.064  0.0079  0.5151 -0.047  0.030 -0.034  0.191
## 5  0.3202 -0.0198 -0.033 -0.0336 -0.0056 -0.061 -0.060 -0.032 -0.017
## 6  0.3092 -0.0479 -0.082  0.2652  0.1567 -0.060 -0.066  0.275  0.381
##   pval_BCRXLvsRef adjp_BCRXLvsRef
## 1         6.1e-11         2.7e-10
## 2         7.5e-04         1.6e-03
## 3         2.6e-11         1.3e-10
## 4         6.2e-02         7.5e-02
## 5         1.6e-14         1.0e-13
## 6         5.6e-02         7.1e-02</styled-content>
                    </preformat>
                </p>
                <p>To report the significant results, we use a heatmap (see 
                    <xref ref-type="fig" rid="f30">Figure 30</xref>). Instead of plotting the absolute expression, we display the normalized expression, which better highlights the direction of marker changes. Additionally, we order the cluster-marker instances by their significance and group them by cell type (cluster).</p>
                <fig fig-type="figure" id="f30" orientation="portrait" position="float">
                    <label>Figure 30. </label>
                    <caption>
                        <title>Normalized expression of signaling markers in the 8 PBMC populations that are significantly differentially expressed between BCR/FcR-XL stimulated and unstimulated condition.</title>
                        <p>The heat represents median (arcsinh-transformed) marker expression that was subsequently normalized per cluster-marker (rows) to mean of zero and standard deviation of one. The color of the heat varies from blue representing relative under-expression to orange representing relative over-expression. Bar at the top of the heatmap indicates the condition the samples (columns) belong to: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) condition. Numbers in the brackets next to the cluster-marker names indicate adjusted p-values and cluster-marker are sorted so that they block per cluster and within each block, markers on the top show the most significant changes between the two conditions. Shown are only the significant cluster-markers for which adjusted p-values &lt; 0.05.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure30.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Keep the significant markers, sort them by significance and group by cluster</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_clusters_markers &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">which</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[,</styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;"> "adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt; </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff))</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">oo &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">order</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster[sign_clusters_markers, </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"cluster"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">],</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">  de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[sign_clusters_markers,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">])</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_clusters_markers &lt;- sign_clusters_markers[oo]</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Get the significant adjusted p-values</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_adjp &lt;- de_out2</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[sign_clusters_markers , </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Normalize expression to mean = 0 and sd = 1</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_s &lt;- expr_median_sample_cluster[sign_clusters_markers,md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id]</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster_norm &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">normalization_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_s)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">mm &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_cluster_norm), md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">plot_differential_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_norm = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_cluster_norm,</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  sign_adjp = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sign_adjp, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">condition = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm],</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  color_conditions = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content>
                    </preformat>
                </p>
            </sec>
            <sec>
                <title>DA of the overall marker expression</title>
                <p>The analysis of 
                    <italic toggle="yes">overall</italic> expression is analogous to the previous section, except that median marker expression is aggregated from all the cells in a given sample, 
                    <xref ref-type="fig" rid="f31">Figure 31</xref>.</p>
                <fig fig-type="figure" id="f31" orientation="portrait" position="float">
                    <label>Figure 31. </label>
                    <caption>
                        <title>Median (arcsinh-transformed) expression of 14 signaling markers calculated from all the cells in a given sample in the PBMC dataset.</title>
                        <p>Values for the two conditions are indicated with different colors: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) samples. Values for each patient are indicated with different shape.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure31.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">ggdf &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">melt</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample[functional_markers, ],</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  antigen = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">functional_markers), </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">id.vars = </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"antigen"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  value.name = </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"median_expression"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">variable.name = </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"sample_id"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Add condition info</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">mm &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id, md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm])</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">ggdf</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id &lt;- </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">factor</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id[mm])</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">ggplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(ggdf) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  geom_boxplot</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">y = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">median_expression, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition,</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">    fill = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition), </styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">position = position_dodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(), </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">alpha = </styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">0.5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">    outlier.color = </styled-content>
                        <styled-content style="font-size:15px;color:#8F5903;">NA</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  geom_point</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">aes</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">x = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">y = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">median_expression, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">color = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition,</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">    shape = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">patient_id), </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">alpha = </styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">0.8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">position = position_jitterdodge</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">())</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;"> +</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  facet_wrap</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">&#x223c; </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">antigen, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">scales = </styled-content>
                        <styled-content style="font-size:15px;color:#4F9905;">"free"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">, </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">nrow = </styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">5</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  theme_bw</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">() </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  theme</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">axis.text.x = element_blank</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(), </styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">axis.ticks.x = element_blank</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">()) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">  scale_color_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values = </styled-content>
                        <styled-content style="font-size:15px;color:#000000;">color_conditions) </styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_fill_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">+</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">scale_shape_manual</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">values = c</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#0000B1;">16</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">17</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">8</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">3</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">12</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">0</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">1</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000B1;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">))</styled-content>
                    </preformat>
                </p>
                <p>Similar to the analysis above, we identify more markers being differentially expressed with the LMM, which accounts for the within patient variability.</p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit a linear model</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">de_out3 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_expression_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_median =</styled-content>
     
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample[functional_markers, ],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">model =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"lm"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_lm,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out3</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE               9
## TRUE                5</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Fit a linear mixed model with patient ID as a random effect</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">de_out4 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">differential_expression_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_median =</styled-content>
     
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample[functional_markers, ],</styled-content>
   
                        <styled-content style="font-size:15px;color:#214A87;">md =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">model =</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"lmer"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">formula =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">formula_lmer,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">K =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">K)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">apply</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out4</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff,</styled-content> 
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">,</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">table)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##       adjp_BCRXLvsRef
## FALSE               3
## TRUE               11</styled-content>
                    </preformat>
                </p>
                <p>As before, we create an output table with the median marker expression calculated in each sample and the p-values, and we plot a heatmap with the significant markers sorted by their statistical significance (
                    <xref ref-type="fig" rid="f32">Figure 32</xref>).</p>
                <fig fig-type="figure" id="f32" orientation="portrait" position="float">
                    <label>Figure 32. </label>
                    <caption>
                        <title>Normalized expression of signaling markers calculated over all the cells in the PBMC dataset that are significantly differentially expressed between BCR/FcR-XL stimulated and unstimulated condition.</title>
                        <p>The heat represents median (arcsinh-transformed) marker expression that was subsequently normalized per marker (rows) to mean of zero and standard deviation of one. The color of the heat varies from blue representing relative under-expression to orange representing relative over-expression. Bar at the top of the heatmap indicates the condition the samples (columns) belong to: violet for the unstimulated (Ref) and orange for the stimulated with BCR/FcR-XL (BCRXL) condition. Numbers in the brackets next to the marker names indicate adjusted p-values and markers are sorted so that markers on the top exhibit the most significant changes between the two conditions. Shown are only the significant markers for which adjusted p-values &lt; 0.05.</p>
                    </caption>
                    <graphic orientation="portrait" position="float" xlink:href="https://f1000research-files.f1000.com/manuscripts/14185/1e5824c4-c80a-4414-81e1-36b85987dd37_figure32.gif"/>
                </fig>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">de_output4 &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">data.frame</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">antigen =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">functional_markers,
  expr_median_sample[functional_markers, ], de_out4</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">pvals, de_out4</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">print</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">head</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_output4),</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">digits=</styled-content>
                        <styled-content style="font-size:15px;color:#0000CF;">2</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">)</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#000000;">##        antigen BCRXL1 BCRXL2 BCRXL3  BCRXL4 BCRXL5  BCRXL6 BCRXL7 BCRXL8
## pNFkB    pNFkB  1.070  0.520  1.144  1.7397  1.143  1.6951  1.195  1.245
## pp38      pp38 -0.052 -0.057 -0.024 -0.0034 -0.061 -0.0006 -0.064 -0.053
## pStat5  pStat5 -0.043 -0.058 -0.041 -0.0103 -0.075 -0.0404 -0.067 -0.060
## pAkt      pAkt  3.053  2.727  2.876  3.2424  1.958  2.6068  2.075  2.416
## pStat1  pStat1  1.356  1.096  1.504  1.6960  0.535  1.9823  0.526  0.566
## pSHP2    pSHP2 -0.053 -0.057 -0.048 -0.0352 -0.073 -0.0435 -0.068 -0.065
##          Ref1   Ref2   Ref3   Ref4   Ref5   Ref6   Ref7   Ref8 
## pNFkB   2.392  2.469  2.670  2.940  1.979  2.025  1.980  1.985 
## pp38    1.280  1.474  1.467  0.939  0.091  0.218  0.062  0.122 
## pStat5 -0.049 -0.049 -0.040  0.100 -0.065 -0.063 -0.059 -0.052 
## pAkt    2.416  2.122  2.300  3.273  1.443  1.573  1.680  2.114 
## pStat1  0.889  0.930  1.474  2.056  0.493  1.097  0.416  0.549 
## pSHP2  -0.071 -0.068 -0.059 -0.038 -0.080 -0.069 -0.073 -0.066 
##        pval_BCRXLvsRef adjp_BCRXLvsRef
## pNFkB          2.3e-09         1.1e-08
## pp38           1.0e-03         1.8e-03
## pStat5         3.0e-01         3.0e-01
## pAkt           3.0e-06         8.3e-06
## pStat1         1.9e-01         2.1e-01
## pSHP2          5.4e-04         1.1e-03
</styled-content>
                    </preformat>
                </p>
                <p>
                    <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                        <styled-content style="font-size:15px;color:#8F5903;">## Keep the significant markers and sort them by significance</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_markers &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">names</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">which</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">sort</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(de_out4</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">])</styled-content> 
                        <styled-content style="font-size:15px;color:#CF5C00;">&lt;</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">FDR_cutoff))</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Get the adjusted p-values</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">sign_adjp &lt;- de_out4</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">adjp[sign_markers ,</styled-content> 
                        <styled-content style="font-size:15px;color:#4F9905;">"adjp_BCRXLvsRef"</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">]</styled-content>

                        <styled-content style="font-size:15px;color:#8F5903;">## Normalize expression to mean = 0 and sd = 1</styled-content>

                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_norm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">normalization_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample[sign_markers, ])</styled-content>


                        <styled-content style="font-size:15px;color:#000000;">mm &lt;-</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">match</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">colnames</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(expr_median_sample_norm), md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">sample_id)</styled-content>

                        <styled-content style="font-size:15px;color:#214A87;">plot_differential_heatmap_wrapper</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">(</styled-content>
                        <styled-content style="font-size:15px;color:#214A87;">expr_norm =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">expr_median_sample_norm,</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">sign_adjp =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">sign_adjp,</styled-content> 
                        <styled-content style="font-size:15px;color:#214A87;">condition =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">md</styled-content>
                        <styled-content style="font-size:15px;color:#CF5C00;">$</styled-content>
                        <styled-content style="font-size:15px;color:#000000;">condition[mm],</styled-content>
  
                        <styled-content style="font-size:15px;color:#214A87;">color_conditions =</styled-content> 
                        <styled-content style="font-size:15px;color:#000000;">color_conditions)</styled-content>
                    </preformat>
                </p>
            </sec>
        </sec>
        <sec id="S4">
            <title>Obtaining higher resolution</title>
            <p>In the proposed workflow, we concentrated on identification of the main cell types in PBMC. Our goal was to identify around 6 main cell types. Following the over-clustering strategy, we have chosen to performed the SOM clustering into 100 (the default) groups followed by the consensus clustering into 20 groups, from which we could annotate 8 cell types. These 8 cell types were then used in the differential analysis.</p>
            <p>If the number of expected cell types is higher, the user can increase the size of the SOM grid in the 
                <monospace>BuildSOM</monospace> function using the 
                <monospace>xdim</monospace> and 
                <monospace>ydim</monospace> arguments and increase the maximum number of consensus clusters in the 
                <monospace>ConsensusClusterPlus</monospace> function with the 
                <monospace>maxK</monospace> argument.</p>
            <p>One could also use a strategy based on subsequent clustering of identified clusters, which we refer to as 
                <italic toggle="yes">reclustering</italic>. In the starting step, one uses the presented workflow to identify the main cell types. In the following steps, the same clustering workflow is applied individually to the cell populations for which more resolution is desired. Restricting to one subpopulation at a time results in easier cluster annotation. The differential analysis can be applied to the final clusters in the same way as described in the workflow assuming tables with cell counts and median marker expression are available.</p>
            <p>The differential analysis could be also conducted on the unmerged (20) consensus clusters and the manual annotation could be done at the end.</p>
        </sec>
        <sec id="D1" sec-type="discussion">
            <title>Discussion</title>
            <p>In this workflow, we have presented a pipeline for diverse differential analyses of HDCyto datasets. First, we highlight quality control steps, where aggregate characteristics of the samples are visualized (e.g. an MDS plot), allowing for verification of the experimental design, detection of batch effects and outlying samples. Next, cell population identification was carried out via clustering, which forms the basis for subsequent differential analyses of cell population abundance, differential marker expression within a population or overall marker expression differences. The approaches to differential analyses proposed here are very general and thus able to model complex experimental designs via design matrices, such as factorial experiments, paired experiments or adjustment for batch effects. We have presented a range of visualizations that help in understanding the data and reporting the results of clustering and differential analyses. The wrapper functions presented in this workflow may need to be tailored to the needs of a different experiment.</p>
            <p>Clustering is one of the most challenging steps in the workflow, and its accuracy is critical to the downstream differential analyses. Getting the right resolution of clusters is crucial, since there can be situations where a biologically meaningful cell population may be differentially enriched between conditions, but in an automatic clustering, was combined with another cell population that behaves differently. We have shown that some level of over-clustering is convenient for detecting meaningful cell populations, since automatic detection of the number of natural clusters is difficult (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>). However, there are tradeoffs between the resolution of clustering and the labor involved in aggregating them to biologically meaningful clusters. Overall, we take an interactive but flexible algorithm-guided approach together with subject-area experts to arrive at sensible cell populations. In particular, we rely on various visualizations, such as dendrograms, t-SNE maps or other dimension reduction techniques to guide us in the process. Alternative strategies could be combined with the statistical inference we present, such as over-clustering combined with data-driven aggregation to the optimal resolution.</p>
            <p>While we have a good understanding of how computational algorithms recapitulate manual gating in high dimensions (
                <xref ref-type="bibr" rid="ref-42">Weber &amp; Robinson, 2016</xref>), one of the open areas of research remains how to best cluster 
                <italic toggle="yes">across</italic> samples. The data analyzed here (
                <xref ref-type="bibr" rid="ref-6">Bodenmiller 
                    <italic toggle="yes">et al.</italic>, 2012</xref>; 
                <xref ref-type="bibr" rid="ref-7">Bruggner 
                    <italic toggle="yes">et al.</italic>, 2014</xref>) was generated using sample barcoding; this strategy reduces inter-sample variability, since all samples are exposed to the same antibody cocktail and measured in a single acquisition (
                <xref ref-type="bibr" rid="ref-45">Zunder 
                    <italic toggle="yes">et al.</italic>, 2015</xref>). Thus, the range of marker expression for each channel should, in principle, be within a similar range across samples.</p>
            <p>In our approach, we aggregated all cells together before clustering. Because of this aggregation, the clustering is blind to the sample labels, and thus in principle, does not bias the downstream statistical inferences. Moreover, we directly obtain consistent clustering between samples. However, some challenges may arise when there are substantial differences in numbers of cells in samples. There is a risk that larger samples may drive the final clustering results. A simple solution to this problem could be ensuring that each sample contributes an equal amount of cells into the clustering analysis. This could be done by sampling an equal number of cells from each sample. However, there are two main drawbacks of this strategy. First, a substantial amount of data (cells) may be removed from the analysis if there are samples with few cells, thus resulting in information loss. Second, during down-sampling, some of the smaller populations may become underrepresented or even skipped. An alternative would be to cluster within each sample and then aggregate a collection of metaclusters across samples (
                <xref ref-type="bibr" rid="ref-31">Pyne 
                    <italic toggle="yes">et al.</italic>, 2009</xref>). A recent approach, called PAC-MAN (
                <xref ref-type="bibr" rid="ref-22">Li 
                    <italic toggle="yes">et al.</italic>, 2017</xref>), uses a combination of high dimensional density estimation, hierarchical clustering and network inference and comparison to extract clusters across samples, with a possibility to handle batch effects.</p>
            <p>Additional challenges may arise when combining data from different instrument acquisitions and additional preprocessing treatments may need to be applied. Despite adjustments through bead-based normalization (
                <xref ref-type="bibr" rid="ref-14">Finck 
                    <italic toggle="yes">et al.</italic>, 2013</xref>), the observed marker expression may be affected by the varying efficiency of antibody binding in each batch and by the ion detection sensitivity after machine calibration. Beyond normalization, other strategies have been proposed, such as equalizing the dynamic range between batches for each marker (e.g. normalization to the 0-1 range, z-scores, quantile normalization), the use of warping functions to eliminate non-linear distortions (see the 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/cydar">cydar</ext-link>
                </italic> vignette), or learning marker distribution shifts between the batches based on a manually gated reference cell type and using it to correct marker expression for the whole dataset (
                <xref ref-type="bibr" rid="ref-3">Arvaniti &amp; Claassen, 2017</xref>).</p>
            <p>Alternatively, one could consider batch-wise clustering of samples. On the other hand, to be able to use those results, one still needs to match cell populations across batches. The matching could be done manually, or with the automated approaches developed for flow cytometry (
                <xref ref-type="bibr" rid="ref-31">Pyne 
                    <italic toggle="yes">et al.</italic>, 2009</xref>). However, a comprehensive evaluation of these approaches and their effect on downstream analyses is still missing, especially when batch effects are present. Overall, we expect that as a general rule, including batch parameters (or other covariates) in the linear modeling helps to mitigate the problem.</p>
            <p>We presented a classical statistical approach where preprocessing of the HDCyto data leads to tables of summaries (e.g. cell counts) or aggregated measurements (e.g. cluster-specific signals) for each sample, which become the input to statistical model. Of course, there are a variety of alternative computational approaches available to the user. We have mentioned 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/nolanlab/citrus">citrus</ext-link>
                </italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="https://github.com/eiriniar/CellCnn">CellCnn</ext-link>
                </italic>, which are both machine-learning approaches that fit a reverse model to ours (i.e. phenotype of interest as the response variable).</p>
            <p>Another set of methods (
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/release/bioc/html/MIMOSA.html">MIMOSA</ext-link>
                </italic> and 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/COMPASS">COMPASS</ext-link>
                </italic>), based on Bayesian hierarchical framework, was proposed in the vaccine development field, where the antigen-specific T-cell response to stimulation for each subject is modeled using mixtures of beta-binomial or Dirichlet-multinomial distributions (
                <xref ref-type="bibr" rid="ref-13">Finak 
                    <italic toggle="yes">et al.</italic>, 2014</xref>; 
                <xref ref-type="bibr" rid="ref-23">Lin 
                    <italic toggle="yes">et al.</italic>, 2015</xref>). These strategies bear similarity to the mixed models applied for differential abundance in this workflow while handling over-dispersion due to subject-to-subject variability.</p>
            <p>Neither of these approaches are directly able to account for batch effects or complicated designs. However, they may have advantages in the search for rare distinguishing populations, which could be used together with our framework for formal statistical testing.</p>
            <p>One of the main goals of this workflow was to highlight how a model-based approach is able to handle complex experimental designs. This becomes important in many experimental situations where covariates (e.g. age, gender, batch) may affect the observed HDCyto data. Thus, the classical regression framework allows also to flexibly test situations well beyond two-group differences. Of course, alternatives exist for two group comparisons, such as the nonparametric Mann-Whitney-Wilcoxon test (
                <xref ref-type="bibr" rid="ref-17">Hartmann 
                    <italic toggle="yes">et al.</italic>, 2016</xref>), which makes no assumptions about normality of the data, or the Student&#x2019;s t-test (
                <xref ref-type="bibr" rid="ref-30">Pejoski 
                    <italic toggle="yes">et al.</italic>, 2016</xref>) and its variations, such as the paired t-test.</p>
            <p>We note that the LM, LMM and GLMM may perform poorly for extremely small samples. Solutions similar to those widely accepted in transcriptomics that share information over variance parameters (
                <xref ref-type="bibr" rid="ref-25">Love 
                    <italic toggle="yes">et al.</italic>, 2014</xref>; 
                <xref ref-type="bibr" rid="ref-32">Ritchie 
                    <italic toggle="yes">et al.</italic>, 2015</xref>; 
                <xref ref-type="bibr" rid="ref-33">Robinson &amp; Smyth, 2007</xref>) could be leveraged. An example of such an approach is 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/release/bioc/html/cydar.html">cydar</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-26">Lun 
                    <italic toggle="yes">et al.</italic>, 2017</xref>), which performs the differential abundance analysis (on hypersphere counts) using the generalized linear modeling capabilities of 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/release/bioc/html/edgeR.html">edgeR</ext-link>
                </italic> (
                <xref ref-type="bibr" rid="ref-28">McCarthy 
                    <italic toggle="yes">et al.</italic>, 2012</xref>).</p>
            <p>In the differential marker expression analysis, we compare the median marker expression between samples, while in many cases this approach is sufficient to detect interesting changes, by summarizing marker expression over cells to a single value we ignore all the other characteristics of the expression distribution, such as bimodality, skewness and variance, which may be relevant in some studies. Thus, it may be interesting to extend our comparisons to the whole marker distributions, instead of just changes in the medians.</p>
            <p>The approach presented in this workflow is not fully automated due to the cluster merging, annotating, and extensive exploratory data analysis steps. In general, our philosophy is that fully automated analyses are to be avoided, but rather a battery of diagnostic checks can be designed, as we have promoted here. Cluster annotation remains a manual step in many other approaches as well. Recently, a tool was proposed for consistent characterization of cell subsets using marker enrichment modeling (MEM) (
                <xref ref-type="bibr" rid="ref-10">Diggins 
                    <italic toggle="yes">et al.</italic>, 2017</xref>).</p>
            <p>To keep the analysis of this workflow reproducible, one needs to define a random seed before running 
                <italic toggle="yes">
                    <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org/packages/FlowSOM">FlowSOM</ext-link>
                </italic> and t-SNE. This is especially important in the clustering step, where the order of clusters may change with different seeds, and the cluster merging needs to be matched to the seed used.</p>
        </sec>
        <sec>
            <title>Software availability</title>
            <p>All software packages used in this workflow are publicly available from the Comprehensive R Archive Network (
                <ext-link ext-link-type="uri" xlink:href="https://cran.r-project.org">https://cran.r-project.org</ext-link>) or the Bioconductor project (
                <ext-link ext-link-type="uri" xlink:href="http://bioconductor.org">http://bioconductor.org</ext-link>). The specific version numbers of the packages used are shown below, along with the version of the R installation.</p>
            <p>Version numbers of all the Bioconductor packages correspond to the release version 3.5 of the Bioconductor project.</p>
            <p>Users can install all required packages and execute the workflow by following the instructions at 
                <ext-link ext-link-type="uri" xlink:href="https://www.bioconductor.org/help/workflows/cytofWorkflow">https://www.bioconductor.org/help/workflows/cytofWorkflow</ext-link>.</p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#214A87;">sessionInfo</styled-content>
                    <styled-content style="font-size:15px;color:#000000;">()</styled-content>
                </preformat>
            </p>
            <p>
                <preformat orientation="portrait" position="float" preformat-type="computer code" xml:space="preserve">
                    <styled-content style="font-size:15px;color:#000000;">## R version 3.4.1 (2017-06-30)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Sierra 10.12.5
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.4_r3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.4_r3.5/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] grid      stats    graphics   grDevices utils     datasets  methods
## [8] base
##
## other attached packages:
##  [1] bindrcpp_0.2                  cytofWorkflow_1.0.4
##  [3] multcomp_1.4-7                TH.data_1.0-8
##  [5] MASS_7.3-47                   survival_2.41-3
##  [7] mvtnorm_1.0-6                 lme4_1.1-14
##  [9] Matrix_1.2-10                 cowplot_0.8.0
## [11] Rtsne_0.13                   ConsensusClusterPlus_1.40.0
## [13] FlowSOM_1.8.0                igraph_1.1.2
## [15] ComplexHeatmap_1.14.0        pheatmap_1.0.8
## [17] RColorBrewer_1.1-2           ggrepel_0.7.0
## [19] limma_3.32.10                dplyr_0.7.4
## [21] reshape2_1.4.2               ggridges_0.4.1
## [23] ggplot2_2.2.1                matrixStats_0.52.2
## [25] flowCore_1.42.3              readxl_1.0.0
## [27] knitr_1.17                   BiocStyle_2.4.1
## [29] colorout_1.1-2
##
## loaded via a namespace (and not attached):
##  [1] nlme_3.1-131             tsne_0.1-3
##  [3] httr_1.3.1               rprojroot_1.2
##  [5] prabclus_2.2-6           tools_3.4.1
##  [7] backports_1.1.0          R6_2.2.2
##  [9] lazyeval_0.2.0           BiocGenerics_0.22.0
## [11] colorspace_1.3-2        trimcluster_0.1-2
## [13] nnet_7.3-12             GetoptLong_0.1.6
## [15] gridExtra_2.2.1         compiler_3.4.1
## [17] BiocWorkflowTools_1.2.0 graph_1.54.0
## [19] Biobase_2.36.2          sandwich_2.4-0
## [21] bookdown_0.4            diptest_0.75-7
## [23] scales_0.5.0            DEoptimR_1.0-8
## [25] robustbase_0.92-7       stringr_1.2.0
## [27] digest_0.6.12           minqa_1.2.4
## [29] rmarkdown_1.6           rrcov_1.4-3
## [31] pkgconfig_2.0.1         htmltools_0.3.6
## [33] highr_0.6               rlang_0.1.2
## [35] GlobalOptions_0.0.12    shape_1.4.3
## [37] bindr_0.1               zoo_1.8-0
## [39] mclust_5.3              dendextend_1.5.2
## [41] magrittr_1.5            modeltools_0.2-21
## [43] Rcpp_0.12.13            munsell_0.4.3
## [45] viridis_0.4.0           stringi_1.1.5
## [47] whisker_0.3-2           yaml_2.1.14
## [49] flexmix_2.3-14          plyr_1.8.4
## [51] parallel_3.4.1          lattice_0.20-35
## [53] splines_3.4.1           circlize_0.4.1
## [55] rjson_0.2.15            fpc_2.1-10
## [57] corpcor_1.6.9           codetools_0.2-15
## [59] stats4_3.4.1            XML_3.98-1.9
## [61] glue_1.1.1              evaluate_0.10.1
## [63] nloptr_1.0.4            cellranger_1.1.0
## [65] gtable_0.2.0            kernlab_0.9-25
## [67] assertthat_0.2.0        class_7.3-14
## [69] pcaPP_1.9-72            viridisLite_0.2.0
## [71] tibble_1.3.4            cluster_2.0.6</styled-content>
                </preformat>
            </p>
        </sec>
    </body>
    <back>
        <ack>
            <title>Acknowledgments</title>
            <p>The authors wish to thank members of the Robinson, Bodenmiller and von Mering groups from the Institute of Molecular Life Sciences, University of Zurich for helpful discussions.</p>
        </ack>
        <ref-list>
            <ref id="ref-1">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Aghaeepour</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Finak</surname>
                            <given-names>G</given-names>
                        </name>
									</person-group>,
                    <collab>FlowCAP Consortium</collab>,
                    <italic toggle="yes">et al.</italic>:
                    <article-title>Critical assessment of automated flow cytometry data analysis techniques.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Methods.</italic>
						</source>Nature Publishing Group, a division of Macmillan Publishers Limited.<year>2013</year>;<volume>10</volume>(<issue>3</issue>):<fpage>228</fpage>&#x2013;<lpage>38</lpage>.
                    <pub-id pub-id-type="pmid">23396282</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nmeth.2365</pub-id>
                    <pub-id pub-id-type="pmcid">3906045</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-2">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Angerer</surname>
                            <given-names>P</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Haghverdi</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>B&#x00fc;ttner</surname>
                            <given-names>M</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>
                        <italic toggle="yes">destiny</italic>: diffusion maps for large-scale single-cell data in R.</article-title>
                    <source>
							
                        <italic toggle="yes">Bioinformatics.</italic>
						</source>
                    <year>2016</year>;<volume>32</volume>(<issue>8</issue>):<fpage>1241</fpage>&#x2013;<lpage>3</lpage>.
                    <pub-id pub-id-type="pmid">26668002</pub-id>
                    <pub-id pub-id-type="doi">10.1093/bioinformatics/btv715</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-3">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Arvaniti</surname>
                            <given-names>E</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Claassen</surname>
                            <given-names>M</given-names>
                        </name>
						</person-group>:
                    <article-title>Sensitive detection of rare disease-associated cell subsets via representation learning.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Commun.</italic>
						</source>
                    <year>2017</year>;<volume>8</volume>: 14825.
                    <pub-id pub-id-type="pmid">28382969</pub-id>
                    <pub-id pub-id-type="doi">10.1038/ncomms14825</pub-id>
                    <pub-id pub-id-type="pmcid">5384229</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-4">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Bendall</surname>
                            <given-names>SC</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Davis</surname>
                            <given-names>KL</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Amir</surname>
                            <given-names>el-AD</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Single-cell trajectory detection uncovers progression and regulatory coordination in human B cell development.</article-title>
                    <source>
							
                        <italic toggle="yes">Cell.</italic>
						</source>Elsevier.<year>2014</year>;<volume>157</volume>(<issue>3</issue>):<fpage>714</fpage>&#x2013;<lpage>25</lpage>.
                    <pub-id pub-id-type="pmid">24766814</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.cell.2014.04.005</pub-id>
                    <pub-id pub-id-type="pmcid">4045247</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-5">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Bendall</surname>
                            <given-names>SC</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Simonds</surname>
                            <given-names>EF</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Qiu</surname>
                            <given-names>P</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Single-cell mass cytometry of differential immune and drug responses across a human hematopoietic continuum.</article-title>
                    <source>
							
                        <italic toggle="yes">Science.</italic>
						</source>American Association for the Advancement of Science,<year>2011</year>;<volume>332</volume>(<issue>6030</issue>):<fpage>687</fpage>&#x2013;<lpage>96</lpage>.
                    <pub-id pub-id-type="pmid">21551058</pub-id>
                    <pub-id pub-id-type="doi">10.1126/science.1198704</pub-id>
                    <pub-id pub-id-type="pmcid">3273988</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-6">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Bodenmiller</surname>
                            <given-names>B</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Zunder</surname>
                            <given-names>ER</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Finck</surname>
                            <given-names>R</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Multiplexed mass cytometry profiling of cellular states perturbed by small-molecule regulators.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Biotechnol.</italic>
						</source>Nature Publishing Group,<year>2012</year>;<volume>30</volume>(<issue>9</issue>):<fpage>858</fpage>&#x2013;<lpage>67</lpage>.
                    <pub-id pub-id-type="pmid">22902532</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nbt.2317</pub-id>
                    <pub-id pub-id-type="pmcid">3627543</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-7">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Bruggner</surname>
                            <given-names>RV</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Bodenmiller</surname>
                            <given-names>B</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Dill</surname>
                            <given-names>DL</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Automated identification of stratifying signatures in cellular subpopulations.</article-title>
                    <source>
							
                        <italic toggle="yes">Proc Natl Acad Sci U S A.</italic>
						</source>
                    <year>2014</year>;<volume>111</volume>(<issue>26</issue>):<fpage>E2770</fpage>&#x2013;<lpage>7</lpage>.
                    <pub-id pub-id-type="pmid">24979804</pub-id>
                    <pub-id pub-id-type="doi">10.1073/pnas.1408792111</pub-id>
                    <pub-id pub-id-type="pmcid">4084463</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-8">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Chen</surname>
                            <given-names>H</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Lau</surname>
                            <given-names>MC</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Wong</surname>
                            <given-names>MT</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Cytofkit: A Bioconductor Package for an Integrated Mass Cytometry Data Analysis Pipeline.</article-title>
                    <source>
							
                        <italic toggle="yes">PLoS Comput Biol.</italic>
						</source>Public Library of Science,<year>2016</year>;<volume>12</volume>(<issue>9</issue>):<fpage>e1005112</fpage>.
                    <pub-id pub-id-type="pmid">27662185</pub-id>
                    <pub-id pub-id-type="doi">10.1371/journal.pcbi.1005112</pub-id>
                    <pub-id pub-id-type="pmcid">5035035</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-9">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Chevrier</surname>
                            <given-names>S</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Crowell</surname>
                            <given-names>H</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Zanotelli</surname>
                            <given-names>VRT</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Channel crosstalk correction in suspension and imaging mass cytometry.</article-title>
                    <source>
							
                        <italic toggle="yes">bioRxiv.</italic>
						</source>Cold Spring Harbor Laboratory.<year>2017</year>.
                    <pub-id pub-id-type="doi">10.1101/185744</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-10">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Diggins</surname>
                            <given-names>KE</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Greenplate</surname>
                            <given-names>AR</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Leelatian</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Characterizing cell subsets using marker enrichment modeling.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Methods.</italic>
						</source>
                    <year>2017</year>;<volume>14</volume>(<issue>3</issue>):<fpage>275</fpage>&#x2013;<lpage>78</lpage>.
                    <pub-id pub-id-type="pmid">28135256</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nmeth.4149</pub-id>
                    <pub-id pub-id-type="pmcid">5330853</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-11">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Finak</surname>
                            <given-names>G</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Jiang</surname>
                            <given-names>M</given-names>
                        </name>
							</person-group>:
                    <article-title>FlowWorkspace: Infrastructure for Representing and Interacting with the Gated Cytometry</article-title>.<year>2011</year>.
                    <ext-link ext-link-type="uri" xlink:href="https://www.bioconductor.org/packages/devel/bioc/manuals/flowWorkspace/man/flowWorkspace.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-12">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Finak</surname>
                            <given-names>G</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Frelinger</surname>
                            <given-names>J</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Jiang</surname>
                            <given-names>W</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>OpenCyto: an open source infrastructure for scalable, robust, reproducible, and automated, end-to-end flow cytometry data analysis.</article-title>
                    <source>
							
                        <italic toggle="yes">PLoS Comput Biol.</italic>
						</source>
                    <year>2014</year>;<volume>10</volume>(<issue>8</issue>):<fpage>e1003806</fpage>.
                    <pub-id pub-id-type="pmid">25167361</pub-id>
                    <pub-id pub-id-type="doi">10.1371/journal.pcbi.1003806</pub-id>
                    <pub-id pub-id-type="pmcid">4148203</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-13">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Finak</surname>
                            <given-names>G</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>McDavid</surname>
                            <given-names>A</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Chattopadhyay</surname>
                            <given-names>P</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Mixture models for single-cell assays with applications to vaccine studies.</article-title>
                    <source>
							
                        <italic toggle="yes">Biostatistics.</italic>
						</source>
                    <year>2014</year>;<volume>15</volume>(<issue>1</issue>):<fpage>87</fpage>&#x2013;<lpage>101</lpage>.
                    <pub-id pub-id-type="pmid">23887981</pub-id>
                    <pub-id pub-id-type="doi">10.1093/biostatistics/kxt024</pub-id>
                    <pub-id pub-id-type="pmcid">3862207</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-14">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Finck</surname>
                            <given-names>R</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Simonds</surname>
                            <given-names>EF</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Jager</surname>
                            <given-names>A</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Normalization of mass cytometry data with bead standards.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry A.</italic>
						</source>
                    <year>2013</year>;<volume>83A</volume>(<issue>5</issue>):<fpage>483</fpage>&#x2013;<lpage>94</lpage>.
                    <pub-id pub-id-type="pmid">23512433</pub-id>
                    <pub-id pub-id-type="doi">10.1002/cyto.a.22271</pub-id>
                    <pub-id pub-id-type="pmcid">3688049</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-15">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Haghverdi</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Buettner</surname>
                            <given-names>F</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Theis</surname>
                            <given-names>FJ</given-names>
                        </name>
						</person-group>:
                    <article-title>Diffusion maps for high-dimensional single-cell analysis of differentiation data.</article-title>
                    <source>
							
                        <italic toggle="yes">Bioinformatics.</italic>
						</source>
                    <year>2015</year>;<volume>31</volume>(<issue>18</issue>):<fpage>2989</fpage>&#x2013;<lpage>98</lpage>.
                    <pub-id pub-id-type="pmid">26002886</pub-id>
                    <pub-id pub-id-type="doi">10.1093/bioinformatics/btv325</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-16">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Hahne</surname>
                            <given-names>F</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>LeMeur</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Brinkman</surname>
                            <given-names>RR</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>flowCore: a Bioconductor package for high throughput flow cytometry.</article-title>
                    <source>
							
                        <italic toggle="yes">BMC Bioinformatics.</italic>
						</source>
                    <year>2009</year>;<volume>10</volume>(<issue>1</issue>):<fpage>106</fpage>.
                    <pub-id pub-id-type="pmid">19358741</pub-id>
                    <pub-id pub-id-type="doi">10.1186/1471-2105-10-106</pub-id>
                    <pub-id pub-id-type="pmcid">2684747</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-17">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Hartmann</surname>
                            <given-names>FJ</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Bernard-Valnet</surname>
                            <given-names>R</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Qu&#x00e9;riault</surname>
                            <given-names>C</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>High-dimensional single-cell analysis reveals the immune signature of narcolepsy.</article-title>
                    <source>
							
                        <italic toggle="yes">J Exp Med.</italic>
						</source>Rockefeller University Press,<year>2016</year>;<volume>213</volume>(<issue>12</issue>):<fpage>2621</fpage>&#x2013;<lpage>33</lpage>.
                    <pub-id pub-id-type="pmid">27821550</pub-id>
                    <pub-id pub-id-type="doi">10.1084/jem.20160897</pub-id>
                    <pub-id pub-id-type="pmcid">5110028</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-18">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Jia</surname>
                            <given-names>C</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Hu</surname>
                            <given-names>Y</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Liu</surname>
                            <given-names>Y</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Mapping Splicing Quantitative Trait Loci in RNA-Seq.</article-title>
                    <source>
							
                        <italic toggle="yes">Cancer Inform.</italic>
						</source>
                    <year>2014</year>;<volume>13</volume>(<issue>Suppl 4</issue>):<fpage>35</fpage>&#x2013;<lpage>43</lpage>.
                    <pub-id pub-id-type="pmid">25452687</pub-id>
                    <pub-id pub-id-type="doi">10.4137/CIN.S13971</pub-id>
                    <pub-id pub-id-type="pmcid">4218654</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-19">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Kotecha</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Krutzik</surname>
                            <given-names>PO</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Irish</surname>
                            <given-names>JM</given-names>
                        </name>
						</person-group>:
                    <article-title>Web-based analysis and publication of flow cytometry experiments.</article-title>
                    <source>
						 
                        <italic toggle="yes">Curr Protoc Cytom.</italic>
						</source>John Wiley &amp; Sons, Inc.<year>2010</year>;<volume>Chapter 10</volume>:<fpage>Unit10.17</fpage>.
                    <pub-id pub-id-type="pmid">20578106</pub-id>
                    <pub-id pub-id-type="doi">10.1002/0471142956.cy1017s53</pub-id>
                    <pub-id pub-id-type="pmcid">4208272</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-20">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Leipold</surname>
                            <given-names>MD</given-names>
                        </name>
						</person-group>:
                    <article-title>Another step on the path to mass cytometry standardization.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry A.</italic>
						</source>
                    <year>2015</year>;<volume>87</volume>(<issue>5</issue>):<fpage>380</fpage>&#x2013;<lpage>82</lpage>.
                    <pub-id pub-id-type="pmid">25904393</pub-id>
                    <pub-id pub-id-type="doi">10.1002/cyto.a.22661</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-21">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Levine</surname>
                            <given-names>JH</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Simonds</surname>
                            <given-names>EF</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Bendall</surname>
                            <given-names>SC</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Data-Driven Phenotypic Dissection of AML Reveals Progenitor-like Cells that Correlate with Prognosis.</article-title>
                    <source>
							
                        <italic toggle="yes">Cell.</italic>
						</source>Elsevier,<year>2015</year>;<volume>162</volume>(<issue>1</issue>):<fpage>184</fpage>&#x2013;<lpage>97</lpage>.
                    <pub-id pub-id-type="pmid">26095251</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.cell.2015.05.047</pub-id>
                    <pub-id pub-id-type="pmcid">4508757</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-22">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Li</surname>
                            <given-names>YH</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Li</surname>
                            <given-names>D</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Samusik</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Scalable Multi-Sample Single-Cell Data Analysis by Partition-Assisted Clustering and Multiple Alignments of Networks.</article-title>
                    <source>
							
                        <italic toggle="yes">bioRxiv.</italic>
						</source>Cold Spring Harbor Labs Journals.<year>2017</year>.
                    <pub-id pub-id-type="doi">10.1101/116566</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-23">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Lin</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Finak</surname>
                            <given-names>G</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Ushey</surname>
                            <given-names>K</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>COMPASS identifies T-cell subsets correlated with clinical outcomes.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Biotechnol.</italic>
						</source>Nature Publishing Group, a division of Macmillan Publishers Limited.<year>2015</year>;<volume>33</volume>(<issue>6</issue>):<fpage>610</fpage>&#x2013;<lpage>6</lpage>.
                    <pub-id pub-id-type="pmid">26006008</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nbt.3187</pub-id>
                    <pub-id pub-id-type="pmcid">4569006</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-24">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Lin</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Frelinger</surname>
                            <given-names>J</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Jiang</surname>
                            <given-names>W</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Identification and visualization of multidimensional antigen-specific T-cell populations in polychromatic cytometry data.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry A.</italic>
						</source>
                    <year>2015</year>;<volume>87</volume>(<issue>7</issue>):<fpage>675</fpage>&#x2013;<lpage>82</lpage>.
                    <pub-id pub-id-type="pmid">25908275</pub-id>
                    <pub-id pub-id-type="doi">10.1002/cyto.a.22623</pub-id>
                    <pub-id pub-id-type="pmcid">4482785</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-25">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Love</surname>
                            <given-names>MI</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Huber</surname>
                            <given-names>W</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Anders</surname>
                            <given-names>S</given-names>
                        </name>
						</person-group>:
                    <article-title>Moderated estimation of fold change and dispersion for RNA-seq data with DESeq2.</article-title>
                    <source>
							
                        <italic toggle="yes">Genome Biol.</italic>
						</source>BioMed Central.<year>2014</year>;<volume>15</volume>(<issue>12</issue>):<fpage>550</fpage>.
                    <pub-id pub-id-type="pmid">25516281</pub-id>
                    <pub-id pub-id-type="doi">10.1186/s13059-014-0550-8</pub-id>
                    <pub-id pub-id-type="pmcid">4302049</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-26">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Lun</surname>
                            <given-names>ATL</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Richard</surname>
                            <given-names>AC</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Marioni</surname>
                            <given-names>JC</given-names>
                        </name>
						</person-group>:
                    <article-title>Testing for differential abundance in mass cytometry data.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Methods.</italic>
						</source>Nature Publishing Group, a division of Macmillan Publishers Limited.<year>2017</year>;<volume>14</volume>(<issue>7</issue>):<fpage>707</fpage>&#x2013;<lpage>9</lpage>.
                    <pub-id pub-id-type="pmid">28504682</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nmeth.4295</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-27">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Mahnke</surname>
                            <given-names>YD</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Roederer</surname>
                            <given-names>M</given-names>
                        </name>
						</person-group>:
                    <article-title>Optimizing a multicolor immunophenotyping assay.</article-title>
                    <source>
							
                        <italic toggle="yes">Clin Lab Med.</italic>
						</source>
                    <year>2007</year>;<volume>27</volume>(<issue>3</issue>):<fpage>469</fpage>&#x2013;<lpage>85</lpage>,<fpage>v</fpage>.
                    <pub-id pub-id-type="pmid">17658403</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.cll.2007.05.002</pub-id>
                    <pub-id pub-id-type="pmcid">2034273</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-28">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>McCarthy</surname>
                            <given-names>DJ</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Chen</surname>
                            <given-names>Y</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Smyth</surname>
                            <given-names>GK</given-names>
                        </name>
						</person-group>:
                    <article-title>Differential expression analysis of multifactor RNA-Seq experiments with respect to biological variation.</article-title>
                    <source>
							
                        <italic toggle="yes">Nucleic Acids Res.</italic>
						</source>
                    <year>2012</year>;<volume>40</volume>(<issue>10</issue>):<fpage>4288</fpage>&#x2013;<lpage>97</lpage>.
                    <pub-id pub-id-type="pmid">22287627</pub-id>
                    <pub-id pub-id-type="doi">10.1093/nar/gks042</pub-id>
                    <pub-id pub-id-type="pmcid">3378882</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-29">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Monti</surname>
                            <given-names>S</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Tamayo</surname>
                            <given-names>P</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Mesirov</surname>
                            <given-names>J</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Consensus Clustering: A Resampling-Based Method for Class Discovery and Visualization of Gene Expression Microarray Data.</article-title>
                    <source>
							
                        <italic toggle="yes">Mach Learn.</italic>
						</source>
                    <year>2003</year>;<volume>52</volume>(<issue>1&#x2013;2</issue>):<fpage>91</fpage>&#x2013;<lpage>118</lpage>.
                    <pub-id pub-id-type="doi">10.1023/A:1023949509487</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-30">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Pejoski</surname>
                            <given-names>D</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Tchitchek</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Rodriguez Pozo</surname>
                            <given-names>A</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Identification of Vaccine-Altered Circulating B Cell Phenotypes Using Mass Cytometry and a Two-Step Clustering Analysis.</article-title>
                    <source>
							
                        <italic toggle="yes">J Immunol.</italic>
						</source>American Association of Immunologists,<year>2016</year>;<volume>196</volume>(<issue>11</issue>):<fpage>4814</fpage>&#x2013;<lpage>31</lpage>.
                    <pub-id pub-id-type="pmid">27183591</pub-id>
                    <pub-id pub-id-type="doi">10.4049/jimmunol.1502005</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-31">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>Pyne</surname>
                            <given-names>S</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Hu</surname>
                            <given-names>X</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Wang</surname>
                            <given-names>K</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Automated high-dimensional flow cytometric data analysis.</article-title>
                    <source>
							
                        <italic toggle="yes">Proc Natl Acad Sci U S A.</italic>
						</source>
                    <year>2009</year>;<volume>106</volume>(<issue>21</issue>):<fpage>8519</fpage>&#x2013;<lpage>24</lpage>.
                    <pub-id pub-id-type="pmid">19443687</pub-id>
                    <pub-id pub-id-type="doi">10.1073/pnas.0903028106</pub-id>
                    <pub-id pub-id-type="pmcid">2682540</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-32">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Ritchie</surname>
                            <given-names>ME</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Phipson</surname>
                            <given-names>B</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Wu</surname>
                            <given-names>D</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>
                        <italic toggle="yes">limma</italic> powers differential expression analyses for RNA-sequencing and microarray studies.</article-title>
                    <source>
							
                        <italic toggle="yes">Nucleic Acids Res.</italic>
						</source>Oxford University Press,<year>2015</year>;<volume>43</volume>(<issue>7</issue>):<fpage>e47</fpage>.
                    <pub-id pub-id-type="pmid">25605792</pub-id>
                    <pub-id pub-id-type="doi">10.1093/nar/gkv007</pub-id>
                    <pub-id pub-id-type="pmcid">4402510</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-33">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Robinson</surname>
                            <given-names>MD</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Smyth</surname>
                            <given-names>GK</given-names>
                        </name>
						</person-group>:
                    <article-title>Moderated statistical tests for assessing differences in tag abundance.</article-title>
                    <source>
							
                        <italic toggle="yes">Bioinformatics.</italic>
						</source>
                    <year>2007</year>;<volume>23</volume>(<issue>21</issue>):<fpage>2881</fpage>&#x2013;<lpage>7</lpage>.
                    <pub-id pub-id-type="pmid">17881408</pub-id>
                    <pub-id pub-id-type="doi">10.1093/bioinformatics/btm453</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-34">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Roederer</surname>
                            <given-names>M</given-names>
                        </name>
						</person-group>:
                    <article-title>Spectral compensation for flow cytometry: visualization artifacts, limitations, and caveats.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry.</italic>
						</source>John Wiley &amp; Sons, Inc.<year>2001</year>;<volume>45</volume>(<issue>3</issue>):<fpage>194</fpage>&#x2013;<lpage>205</lpage>.
                    <pub-id pub-id-type="pmid">11746088</pub-id>
                    <pub-id pub-id-type="doi">10.1002/1097-0320(20011101)45:3&lt;194::AID-CYTO1163&gt;3.0.CO;2-C</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-35">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Saeys</surname>
                            <given-names>Y</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Gassen</surname>
                            <given-names>SV</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Lambrecht</surname>
                            <given-names>BN</given-names>
                        </name>
						</person-group>:
                    <article-title>Computational flow cytometry: helping to make sense of high-dimensional immunology data.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Rev Immunol.</italic>
						</source>Nature Publishing Group, a division of Macmillan Publishers Limited.<year>2016</year>;<volume>16</volume>(<issue>7</issue>):<fpage>449</fpage>&#x2013;<lpage>62</lpage>.
                    <pub-id pub-id-type="pmid">27320317</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nri.2016.56</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-36">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Tang</surname>
                            <given-names>J</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Liu</surname>
                            <given-names>J</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Zhang</surname>
                            <given-names>M</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Visualizing Large-scale and High-dimensional Data.</article-title>
                    <italic toggle="yes">CoRR</italic>abs/1602.00370;<year>2016</year>.
                    <pub-id pub-id-type="doi">10.1145/2872427.2883041</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-37">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>van der Maaten</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Hinton</surname>
                            <given-names>G</given-names>
                        </name>
						</person-group>:
                    <article-title>Visualizing high-dimensional data using t-sne.</article-title>
                    <source>
							
                        <italic toggle="yes">J Mach Learn Res.</italic>
						</source>
                    <year>2008</year>;<fpage>2579</fpage>&#x2013;<lpage>2605</lpage>.
                    <ext-link ext-link-type="uri" xlink:href="http://www.jmlr.org/papers/volume9/vandermaaten08a/vandermaaten08a.pdf">Reference Source</ext-link>
                </mixed-citation>
            </ref>
            <ref id="ref-38">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Van Gassen</surname>
                            <given-names>S</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Callebaut</surname>
                            <given-names>B</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Van Helden</surname>
                            <given-names>MJ</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>FlowSOM: Using self-organizing maps for visualization and interpretation of cytometry data.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry A.</italic>
						</source>
                    <year>2015</year>;<volume>87</volume>(<issue>7</issue>):<fpage>636</fpage>&#x2013;<lpage>45</lpage>.
                    <pub-id pub-id-type="pmid">25573116</pub-id>
                    <pub-id pub-id-type="doi">10.1002/cyto.a.22625</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-39">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
								
                        <name name-style="western">
                            <surname>van Unen</surname>
                            <given-names>V</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Li</surname>
                            <given-names>N</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Molendijk</surname>
                            <given-names>I</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Mass Cytometry of the Human Mucosal Immune System Identifies Tissue- and Disease-Associated Immune Subsets.</article-title>
                    <source>
							
                        <italic toggle="yes">Immunity.</italic>
						</source>
                    <year>2016</year>;<volume>44</volume>(<issue>5</issue>):<fpage>1227</fpage>&#x2013;<lpage>39</lpage>.
                    <pub-id pub-id-type="pmid">27178470</pub-id>
                    <pub-id pub-id-type="doi">10.1016/j.immuni.2016.04.014</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-40">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Wang</surname>
                            <given-names>B</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Ramazzotti</surname>
                            <given-names>D</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>De Sano</surname>
                            <given-names>L</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>SIMLR: A Tool for Large-Scale Single-Cell Analysis by Multi-Kernel Learning.</article-title>
                    <source>
							
                        <italic toggle="yes">bioRxiv.</italic>
						</source>Cold Spring Harbor Labs Journals.<year>2017</year>.
                    <pub-id pub-id-type="doi">10.1101/118901</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-41">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Wattenberg</surname>
                            <given-names>M</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Vi&#x00e9;gas</surname>
                            <given-names>F</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Johnson</surname>
                            <given-names>I</given-names>
                        </name>
						</person-group>:
                    <article-title>How to Use t-SNE Effectively.</article-title>
                    <source>
							
                        <italic toggle="yes">Distill.</italic>
						</source>
                    <year>2016</year>.
                    <pub-id pub-id-type="doi">10.23915/distill.00002</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-42">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Weber</surname>
                            <given-names>LM</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Robinson</surname>
                            <given-names>MD</given-names>
                        </name>
						</person-group>:
                    <article-title>Comparison of clustering methods for high-dimensional single-cell flow and mass cytometry data.</article-title>
                    <source>
							
                        <italic toggle="yes">Cytometry A.</italic>
						</source>
                    <year>2016</year>;<volume>89</volume>(<issue>12</issue>):<fpage>1084</fpage>&#x2013;<lpage>96</lpage>.
                    <pub-id pub-id-type="pmid">27992111</pub-id>
                    <pub-id pub-id-type="doi">10.1002/cyto.a.23030</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-43">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Wilkerson</surname>
                            <given-names>MD</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Hayes</surname>
                            <given-names>DN</given-names>
                        </name>
						</person-group>:
                    <article-title>ConsensusClusterPlus: a class discovery tool with confidence assessments and item tracking.</article-title>
                    <source>
							
                        <italic toggle="yes">Bioinformatics.</italic>
						</source>
                    <year>2010</year>;<volume>26</volume>(<issue>12</issue>):<fpage>1572</fpage>&#x2013;<lpage>3</lpage>.
                    <pub-id pub-id-type="pmid">20427518</pub-id>
                    <pub-id pub-id-type="doi">10.1093/bioinformatics/btq170</pub-id>
                    <pub-id pub-id-type="pmcid">2881355</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-44">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Zhao</surname>
                            <given-names>K</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Lu</surname>
                            <given-names>ZX</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Park</surname>
                            <given-names>JW</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>GLiMMPS: robust statistical model for regulatory variation of alternative splicing using RNA-seq data.</article-title>
                    <source>
							
                        <italic toggle="yes">Genome Biol.</italic>
						</source>BioMed Central Ltd,<year>2013</year>;<volume>14</volume>(<issue>7</issue>):<fpage>R74</fpage>.
                    <pub-id pub-id-type="pmid">23876401</pub-id>
                    <pub-id pub-id-type="doi">10.1186/gb-2013-14-7-r74</pub-id>
                    <pub-id pub-id-type="pmcid">4054007</pub-id>
                </mixed-citation>
            </ref>
            <ref id="ref-45">
                <mixed-citation publication-type="journal">
                    <person-group person-group-type="author">
							
                        <name name-style="western">
                            <surname>Zunder</surname>
                            <given-names>ER</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Finck</surname>
                            <given-names>R</given-names>
                        </name>
							
                        <name name-style="western">
                            <surname>Behbehani</surname>
                            <given-names>GK</given-names>
                        </name>
							
                        <etal/>
						</person-group>:
                    <article-title>Palladium-based mass tag cell barcoding with a doublet-filtering scheme and single-cell deconvolution algorithm.</article-title>
                    <source>
							
                        <italic toggle="yes">Nat Protoc.</italic>
						</source>Nature Publishing Group.<year>2015</year>;<volume>10</volume>(<issue>2</issue>):<fpage>316</fpage>&#x2013;<lpage>33</lpage>.
                    <pub-id pub-id-type="pmid">25612231</pub-id>
                    <pub-id pub-id-type="doi">10.1038/nprot.2015.020</pub-id>
                    <pub-id pub-id-type="pmcid">4347881</pub-id>
                </mixed-citation>
            </ref>
        </ref-list>
    </back>
    <sub-article article-type="reviewer-report" id="report23051">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.12553.r23051</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Finak</surname>
                        <given-names>Greg</given-names>
                    </name>
                    <xref ref-type="aff" rid="r23051a1">1</xref>
                    <role>Referee</role>
                    <uri content-type="orcid">https://orcid.org/0000-0003-4341-9090</uri>
                </contrib>
                <contrib contrib-type="author">
                    <name>
                        <surname>Gottardo</surname>
                        <given-names>Raphael</given-names>
                    </name>
                    <xref ref-type="aff" rid="r23051a1">1</xref>
                    <role>Co-referee</role>
                </contrib>
                <aff id="r23051a1">
                    <label>1</label>Vaccine and Infectious Disease Division (VIDD), Fred Hutchinson Cancer Research Center, Seattle, WA, USA</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>8</day>
                <month>6</month>
                <year>2017</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2017 Finak G and Gottardo R</copyright-statement>
                <copyright-year>2017</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport23051" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.11622.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>Nowicka and colleagues present a detailed workflow for analyzing high dimensional cytometry data using open source tools within the Bioconductor framework.&#x00a0;</p>
            <p> </p>
            <p> The paper provides a clear path for analyzing high dimensional cytometry data, with biomarker discovery in mind, starting from raw data, through preprocessing, population discovery, annotation, and differential abundance analysis.&#x00a0;</p>
            <p> </p>
            <p> Two particular strengths of the proposed approach are i) the decision to use expert-guided merging of cell populations, and ii) the model-based differential abundance analysis of cell populations.&#x00a0;</p>
            <p> </p>
            <p> The proposed visualization and summaries of the data make i) straightforward to follow and justify, and adequate alternatives are provided and shown to perform equally well&#x00a0;in instances where manual merging of many clusters would be cumbersome.&#x00a0;</p>
            <p> </p>
            <p> The modeling of cell population counts, rather than proportions, is an approach that we strongly support, and the use of logistic regression with mixed effects is a natural approach that is probably insufficiently appreciated by the community at large. That said, some of the methods proposed in the workflow have been in use in the vaccine development field for some time and should be appropriately cited.</p>
            <p> Specifically, in the section "Visual representation with tSNE", the authors promote coloring individual cells on a tSNE map by expression level, and later still, stratifying by condition (Fig. 11). We point the authors the article by Lin et al.
                <sup>
                    <xref ref-type="bibr" rid="rep-ref-23051-1">1</xref>
                </sup>,&#x00a0;&#x00a0;where a very similar approach, using bioconductor tools, is undertaken to identify and visualize polyfunctional Ag-specific T-cells.</p>
            <p> </p>
            <p> The discussion of existing methodological approaches to identify cytometry&#x00a0;biomarkers associated with outcome and the discussion of modeling cell counts in favor of modeling of proportions is important, but should also reference existing work in the vaccine development field. Our group has&#x00a0;done substantial work in this area, developing count-based models for antigen-specific T-cell&#x00a0;response to stimulation[ref-2
                <sup>,</sup>
                <sup>
                    <xref ref-type="bibr" rid="rep-ref-23051-3">3</xref>
                </sup>, the latter of which identified&#x00a0;a novel biomarker of infection risk in an HIV clinical trial.</p>
            <p> </p>
            <p> While these methods do not account for covariates, they are relevant to the discussion since&#x00a0;they utilize the Beta-binomial and Dirichlet-Multinomial distributions in a Bayesian formulation to handle over-dispersion due to subject-to-subject variability (an alternative to mixed effects modeling), and warrant mention here.</p>
            <p> </p>
            <p> Some additional minor points: the citation of flowCore (p5) should reference the journal publication describing the software
                <sup>
                    <xref ref-type="bibr" rid="rep-ref-23051-4">4</xref>
                </sup>, since it is available, rather than the software vignette.</p>
            <p> </p>
            <p> Finally, note that flowCore is not used for analysis (p4),&#x00a0;&#x00a0;which is this context we take to mean clustering or gating, but rather is an infrastructure package that will read, write and&#x00a0;transform cytometry data, as well as defining gate objects.</p>
            <p> </p>
            <p> The core infrastructure for actually performing data-driven gating in Bioconductor is implemented in packages like flowWorkspace (Finak G, Jiang M, Gottardo R. flowWorkspace: Infrastructure for representing and interacting with the gated cytometry. 2011.) and &#x00a0;openCyto
                <sup>
                    <xref ref-type="bibr" rid="rep-ref-23051-5">5</xref>
                </sup>.</p>
            <p> </p>
            <p> The citations above should be added and updated for completeness and clarity.</p>
            <p> </p>
            <p> Other than the above, the article is scientifically sound and the conclusions are justified by the data.</p>
            <p>Is the rationale for developing the new method (or application) clearly explained?</p>
            <p>Yes</p>
            <p>Is the description of the method technically sound?</p>
            <p>Yes</p>
            <p>Are the conclusions about the method and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>If any results are presented, are all the source data underlying the results available to ensure full reproducibility?</p>
            <p>Yes</p>
            <p>Are sufficient details provided to allow replication of the method development and its use by others?</p>
            <p>Yes</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>We confirm that we have read this submission and believe that we have an appropriate level of expertise to confirm that it is of an acceptable scientific standard.</p>
        </body>
        <back>
            <ref-list>
                <title>References</title>
                <ref id="rep-ref-23051-1">
                    <label>1</label>
                    <mixed-citation publication-type="journal">
                        <person-group person-group-type="author"/>:
                        <article-title>Identification and visualization of multidimensional antigen-specific T-cell populations in polychromatic cytometry data.</article-title>
                        <source>
                            <italic>Cytometry A</italic>
                        </source>.<year>2015</year>;<volume>87</volume>(<issue>7</issue>) :
                        <elocation-id>10.1002/cyto.a.22623</elocation-id>
                        <fpage>675</fpage>-<lpage>82</lpage>
                        <pub-id pub-id-type="pmid">25908275</pub-id>
                        <pub-id pub-id-type="doi">10.1002/cyto.a.22623</pub-id>
                    </mixed-citation>
                </ref>
                <ref id="rep-ref-23051-2">
                    <label>2</label>
                    <mixed-citation publication-type="journal">
                        <person-group person-group-type="author"/>:
                        <article-title>Mixture models for single-cell assays with applications to vaccine studies.</article-title>
                        <source>
                            <italic>Biostatistics</italic>
                        </source>.<year>2014</year>;<volume>15</volume>(<issue>1</issue>) :
                        <elocation-id>10.1093/biostatistics/kxt024</elocation-id>
                        <fpage>87</fpage>-<lpage>101</lpage>
                        <pub-id pub-id-type="pmid">23887981</pub-id>
                        <pub-id pub-id-type="doi">10.1093/biostatistics/kxt024</pub-id>
                    </mixed-citation>
                </ref>
                <ref id="rep-ref-23051-3">
                    <label>3</label>
                    <mixed-citation publication-type="journal">
                        <person-group person-group-type="author"/>:
                        <article-title>COMPASS identifies T-cell subsets correlated with clinical outcomes.</article-title>
                        <source>
                            <italic>Nat Biotechnol</italic>
                        </source>.<year>2015</year>;<volume>33</volume>(<issue>6</issue>) :
                        <elocation-id>10.1038/nbt.3187</elocation-id>
                        <fpage>610</fpage>-<lpage>6</lpage>
                        <pub-id pub-id-type="pmid">26006008</pub-id>
                        <pub-id pub-id-type="doi">10.1038/nbt.3187</pub-id>
                    </mixed-citation>
                </ref>
                <ref id="rep-ref-23051-4">
                    <label>4</label>
                    <mixed-citation publication-type="journal">
                        <person-group person-group-type="author"/>:
                        <article-title>flowCore: a Bioconductor package for high throughput flow cytometry.</article-title>
                        <source>
                            <italic>BMC Bioinformatics</italic>
                        </source>.<year>2009</year>;<volume>10</volume>:
                        <elocation-id>10.1186/1471-2105-10-106</elocation-id>
                        <fpage>106</fpage>
                        <pub-id pub-id-type="pmid">19358741</pub-id>
                        <pub-id pub-id-type="doi">10.1186/1471-2105-10-106</pub-id>
                    </mixed-citation>
                </ref>
                <ref id="rep-ref-23051-5">
                    <label>5</label>
                    <mixed-citation publication-type="journal">
                        <person-group person-group-type="author"/>:
                        <article-title>OpenCyto: an open source infrastructure for scalable, robust, reproducible, and automated, end-to-end flow cytometry data analysis.</article-title>
                        <source>
                            <italic>PLoS Comput Biol</italic>
                        </source>.<year>2014</year>;<volume>10</volume>(<issue>8</issue>) :
                        <elocation-id>10.1371/journal.pcbi.1003806</elocation-id>
                        <fpage>e1003806</fpage>
                        <pub-id pub-id-type="pmid">25167361</pub-id>
                        <pub-id pub-id-type="doi">10.1371/journal.pcbi.1003806</pub-id>
                    </mixed-citation>
                </ref>
            </ref-list>
        </back>
        <sub-article article-type="response" id="comment3144-23051">
            <front-stub>
                <contrib-group>
                    <contrib contrib-type="author">
                        <name>
                            <surname>Robinson</surname>
                            <given-names>Mark</given-names>
                        </name>
                        <aff>University of Zurich, Switzerland</aff>
                    </contrib>
                </contrib-group>
                <author-notes>
                    <fn fn-type="conflict">
                        <p>
                            <bold>Competing interests: </bold>No competing interests.</p>
                    </fn>
                </author-notes>
                <pub-date pub-type="epub">
                    <day>31</day>
                    <month>10</month>
                    <year>2017</year>
                </pub-date>
            </front-stub>
            <body>
                <p>Thank you for taking the time to read and review our paper. Following the suggestion of the reviewer, we have incorporated the missing references, including the reference to Lin et al. [1] in the "Visual representation with tSNE" section, and references to MIMOSA [2] and COMPASS [3] methods in the "Discussion" section. We have also fixed references in the "Data preprocessing" section, including the reference to the flowCore package [4]. We have clarified that the packages that can be used for cell gating are flowWorkspace [5] and openCyto [6].</p>
                <p> </p>
                <p> References</p>
                <p> [1] Lin Lin, Jacob Frelinger, Wenxin Jiang, Greg Finak, Chetan Seshadri, Pierre-Alexandre Bart, Giuseppe Pantaleo, Julie McElrath, Steve DeRosa, and Raphael Gottardo. 
                    <italic>Identification and visualization of multidimensional antigen-specific T-cell populations in polychromatic cytometry data</italic>.
                    <bold> Cytometry Part A</bold>, 87(7):675&#x2013;682, 2015.</p>
                <p> [2] Greg Finak, Andrew McDavid, Pratip Chattopadhyay, Maria Dominguez, Steve De Rosa, Mario Roederer, and Raphael Gottardo. 
                    <italic>Mixture models for single-cell assays with applications to vaccine studies</italic>. 
                    <bold>Biostatistics</bold>, 15(1):87&#x2013;101, 2014.</p>
                <p> [3] Lin Lin, Greg Finak, Kevin Ushey, Chetan Seshadri, Thomas R Hawn, Nicole Frahm, Thomas J Scriba, Hassan Mahomed, Willem Hanekom, Pierre-Alexandre Bart, Giuseppe Pantaleo, Georgia D Tomaras, Supachai Rerks-Ngarm, Jaranit Kaewkungwal, Sorachai Nitayaphan, Punnee Pitisuttithum, Nelson L Michael, Jerome H Kim, Merlin L Robb, Robert J O&#x2019;Connell, Nicos Karasavvas, Peter Gilbert, Stephen C De Rosa, M Juliana McElrath, and Raphael Gottardo. 
                    <italic>COMPASS identifies T-cell subsets correlated with clinical outcomes</italic>. 
                    <bold>Nat Biotech</bold>, 33(6):610&#x2013;616, jun 2015.</p>
                <p> [4] Florian Hahne, Nolwenn LeMeur, Ryan R Brinkman, Byron Ellis, Perry Haaland, Deepayan Sarkar, Josef Spidlen, Errol Strain, and Robert Gentleman. 
                    <italic>flowCore: a Bioconductor package for high throughput flow cytometry</italic>. 
                    <bold>BMC Bioinformatics</bold>, 10(1):106, apr 2009.</p>
                <p> [5] Greg Finak and Mike Jiang. 
                    <italic>flowWorkspace: Infrastructure for representing and interacting with the gated cytometry</italic>, 2011. R package version 3.24.4.</p>
                <p> [6] Greg Finak, Jacob Frelinger, Wenxin Jiang, Evan W EW Newell, John Ramey, Mark MM Davis, SA Spyros a Kalams, SC Stephen C De Rosa, and Raphael Gottardo. OpenCyto: An 
                    <italic>Open Source Infrastructure for Scalable, Robust, Reproducible, and Automated, End-to-End Flow Cytometry Data Analysis</italic>. 
                    <bold>PLoS Computational Biology</bold>, 10(8):e1003806, 2014.</p>
            </body>
        </sub-article>
    </sub-article>
    <sub-article article-type="reviewer-report" id="report23055">
        <front-stub>
            <article-id pub-id-type="doi">10.5256/f1000research.12553.r23055</article-id>
            <title-group>
                <article-title>Reviewer response for version 1</article-title>
            </title-group>
            <contrib-group>
                <contrib contrib-type="author">
                    <name>
                        <surname>Lun</surname>
                        <given-names>Aaron T. L.</given-names>
                    </name>
                    <xref ref-type="aff" rid="r23055a1">1</xref>
                    <role>Referee</role>
                    <uri content-type="orcid">https://orcid.org/0000-0002-3564-4813</uri>
                </contrib>
                <contrib contrib-type="author">
                    <name>
                        <surname>Marioni</surname>
                        <given-names>John C.</given-names>
                    </name>
                    <xref ref-type="aff" rid="r23055a2">2</xref>
                    <xref ref-type="aff" rid="r23055a1">1</xref>
                    <xref ref-type="aff" rid="r23055a3">3</xref>
                    <role>Co-referee</role>
                </contrib>
                <aff id="r23055a1">
                    <label>1</label>CRUK (Cancer Research UK) Cambridge Institute, University of Cambridge, Cambridge, UK</aff>
                <aff id="r23055a2">
                    <label>2</label>Wellcome Trust Sanger Institute, Wellcome Genome Campus, Cambridge, UK</aff>
                <aff id="r23055a3">
                    <label>3</label>EMBL-European Bioinformatics Institute (EMBL-EBI), Wellcome Genome Campus, Cambridge, UK</aff>
            </contrib-group>
            <author-notes>
                <fn fn-type="conflict">
                    <p>
                        <bold>Competing interests: </bold>No competing interests were disclosed.</p>
                </fn>
            </author-notes>
            <pub-date pub-type="epub">
                <day>6</day>
                <month>6</month>
                <year>2017</year>
            </pub-date>
            <permissions>
                <copyright-statement>Copyright: &#x00a9; 2017 Lun ATL and Marioni JC</copyright-statement>
                <copyright-year>2017</copyright-year>
                <license xlink:href="https://creativecommons.org/licenses/by/4.0/">
                    <license-p>This is an open access peer review report distributed under the terms of the Creative Commons Attribution Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
                </license>
            </permissions>
            <related-article ext-link-type="doi" id="relatedArticleReport23055" related-article-type="peer-reviewed-article" xlink:href="10.12688/f1000research.11622.1"/>
            <custom-meta-group>
                <custom-meta>
                    <meta-name>recommendation</meta-name>
                    <meta-value>approve</meta-value>
                </custom-meta>
            </custom-meta-group>
        </front-stub>
        <body>
            <p>Nowicka et al. describe a comprehensive workflow for a multi-sample analysis of a mass cytometry data set.&#x00a0;They provide methods and guidelines for data processing and quality control, clustering and interpretation/visualization of the clusters.&#x00a0;They also describe the application of statistical methods for differential analyses within clusters.&#x00a0;The article is clear and well-written, with some opportunities for improvement that we have listed below.&#x00a0;Overall, this will be useful resource for people looking to use R/Bioconductor for cytometry data analysis.</p>
            <p> </p>
            <p> 
                <bold>MAJOR COMMENTS:</bold> 
                <list list-type="order">
                    <list-item>
                        <p>The principle of pooling samples prior to clustering is important to ensure that the clustering is blind to the sample labels, and thus does not bias the downstream statistical inferences. However, in data sets where the number of cells is highly variable across samples, larger samples may drive the final clustering result. The authors may consider downweighting cells from larger samples during the clustering procedure, to ensure that each sample contributes equally to the outcome.</p>
                    </list-item>
                    <list-item>
                        <p>In what scenarios is the NRS useful? In a mass cytometry experiment, the panel is explicitly designed to interrogate markers of interest, so outside of quality control it makes little sense to discard them in the analysis. Indeed, low variance contributions in PCA does not mean that the marker is not relevant, e.g., if it marks a small population.</p>
                    </list-item>
                    <list-item>
                        <p>If the expected number of cell types is not known in advance, how many metaclusters should be chosen? In very heterogeneous populations, it is easy to imagine that there may well be more than 20 distinct cell subpopulations.</p>
                    </list-item>
                    <list-item>
                        <p>In the discussion, the authors state that "Overall, we expect that as a general rule, including batch parameters (or other covariates) in the linear modeling largely mitigates the problem." This is true to some extent, but will not protect the clustering from batch effects. If the batch effect shifts the intensity distribution between batches, it is possible that a subpopulation in samples of one batch is clustered with the wrong subpopulation in samples of another batch. The counts or median intensities of the cluster are inherently compromised and cannot be fixed by blocking on the batch effect in the model. In other words; when testing for changes in abundance in mass cytometry, the cells are analogous to individual reads in a transcriptomics experiment, while the vector of intensities is analogous to the genic region in which reads are counted. If the batch effect is affecting the intensities, it is analogous to changes in the definition of the genes between batches.</p>
                    </list-item>
                    <list-item>
                        <p>The authors mention using observation weights to describe the uncertainty of the median intensities when testing for differential expression of markers. We note that we have also used this approach in cydar, and it seems to work well. For differential expression of markers within each cluster, the differences in size between clusters are largely irrelevant - all else being equal, if clusters are small, the medians should be more variable, and this should be considered by the inference machinery when computing p-values.</p>
                    </list-item>
                </list> </p>
            <p> 
                <bold>MINOR COMMENTS:</bold> 
                <list list-type="bullet">
                    <list-item>
                        <p>A mention should be made of the fact that fsApply combines the intensity matrices from all data sets; this was not obvious from the code.</p>
                    </list-item>
                    <list-item>
                        <p>There are many ways to do hypothesis testing in GLMMs, with options ranging from Wald Z-tests, LRTs and parametric bootstrapping/MCMC. Some words on what glht actually does would be useful.</p>
                    </list-item>
                    <list-item>
                        <p>Some of the figure captions could be explained in more detail. For example, the numbers and colouring of the entries of the heatmap in Figure 4 are presumably the median marker intensities, but this should be explicitly stated.</p>
                    </list-item>
                    <list-item>
                        <p>Some minor typographical errors: " (Angerer et al., 2016))", "use the flowCore [package]."</p>
                    </list-item>
                    <list-item>
                        <p>The PBMC data set is described as "12 different stimulation conditions", but presumably only one was actually used (BCR/FcR-XL). This could be clarified.</p>
                    </list-item>
                </list>
            </p>
            <p>Is the rationale for developing the new method (or application) clearly explained?</p>
            <p>Yes</p>
            <p>Is the description of the method technically sound?</p>
            <p>Yes</p>
            <p>Are the conclusions about the method and its performance adequately supported by the findings presented in the article?</p>
            <p>Yes</p>
            <p>If any results are presented, are all the source data underlying the results available to ensure full reproducibility?</p>
            <p>Yes</p>
            <p>Are sufficient details provided to allow replication of the method development and its use by others?</p>
            <p>Yes</p>
            <p>Reviewer Expertise:</p>
            <p>NA</p>
            <p>We confirm that we have read this submission and believe that we have an appropriate level of expertise to confirm that it is of an acceptable scientific standard.</p>
        </body>
        <sub-article article-type="response" id="comment3145-23055">
            <front-stub>
                <contrib-group>
                    <contrib contrib-type="author">
                        <name>
                            <surname>Robinson</surname>
                            <given-names>Mark</given-names>
                        </name>
                        <aff>University of Zurich, Switzerland</aff>
                    </contrib>
                </contrib-group>
                <author-notes>
                    <fn fn-type="conflict">
                        <p>
                            <bold>Competing interests: </bold>No competing interests</p>
                    </fn>
                </author-notes>
                <pub-date pub-type="epub">
                    <day>31</day>
                    <month>10</month>
                    <year>2017</year>
                </pub-date>
            </front-stub>
            <body>
                <p>Thank you for taking the time to read and review our paper.</p>
                <p> </p>
                <p> MAJOR POINTS: 
                    <list list-type="order">
                        <list-item>
                            <p>As far as we understand, downweighting of cells (e.g., from larger samples) is not currently possible with FlowSOM. We think that, in general, it may be difficult to incorporate down- weighting into existing clustering algorithms that are tailored for cytometry data, but indeed it is worth considering.</p>
                            <p> One of the easy solutions to ensure that each sample contributes equally to the outcome could be down-sampling so that equal amount of cells from each sample is used in clustering. However, there are two main drawbacks of this strategy. First, a substantial amount of data (cells) may be removed from the analysis resulting in information loss. Second, during down-sampling, some of the rarer populations may become underrepresented or even skipped. Overall, it is also hard to know exactly what "drive the clustering" really means. We highlight these issues now in the "Discussion" section.</p>
                        </list-item>
                        <list-item>
                            <p>NRS can be used to define new panels as it was done in Levine et al. [1]. Indeed, when there is no need for redefining the panel, it can be used as a quality control step. We mention that now in the "Marker ranking based on the non-redundancy score" section.</p>
                            <p> In Levine et al., the NRS score was used to identify a set of surface markers that is "sufficient" to detect the main clusters in the AML data. As the number of markers that can be measured is limited, they could use only 16 channels for surface markers, while the remaining 15 channels were used for signaling markers. Based on average NRS, they identified the 16 surface markers, among 42, that explained the highest amount of variance in their data. The final set was slightly redefined (two markers with high scores were excluded and two markers with low scores were included) based on the biological knowledge, which agrees with the reviewer&#x2019; statement that low variance contributions in PCA do not mean that the marker is not relevant and vice versa. However, we think that NRS can still serve as a relevant guide in marker selection. The final set was then used in the panels in the following experiments.</p>
                        </list-item>
                        <list-item>
                            <p>In general, as rule of thumb, we would suggest setting the number of consensus clusters (parameter maxK in ConsensusClusterPlus) to at least twice the number of expected cell populations. As this number increases, it is necessary to also increase the size of the grid in the SOM step (parameters xdim and ydim in BuildSOM).&#x00a0; It is not necessary to know the exact number of cell types but rather the upper boundary for this number and treat that as the expected number. We also propose a strategy of re-clustering, where first main cell types are identified and extracted and then reclustered in a secondary analysis.&#x00a0; In the updated version of our workflow, we have also added a section called "Obtaining higher resolution" where we describe solutions using a higher amount of clusters for higher resolution.</p>
                        </list-item>
                        <list-item>
                            <p>Yes, we fully agree that including batch effects into the linear modeling does not fully protect the clustering from the batch effect. That is why it is important to account for batches already at the clustering step if possible, although this is itself still a rather open (methodological research) question. Current approaches rely on, for example, equalizing the dynamic range between batches for each marker (e.g. normalization to the 0-1 range, z-scores, quantile normalization), the use of warping functions to eliminate non-linear distortions (cydar [2]), or learning marker distribution shifts between the batches based on a manually gated reference cell type and using it to correct marker expression for the whole dataset (CellCnn [3]). A recent method called MASC [4] that, similarly to our workflow, employs mixed models for the differential abundance analysis deals with batches by identifying and excluding from the clustering analysis markers with high between-batch variability and poorly recorded cells, such as cells with extreme expression values. One could also consider, batch-wise clustering and aggregation, but these strategies also require further study. However, the effectiveness of these approaches has not been sufficiently studied, yet. We still recommend including batch information in the differential analysis as it may further help to mitigate the problem.</p>
                        </list-item>
                        <list-item>
                            <p>Indeed, we agree that the size of clusters should be built into in the inference. This happens automatically in the differential abundance analysis, since we use (over-dispersed) logistic regression. In the differential marker expression analysis, where the medians are compared, one could account for the variability of medians calculated over clusters by assigning lower weights to clusters with lower cell counts. We have not done this in the current workflow, as we are still assessing the effect of it on the power and error control of the methods.</p>
                        </list-item>
                    </list> </p>
                <p> MINOR POINTS: 
                    <list list-type="bullet">
                        <list-item>
                            <p>We now mention that the fsApply function, by default, combines intensity matrices from all data sets.</p>
                        </list-item>
                        <list-item>
                            <p>We have now added some text explaining that the glht function uses t-tests to test the hypothesis.</p>
                        </list-item>
                        <list-item>
                            <p>We have now updated the figure captions, especially those that correspond to Figures 4, 6, 7, 8, 14, 28, 30, and 32.</p>
                        </list-item>
                        <list-item>
                            <p>We have fixed the identified typos.</p>
                        </list-item>
                        <list-item>
                            <p>We have updated the description of the PBMC dataset.</p>
                        </list-item>
                    </list> </p>
                <p> References</p>
                <p> </p>
                <p> [1] &#x00a0;Jacob H. Levine, Erin F. Simonds, Sean C. Bendall, Kara L. Davis, El-ad D. Amir, Michelle D. Tadmor, Oren Litvin, Harris G. Fienberg, Astraea Jager, Eli R. Zunder, Rachel Finck, Amanda L. Gedman, Ina Radtke, James R. Downing, Dana Pe&#x2019;er, and Garry P. Nolan. 
                    <italic>Data-Driven Phenotypic Dissection of AML Reveals Progenitor-like Cells that Correlate with Prognosis</italic>. 
                    <bold>Cell</bold>, 162(1):184&#x2013;97, jun 2015.</p>
                <p> [2] &#x00a0;Aaron T L Lun, Arianne C Richard, and John C Marioni. 
                    <italic>Testing for differential abundance in mass cytometry data</italic>. 
                    <bold>Nat Meth</bold>, 14(7):707&#x2013;709, jul 2017.</p>
                <p> [3] &#x00a0;Eirini Arvaniti and Manfred Claassen. 
                    <italic>Sensitive detection of rare disease-associated cell subsets via representation learning</italic>. 
                    <bold>Nature Communications</bold>, 8:14825, apr 2017.</p>
                <p> [4] &#x00a0;Chamith Y Fonseka, Deepak A Rao, Nikola C Teslovich, Susan K Hannes, Kamil Slowikowski, Michael F Gurish, Laura T Donlin, Michael E Weinblatt, Elena M Massarotti, Jonathan S Coblyn, Simon M Helf- gott, Derrick J Todd, Vivian P Bykerk, Elizabeth W Karlson, Joerg Ermann, Yvonne C Lee, Michael B Brenner, and Soumya Raychaudhuri. 
                    <italic>Reverse Association Of Single Cells To Rheumatoid Arthritis Accounting For Mixed Effects Identifies An Expanded CD27- HLA-DR+ Effector Memory CD4+ T Cell Population</italic>. 
                    <bold>bioRxiv</bold>, 2017.</p>
            </body>
        </sub-article>
    </sub-article>
</article>
