forked from Sage-Bionetworks/sageseqr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsageseqr-report.Rmd
151 lines (125 loc) · 4.35 KB
/
sageseqr-report.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
---
date: "`r date()`"
output:
html_document:
toc: true
toc_float: true
---
```{css, echo = FALSE}
/* Whole document: */
body{
font-family: Lato;
font-size: 12pt;
}
/* Headers */
h1,h2,h3,h4,h5,h6{
font-size: 24pt;
}
```
```{r title, echo = FALSE}
project <- config::get("report")
```
---
title: `r project`
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
fig.align = 'left',
fig.width = 10,
fig.height = 10)
library(sageseqr)
```
# Data
# Explore Metadata
```{r sample_summary, message = FALSE}
targets::tar_load(clean_md)
var <- config::get("x_var")
summary <- dplyr::group_by_at(clean_md, var)
summary <- dplyr::summarise(summary, count = dplyr::n())
knitr::kable(summary)
```
Visualize the distribution of data.
```{r boxplot}
targets::tar_read(boxplots)
```
```{r boxplot_sex_chromosomes, results = "asis", fig.dim = c(5,5)}
if (!is.null(config::get("sex check"))) {
cat("Visualize gene expression of sex chromosomes using XIST
as a X-chromosome marker and UTY as a Y-chromosome marker.")
targets::tar_read(sex_plot)$plot
}
```
```{r sex_chromosome_pca, results = "asis", fig.dim = c(10,5)}
if (!is.null(config::get("sex check"))) {
cat("Visualize gene expression across X and Y chromosomes by principal component analysis (PCA).")
targets::tar_read(sex_plot)$plot
}
```
Sample swaps identified by discordant sex label, are `r glue::glue_collapse(targets::tar_read(sex_plot_pca)$discordant, ", ", last = " and ")`.
```{r outlier_list, results = "asis"}
if (!is.null(targets::tar_read(sex_plot_pca)$outliers)) {
list <- glue::glue_collapse(targets::tar_read(sex_plot_pca)$outliers, ", ", last = " and ")
glue::glue("Possible outliers, identified as 2 standard deviations from the mean of samples n split by {config::get('sex check')} are {list}.")
} else {
cat("No outliers identified.")
}
```
Visualize the relationships between covariates.
```{r heatmap_covariates}
correlation_input <- targets::tar_read(
correlation_plot
)$plot
col2 <- grDevices::colorRampPalette(rev(c("#67001F", "#B2182B", "#D6604D", "#F4A582",
"#FDDBC7", "#FFFFFF", "#D1E5F0", "#92C5DE",
"#4393C3", "#2166AC", "#053061")))
corrplot::corrplot(correlation_input, col = col2(200), tl.col = "#000000")
```
# Filter Genes
Remove genes that have less than `r config::get("cpm threshold")` counts per million (CPM) in at least `r config::get("percent threshold")` of samples per specified condition.
`r dim(targets::tar_read(filtered_counts))[1]` genes are used in this analysis.
```{r filter_genes}
knitr::kable(targets::tar_read(biotypes))
```
Check distribution of correlation between genes.
```{r histogram}
targets::tar_read(gene_coexpression)
```
# Identify Outliers
```{r plot_outliers}
targets::tar_read(outliers)$plot
```
Outliers, based on logCPM expression, are `r glue::glue_collapse(targets::tar_read(outliers)$outliers, ", ", last = " and ")`.
# Identify Dropped Gene Features
Gene features dropped, because they are not annotated in BioMart, are `r glue::glue_collapse(targets::tar_read(dropped), ", ", last = " and ")`.
# Significant Covariates
Significant covariates are identified by the pearson correlation (p-value of 1%) between principal component analysis (PCA) of normalized transcripts and variables that meet a 0.1 false discovery rate (FDR) threshold. Significant covariates to adjust for are `r glue::glue_collapse(targets::tar_read(significant_covariates_plot)$significant_covariates, ", ", last = " and ")`.
```{r pca_and_significant_covariates}
targets::tar_read(
significant_covariates_plot
)$pc_results
```
# Model Identification
Covariates are added as fixed and random effects iteratively if model improvement by Bayesian Information Criteria (BIC) was observed.
```{r model, results = "asis"}
if (!isTRUE(config::get("skip model"))) {
summary <- targets::tar_read(model)
glue::glue('The best model is: {glue::glue_collapse(as.character(summary$formula), " ")}')
} else {
glue::glue(
'\n\nStepwise regression model not quantified.\n\n'
)
}
```
\n
```{r model_description}
if (!isTRUE(config::get("skip model"))) {
knitr::kable(summary$to_visualize)
}
```
# Differential Expression
```{r differential_expression}
plots <- targets::tar_read(plot_de_volcano)
for(p in plots) {
print(p)
}
```