-
Notifications
You must be signed in to change notification settings - Fork 1
Home
http://dev.lis.ncgr.org:50003/en/blog/2020/07/20/zbrowse/
(TODO: post on legumefederation.org)
Ziegler (2015) Zbrowse.
This comes with ZBrowse (as ZBrowseDocumentation.pdf), or
https://github.com/baxterlabZbrowse/ZBrowse
Ziegler GR, Hartsock RH, Baxter I. (2015) Zbrowse: an interactive GWAS results browser. PeerJ Computer Science 1:e3
https://doi.org/10.7717/peerj-cs.3
(beyond those that came with the original ZBrowse)
jsonlite
Rsamtools
shinyjs
stringi
-
Annotations file: either local in the ZBrowse directory (not its annotations subdirectory), or on a remote server.
-
in the organisms subdirectory, create an organism file.
Line 1 - the organism name
Line 2 - its chromosome lengths
Line 3 - location (local or remote) of its annotations file (from step 1 above)
Line 4 - its base URL for genomic linkages (legumeinfo.org xor legumefederation.org) -
In www/config/datasetProperties.csv, add a line for this organism’s default dataset, following the pattern of Arabidopsis thaliana GWAS or Medicago truncatula GWAS.
-
In buildGWAS.R, add any remote GWAS URLs, specify their column names, and do any special handling.
-
In server.R, Add the new organism and its default GWAS dataset to legumeInfo.organisms and legumeInfo.gwas respectively (near the top of the file). You only need to do the latter if its GWAS data live on a remote server.
In create_zChart, add any special handling for this organism. For example, start at the line
} else if (values[[jth_ref("organism", j)]] %in% c("Medicago truncatula", "Soybean")) { # strand is '+' or '-'
to see how we do it for Medicago truncatula (and now Soybean).
If the annotations are local and require further parsing of the description field, do something similar to what I did for pigeonpea,
if (values[[jth_ref("organism", j)]] == "Pigeonpea") {
# Extract the short description from the annotation
...
}
Add the new organism to the hard-coded parts of geneToQueryTrack and abbrSpeciesName2, if necessary. To avoid the abbrSpeciesName2 issue, make the organism name its full Latin name instead of its common name, such as “Glycine max” instead of “Soybean”.
In the original ZBrowse, the user had to specify the organism by hand, but now we infer the correct organism from the dataset.
Append to Current Dataset
If checked, this combines all requested traits (local and remote) into the currently selected dataset. (I prefer doing it this way.)
If unchecked, it ignores the current dataset, loads each trait into a separate dataset, and displays one of these. (This is the default, for consistency with the original ZBrowse.)
The default (Medicago truncatula GWAS and Arabidopsis thaliana GWAS) datasets contain no traits (at first), allowing you to stock them (with Append to Current Dataset checked) from local or remote files.
Local Trait Files: Browse button
For “Javascript security reasons”, there appears to be no way to clear the display of which local files are scheduled to be loaded. However, changing the dataset should correctly clear the local file list in the background.
server.R
(where the bulk of the action is)
jth_ref()
The cleanest way (that I could think of) to parametrize the code by species. For example,
inputjth_ref("datasets", 1) and input$datasets are identical, and
inputjth_ref("datasets", 2) and input$datasets2 are identical. This is a property of R lists.
values <- reactiveValues()
values stores reactive quantities such as values$organism that are not part of reactive input or output.
observe()
Code in an observe() block gets executed when the user changes any reactive quantity (input$xxx, output$xxx, values$xxx) mentioned within it.
See the Shiny documentation for more details on reactive programming.
loadRemoteData()
Analogous to loadUserData() which is for local GWAS files.
gChart = the Manhattan plot in the Whole Genome view
pChart = the Manhattan plot in the Chromosome view
zChart = the forward and reverse genes plot in the Chromosome view
microSyntenySearch, geneToQueryTrack, provideMultipleURLs, doClickOnLine
These strings contain the Javascript code to invoke when the user clicks on a gene in a zChart. Be careful, R cannot detect Javascript errors due to subtle things like missing semicolons!
Currently there are three possibilities for doClickOnLine:
- If the Genomic Linkage box is checked and we clicked on a gene in the organism 1 zChart, do the genomic linkages query. Otherwise (organism 2 or the Genomic Linkage box is unchecked), we want to launch a URL for the selected gene:
- If the gene’s URL refers to the Legume Information System (for now, this only applies to Medicago truncatula), query LIS for all available URLs and let the user launch them from a dialog box.
- Otherwise, the gene has a single URL. Launch it.
Genomic linkage query results
The code starts near the end of the file, at
observe({
# Handle and display genomic linkage query results
...
I found it easier to handle the results in R instead of Javascript, as the latter was able to update only certain elements of the user interface.
results1 = list of neighboring genes from organism 1
results2 = list of related genes from organism 2
Gene family colors
A successful genomic linkage query returns nf gene families common to the two organisms. We map them to nf colors, uniformly distributed along a rainbow color scheme from red to magenta.
Advantage: as the rainbow has a familiar order, the user easily notices when the corresponding genes of organism 2 are “out of order” relative to organism 1.
Disadvantage: for large nf, the colors of neighboring highlighted genes may be too similar to distinguish.
(added since the original ZBrowse)
buildAnnotations.R Reads the genome annotations from a (local or remote) GFF3 file.
buildGWAS.R Reads a “dataset” (GWAS data frame) from remote GWAS files.
common.R
gChart.R
pChart.R
servicesAPI.R
zChart.R