Chapters and reference
- 6.1Import sequences and annotations
- 6.2Import intervals and paired intervals
- 6.3Signals and coverage data
- 6.4Aligned characters and source coordinates
- 6.5Relationships, variants and annotations
- 6.6Import nucleotide and protein alignments
- 6.7BLASTp protein comparisons
- 6.8Protein-to-genome coordinate projection
- 6.9Data workflows
- 6.10Sequence comparisons from source files
- 6.11Flagship data sources and construction
Data and workflows · Section 2 of 12
6.1 Import sequences and annotations
On this page
Data preparation and settings (expand)
R · Example code
library(dplyr)
seqs <- seq_data_example |>
select(accver, length)
links <- ribbon_data_example |>
select(qaccver, saccver, qstart, qend, sstart, send)
# Recover biological strands from the source annotation field.
genes <- gene_data_example |>
transmute(accver, start, end, strand = source_strand)Extract the input bundle so the working directory contains examples/. Each section names its optional dependencies.
1 Adapt an existing table
The preparation above loads the input tables. These examples rename columns of bundled source-backed sequences, links and genes; they do not invent alignments.
R · Example code
renamed_sequences <- seqs |>
rename(chrom = accver, size = length)
sequence_input <- as_ggchord_seq(renamed_sequences, mapping = c(accver = "chrom", length = "size"))
renamed_features <- genes |>
rename(chrom = accver, left = start, right = end)
feature_input <- as_ggchord_feature(renamed_features,
mapping = c(accver = "chrom", start = "left", end = "right")
)
link_input <- as_ggchord_link(links)Output / text
.source_row qaccver saccver qstart qend sstart send
1 1 MT108731.1 MT118296.1 26298 51139 7121 31959
2 2 MT108731.1 MT118296.1 21513 25922 2365 6772
3 3 MT108731.1 MT118296.1 20376 20677 403 704
4 4 MT108731.1 OQ646790.1 45278 50839 27955 33476Adapters return ordinary frames with ggchord_conversion provenance. IDs remain unchanged. Supply reliable full lengths rather than using maximum feature ends. See alignment input for minimal fields and coordinate units.
2 GenBank: retain record identity
R · Example code
# The original NCBI L09137.2 record identifies pUC19c; keep that identity.
genbank_result <- NULL
if (nzchar(Sys.which("python3")) && identical(suppressWarnings(system2("python3",
c("-c", shQuote("from Bio import SeqIO")),
stdout = FALSE, stderr = FALSE
)), 0L)) {
genbank_result <- read_genbank("examples/format-inputs/pUC19c-L09137.2.gb")
}Output / text
NULLThis is the original NCBI L09137.2 record, named pUC19c; do not rename it to the bundled pUC19. Results include seq_data, features$annotation and report, retaining segmented locations and record/feature provenance. The selected Python needs Biopython already installed; no automatic installation occurs. unsupported = "report" records unsupported locations rather than guessing bounds.
The GenBank example was rerun with Python Biopython 1.85 enabled: it returned L09137.2, length 2686 bp and one annotation row. For a separate documentation environment, install Biopython with that Python’s python3 -m pip install biopython, then put its executable on PATH before starting R. Do not treat an optional-dependency skip or NULL as successful import.
An explicit python path keeps the selected virtual environment, including interpreter symlinks; no environment is installed or modified.
Extract the manual bundle so the working directory contains examples/. Read one format at a time, inspect a few rows, then match sequence IDs.
3 FASTA lengths and GFF3 annotations
R · Example code
head(read_fasta_lengths(files = "examples/fasta/*.fna"), 4)| accver | length | .source_line |
|---|---|---|
| MT108731.1 | 64323 | 1 |
| MT118296.1 | 32090 | 1 |
| OQ646790.1 | 57367 | 1 |
| OR222515.1 | 83080 | 1 |
FASTA supplies full lengths. GFF3 supplies intervals, types and source strands. Select CDS for plotting as needed.
| accver | start | end | strand | type |
|---|---|---|---|---|
| MT108731.1 | 13064 | 14554 | + | CDS |
| MT108731.1 | 22920 | 23705 | + | CDS |
| MT108731.1 | 23894 | 24814 | + | CDS |
| MT108731.1 | 27115 | 28053 | + | CDS |
4 Read a BLAST table
| qaccver | saccver | qstart | qend | sstart | send |
|---|---|---|---|---|---|
| MT108731.1 | MT118296.1 | 26298 | 51139 | 7121 | 31959 |
| MT108731.1 | MT118296.1 | 21513 | 25922 | 2365 | 6772 |
| MT108731.1 | MT118296.1 | 20691 | 21146 | 1032 | 1495 |
Each row contains two intervals. Keep their endpoint order and check both sequence IDs against the FASTA records. See alignment inputs for standard BLAST output.
5 Convert Bioconductor objects directly
With GenomicRanges installed, convert one interval into a feature table. Known full lengths are supplied in seqlengths and can be extracted with as_ggchord_seq(gr).
| accver | start | end | strand | .source_row | directionality | source_strand |
|---|---|---|---|---|---|---|
| a | 10 | 30 | + | 1 | forward | + |
The first GInteractions anchor is the query, and the second is the subject. This minimal example joins two intervals. It also requires InteractionSet.
| qaccver | saccver | qstart | qend | sstart | send | qstrand | sstrand | .source_row | .query_anchor | .subject_anchor | orientation_known | direction | query_directionality | subject_directionality |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| a | b | 10 | 30 | 40 | 60 | * | * | 1 | 1 | 2 | FALSE | None | none | none |
See import and conversion for other inputs. Use the converted tables to add layers.