README.md

DNAPlotR

Build Status codecov.io

Install

An R library to plot a visual representation of a vector of DNA sequences. To install directly from github, use the devtools library and run:

devtools::install_github("sherrillmix/dnaplotr")

Then load the library as normal using:

library(dnaplotr)

Main functions

plotDNA

plotDNA(seqs) takes a character vector of strings representing DNA sequences and plots them to the current device. By default, A, C, T and G are colored, - are colored gray and all other characters are white. For example:

seqs<-c('ACACA','ACACA','ACACT','ACA-A')
plotDNA(seqs)

plot of chunk seqExample

plotAA

plotAA(seqs) takes a character vector of strings representing amino acid sequences and plots them to the current device. By default, amino acids are colored according to a colorscheme modified from JMol that seeks to assign similar colors to amino acids with similar properties. In addition, - are colored gray, stop codons (annotated as X) are black and all other characters are white. For example:

fakeAA<-c('MALWTRLRPLLALLALWPPPPARAFVNQHLCGSHLVEALY',
'MALWTRLRPLLALLALWPLPPARAFVNQHLCGSHLVEALY',
'MALWTRLRPLLALLALWPPPPARAFVNX')
plotAA(fakeAA,groups=c('Ref','Sub','Stop'))

plot of chunk aaExample

Helper functions

replaceOuterGaps

replaceOuterGaps(seqs) marks gaps at the ends of sequences differently than internal indels. For example:

seqs<-c('--AA-A','--AA--','A-AA-A')
replaceOuterGaps(seqs)
## [1] "..AA-A" "..AA.." "A-AA-A"

replaceAfterStop

replaceAfterStop(seqs) marks amino acids after a stop codon. For example:

seqs<-c('AAARXAA','AAARX','ARARAXRRAXAAR')
replaceAfterStop(seqs)
## [1] "AAARXXX"       "AAARX"         "ARARAXXXXXXXX"

More complex example

A more complex example displaying 1000 sequences is:

fakeSeqs<-createFakeDNA(1000)
refSeq<-fakeSeqs[1]
fakeSeqs<-fakeSeqs[-1]
species<-sprintf('Species %s',sub(' [0-9]+$','',names(fakeSeqs)))
par(mar=c(3.5,4.4,.5,7))
plotDNA(fakeSeqs,groups=species,groupCexScale=TRUE)

To produce something like: Example of DNA plot See generatePlots.R or inst/doc/example.pdf for complete plotting details.



sherrillmix/dnaplotr documentation built on Oct. 29, 2022, 4:42 p.m.