---
title: "How to interpret the HTML report generated by `cellCellReport` function"
author:
- name: Koki Tsuyuzaki
  affiliation: Laboratory for Bioinformatics Research,
    RIKEN Center for Biosystems Dynamics Reseach
- name: Manabu Ishii
  affiliation: Laboratory for Bioinformatics Research,
    RIKEN Center for Biosystems Dynamics Reseach
- name: Itoshi Nikaido
  affiliation: Laboratory for Bioinformatics Research,
    RIKEN Center for Biosystems Dynamics Reseach
  email: k.t.the-answer@hotmail.co.jp
package: scTensor
output:
  BiocStyle::html_document
vignette: |
  %\VignetteIndexEntry{scTensor: 2. Interpretation of HTML report}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Introduction

Here, we explain the way to interpret of HTML report generated by `cellCellReport`.
If `cellCellDecomp` is properly finished, we can perform `cellCellReport`
function to output the HTML report.
The results can be confirmed by typing `example(cellCellReport)`.
The report will be generated in the temporary directory (it costs 5 to 10 minutes).
The output directory contains some files and directories as follows.

- **index.{Rmd,html}** : The main HTML report
- **reanalysis.RData** : The R binary file for using in the HTML report and reanalysis of scTensor
- **Workflow_2.png** : The figure for the section 1. About scTensor Algorithm in the HTML report
- **figures** : The directory containing some figures for the HTML report
- **ligand.{Rmd,html}** : The HTML report for the section 6. Gene-wise Hypergraph in the HTML report
- **ligand_all.{Rmd,html}** : The HTML report for the section 6. Gene-wise Hypergraph in the HTML report
- **receptor.{Rmd,html}** : The HTML report for the section 6. Gene-wise Hypergraph in the HTML report
- **receptor_all.{Rmd,html}** : The HTML report for the section 6. Gene-wise Hypergraph in the HTML report
- **pattern_X_Y.{Rmd,html}** : The HTML report for For the section 7. (Ligand-Cell, Receptor-Cell, ) -related L-R Pairs in the HTML report

Here, look at the index.html.

![Figure1 : HTML report of `cellCellReport`](Report_HEADER.png)

# Interpretation of "1. About scTensor Algorithm"

In the HTML report, the 1st item describes the overview of `r Biocpkg("scTensor")` and other CCI-related packages.

![Figure2: 1. About scTensor Algorithm](Report_1.png)

# Interpretation of "2. Global statistics and plots"

The 2nd item describes all the R objects saved in **reanalysis.RData**,
which contains the result of `r Biocpkg("scTensor")`.
This file is saved in the output directory (**out.dir**) specified in `cellCellReport`,
and the user also can re-analyze the result of `r Biocpkg("scTensor")`.

![Figure3: 2. Global statistics and plots](Report_2.jpg)

Using `r CRANpkg("plotly")` package, `cellCellReport` generates some interactive plots.
For example, in item 2.1, the number of cells in each cell type can be confirmed when the cursor moved on the box.

![Figure4: 2.1 Number of cells in each celltype](Report_2_1.jpg)

In item 2.2, the number of expressed genes in each cell type (Non-zero genes) can be confirmed when the cursor moved on the box.
![Figure5: 2.2 Number of expressed genes in each cell type (Non-zero genes)](Report_2_2.jpg)

In item 2.3, two-dimensional plot user specified can be confirmed.
![Figure6: 2.3 Two dimensional plot of all cells](Report_2_3.jpg)

In item 2.4, distribution of core tensor values and the value of each (Ligand-Cell-type, Receptor-Cell-type, LR-pair) pattern can be confirmed.

The red bars mean that these values are selected by the threshold (**thr** parameters) in `cellCellReport`.

Note that the thr can be specified from 0 to 100,
the large thr value will generate too many HTML files (cf. 8. (Ligand-Cell, Receptor-Cell, LR-pair) Patterns)
and takes a long time.

![Figure7 : 2.4 Distribution of core tensor values](Report_2_4.png)

The 3-order CCI-tensor consisting of Cell_L $\times$ Cell_R $\times$ LR-pair (LR) are decomposed by `r CRANpkg("nnTensor")`,
in which the tensor is iteratively matricised to mode-1 (Ligand-Cell direction) and mode-2 (Receptor-Cell direction).

In each direction, NMF is performed and the strength of each directional patterns are summarized in the bar plots.

For example, in item 2.5, distribution of mode-1 matricised tensor can be confirmed.

![Figure8: 2.5 Distribution of mode-1 matricised tensor (Ligand-Cell Direction) (1/2)](Mode1.jpg)

![Figure9: 2.5 Distribution of mode-1 matricised tensor (Ligand-Cell Direction) (2/2)](Report_2_5.jpg)

