-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
172 lines (137 loc) · 5.94 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/",
out.width = "100%"
)
```
# LIRA
LIRA is an R package to predict the effectiveness of immunotherapy in patients with NSCLC.
## 1.Introduction
1.LIRA was designed to predict the response to immunotherapy in patients with NSCLC.
2.This package consists a random survival model based on expression profiles of 50 genes, which were selected through univariate Cox regression and subgroup analysis.
3.This package provides functions for different scenarios and allows visual assessment to determine whether patients are suitable for immunotherapy.
## 2.Installation
It is essential that you have R 3.6.3 or above already installed on your computer or server. Before installing LIRA, please install all dependencies by executing the following command in R console:
The dependencies includes`IOBR`,`crayon`,`ggplot2`,`randomForest`,`randomForestSRC`.
#### Graphical abstract for construction and clinical application of LIRA
![LIRA logo](./man/figures/LIRA-workflow.png)
```{r installation, warning=FALSE, message=FALSE}
if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager")
depens<-c( "crayon", "ggplot2", "randomForest", "randomForestSRC")
for(i in 1:length(depens)){
depen<-depens[i]
if (!requireNamespace(depen, quietly = TRUE)) BiocManager::install(depen,update = FALSE)
}
if (!requireNamespace("IOBR", quietly = TRUE)) devtools::install_github("IOBR/IOBR")
```
Then, you can start to install IOBR from github by typing the following code into your R session:
```{r warning=FALSE}
if (!requireNamespace("LIRA", quietly = TRUE))
remotes::install_github("LiaoWJLab/LIRA")
```
Load the IOBR package in your R session after the installation is complete:
```{r message=FALSE, warning=FALSE}
library(LIRA)
library(IOBR)
library(tidyverse)
```
## 3.Usage
### Obtain dataset from TCGA using UCSCXenaTools R package.
For transcriptome data of TCGA data sets, we strongly recommend user to use UCSCXenaTools R package. Here, we download counts data of TCGA-LUAD from UCSC using UCSCXenaTools R package
```{r, eval=FALSE}
if (!requireNamespace("UCSCXenaTools", quietly = TRUE))
BiocManager::install("UCSCXenaTools")
library(UCSCXenaTools)
eset<-XenaGenerate(subset = XenaCohorts =="GDC TCGA Lung Adenocarcinoma (LUAD)") %>%
XenaFilter(filterDatasets = "TCGA-LUAD.htseq_counts.tsv") %>%
XenaQuery() %>%
XenaDownload() %>%
XenaPrepare()
```
```{r, message=FALSE, warning=FALSE}
eset<- readr::read_tsv("TCGA-LUAD.htseq_counts.tsv.gz")
# Remove the version numbers in Ensembl ID.
eset$Ensembl_ID<-substring(eset$Ensembl_ID, 1, 15)
eset<-column_to_rownames(eset, var = "Ensembl_ID")
# Revert back to original format because the data from UCSC was log2(x+1)transformed.
eset<-(2^eset)-1
head(eset[1:5,1:5])
#remove normal sample of TCGA-LUAD
eset<- eset[,!substring(colnames(eset), 14,16)=="11A"]
colnames(eset)<- substring(colnames(eset), 1,12)
summary(duplicated(colnames(eset)))
eset<- eset[,!duplicated(colnames(eset))]
```
### Transform count data to TPM using [IOBR package](https://iobr.github.io/book/).
```{r}
eset_tpm <- count2tpm(countMat = eset, idType = "Ensembl")
#using phenotype data derived from TCGA paper [https://pubmed.ncbi.nlm.nih.gov/34019806/]
data(pdata_luad)
summary(pdata_luad$ID%in%colnames(eset))
```
### Annotating genes in expression matrix and remove duplicate genes using [IOBR package](https://iobr.github.io/book/).
```{r}
eset <- anno_eset(eset = eset, annotation = anno_grch38, probe = "id", symbol = "symbol")
```
## Calculate LIRA score of TCGA-LUAD samples
```{r, message=FALSE, warning=FALSE}
res <- lira_model(eset = eset,
pdata = pdata_luad,
id_pdata = "ID",
scale = TRUE)
res <- res$score
```
```{r}
p1<- ggplot(res, aes(x= LIRA)) +
geom_histogram(bins = 30, colour = "grey", alpha = 0.5)+
design_mytheme(axis_angle = 0)+
scale_fill_manual(values = palettes(palette = "jco", show_col = FALSE))
```
```{r, fig.width=13, fig.height=7, message=FALSE, warning=FALSE}
library(survminer)
res<- best_cutoff(pdata = res, time = "os_time", status = "os_status", variable = "LIRA", PrintResult = FALSE)
# help("surv_group")
p2<- surv_group(
input_pdata = res,
target_group = "LIRA_binary",
levels = c("High", "Low"),
reference_group = "High",
project = "TCGA-LUAD",
time = "os_time",
status = "os_status",
time_type = "day",
break_month = "auto",
cols = NULL,
palette = "jama",
mini_sig = "",
save_path = paste0("man/figures"))
p1+p2
```
```{r, message=FALSE, results='hide',warning=FALSE, fig.show='hide'}
tme<- calculate_sig_score(eset = eset_tpm, pdata = res, signature = signature_collection, method = "PCA", adjust_eset = TRUE)
# colnames(tme)
p1<- sig_box(data = tme, signature = "CD_8_T_effector", variable = "LIRA_binary", palette = "jama")
p2<- sig_box(data = tme, signature = "Nature_metabolism_Hypoxia", variable = "LIRA_binary", palette = "jama")
p3<- sig_box(data = tme, signature = "Ferroptosis", variable = "LIRA_binary", palette = "jama")
p4<- sig_box(data = tme, signature = "Glutathione_Metabolism", variable = "LIRA_binary", palette = "jama")
```
Combination of plots
```{r, fig.width = 13, fig.height = 6}
if (!requireNamespace("patchwork", quietly = TRUE)) install.packages("patchwork")
library(patchwork)
p<-(p1|p2|p3|p4)
p + plot_annotation(tag_levels = 'A')
```
References
---------
1.Wang ZJ, Fang YR, ..., Liao WJ, Zeng DQ; Predicting Immunotherapy Outcomes in NSCLC using RNA and pathology: Insights from OAK, POPLAR, and ORIENT-11 Trials. (2024).
Reporting bugs
---------
Please report bugs to the [Github issues page](https://github.com/LiaoLab/LIRA/issues)
E-mail any questions to dongqiangzeng0808@gmail.com