-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
98 lines (67 loc) · 2.24 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
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(
fig.path = "man/figures/",
fig.width = 7,
fig.height = 7,
dpi = 300
)
```
# plasmapR
<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/bradyajohnston/plasmapR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/bradyajohnston/plasmapR?branch=main)
[![R-CMD-check](https://github.com/bradyajohnston/plasmapR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/bradyajohnston/plasmapR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
This is an R package for making plasmid maps using `{ggplot2}`.
## Installation
> This package is still very early in development and the API may change. The
> parser for `.gb` files works most of the time but has not been tested
> extensively.
```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("bradyajohnston/plasmapr")
```
## Example
`plasmapR` provides functions for parsing and plotting .gb plasmid files.
Once a plasmid has been exported in Genbank format it can be parsed and plotted.
```{r example-plasmid, dev='ragg_png'}
library(plasmapR)
fl <- system.file('extdata', 'petm20.gb', package = "plasmapR")
fl |>
read_gb() |>
plot_plasmid(name = "pETM-20")
```
Access the features by turning the plasmid into a data.frame.
```{r}
fl <- system.file('extdata', 'petm20.gb', package = "plasmapR")
plasmid <- fl |>
read_gb()
dat <- plasmid |>
as.data.frame()
head(dat)
dat[dat$type == "CDS", ] |>
plot_plasmid(name = "pETM-20")
```
It's not currently intended for linear display, but it can be used as such. I recommend checking out the [`gggenese`](https://wilkox.org/gggenes/) package.
```{r}
#| fig-height: 3
#| message: false
#| warning: false
dat[dat$type == "CDS", ] |>
plot_plasmid(name = NULL) +
ggplot2::coord_cartesian() +
ggplot2::scale_y_continuous(limits = NULL)
```
## A {ggplot2} Object
The result of the call is just a {ggplot2} plot, which you can further customise
to your liking with themes, etc.
```{r example-theme, dev='ragg_png'}
fl <- system.file('extdata', '20.gb', package = "plasmapR")
plt <- fl |>
read_gb() |>
plot_plasmid()
plt + ggplot2::theme_bw()
```