knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE)

R Library Decipher

if (!require(DECIPHER)) {
  BiocManager::install("DECIPHER")
}
library(DECIPHER)

Download Data

remote_folder="https://raw.githubusercontent.com/PacktPublishing/R-Bioinformatics-Cookbook/master/datasets/ch3"
# change "Chapter03" to "ch3"
fa_file = "plastid_genomes.fa"
if (!file.exists(fa_file)) {
  download.file(file.path(remote_folder,fa_file),fa_file)
}
stopifnot(file.exists(fa_file))

Reading DNA Sequences

library(Biostrings)
seqs <- readDNAStringSet(fa_file)
seqs

Prepare Local "Indices"

sequence_names <- names(seqs)
Seqs2DB(seqs, "XStringSet", "long_db", sequence_names)

Find Synteny

synteny = FindSynteny("long_db")
pairs(synteny)

Plot Syntenic Blocks

plot(synteny)

Align Syntenic Blocks

alignment = AlignSynteny(synteny, "long_db")

Save Pairwise Alignments

blocks = unlist(alignment[[1]])
writeXStringSet(blocks, "genome_blocks_out.fa")


eckartbindewald/bfxapps2 documentation built on Feb. 6, 2025, 3:22 a.m.