Likewise, in item 2.6, distribution of mode-2 matricised tensor can be confirmed,

![Figure10 : 2.6 Distribution of mode-2 matricised tensor (Receptor-Cell Direction) (1/2)](Mode2.jpg)

![Figure11 : 2.6 Distribution of mode-2 matricised tensor (Receptor-Cell Direction) (2/2)](Report_2_6.jpg)

# Interpretation of "3. Ligand-Cell Patterns"

In the 3rd item, using heatmap of `r CRANpkg("plotly")`, user can interactively confirm the detail of Ligand-Cell Patterns extracted by `r CRANpkg("nnTensor")`.

![Figure14 : 3. Ligand-Cell Patterns](Report_3.jpg)

# Interpretation of "4. Receptor-Cell Patterns"

Likewise, in the 4th item, the user can interactively confirm the detail of Receptor-Cell Patterns.

![Figure15 : 4. Receptor-Cell Patterns](Report_4.jpg)

# Interpretation of "5. CCI-wise Hypergraph"

In the 6th item describes, the strength between Ligand-Cell Patterns and Receptor-Cell Patterns (CCI-strength),
by the summation of the core tensor with the mode-3 direction,
a matrix consisting of the number of Ligand-Cell Patterns $\times$ the number of Receptor-Cell Patterns.

![Figure18 : 6. CCI-wise Hypergraph (1/2)](Mode3Sum.jpg)
![Figure19 : 6. CCI-wise Hypergraph (2/2)](Report_5.png)

# Interpretation of "6. Gene-wise Hypergraph"

In the 7th item, the relationship between LR-pairs, which coexpressed in any LR-pair pattern at least one time.
Ligand genes are described as red nodes,
receptor genes are described as blue nodes,
and corresponding LR-pair patterns are described as the color of edges.
Using `r CRANpkg("visNetwork")` package,
these interactions can be interactively visualized.

![Figure20 : 7. Gene-wise Hypergraph](Report_6.png)

Under the gene-wise hypergraph, four hyper-links are embedded.

In the 1st link, the details of gene-wise hypergraph can be confirmed as a corresponding table in a ligand gene-centric manner.
This page can work as reverse lookup search by "Ctrl + F";
by typing the gene name of ligand that the user is interested in,
the partner receptors, which are coexpressed in some LR-pair patterns,
also can be found.
![Figure21: Details of Ligand Gene-centric Overview (selected)](Ligand_selected.png)


In the 2nd link, the user can find all the partner receptors,
even if the partner receptors are not coexpressed in any LR-pair pattern,
and if they are not included in the data matrix.
![Figure22: Details of Ligand Gene-centric Overview (all)](Ligand_all.png)

Likewise, the receptor gene-centric reverse search page is embedded in the 3rd link,
![Figure23: Details of Receptor Gene-centric Overview (selected)](Receptor_selected.png)

and, in the 4th link, all the partner ligand genes are included.
![Figure24: Details of Receptor Gene-centric Overview (all) (1/2)](Receptor_all_HEADER.png)
![Figure25 : Details of Receptor Gene-centric Overview (all) (2/2)](Receptor_all.png)

# Interpretation of "7. (Ligand-Cell, Receptor-Cell, LR-pair) Patterns"

In the 8th item, the details of (Ligand-Cell, Receptor-Cell, LR-pair) Patterns are ordered by the size of core tensor, and the link of each pattern is embedded.

(Note that the number of the number of links is dependent on the **thr** parameter of `cellCellReport`.)
![Figure26: 8. (Ligand-Cell, Receptor-Cell, LR-pair) Patterns](Report_7.png)

For example, the 1st link describes the details of (3,2,) Pattern, which means the relationship of *1*st pattern of Ligand-Cell patterns, *1*st pattern of Receptor-Cell patterns, and *5*th pattern of LR-pair patterns.
![Figure27 : Details of (3,2,) Pattern (1/3)](Details_32_HEADER.png)

In this pattern, only one LR-pair is coexpressed (INSL3 and GNG11).
The hyperlinks to many databases and PubMed are also embedded.
The degree of the size of the LR-pair in the LR-pair pattern is quantified as P-value and Q-value.
![Figure28 : Details of (3,2,) Pattern (2/3)](Details_32_Pair.png)

Under the LR-pair list,
the results of many enrichment analysis is also embedded such as Gene Ontology (BP/MF/CC), Reactome, MeSH...etc.
![Figure29 : Details of (3,2,) Pattern (3/3)](Details_32_EA_HEADER.png)

User can confirm the detail of the result of `r Biocpkg("scTensor")`, and perform the biological interpretation.

# Session information {.unnumbered}

```{r sessionInfo, echo=FALSE}
sessionInfo()
```
