Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bradyajohnston/plasmapr

Creating plasmid maps inside ggplot.
https://github.com/bradyajohnston/plasmapr

Last synced: 19 days ago
JSON representation

Creating plasmid maps inside ggplot.

Awesome Lists containing this project

README

        

---
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

[![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)

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()
```