knitr::opts_chunk$set(echo = TRUE, message=FALSE, warning=FALSE)
if (!require(DECIPHER)) { BiocManager::install("DECIPHER") } library(DECIPHER)
root <- system.file(package="bfxapps2") stopifnot(file.exists(root)) remote_folder = file.path(root, "extdata/coronaviridae") # https://raw.githubusercontent.com/PacktPublishing/R-Bioinformatics-Cookbook/master/datasets/ch3" fa_file = file.path(remote_folder,"coronaviridae.fasta") # "plastid_genomes.fa" # if (!file.exists(fa_file)) { # download.file(file.path(remote_folder,fa_file),fa_file) # } stopifnot(file.exists(fa_file))
library(Biostrings) seqs <- readDNAStringSet(fa_file) seqs
sequence_names <- unlist(lapply(strsplit(names(seqs),split=" "),FUN=function(x){x[1]})) Seqs2DB(seqs, "XStringSet", "corona_db", sequence_names, replaceTbl = TRUE)
synteny = FindSynteny("corona_db") pairs(synteny)
plot(synteny)
alignment = AlignSynteny(synteny, "corona_db")
blocks = unlist(alignment[[1]]) writeXStringSet(blocks, "corona_blocks_out.fa")
library(dplyr) library(rtracklayer) gff_file=file.path(remote_folder,"GCF_009858895.2_ASM985889v3_genomic.gff") gff <- rtracklayer::readGFF(gff_file)
ids = which(gff$gene == "S") gff[ids,c("start","end","type","gene")]
synteny[1,2][[1]]%>% as.data.frame() %>% filter(start1 >= 21563 & start1 <= 25384)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.