Skip to content

Instantly share code, notes, and snippets.

@jkanche
Last active April 7, 2020 19:18
Show Gist options
  • Save jkanche/1cd32ad8b2af9d59c834508ddc468359 to your computer and use it in GitHub Desktop.
Save jkanche/1cd32ad8b2af9d59c834508ddc468359 to your computer and use it in GitHub Desktop.
Interactively Query, Transform and Visualize Genomic data from flat files using Epiviz

Interactively Query and Visualize Genomic data from flat files using Epiviz

  • Define data sets (available locally or publicly) as a json configuration file - data.json

  • Run the Epiviz File Server

    Install package through PyPI

    $ pip install epivizfileserver

    or using conda conda

    $ conda create -n epiviz python=3.7

    $ pip install epivizfileserver

    The epiviz python script allows users to load data from the configuration file and define transformations

    $ python epiviz.py

    more information on the file server is available at - Documentation or GitHub

  • Epiviz Components allows users to interactively visualize and embed tracks on most web based platforms that support HTML.

    • First create a directory

    $ mkdir epiviz && cd

    • Use bower to install dependencies

    $ bower init

    $ bower install epiviz/epiviz-chart

    • Create an index.html file to add Epiviz Components that query data from the Epiviz file server, more information on components is available at GitHub
  • Use Caddy or any web server to serve the Components

    $ cd epiviz && caddy

Epiviz Components

[
{
"url": "http://egg2.wustl.edu/roadmap/data/byFileType/signal/consolidated/macs2signal/pval/E070-H3K9me3.pval.signal.bigwig",
"file_type": "bigwig",
"datatype": "feature",
"name": "Brain Germinal Matrix - H3k9me3 signal",
"id": "E070-H3K9me3",
"annotation": {
"group": "H3K9me3",
"tissue": "Brain Germinal Matrix"
},
"metadata": []
},
{
"url": "http://egg2.wustl.edu/roadmap/data/byFileType/signal/consolidated/macs2signal/pval/E071-H3K9me3.pval.signal.bigwig",
"file_type": "bigwig",
"datatype": "feature",
"name": "Brain Hippocampus Middle - H3k9me3 signal",
"id": "E071-H3K9me3",
"annotation": {
"group": "H3K9me3",
"tissue": "Brain Hippocampus Middle"
},
"metadata": []
},
{
"url": "http://egg2.wustl.edu/roadmap/data/byFileType/signal/consolidated/macs2signal/pval/E070-H3K27me3.pval.signal.bigwig",
"file_type": "bigwig",
"datatype": "feature",
"name": "Brain Germinal Matrix - H3K27me3 signal",
"id": "E070-H3K27me3",
"annotation": {
"group": "H3K27me3",
"tissue": "Brain Germinal Matrix"
},
"metadata": []
},
{
"url": "http://egg2.wustl.edu/roadmap/data/byFileType/signal/consolidated/macs2signal/pval/E071-H3K27me3.pval.signal.bigwig",
"file_type": "bigwig",
"datatype": "feature",
"name": "Brain Hippocampus Middle - H3K27me3 signal",
"id": "E071-H3K27me3",
"annotation": {
"group": "H3K27me3",
"tissue": "Brain Hippocampus Middle"
},
"metadata": []
}
]
from epivizfileserver import setup_app, create_fileHandler, MeasurementManager
import os
import numpy
import pickle
if __name__ == "__main__":
# create measurements manager
mMgr = MeasurementManager()
# create file handler
mHandler = create_fileHandler()
# add genome annotation
genome = mMgr.add_genome("hg19")
# define datasets/files available to the File server instance
fmeasurements = mMgr.import_files(os.getcwd() + "/data.json", mHandler)
# define computations over files
ms = [m for m in fmeasurements if m.annotation["group"] == "H3K9me3"]
cms = mMgr.add_computed_measurement("computed", "diff_brain_H3K9me3_signal", "Diff Brain H3K9me3 Signal", measurements=ms,
computeFunc=numpy.mean, annotation={"group": "computed_atac"})
ms = [m for m in fmeasurements if m.annotation["group"] == "H3K27me3"]
cms = mMgr.add_computed_measurement("computed", "diff_brain_H3K27me3_signal", "Diff Brain H3K27me3 Signal", measurements=ms,
computeFunc=numpy.mean, annotation={"group": "computed_atac"})
# run the app
app = setup_app(mMgr)
app.run(host="0.0.0.0", port=8000)
{
"name": "epiviz-app",
"authors": ["Jayaram Kancherla <jayaram.kancherla@gmail.com>"],
"license": "MIT",
"dependencies": {
"polymer": "Polymer/polymer#^2.0.0",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0",
"epiviz-charts": "epiviz/epiviz-chart"
},
"resolutions": {
"polymer": "^2.0.0",
"lodash": "^4.17.10"
},
"private": true
}
<!doctype html>
<html lang="en">
<head>
<title>epiviz Charts Demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/jquery-ui/jquery-ui.js"></script>
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<script src="bower_components/epiviz-charts/src/renderingQueues/renderingQueue.js"></script>
<link rel="import" href="bower_components/epiviz-data-source/epiviz-data-source.html">
<link rel="import" href="bower_components/epiviz-charts/epiviz-charts.html">
</head>
<body>
<!-- Let the components know where the epiviz file server is running -->
<epiviz-data-source provider-type="epiviz.data.WebServerDataProvider" provider-id="fileapi"
provider-url="http://localhost:8000">
</epiviz-data-source>
<!-- initiliaze navigation to a gene location or genomic region -->
<epiviz-navigation
chr="chr18"
start=32254012
end=42505003
>
<!-- add a genes track for hg19 -->
<epiviz-genes-track slot="charts" dim-s='["hg19"]'></epiviz-genes-track>
<!-- add signal tracks for brain tissues -->
<epiviz-line-track slot="charts" dim-s='["E070-H3K9me3", "E071-H3K9me3"]'></epiviz-line-track>
<epiviz-line-track slot="charts" dim-s='["E070-H3K27me3", "E071-H3K27me3"]'></epiviz-line-track>
<!-- add signal tracks computed diff in histone modification across tissues -->
<epiviz-line-track slot="charts" dim-s='["diff_brain_H3K9me3_signal", "diff_brain_H3K27me3_signal"]'></epiviz-line-track>
</epiviz-navigation>
<noscript>
Please enable JavaScript to view this website.
</noscript>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment