Installation - yzhong005/ggplasmidZY GitHub Wiki

Installation and input formats

Install from GitHub

The easiest installation uses remotes and downloads the current package source from GitHub:

install.packages("remotes")
remotes::install_github("yzhong005/ggplasmidZY")

library(ggplasmidZY)

The package imports ggplot2 and ggsci, so R installs them automatically as dependencies. ragg is suggested, rather than required, for high-quality raster output. Install it when you want to use it as a graphics device:

install.packages("ragg")

To update an existing installation, run remotes::install_github() again and restart RStudio after the installation finishes.

Install a local checkout in RStudio

Use this workflow while editing the package locally:

  1. Open the package project or set the working directory to the package folder.
  2. Install the package dependencies.
  3. Install the local source package with repos = NULL.
  4. Restart RStudio or reload the package before testing a new version.
install.packages(c("ggplot2", "ggsci", "remotes"))

# Run this from the package root containing DESCRIPTION and R/.
remotes::install_local(".", upgrade = "never")

library(ggplasmidZY)

For package development checks, install devtools and run the check from the same package root:

install.packages("devtools")
devtools::check()

Choose an input type

ggplasmid() accepts a parsed GenBank object, a GenBank file path, or an annotation table. The input type determines where the sequence used for GC content and GC skew comes from.

GenBank input

When the GenBank file contains an ORIGIN sequence, the sequence and feature annotation are read together. No separate FASTA file is needed:

gbk_file <- "path/to/your_genome.gbk"
annotation <- read_plasmid_annotation(gbk = gbk_file)

ggplasmid(
  annotation = annotation,
  name = "my-genome",
  layout = "circular",
  palette = "igv"
)

You can also pass the file path directly:

ggplasmid(
  gbk = "path/to/your_genome.gbk",
  name = "my-genome",
  layout = "linear",
  plot_line_num = 4
)

Annotation table plus FASTA

Use this input type when the annotation is stored separately from the genome sequence. The table must contain at least start and end coordinates. Read your own FASTA file and pass the resulting object as fasta:

features <- read_annotation_table("path/to/features.tsv")
fasta <- read_fasta("path/to/your_genome.fasta")

ggplasmid(
  annotation = features,
  fasta = fasta,
  genome_length = fasta$length[1](/yzhong005/ggplasmidZY/wiki/1),
  name = "my-genome",
  layout = "linear",
  plot_line_num = 4
)

The FASTA object supplies the sequence for GC content and GC skew and also provides the genome length when genome_length is not supplied. The packaged pSGNDM-5 FASTA is used only in public examples to make them reproducible:

demo_fasta <- read_fasta(
  system.file("extdata", "pSGNDM_5.fasta", package = "ggplasmidZY")
)

Required and recognized table columns

start and end are required, but common alternatives are detected automatically. A category column is recommended because it controls feature-arrow colors and can also control label colors when label_text_colour = "category". Other column names are accepted for the standard fields:

  • Coordinates: start/begin/from/left and end/stop/to/right
  • Strand: strand/frame/direction
  • Label text: label/product/annotation/function/gene/name/note
  • Category: category/group/function_category/class
  • Feature type: type/feature/region

If no category column is supplied, ggplasmid() infers categories from the feature label and type when possible. For custom label colors, add columns containing valid R colors and pass their names to label_text_colour and label_line_colour:

features$label_colour <- "#2166AC"
features$line_colour <- "grey45"

ggplasmid(
  annotation = features,
  fasta = fasta,
  genome_length = fasta$length[1](/yzhong005/ggplasmidZY/wiki/1),
  label_text_colour = "label_colour",
  label_line_colour = "line_colour"
)

gene_highlight() sets selected gene-arrow fill colors. Label text and leader-line colors are controlled separately. Set label_text_colour = "category" when label text should follow the feature/category colors, or use valid color columns for fully custom label and line colors.

Sequence regions

For GenBank or annotation-table input, region_start and region_end select a 1-based inclusive sequence window. Features and sequence-derived GC tracks are clipped and rebased to the selected region:

ggplasmid(
  gbk = "path/to/your_genome.gbk",
  region_start = 1300,
  region_end = 16890,
  layout = "linear",
  plot_line_num = 2
)

See Linear maps for a complete cropped-region example.