Learn R Programming

DECIPHER (version 1.12.0)

BrowseSequences: View Sequences In A Web Browser

Description

Opens an html file in a web browser to show the sequences in an XStringSet.

Usage

BrowseSequences(myXStringSet, htmlFile = paste(tempdir(), "/myXStringSet.html", sep = ""), colorPatterns = TRUE, highlight = 0, patterns = c("-", alphabet(myXStringSet, baseOnly=TRUE)), colors = substring(rainbow(length(patterns), v=0.8, start=0.9, end=0.7), 1, 7), colWidth = Inf, ...)

Arguments

myXStringSet
A XStringSet object of sequences.
htmlFile
Character string giving the location where the html file should be written.
colorPatterns
Logical specifying whether to color matched patterns, or an integer vector providing pairs of start and stop boundaries for coloring.
highlight
Numeric specifying which sequence in the set to use for comparison or 0 to color all sequences (default).
patterns
Character vector containing regular expressions to be colored in the XStringSet. Regular expressions are searched sequentially with multiple matches allowed, even within other previously matched patterns. (See details section below.)
colors
Character vector providing the color for each of the matched patterns. Typically a character vector with elements of 7 characters, ``#'' followed by the red, blue, green values in hexadecimal (after rescaling to 0 ... 255). Positions with background color have white font.
colWidth
Integer giving the maximum number of nucleotides wide the display can be before starting a new page. Must be a multiple of 20 (e.g., 100), or Inf (the default) to display all the sequences in one set of rows.
...
Additional arguments to adjust the appearance of the consensus sequence at the base of the display. Passed directly to ConsensusSequence for an AAStringSet, DNAStringSet, or RNAStringSet, or to consensusString for a BStringSet.

Value

Creates an html file containing sequence data and opens it in a web browser for easy viewing. The layout has the sequence name on the left, position legend on the top, cumulative number of nucleotides on the right, and consensus sequence on the bottom.Returns htmlFile if the html file was written successfully.

Details

BrowseSequences converts an XStringSet into html format for viewing in a web browser. If patterns are supplied then they are matched as regular expressions, and colored according to colors. Some web browsers cannot quickly display a large amount colored text, so it is recommended to use color = FALSE or to highlight a sequence when viewing a large XStringSet. Highlighting will only show all of the characters in the highlighted sequence, and convert all matching positions in the other sequences into dots without color.

Patterns are not matched across column breaks, so multi-character patterns should be carefully considered when colWidth is less than the maximum sequence length. Patterns are matched sequentially in the order provided, so it is feasible to use nested patterns such as c("ACCTG", "CC"). In this case the ``CC'' could be colored differently inside the previously colored ``ACCTG''. Note that patterns overlapping the boundaries of a previously matched pattern will not be matched. For example, ``ACCTG'' would not be matched if patterns=c("CC", "ACCTG").

See Also

BrowseDB, ConsensusSequence

Examples

Run this code
db <- system.file("extdata", "Bacteria_175seqs.sqlite", package="DECIPHER")
dna <- SearchDB(db)
BrowseSequences(dna, colWidth=100, highlight=1)

# color bases in alternating groups with a different color scheme
BrowseSequences(dna[1:5],
	colorPatterns=seq(1, width(dna)[1], 10),
	patterns=c("A", "C", "G", "T", "-"),
	colors=c("#1E90FF", "#32CD32", "#9400D3", "#000000", "#EE3300"))

# color all restriction sites
data(RESTRICTION_ENZYMES)
sites <- RESTRICTION_ENZYMES
sites <- sites[order(nchar(sites))] # match shorter sites first
# convert all restriction sites into regular expressions
for (degeneracy in names(IUPAC_CODE_MAP)[5:15]) {
    sites <- gsub(degeneracy,
        paste("[", degeneracy, "|",
            paste(strsplit(IUPAC_CODE_MAP[degeneracy], "")[[1]],
                collapse="|"),
            "]",
            sep=""),
        sites)
}
dna <- SearchDB(db, remove="all") # unaligned sequences
BrowseSequences(dna, patterns=sites)

Run the code above in your browser using DataLab