knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette will go further in detail for the drawProtein()
function, as well as review other functions provided by the package.
The drawProtein function is the main drawing function. The function takes in arguments to draw proteins like so:
#To draw a single protein uniprotProteinView::drawProtein("Q04206") #To draw multiple using list style uniprotProteinView::drawProtein(list("Q04206", "Q9D270")) #To draw multiple using vector style uniprotProteinView::drawProtein(c("Q04206", "Q9D270")) #To draw multiple specifically using type/colors list format uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "Q9D270")))
As the above examples show in the final example, the format for entries using the drawProtein()
function can have multiple formats for the arguments, but the "truest" form is using a list with a type vector and a colors vector, as shown in the code below
uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "Q9D270"), colors = c("red", "green")))
For colors, if the user leaves the element blank, then a random color will be chosen, however if the user provides the format:
uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "Q9D270"), colors = "red"))
Then the first protein will be drawn red, while the second will be a random color. The function provides colors in a index fashion, where the element in the same index position will have that color assigned, and if no color is present, then a random color is given. The color can be given in with a string with a color name (example: red
), in hexadecimal (example: #ffffff
), or using the rgb()
function (example: rgb(0, 0.5, 1)
), provided by the grDevices
package. Thus the user can use the following code to insert random color choices between specified color entries. Note that the function recognizes the word "random" as the user wanting a random color.
#This will draw the first protein red, second random color, third green uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "Q9D270", "Q06628"), colors = c("red", "random", "green")))
For protein entries, the user has the option to also select a random entry as well:
uniprotProteinView::drawProtein("random")
This will find a random human protein, as human is the default. To choose another organism, use the UniProt organism ID, an example using mouse (id = 10090):
uniprotProteinView::drawProtein("random orgid:10090")
To specify how many randoms the user can use the number
key word:
uniprotProteinView::drawProtein("random number:10")
The above function will get 10 random human proteins, and graph them, putting it all together:
#This function will draw the Q04206 protein red, and then 5 random mouse proteins, random colors uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "random orgid:10090 number:5"), colors = "red")) #As an alternative, you can also specify how many random colors are used as well, like so. #This will draw Q04206 red, 4 random proteins random colors, and the final random protein green uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "random orgid:10090 number:5"), colors = c("red", "random number:4", "green")))
To draw features on the protein, the format is the same, using type/colors list
#This will the draw the protein with any and all features that match the name 'domain' uniprotProteinView::drawProtein("Q04206", types = "domain")
The types specifier does a literal search (capitalization ignored) for all feature names, and if they should match will draw them. These features are applied to all proteins. Colors for the features can be done in the same way as the proteins.
uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "random orgid:10090 number:5"), colors = c("red", "random number:4", "green")), types = list(type = c("domain", "region of interest"), colors = c("black", "pink")) )
All features provided by the UniProt API have a name and a description. Thus the types
argument will preform a literal search on all names, however you can also search the description using a pattern. The description search takes in a term, like "phos" and then searches through all descriptions to see if any of them have "phos" somewhere in the name, so "Phosphoserine" would return true. This argument is usually used to search for modified residues, as the name for them is "modified residue" while the description would be "Phosphoserine".
#The input for the descriptionSearch argument is also of the same type/colors format, here we only give it a string, and thus it will have a random color applied to it uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "random orgid:10090 number:5"), colors = c("red", "random number:4", "green")), types = list(type = c("domain", "region of interest"), colors = c("black", "pink")), descriptionSearch = "phos" )
Some features the user may also want to offset set. Traditionally this is used for things such as secondary structure features, thus the offSetFeatures
argument will do a literal search through the feature names, and if any should match will draw them, offset.
uniprotProteinView::drawProtein(proteins = list(type = c("Q04206", "random orgid:10090 number:5"), colors = c("red", "random number:4", "green")), types = list(type = c("domain", "region of interest"), colors = c("black", "pink")), descriptionSearch = "phos", offSetFeatures = list(type = c("strand", "helix", "turn"), colors = c("green", "random", "pink")) )
Other arguments that can be set by the function drawProtein()
are:
btwnSpacingStart
: This argument is used to define when the offSetFeatures start drawing from, default is 1 as the height of proteins are drawn by increments of 1
btwnSpacing
: This argument defines how tall the offSetFeatures are, default is 0.3
title
: Title of the plot, default is NULL
saveGlobal
: This argument defines if the protein XML and features data should be saved to global variables of the name uniProtProteinView_xmls
and uniProtProteinView_data
, respectivly
showProgress
: This argument defines if the progress of the protein download and parsing should be shown, default is TRUE
This function, when called, opens up a shiny app. Alternatively, the user can visit the webpage: ShinyApp
uniprotProteinView::runUniprotProteinDraw()
This function is the main function to retrieve XML data from the UniProt API. It will handle all data retrieval for the user. It is exported primarily for use by the Shiny App. For arguments this function
webPageData <- uniprotProteinView::getProtein("Q04206", FALSE)
This function is used to parse a list of proteins, and return a list of equal size, where instead of protein XML data, is a data frame of all the features that the protein contains. Exported primarily for use by the Shiny App
webPageData <- uniprotProteinView::getProtein("Q04206", FALSE) features <- uniprotProteinView::getFeaturesDataFrame(webPageData)
Alternatively, if the user wishes to provide arguments to the drawProtein()
function after using the XML and features data frame, they can. To do this, use the following format:
xml <- uniprotProteinView::getProtein("Q04206", FALSE) features <- uniprotProteinView::getFeaturesDataFrame(xml) matrix <- rbind(list(xml = xml[[1]], features = features[[1]], colors = "red")) uniprotProteinView::drawProtein(proteins = list(preComputed = matrix))
The preComputed
method, must provide the function with a list containing a named element called "preComputed". This should itself have a matrix with column names of "xml", "features", and "colors". The colors input is for the colors of the protein. Each row should have its own xml, features and colors, where colors is equal to a single color. Further, if the user is trying to add csv data to the drawProtein function, this is the method to do so. For xml data, this argument is actually partially not required for when using the preComputed
input method. All that is required here is a list with a field called name
, thus the following is a completely valid input.
xml <- uniprotProteinView::getProtein("Q04206", "Q06628", FALSE) features <- uniprotProteinView::getFeaturesDataFrame(xml) matrix <- rbind(list(xml = list(name = "Apple"), features = features[[1]], colors = "red")) matrix <- rbind(matrix, list(xml = list(name = "Pear"), features = features[[1]], colors = "green")) uniprotProteinView::drawProtein(proteins = list(preComputed = matrix))
There by from this, one means the user can load up information and feed it into the drawProtein function, might be to use the file name for the name parameter for xml, and then the csv data for the features data frame.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.