-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathknit_atacQC_v2.qmd
executable file
·212 lines (154 loc) · 5.43 KB
/
knit_atacQC_v2.qmd
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
params:
title: title
id: trex_id
genome: genome
annot: annot
date: today
title: "`r params$title`"
author: <a href="https://trex.biotech.cornell.edu/"> Transcriptional Regulation & Expression Facility </a>
format:
html:
standalone: true
embed-resources: true
toc: true
toc-location: left
toc-title: "Summary"
grid:
content-mode: full
sidebar-width: 350px
body-width: 1600px
---
------------------------------------------------------------------------
```{=html}
<style type="text/css">
.quarto-title-banner {
height: 100px; /* Adjust the height value as needed */
}
.main-container {
max-width: 90% !important;
margin: auto;
}
.quarto-title-meta-contents a:hover {
color: #c44900;
}
.trex-logo:hover {
transform: scale(2);
transition: transform 0.2s ease-in-out;
transform-origin: right center;
}
</style>
```
[![](https://raw.githubusercontent.com/bixBeta/atac/main/img/trex-mini.png){.trex-logo fig-align="right"}](https://trex.biotech.cornell.edu/)
<hr>
## Fragment Size Distributions
```{r , fig.show='hold', echo=F, results='asis'}
# Begin the tabset panel
cat('::: {.panel-tabset}\n')
p1 <- list.files("./atacQC.out", pattern = "fragSize.png$", full.names = T)
my_elements <- c("Tab 1", "Tab 2", "Tab 3")
# Loop over the elements and create a tab for each
for (element in p1) {
cat(paste0('## ', gsub(pattern = ".fragSize.png", replacement = "", x = basename(element)), '\n\n'))
cat(paste0("![](", element , ")", "{width=800}" ))
# Your content for each tab goes here
#knitr::include_graphics(p1[element])
# For example, you can include images, text, or other R outputs
cat('\n\n')
}
# End the tabset panel
cat(':::\n')
```
## TSSE Scores
[Encode Guidelines](https://www.encodeproject.org/atac-seq/#standards)
```{r echo=FALSE, warning=FALSE, out.width='60%', out.height='100%'}
suppressPackageStartupMessages(library(ggplot2))
suppressPackageStartupMessages(library(plotly))
tsseScores <- readRDS("atacQC.out/tsseScores.RDS")
tsseScores.df = as.data.frame(round(unlist(tsseScores), 2))
colnames(tsseScores.df) = "value"
tsseScores.df$Samples = rownames(tsseScores.df)
# ggplotly(ggplot(data = tsseScores.df, aes(x = labels, y = value )) + geom_bar(stat = "identity") +
# geom_text(aes(label=value), vjust=1.6, color="white", size=3.5) + ggtitle("Transcription Start Site (TSS) Enrichment Scores") +
# xlab("Sample") + ylab("TSS Score") + scale_y_continuous() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)))
m <- list(
l = 1,
r = 1,
b = 50,
t = 50,
pad = 1
)
plot_ly(data = tsseScores.df, x = ~ Samples, y= ~ value, type = "bar",
colors = c('#c1b8c8'),
text = ~ value, height = 600,
marker = list(size = 14,
color = '#c1b8c8',
line = list(width = 1)),
hovertemplate = paste("%{x}<br>%{text}<extra>TSSE-Score</extra>")) %>%
layout(autosize = T, margin =m, title = "Transcription Start Site (TSS) Enrichment Scores",
scene = list(xaxis = list(title = paste0(" %")),
yaxis = list(title = paste0(" %"))
), margin = m
) %>% layout(legend = list(orientation = 'v', xanchor = "left"))
```
## Peaks Annotations
```{r echo=FALSE, eval=T, out.width=1000, out.height=1000, warning=FALSE}
logs = list.files(path = "./atacQC.out/", pattern = "__percent__annot__log.txt$", full.names = T)
logs.list = list()
for (i in 1:length(logs)) {
logs.list[[i]] <- read.table(logs[i], header = T, sep = "\t", row.names = 1)
names(logs.list)[[i]] <- gsub(pattern = "_peaks.narrowPeak__percent__annot__log.txt",
replacement = "", basename(logs[[i]]))
}
logs.df <- do.call("rbind", logs.list)
suppressPackageStartupMessages(library(tidyr))
logs.df$tmp = rownames(logs.df)
logs.df = separate(logs.df, col = tmp, into = "sampleID", sep = "\\.", extra = "drop")
colors<- c("#EF8A62",
"#1f78b4",
"#1b9e77",
"#736372",
"#E9A3C9",
"#A1D76A",
"#FFFF33",
"grey",
"#b3e2cd",
"#67A9CF",
"peachpuff2",
"red",
"magenta3",
"blue",
"yellow"
)
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(plotly))
logs.df$Frequency = round(logs.df$Frequency, 1)
m <- list(
l = 50,
r = 50,
b = 100,
pad = 20
)
logs.df %>% plot_ly(x = ~Frequency, y = ~sampleID, type = 'bar', orientation = "h",
name = ~Feature, color = ~Feature, colors =rev(colors) ) %>%
layout(yaxis = list(title = 'Percentage(%)'), barmode = 'stack',
legend = list(orientation = 'h', xanchor = "center",
x = 0.5, y = -0.1), margin = m)
```
## Read Count Frequencies
```{r , fig.show='hold', echo=F, results='asis'}
# Begin the tabset panel
cat('::: {.panel-tabset}\n')
p2 <- list.files("./atacQC.out/", pattern = ".narrowPeak.Distribution.png$", full.names = T)
# Loop over the elements and create a tab for each
for (element in p2) {
cat(paste0('## ', gsub(pattern = ".narrowPeak.Distribution.png", replacement = "", x = basename(element)), '\n\n'))
cat(paste0("![](", element , ")", "{width=800}" ))
# Your content for each tab goes here
#knitr::include_graphics(p1[element])
# For example, you can include images, text, or other R outputs
cat('\n\n')
}
# End the tabset panel
cat(':::\n')
```