-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.Rmd
More file actions
38 lines (34 loc) · 867 Bytes
/
Copy pathreport.Rmd
File metadata and controls
38 lines (34 loc) · 867 Bytes
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
---
title: "report.Rmd"
output: html_document
params:
path: "data.tsv"
---
```{r setup, include=FALSE}
library(tidyverse)
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
plot_map <- function(df, xmax, width = 0.01)
{
width <- width / ((xmax * width) / (max(df$Kbp) * width))
ggplot(df, aes(Kbp, id)) +
geom_tile(width = width) +
scale_fill_continuous(na.value = "transparent") +
facet_wrap(enzyme ~ ., ncol = 1, scales = "free_x") +
theme_minimal() +
theme(
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
legend.position = "bottom"
)
}
```
```{r, fig.height = 8, fig.width=10}
df <-
read_tsv(params$path) %>%
mutate(Kbp = size / 1000) %>%
mutate_at("id", factor, levels = rev(unique(.$id))) %>%
ungroup()
split(df, df$enzyme) %>% lapply(plot_map, max(df$Kbp), width = 1 / 4)
```