This package has been created to allow the creation of protein schematics based on the data obtained from the Uniprot Protein Database.
The basic workflow is: 1. to provide one or more Uniprot IDs 2. get a list of feature from the Uniprot API 3. draw the basic chains of these proteins 4. add features as desired
drawProteins uses the package httr to interact with the Uniprot API and extract a JSON object into R. The JSON object is used to create a data.table.
The graphing package ggplot2 is then used to create the protein schematic.
Currently, drawProteins interacts with the [Uniprot database]http://www.uniprot.org/. At least one working Uniprot accession numbers must be provided. More than one can be provided but they must be separated by a single space. The spaces are replaced to create an url that can be used to query the Uniprot API
get_features() function uses the Uniprot API to return the features of a
protein - the chain, domain information and other annotated features such as
“repeats” and “motifs”. Post-translational modifications, such as
phosphorylations, are also provided.
httr::content() function is then used to extract the content. From the
get_features() function, this will provide lists of lists. The length of the
parent lists corresponds to the number of accession numbers provided.
Interestingly, the order sometimes appears different to that provided. Each of
lists inside the parent list are a list of six - one for each protein - that
contains names of the proteins and the features.
As an example, we will retrieve the details of a protein called Rel A or NF-kappaB, p65, a well studied transcription factor.
With internet access, this can be retreived from Uniprot with this code:
# accession numbers of rel A drawProteins::get_features("Q04206") -> rel_json
 "Download has worked"
The next step in the workflow is to convert the data from the Uniprot API into a dataframe that can be used with ggplot2.
feature_to_dataframe() function will convert the list of lists of six
provided by the
get_features() function to a dataframe which can then be
used to plot the schematics.
feature_to_dataframe() function will also add an “order” value to allow
plotting. The order goes from the bottom in the manner of a graph.
drawProteins::feature_to_dataframe(rel_json) -> rel_data # show in console head(rel_data[1:4])
type description begin end featuresTemp CHAIN Transcription factor p65 1 551 featuresTemp.1 DOMAIN RHD 19 306 featuresTemp.2 REGION Disordered 309 348 featuresTemp.3 REGION Transcriptional activation domain 3 342 389 featuresTemp.4 REGION Transcriptional activation domain 1 415 476 featuresTemp.5 REGION Disordered 506 530
The data can be plotted with ggplot2 using the
The first step is to make canvas with
draw_canvas which is based on the
longest protein that is being drawin. This can be done using a pipe in the
draw_canvas(rel_data) -> p p
Then we can plot the protein chain. We use the
draw_chain() function to which
we have to provide the ggplot object
p and the data which is
p <- draw_chains(p, rel_data) p
Now, we add the domains which are drawn to scale in terms of their lengths. We
draw_domains() function to which we have to provide the
p and the data which is called
The default is to label the chains. The labels can be removed using the
label_chains = FALSE.
p <- draw_domains(p, rel_data) p
To show this visualisation better, a white background helps as well as removing the y-axis and the grid. Also changing the size of the text using the base_size argument. This can be done with this code:
# white background and remove y-axis p <- p + theme_bw(base_size = 20) + # white background theme(panel.grid.minor=element_blank(), panel.grid.major=element_blank()) + theme(axis.ticks = element_blank(), axis.text.y = element_blank()) + theme(panel.border = element_blank()) p
draw_regions(p, rel_data) # adds activation domain
draw_repeat(p, rel_data) # doesn't add anything in this case
draw_motif(p, rel_data) # adds 9aa Transactivation domain & NLS
# add phosphorylation sites from Uniprot draw_phospho(p, rel_data, size = 8)
In this way it’s possible to chose the geoms that give the information desired in the way you like. Some customisation is possible as described below.
For Rel A, my recommendation would be the following workflow.
draw_canvas(rel_data) -> p p <- draw_chains(p, rel_data) p <- draw_domains(p, rel_data) p <- draw_regions(p, rel_data) p <- draw_motif(p, rel_data) p <- draw_phospho(p, rel_data, size = 8) p <- p + theme_bw(base_size = 20) + # white backgnd & change text size theme(panel.grid.minor=element_blank(), panel.grid.major=element_blank()) + theme(axis.ticks = element_blank(), axis.text.y = element_blank()) + theme(panel.border = element_blank()) p