---
title: "Tutorials"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Tutorials}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

# TOmicsVis

## 1. Introduction

#### 1.1 Meta Information

**TOmicsVis**: TranscriptOmics Visualization.

**Website**: <https://benben-miao.github.io/TOmicsVis/>

#### 1.2 Github and CRAN Install

**New!!! TOmicsVis Shinyapp:**

```{r eval=FALSE}
# Start shiny application.
TOmicsVis::tomicsvis()
```

![TOmicsVis Shinyapp](https://benben-miao.github.io/TOmicsVis/TOmicsVis-Shinyapp.png)

[![](https://cranlogs.r-pkg.org/badges/grand-total/TOmicsVis?color=orange)](https://cran.r-project.org/package=TOmicsVis)

**1.2.1 Install required packages from Bioconductor:**

```{r eval=FALSE}
# Install required packages from Bioconductor
install.packages("BiocManager")
BiocManager::install(c("ComplexHeatmap", "EnhancedVolcano", "clusterProfiler", "enrichplot", "impute", "preprocessCore", "Mfuzz"))
```

**1.2.2 Github**: <https://github.com/benben-miao/TOmicsVis/>

**Install from Github:**

```{r eval=FALSE}
install.packages("devtools")
devtools::install_github("benben-miao/TOmicsVis")

# Resolve network by GitClone
devtools::install_git("https://gitclone.com/github.com/benben-miao/TOmicsVis.git")
```

**1.2.3 CRAN**: <https://cran.r-project.org/package=TOmicsVis>

**Install from CRAN:**

```{r eval=FALSE}
# Install from CRAN
install.packages("TOmicsVis")
```

#### 1.3 Articles and Courses

**Videos Courses:** <https://space.bilibili.com/34105515/channel/series>

**Article Introduction:** [全解TOmicsVis完美应用于转录组可视化R包](https://mp.weixin.qq.com/s/g8sRcK_ExlsOFniMWEJnVQ)

**Article Courses:** [TOmicsVis 转录组学R代码分析及可视化视频](https://mp.weixin.qq.com/s/mVXJmHPAnC9J1-zMj7eG7g)

#### 1.4 About and Authors

**OmicsSuite**: [Omics Suite Github: https://github.com/omicssuite/](https://github.com/omicssuite/)

**Authors**:

-   [benben-miao Github: https://github.com/benben-miao/](https://github.com/benben-miao/)

-   [dongwei1220 Github: https://github.com/dongwei1220/](https://github.com/dongwei1220/)

## 2. Libary packages

```{r}
# 1. Library TOmicsVis package
library(TOmicsVis)

# 2. Extra package
# install.packages("ggplot2")
library(ggplot2)
```

## 3. Usage cases

### 3.1 Samples Statistics

#### 3.1.1 quantile_plot

**Input Data:** Dataframe: Weight and Sex traits dataframe (1st-col: Weight, 2nd-col: Sex).

**Output Plot:** Quantile plot for visualizing data distribution.

```{r quantile_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(weight_sex)
head(weight_sex)

# 2. Run quantile_plot plot function
quantile_plot(
  data = weight_sex,
  my_shape = "fill_circle",
  point_size = 1.5,
  conf_int = TRUE,
  conf_level = 0.95,
  split_panel = "Split_Panel",
  legend_pos = "right",
  legend_dir = "vertical",
  sci_fill_color = "Sci_NPG",
  sci_color_alpha = 0.75,
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::quantile_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/quantile_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::quantile_plot
```

#### 3.1.2 box_plot

**Input Data:** Dataframe: Length, Width, Weight, and Sex traits dataframe (1st-col: Value, 2nd-col: Traits, 3rd-col: Sex).

**Output Plot:** Plot: Box plot support two levels and multiple groups with P value.

```{r box_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(traits_sex)
head(traits_sex)

# 2. Run box_plot plot function
box_plot(
  data = traits_sex,
  test_method = "t.test",
  test_label = "p.format",
  notch = TRUE,
  group_level = "Three_Column",
  add_element = "jitter",
  my_shape = "fill_circle",
  sci_fill_color = "Sci_AAAS",
  sci_fill_alpha = 0.5,
  sci_color_alpha = 1,
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::box_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/box_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::box_plot
```

#### 3.1.3 violin_plot

**Input Data:** Dataframe: Length, Width, Weight, and Sex traits dataframe (1st-col: Value, 2nd-col: Traits, 3rd-col: Sex).

**Output Plot:** Plot: Violin plot support two levels and multiple groups with P value.

```{r violin_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(traits_sex)

# 2. Run violin_plot plot function
violin_plot(
  data = traits_sex,
  test_method = "t.test",
  test_label = "p.format",
  group_level = "Three_Column",
  violin_orientation = "vertical",
  add_element = "boxplot",
  element_alpha = 0.5,
  my_shape = "plus_times",
  sci_fill_color = "Sci_AAAS",
  sci_fill_alpha = 0.5,
  sci_color_alpha = 1,
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::violin_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/violin_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::violin_plot
```

#### 3.1.4 survival_plot

**Input Data:** Dataframe: survival record data (1st-col: Time, 2nd-col: Status, 3rd-col: Group).

**Output Plot:** Survival plot for analyzing and visualizing survival data.

```{r survival_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(survival_data)
head(survival_data)

# 2. Run survival_plot plot function
survival_plot(
  data = survival_data,
  curve_function = "pct",
  conf_inter = TRUE,
  interval_style = "ribbon",
  risk_table = TRUE,
  num_censor = TRUE,
  sci_palette = "aaas",
  ggTheme = "theme_light",
  x_start = 0,
  y_start = 0,
  y_end = 100,
  x_break = 10,
  y_break = 10
)
```

Get help using command `?TOmicsVis::survival_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/survival_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::survival_plot
```

### 3.2 Traits Analysis

#### 3.2.1 corr_heatmap

**Input Data:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Output Plot:** Plot: heatmap plot filled with Pearson correlation values and P values.

```{r corr_heatmap, fig.width=10.00, fig.height=6.18}
# 1. Load example dataset
data(gene_expression)
head(gene_expression)

# 2. Run corr_heatmap plot function
corr_heatmap(
  data = gene_expression,
  corr_method = "pearson",
  cell_shape = "square",
  fill_type = "full",
  lable_size = 3,
  axis_angle = 45,
  axis_size = 12,
  lable_digits = 3,
  color_low = "blue",
  color_mid = "white",
  color_high = "red",
  outline_color = "white",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::corr_heatmap` or reference page <https://benben-miao.github.io/TOmicsVis/reference/corr_heatmap.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::corr_heatmap
```

#### 3.2.2 pca_analysis

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Table:** PCA dimensional reduction analysis for RNA-Seq.

```{r pca_analysis, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)

data(samples_groups)
head(samples_groups)

# 2. Run pca_analysis plot function
res <- pca_analysis(gene_expression, samples_groups)
head(res)
```

Get help using command `?TOmicsVis::pca_analysis` or reference page <https://benben-miao.github.io/TOmicsVis/reference/pca_analysis.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::pca_analysis
```

#### 3.2.3 pca_plot

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Plot:** Plot: PCA dimensional reduction visualization for RNA-Seq.

```{r pca_plot, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)

data(samples_groups)
head(samples_groups)

# 2. Run pca_plot plot function
pca_plot(
  sample_gene = gene_expression,
  group_sample = samples_groups,
  xPC = 1,
  yPC = 2,
  point_size = 5,
  text_size = 5,
  fill_alpha = 0.10,
  border_alpha = 0.00,
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::pca_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/pca_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::pca_plot
```

#### 3.2.4 tsne_analysis

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Table:** TSNE analysis for analyzing and visualizing TSNE algorithm.

```{r tsne_analysis, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)
data(samples_groups)

# 2. Run tsne_analysis plot function
res <- tsne_analysis(gene_expression, samples_groups)
head(res)
```

Get help using command `?TOmicsVis::tsne_analysis` or reference page <https://benben-miao.github.io/TOmicsVis/reference/tsne_analysis.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::tsne_analysis
```

#### 3.2.5 tsne_plot

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Plot:** TSNE plot for analyzing and visualizing TSNE algorithm.

```{r tsne_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)
data(samples_groups)

# 2. Run tsne_plot plot function
tsne_plot(
  sample_gene = gene_expression,
  group_sample = samples_groups,
  seed = 1,
  multi_shape = FALSE,
  point_size = 5,
  point_alpha = 0.8,
  text_size = 5,
  text_alpha = 0.80,
  fill_alpha = 0.10,
  border_alpha = 0.00,
  sci_fill_color = "Sci_AAAS",
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::tsne_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/tsne_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::tsne_plot
```

#### 3.2.6 umap_analysis

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Table:** UMAP analysis for analyzing RNA-Seq data.

```{r umap_analysis, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)
data(samples_groups)

# 2. Run tsne_plot plot function
res <- umap_analysis(gene_expression, samples_groups)
head(res)
```

Get help using command `?TOmicsVis::umap_analysis` or reference page <https://benben-miao.github.io/TOmicsVis/reference/umap_analysis.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::umap_analysis
```

#### 3.2.7 umap_plot

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Plot:** UMAP plot for analyzing and visualizing UMAP algorithm.

```{r umap_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)
data(samples_groups)

# 2. Run tsne_plot plot function
umap_plot(
  sample_gene = gene_expression,
  group_sample = samples_groups,
  seed = 1,
  multi_shape = TRUE,
  point_size = 5,
  point_alpha = 1,
  text_size = 5,
  text_alpha = 0.80,
  fill_alpha = 0.00,
  border_alpha = 0.00,
  sci_fill_color = "Sci_AAAS",
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::umap_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/umap_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::umap_plot
```

#### 3.2.8 dendro_plot

**Input Data:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Output Plot:** Plot: dendrogram for multiple samples clustering.

```{r dendro_plot, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression)

# 2. Run plot function
dendro_plot(
  data = gene_expression,
  dist_method = "euclidean",
  hc_method = "ward.D2",
  tree_type = "rectangle",
  k_num = 5,
  palette = "npg",
  color_labels_by_k = TRUE,
  horiz = FALSE,
  label_size = 1,
  line_width = 1,
  rect = TRUE,
  rect_fill = TRUE,
  xlab = "Samples",
  ylab = "Height",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::dendro_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/dendro_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::dendro_plot
```

### 3.3 Differential Expression Analyais

#### 3.3.1 venn_plot

**Input Data2:** Dataframe: Paired comparisons differentially expressed genes (degs) among groups (1st-col~: degs of paired comparisons).

**Output Plot:** Venn plot for stat common and unique gene among multiple sets.

```{r venn_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_lists)
head(degs_lists)

# 2. Run venn_plot plot function
venn_plot(
  data = degs_lists,
	title_size = 1,
	label_show = TRUE,
	label_size = 0.8,
	border_show = TRUE,
	line_type = "longdash",
	ellipse_shape = "circle",
	sci_fill_color = "Sci_AAAS",
	sci_fill_alpha = 0.65
)
```

Get help using command `?TOmicsVis::venn_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/venn_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::venn_plot
```

#### 3.3.2 upsetr_plot

**Input Data2:** Dataframe: Paired comparisons differentially expressed genes (degs) among groups (1st-col~: degs of paired comparisons).

**Output Plot:** UpSet plot for stat common and unique gene among multiple sets.

```{r upsetr_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_lists)
head(degs_lists)

# 2. Run upsetr_plot plot function
upsetr_plot(
  data = degs_lists,
  sets_num = 4,
  keep_order = FALSE,
  order_by = "freq",
  decrease = TRUE,
  mainbar_color = "#006600",
  number_angle = 45,
  matrix_color = "#cc0000",
  point_size = 4.5,
  point_alpha = 0.5,
  line_size = 0.8,
  shade_color = "#cdcdcd",
  shade_alpha = 0.5,
  setsbar_color = "#000066",
  setsnum_size = 6,
  text_scale = 1.2
)
```

Get help using command `?TOmicsVis::upsetr_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/upsetr_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::upsetr_plot
```

#### 3.3.3 flower_plot

**Input Data2:** Dataframe: Paired comparisons differentially expressed genes (degs) among groups (1st-col~: degs of paired comparisons).

**Output Plot:** Flower plot for stat common and unique gene among multiple sets.

```{r flower_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_lists)

# 2. Run plot function
flower_plot(
  flower_dat = degs_lists,
  angle = 90,
  a = 1,
  b = 2,
  r = 1,
  ellipse_col_pal = "Spectral",
  circle_col = "white",
  label_text_cex = 1
)
```

Get help using command `?TOmicsVis::flower_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/flower_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::flower_plot
```

#### 3.3.4 volcano_plot

**Input Data2:** Dataframe: All DEGs of paired comparison CT-vs-LT12 stats dataframe (1st-col: Genes, 2nd-col: log2FoldChange, 3rd-col: Pvalue, 4th-col: FDR).

**Output Plot:** Volcano plot for visualizing differentailly expressed genes.

```{r volcano_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_stats)
head(degs_stats)

# 2. Run volcano_plot plot function
volcano_plot(
  data = degs_stats,
  title = "CT-vs-LT12",
  log2fc_cutoff = 1,
  pq_value = "pvalue",
  pq_cutoff = 0.05,
  cutoff_line = "longdash",
  point_shape = "large_circle",
  point_size = 2,
  point_alpha = 0.5,
  color_normal = "#888888",
  color_log2fc = "#008000",
  color_pvalue = "#0088ee",
  color_Log2fc_p = "#ff0000",
  label_size = 3,
  boxed_labels = FALSE,
  draw_connectors = FALSE,
  legend_pos = "right"
)
```

Get help using command `?TOmicsVis::volcano_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/volcano_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::volcano_plot
```

#### 3.3.5 ma_plot

**Input Data2:** Dataframe: All DEGs of paired comparison CT-vs-LT12 stats2 dataframe (1st-col: Gene, 2nd-col: baseMean, 3rd-col: Log2FoldChange, 4th-col: FDR).

**Output Plot:** MversusA plot for visualizing differentially expressed genes.

```{r ma_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_stats2)
head(degs_stats2)

# 2. Run volcano_plot plot function
ma_plot(
  data = degs_stats2,
  foldchange = 2,
  fdr_value = 0.05,
  point_size = 3.0,
  color_up = "#FF0000",
  color_down = "#008800",
  color_alpha = 0.5,
  top_method = "fc",
  top_num = 20,
  label_size = 8,
  label_box = TRUE,
  title = "CT-vs-LT12",
  xlab = "Log2 mean expression",
  ylab = "Log2 fold change",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::ma_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/ma_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::ma_plot
```

#### 3.3.6 heatmap_group

**Input Data1:** Dataframe: Shared DEGs of all paired comparisons in all samples expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Plot:** Heatmap group for visualizing grouped gene expression data.

```{r heatmap_group, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression2)
data(samples_groups)

# 2. Run heatmap_group plot function
heatmap_group(
  sample_gene = gene_expression2[1:30,],
  group_sample = samples_groups,
  scale_data = "row",
  clust_method = "complete",
  border_show = TRUE,
  border_color = "#ffffff",
  value_show = TRUE,
  value_decimal = 2,
  value_size = 5,
  axis_size = 8,
  cell_height = 10,
  low_color = "#00880055",
  mid_color = "#ffffff",
  high_color = "#ff000055",
  na_color = "#ff8800",
  x_angle = 45
)
```

Get help using command `?TOmicsVis::heatmap_group` or reference page <https://benben-miao.github.io/TOmicsVis/reference/heatmap_group.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::heatmap_group
```

#### 3.3.7 circos_heatmap

**Input Data2:** Dataframe: Shared DEGs of all paired comparisons in all samples expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~: Samples).

**Output Plot:** Circos heatmap plot for visualizing gene expressing in multiple samples.

```{r circos_heatmap, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression2)
head(gene_expression2)

# 2. Run circos_heatmap plot function
circos_heatmap(
  data = gene_expression2[1:50,],
  low_color = "#0000ff",
  mid_color = "#ffffff",
  high_color = "#ff0000",
  gap_size = 25,
  cluster_run = TRUE,
  cluster_method = "complete",
  distance_method = "euclidean",
  dend_show = "inside",
  dend_height = 0.2,
  track_height = 0.3,
  rowname_show = "outside",
  rowname_size = 0.8
)
```

Get help using command `?TOmicsVis::circos_heatmap` or reference page <https://benben-miao.github.io/TOmicsVis/reference/circos_heatmap.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::circos_heatmap
```

#### 3.3.8 chord_plot

**Input Data2:** Dataframe: Shared DEGs of all paired comparisons in all samples expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~: Samples).

**Output Plot:** Chord plot for visualizing the relationships of pathways and genes.

```{r chord_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load chord_data example datasets
data(gene_expression2)
head(gene_expression2)

# 2. Run chord_plot plot function
chord_plot(
  data = gene_expression2[1:30,],
  multi_colors = "VividColors",
  color_seed = 10,
  color_alpha = 0.3,
  link_visible = TRUE,
  link_dir = -1,
  link_type = "diffHeight",
  sector_scale = "Origin",
  width_circle = 3,
  dist_name = 3,
  label_dir = "Vertical",
  dist_label = 0.3,
  label_scale = 0.8
)
```

Get help using command `?TOmicsVis::chord_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/chord_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::chord_plot
```

### 3.4 Advanced Analysis

#### 3.4.1 gene_rank_plot

**Input Data:** Dataframe: All DEGs of paired comparison CT-vs-LT12 stats dataframe (1st-col: Genes, 2nd-col: log2FoldChange, 3rd-col: Pvalue, 4th-col: FDR).

**Output Plot:** Gene cluster trend plot for visualizing gene expression trend profile in multiple samples.

```{r gene_rank_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(degs_stats)

# 2. Run plot function
gene_rank_plot(
  data = degs_stats,
  log2fc = 1,
  palette = "Spectral",
  top_n = 10,
  genes_to_label = NULL,
  label_size = 5,
  base_size = 12,
  title = "Gene ranking dotplot",
  xlab = "Ranking of differentially expressed genes",
  ylab = "Log2FoldChange"
)
```

Get help using command `?TOmicsVis::gene_rank_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/gene_rank_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::gene_rank_plot
```

#### 3.4.2 gene_cluster_trend

**Input Data2:** Dataframe: Shared DEGs of all paired comparisons in all groups expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~n-1-col: Groups, n-col: Pathways).

**Output Plot:** Gene cluster trend plot for visualizing gene expression trend profile in multiple samples.

```{r gene_cluster_trend, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression3)

# 2. Run plot function
gene_cluster_trend(
  data = gene_expression3[,-7],
  thres = 0.25,
  min_std = 0.2,
  palette = "PiYG",
  cluster_num = 4
)
```

Get help using command `?TOmicsVis::gene_cluster_trend` or reference page <https://benben-miao.github.io/TOmicsVis/reference/gene_cluster_trend.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::gene_cluster_trend
```

#### 3.4.3 trend_plot

**Input Data2:** Dataframe: Shared DEGs of all paired comparisons in all groups expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~n-1-col: Groups, n-col: Pathways).

**Output Plot:** Trend plot for visualizing gene expression trend profile in multiple traits.

```{r trend_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression3)
head(gene_expression3)

# 2. Run trend_plot plot function
trend_plot(
  data = gene_expression3[1:100,],
  scale_method = "centerObs",
  miss_value = "exclude",
  line_alpha = 0.5,
  show_points = TRUE,
  show_boxplot = TRUE,
  num_column = 1,
  xlab = "Traits",
  ylab = "Genes Expression",
  sci_fill_color = "Sci_AAAS",
  sci_fill_alpha = 0.8,
  sci_color_alpha = 0.8,
  legend_pos = "right",
  legend_dir = "vertical",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::trend_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/trend_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::trend_plot
```

#### 3.4.4 wgcna_pipeline

**Input Data1:** Dataframe: All genes in all samples expression dataframe of RNA-Seq (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: Samples and groups for gene expression (1st-col: Samples, 2nd-col: Groups).

**Output Plot:** WGCNA analysis pipeline for RNA-Seq.

```{r wgcna_pipeline, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load wgcna_pipeline example datasets
data(gene_expression)
head(gene_expression)

data(samples_groups)
head(samples_groups)

# 2. Run wgcna_pipeline plot function
# wgcna_pipeline(gene_expression[1:3000,], samples_groups)
```

Get help using command `?TOmicsVis::wgcna_pipeline` or reference page <https://benben-miao.github.io/TOmicsVis/reference/wgcna_pipeline.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::wgcna_pipeline
```

#### 3.4.5 network_plot

**Input Data:** Dataframe: Network data from WGCNA tan module top-200 dataframe (1st-col: Source, 2nd-col: Target).

**Output Plot:** Network plot for analyzing and visualizing relationship of genes.

```{r network_plot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(network_data)
head(network_data)

# 2. Run network_plot plot function
network_plot(
  data = network_data,
  calc_by = "degree",
  degree_value = 0.5,
  normal_color = "#008888cc",
  border_color = "#FFFFFF",
  from_color = "#FF0000cc",
  to_color = "#008800cc",
  normal_shape = "circle",
  spatial_shape = "circle",
  node_size = 25,
  lable_color = "#FFFFFF",
  label_size = 0.5,
  edge_color = "#888888",
  edge_width = 1.5,
  edge_curved = TRUE,
  net_layout = "layout_on_sphere"
)
```

Get help using command `?TOmicsVis::network_plot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/network_plot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::network_plot
```

#### 3.4.6 heatmap_cluster

**Input Data:** Dataframe: Shared DEGs of all paired comparisons in all samples expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~: Samples).

**Output Plot:** Heatmap cluster plot for visualizing clustered gene expression data.

```{r heatmap_cluster, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression2)
head(gene_expression2)

# 2. Run network_plot plot function
heatmap_cluster(
  data = gene_expression2,
  dist_method = "euclidean",
  hc_method = "average",
  k_num = 5,
  show_rownames = FALSE,
  palette = "RdBu",
  cluster_pal = "Set1",
  border_color = "#ffffff",
  angle_col = 45,
  label_size = 10,
  base_size = 12,
  line_color = "#0000cd",
  line_alpha = 0.2,
  summary_color = "#0000cd",
  summary_alpha = 0.8
)
```

Get help using command `?TOmicsVis::heatmap_cluster` or reference page <https://benben-miao.github.io/TOmicsVis/reference/heatmap_cluster.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::heatmap_cluster
```

### 3.5 GO and KEGG Enrichment

#### 3.5.1 go_enrich

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Table:** GO enrichment analysis based on GO annotation results (None/Exist Reference Genome).

```{r go_enrich, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)
head(gene_go_kegg)

# 2. Run go_enrich analysis function
res <- go_enrich(
  go_anno = gene_go_kegg[,-5],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05
)
head(res)
```

Get help using command `?TOmicsVis::go_enrich` or reference page <https://benben-miao.github.io/TOmicsVis/reference/go_enrich.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::go_enrich
```

#### 3.5.2 go_enrich_stat

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** GO enrichment analysis and stat plot (None/Exist Reference Genome).

```{r go_enrich_stat, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run go_enrich_stat analysis function
go_enrich_stat(
  go_anno = gene_go_kegg[,-5],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  max_go_item = 15,
  strip_fill = "#CDCDCD",
  xtext_angle = 45,
  sci_fill_color = "Sci_AAAS",
  sci_fill_alpha = 0.8,
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::go_enrich_stat` or reference page <https://benben-miao.github.io/TOmicsVis/reference/go_enrich_stat.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::go_enrich_stat
```

#### 3.5.3 go_enrich_bar

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** GO enrichment analysis and bar plot (None/Exist Reference Genome).

```{r go_enrich_bar, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run go_enrich_bar analysis function
go_enrich_bar(
  go_anno = gene_go_kegg[,-5],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  sign_by = "p.adjust",
  category_num = 30,
  font_size = 12,
  low_color = "#ff0000aa",
  high_color = "#008800aa",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::go_enrich_bar` or reference page <https://benben-miao.github.io/TOmicsVis/reference/go_enrich_bar.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::go_enrich_bar
```

#### 3.5.4 go_enrich_dot

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** GO enrichment analysis and dot plot (None/Exist Reference Genome).

```{r go_enrich_dot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run go_enrich_dot analysis function
go_enrich_dot(
  go_anno = gene_go_kegg[,-5],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  sign_by = "p.adjust",
  category_num = 30,
  font_size = 12,
  low_color = "#ff0000aa",
  high_color = "#008800aa",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::go_enrich_dot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/go_enrich_dot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::go_enrich_dot
```

#### 3.5.5 go_enrich_net

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** GO enrichment analysis and net plot (None/Exist Reference Genome).

```{r go_enrich_net, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run go_enrich_net analysis function
go_enrich_net(
  go_anno = gene_go_kegg[,-5],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  category_num = 20,
  net_layout = "circle",
  net_circular = TRUE,
  low_color = "#ff0000aa",
  high_color = "#008800aa"
)
```

Get help using command `?TOmicsVis::go_enrich_net` or reference page <https://benben-miao.github.io/TOmicsVis/reference/go_enrich_net.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::go_enrich_net
```

#### 3.5.6 kegg_enrich

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** GO enrichment analysis based on GO annotation results (None/Exist Reference Genome).

```{r kegg_enrich, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)
head(gene_go_kegg)

# 2. Run go_enrich analysis function
res <- kegg_enrich(
  kegg_anno = gene_go_kegg[,c(1,5)],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05
)
head(res)
```

Get help using command `?TOmicsVis::kegg_enrich` or reference page <https://benben-miao.github.io/TOmicsVis/reference/kegg_enrich.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::kegg_enrich
```

#### 3.5.7 kegg_enrich_bar

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** KEGG enrichment analysis and bar plot (None/Exist Reference Genome).

```{r kegg_enrich_bar, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run kegg_enrich_bar analysis function
kegg_enrich_bar(
  kegg_anno = gene_go_kegg[,c(1,5)],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  sign_by = "p.adjust",
  category_num = 30,
  font_size = 12,
  low_color = "#ff0000aa",
  high_color = "#008800aa",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::kegg_enrich_bar` or reference page <https://benben-miao.github.io/TOmicsVis/reference/kegg_enrich_bar.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::kegg_enrich_bar
```

#### 3.5.8 kegg_enrich_dot

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** KEGG enrichment analysis and dot plot (None/Exist Reference Genome).

```{r kegg_enrich_dot, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run kegg_enrich_dot analysis function
kegg_enrich_dot(
  kegg_anno = gene_go_kegg[,c(1,5)],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  sign_by = "p.adjust",
  category_num = 30,
  font_size = 12,
  low_color = "#ff0000aa",
  high_color = "#008800aa",
  ggTheme = "theme_light"
)
```

Get help using command `?TOmicsVis::kegg_enrich_dot` or reference page <https://benben-miao.github.io/TOmicsVis/reference/kegg_enrich_dot.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::kegg_enrich_dot
```

#### 3.5.9 kegg_enrich_net

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** KEGG enrichment analysis and net plot (None/Exist Reference Genome).

```{r kegg_enrich_net, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)

# 2. Run kegg_enrich_net analysis function
kegg_enrich_net(
  kegg_anno = gene_go_kegg[,c(1,5)],
  degs_list = gene_go_kegg[100:200,1],
  padjust_method = "fdr",
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  category_num = 20,
  net_layout = "circle",
  net_circular = TRUE,
  low_color = "#ff0000aa",
  high_color = "#008800aa"
)
```

Get help using command `?TOmicsVis::kegg_enrich_net` or reference page <https://benben-miao.github.io/TOmicsVis/reference/kegg_enrich_net.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::kegg_enrich_net
```

### 3.6 Tables Operations

#### 3.6.1 table_split

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Table:** Table split used for splitting a grouped column to multiple columns.

```{r table_split, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg2)
head(gene_go_kegg2)

# 2. Run table_split function
res <- table_split(
  data = gene_go_kegg2,
  grouped_var = "go_category",
  value_var = "go_term",
  miss_drop = TRUE
)
head(res)
```

Get help using command `?TOmicsVis::table_split` or reference page <https://benben-miao.github.io/TOmicsVis/reference/table_split.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::table_split
```

#### 3.6.2 table_merge

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Table:** Table merge used to merge multiple variables to on variable.

```{r table_merge, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_go_kegg)
head(gene_go_kegg)

# 2. Run function
res <- table_merge(
  data = gene_go_kegg,
  merge_vars = c("biological_process", "cellular_component", "molecular_function"),
  new_var = "go_category",
  new_value = "go_term",
  na_remove = FALSE
)
head(res)
```

Get help using command `?TOmicsVis::table_merge` or reference page <https://benben-miao.github.io/TOmicsVis/reference/table_merge.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::table_merge
```

#### 3.6.3 table_filter

**Input Data:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Table:** Table filter used to filter row by column condition.

```{r table_filter, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(traits_sex)
head(traits_sex)

# 2. Run function
res <- table_filter(
	data = traits_sex, 
	Sex == "Male" & Traits == "Weight" & Value > 40
	)
head(res)
```

Get help using command `?TOmicsVis::table_filter` or reference page <https://benben-miao.github.io/TOmicsVis/reference/table_filter.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::table_filter
```

#### 3.6.4 table_cross

**Input Data1:** Dataframe: Shared DEGs of all paired comparisons in all samples expression dataframe of RNA-Seq. (1st-col: Genes, 2nd-col~: Samples).

**Input Data2:** Dataframe: GO and KEGG annotation of background genes (1st-col: Genes, 2nd-col: biological_process, 3rd-col: cellular_component, 4th-col: molecular_function, 5th-col: kegg_pathway).

**Output Plot:** Table cross used to cross search and merge results in two tables.

```{r table_cross, warning=FALSE, fig.width=10.00, fig.height=6.18}
# 1. Load example datasets
data(gene_expression2)
head(gene_expression2)

data(gene_go_kegg)
head(gene_go_kegg)

# 2. Run function
res <- table_cross(
  data1 = gene_expression2,
  data2 = gene_go_kegg,
  inter_var = "Genes",
  left_index = TRUE,
  right_index = TRUE
)
head(res)
```

Get help using command `?TOmicsVis::table_cross` or reference page <https://benben-miao.github.io/TOmicsVis/reference/table_cross.html>.

```{r}
# Get help with command in R console.
# ?TOmicsVis::table_cross
```
