plotDNA | R Documentation |
Take a vector of strings representing DNA sequences and plot them to the current device. A, C, T and G are colored, - are colored gray and all other characters are white.
plotDNA( seqs, seqCounts = rep(1, length(seqs)), cols = c(A = "green", T = "red", C = "blue", G = "yellow", `-` = "grey", default = "white"), xlab = "Position", ylab = "Sequence Read", display = c(groups = !is.null(groups)), xStart = 1, groups = NULL, groupCexScale = FALSE, refSeq = NULL, res = 0, ... ) plotAA(..., mar = NULL, cols = dnaplotr::aminoCols)
seqs |
A character vector containing DNA sequences |
seqCounts |
A integer vector with the number of counts for each sequence. This can be used to improve run time and file size if some sequences are duplicated multiple times (default: 1 for each entry in seqs) |
cols |
A named vector with names corresponding to the DNA bases and values showing the appropriate color (default: A: green, T: red, C: blue, G: yellow, -: grey) |
xlab |
A string specifying the x-axis label (default: Position) |
ylab |
A string specifying the y-axis label (default: Sequence read) |
display |
A logical vector with element names in 'legend', 'xAxis', 'yAxis', 'groups' where a FALSE suppresses outputting that plot element (default: TRUE for all or any missing elements) |
xStart |
First base in plot should be labelled as this (default: 1) |
groups |
Group sequences by group and show label on right side of plot. Note that any prior ordering of sequences will be disrupted. Use a factor and reorder the levels to set a particular order of groups. |
groupCexScale |
A logical whether to scale group label size by the number of sequences. Useful to highlight more abundant groups and help squeeze in labels on smaller groups. |
refSeq |
Reference sequence used for numbering the x-axis without counting gaps present in this sequence (note that for further annotations outside this function, e.g. abline(v=3), the axis will be from xStart:xStart+max(nchar(seqs)) without any adjustments to ignore reference gaps |
res |
If res greater than 0 then render the colors as a raster graphic with this res x res resolution. Useful for embedding a raster graphic inside a pdf where the file size would otherwise be too large. Note that this parameter is best left at 0 except in special circumstances. |
... |
Additional arguments to plot |
mar |
margin sizes as in |
an invisible vector of the mean vertical position for groupings (empty if 'groups' is null)
plotAA()
: Plot a bunch of AA sequences
plotDNA(c('ACACA','ACACA','ACACT')) refSeq<-'AC---A' seqs<-c('ACTGGA','ACTGCA','ACTGGC','GCTGGG','GGGG',refSeq) par(mar=c(4,5,.5,6),cex.axis=2,cex.lab=2) groupOrder<-c('Group2','Group1','Group3','Reference') groups<-factor(c('Group1','Group2','Group3','Group1','Group3','Reference'),levels=groupOrder) seqCounts<-c(30,10,10,15,5,5) plotDNA(seqs,seqCounts=seqCounts,groups=groups,xStart=10,groupCexScale=TRUE,refSeq=refSeq) 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) fakeAA<-c('MALWTRLRPLLALLALWPPPPARAFVNQHLCGSHLVEALY', 'MALWTRLRPLLALLALWPLPPARAFVNQHLCGSHLVEALY', 'MALWTRLRPLLALLALWPPPPARAFVNX') plotAA(fakeAA,groups=c('Ref','Sub','Stop')) #set res>0 if vector file sizes are too large plotAA(fakeAA,groups=c('Ref','Sub','Stop'),res=500)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.