---
title: "Examples of Accessible Functions"
output: 
  rmarkdown::html_document:
    toc: true
    toc_float: true
    toc_depth: 3
author: ["Shixiang Wang, Yi Xiong, Longfei Zhao, Kai Gu, Yin Li, Fei Zhao"]
date: "`r Sys.Date()`"
vignette: >
  %\VignetteIndexEntry{Accessible Functions}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

Firstly, assume you have already installed **UCSCXenaShiny** package.

```{r setup}
library(UCSCXenaShiny)
```

## Tutorial Book

From UCSCXenaShiny v2, we provide a comprehensive [tutorial book](https://lishensuo.github.io/UCSCXenaShiny_Book/) for introducing how to use the datasets, functions, and the Shiny application.

## Fetch Data

We provide function to retrieve multi-dimensional data including genomic, epigenomic, transcriptomic, and proteomic data from TCGA (note, this actually contains data from TCGA/TARGET/GTEx databases) and CCLE Pan-Cancer dataset for single identifier (e.g., gene, protein).

Check parameters:

```{r}
args(query_pancan_value)
```

For TCGA gene expression data, we use Xena dataset with ID `TcgaTargetGtex_rsem_gene_tpm` which includes 19131 samples with tumor tissue samples and normal tissue samples. The expression value unit is `log2(tpm+0.001)`.

Let's check several examples.

### Fetch Gene Expression

```{r}
gene_expr <- query_pancan_value("TP53")
```

```{r}
str(gene_expr)
```

### Fetch Transcript Expression

```{r eval=FALSE}
transcript_expr <- query_pancan_value("ENST00000000233", data_type = "transcript")
```

### Fetch Gene CNV

```{r eval=FALSE}
gene_cnv <- query_pancan_value("TP53", data_type = "cnv")
```

### Fetch Gene Mutation

```{r eval=FALSE}
gene_mut <- query_pancan_value("TP53", data_type = "mutation")
```

### Fetch miRNA mature strand expression

```{r eval=FALSE}
miRNA_expr <- query_pancan_value("hsa-let-7a-2-3p", data_type = "miRNA")
```

## Data Visualization

### Visualize Single Gene Expression in PANCAN Dataset

```{r fig.width=12}
vis_toil_TvsN(Gene = "TP53", Mode = "Violinplot", Show.P.value = FALSE, Show.P.label = FALSE)
```

### Compare Gene Expression Level in Single Cancer Type

```{r fig.width=5}
vis_toil_TvsN_cancer(
  Gene = "TP53",
  Mode = "Violinplot",
  Show.P.value = TRUE,
  Show.P.label = TRUE,
  Method = "wilcox.test",
  values = c("#DF2020", "#DDDF21"),
  TCGA.only = FALSE,
  Cancer = "ACC"
)
```

### Compare Gene Expression Level in Different Anatomic Regions

This function needs [gganatogram](https://github.com/jespermaag/gganatogram) package, which is not on CRAN. Please install it before using this function.


```
if (require("gganatogram")) {
  vis_pancan_anatomy(Gene = "TP53", Gender = c("Female", "Male"), option = "D")
}
```

[Click to see the output](https://gitee.com/ShixiangWang/ImageCollection/raw/master/png/20210322130516.png)

### Visualize Relationship between Gene Expression and Prognosis in the PANCAN Dataset

```{r fig.width=5, fig.height=6}
vis_unicox_tree(
  Gene = "TP53",
  measure = "OS",
  threshold = 0.5,
  values = c("grey", "#E31A1C", "#377DB8")
)
```

### Other Functions and Data

All exported data and functions are organized at [here](https://openbiox.github.io/UCSCXenaShiny/reference/index.html).