<jupyter_start><jupyter_text>Synced heatmaps<jupyter_code>from higlass.client import View, Track
import higlass

t1 = Track(track_type='top-axis', position='top')
t2 = Track(track_type='heatmap', position='center',
          tileset_uuid='CQMd6V_cRw6iCI_-Unl3PQ',
          server="http://higlass.io/api/v1/")

# the entire viewport has a width of 12 so a width of 6 for
# each view means they take up half the width
view1 = View([t1, t2], width=6)
view2 = View([t1, t2], width=6, x=6)

display, server, viewconf = higlass.display(
    [view1, view2],
    location_syncs = [[view1, view2]],
    zoom_syncs = [[view1, view2]],
    value_scale_syncs = [[(view1, t2), (view2, t2)]])
display<jupyter_output><empty_output><jupyter_text>Value scale syncing<jupyter_code>from higlass.client import View, Track
import higlass

t1 = Track(track_type='top-axis', position='top')
t2 = Track(track_type='heatmap', position='center',
          tileset_uuid='CQMd6V_cRw6iCI_-Unl3PQ',
          server="http://higlass.io/api/v1/",
          height=250,
          options={ 'valueScaleMax': 0.5 })

# the entire viewport has a width of 12 so a width of 6 for
# each view means they take up half the width
view1 = View([t1, t2], width=6)
view2 = View([t1, t2], width=6, x=6)

display, server, viewconf = higlass.display(
    [view1, view2],
    value_scale_syncs = [[(view1, t2), (view2, t2)]])
display<jupyter_output><empty_output><jupyter_text>Remote heatmaps<jupyter_code>from higlass.utils import hg_cmap

track_def = {
    "track_type": 'heatmap', 
    "position": 'center',
    "tileset_uuid": 'CQMd6V_cRw6iCI_-Unl3PQ',
    "server": "http://higlass.io/api/v1/",
    "height": 210,
    "options": {}
}

t1 = Track(**track_def)
t2 = Track(**{ **track_def, "tileset_uuid": "QvdMEvccQuOxKTEjrVL3wA" })
t3 = (t1 / t2).change_attributes(
    options={
        'colorRange': hg_cmap('coolwarm'),
        'valueScaleMin': 0.1,
        'valueScaleMax': 10,
    })
domain = [7e7,8e7]

v1 = View([t1], x=0, width=4, initialXDomain=domain)
v2 = View([t3], x=4, width=4, initialXDomain=domain)
v3 = View([t2], x=8, width=4, initialXDomain=domain)

display, server, viewconf = higlass.display([v1, v2, v3])
display
QvdMEvccQuOxKTEjrVL3wA
viewconf<jupyter_output><empty_output><jupyter_text>Remote bigWig tiles<jupyter_code>ts1 = higlass.tilesets.bigwig(
    'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeSydhTfbs/wgEncodeSydhTfbsGm12878InputStdSig.bigWig')
view1 = View([Track('horizontal-bar', tileset=ts1)])
display, server, viewconf = higlass.display([view1])

display<jupyter_output><empty_output><jupyter_text>Local cooler filesThis section describes how to load cooler files that are on the same filesystem as the Jupyter notebook. If the Jupyter kernel is not running on localhost, see the section on [Remote Jupyter notebooks](https://docs-python.higlass.io/getting_started.htmlremote-jupyter-notebook) in the docs.<jupyter_code>ts1 = higlass.tilesets.cooler('../test/data/Dixon2012-J1-NcoI-R1-filtered.100kb.multires.cool')
tr1 = Track('heatmap', tileset=ts1)
view1 = View([tr1])
display, server, viewconf = higlass.display([view1])

display<jupyter_output><empty_output><jupyter_text>Local bigWig files (with chromsizes)<jupyter_code>chromsizes = [
 ('chr1', 249250621),
 ('chr2', 243199373),
 ('chr3', 198022430),
 ('chr4', 191154276),
 ('chr5', 180915260),
 ('chr6', 171115067),
 ('chr7', 159138663),
 ('chr8', 146364022),
 ('chr9', 141213431),
 ('chr10', 135534747),
 ('chr11', 135006516),
 ('chr12', 133851895),
 ('chr13', 115169878),
 ('chr14', 107349540),
 ('chr15', 102531392),
 ('chr16', 90354753),
 ('chr17', 81195210),
 ('chr18', 78077248),
 ('chr20', 63025520),
 ('chr19', 59128983),
 ('chr21', 48129895),
 ('chr22', 51304566),
 ('chrX', 155270560),
 ('chrY', 59373566),
 ('chrM', 16571),
]

bigwig_fp = '../test/data/wgEncodeCaltechRnaSeqHuvecR1x75dTh1014IlnaPlusSignalRep2.bigWig'
ts = higlass.tilesets.bigwig(bigwig_fp, chromsizes=chromsizes)
cs = higlass.tilesets.ChromSizes(chromsizes)

view1 = View([
    Track('top-axis'),
    Track('horizontal-bar', tileset=ts),
    Track('horizontal-chromosome-labels', position='top', tileset=cs)
])
display, server, viewconf = higlass.display([view1])

display<jupyter_output><empty_output><jupyter_text>Local bedlike data<jupyter_code>from higlass.client import View, Track
from higlass.inline_tiles import bedtiles
import higlass

bed = [['chr1', 1000, 2000, 'item #1', '.', '+'],
       ['chr2', 3000, 3500, 'item #1', '.', '-']]

chroms = [['chr1', 2100], ['chr2', 4000]]


data = bedtiles(bed, chroms)
track = Track(track_type='bedlike', position='top',
              height=50, data=data, options={"minusStrandColor": "red"})


d,s,v = higlass.display([[track]])
d<jupyter_output><empty_output><jupyter_text>Custom data<jupyter_code>import numpy as np

dim = 2000
I, J = np.indices((dim, dim))
data = (
    -(J + 47) * np.sin(np.sqrt(np.abs(I / 2 + (J + 47)))) 
    - I * np.sin(np.sqrt(np.abs(I - (J + 47))))
)
import clodius.tiles.npmatrix
from higlass.tilesets import Tileset

ts = Tileset(
    tileset_info=lambda: clodius.tiles.npmatrix.tileset_info(data),
    tiles=lambda tids: clodius.tiles.npmatrix.tiles_wrapper(data, tids)
)

display, server, viewconf = higlass.display([
    View([
        Track(track_type='top-axis', position='top'),
        Track(track_type='left-axis', position='left'),
        Track(track_type='heatmap', 
                  position='center',
                  tileset=ts,
                  height=250,
                 options={ 'valueScaleMax': 0.5 }),

    ])
])
display
%%time

import requests
import json

url = 'http://localhost:{}/api/v1/register_url/'.format(server.port)
print('url:', url)
ret = requests.post(url,
             json={
                 'fileUrl': 'http://hgdownload.cse.ucsc.edu/goldenpath/hg19/encodeDCC/wgEncodeSydhTfbs/wgEncodeSydhTfbsGm12878InputStdSig.bigWig',
                 #'fileUrl': 'http://localhost:8111/wgEncodeCaltechRnaSeqHuvecR1x75dTh1014IlnaPlusSignalRep2.bigWig',
                 'filetype': "bigwig"
             })

print("content:", ret.content)

uid = json.loads(ret.content)['uid']
url = 'http://localhost:{}/api/v1/tiles/?d={}.2.0&d={}.2.1&d={}.2.2'.format(server.port, uid, uid, uid)
#url = "http://localhost:8111/wgEncodeCaltechRnaSeqHuvecR1x75dTh1014IlnaPlusSignalRep2.bigWig"
req = requests.get(url)
print('req', req.content)

"""
url = 'http://localhost:{}/api/v1/tileset_info/?d={}'.format(server.port, uid)
print('url:', url);
req = requests.get(url)
print('req', req.content)
"""<jupyter_output>url: http://localhost:45817/api/v1/register_url/
content: b'{\n  "uid": "bQk8elEiTtiXy9LdS5Pk8w"\n}\n'
req b'{\n  "bQk8elEiTtiXy9LdS5Pk8w.2.0": {\n    "dense": "kw2BQHVgtT/ZGos/qgR/P+hTQD+ZOmU/uN6MP8kCiT/NssY/O6O1P5wgkT8GtbU/3PZfP17/dT/AVoQ/C1myP+ASyj+0e1k/WqOVP+YAij+Sm5s/Cd+bP8jgtj9Nkbo/YfC+P/s3xD+skM8/aOi9P8lqej9hJoo/4nitP3fNxD8yVoc/oYl+P41Dnz8RJYo/03aiP1FeoT/xDcI/3QqmP37mqD+MHZw/8JybP6e6vD/tWK4/Dh1wPy0YUT9gpDE/gqFZP06rqD+Zq5w/BfaNP/2slD8UmGM/7YlWPxpjST9/x5Y/7WFwP0QmQj/Sllg/gItoP4cvaz9v2YU/HoSCP+7xkD9aa18/YT0sP25UXD8UuTc/DlUdP/ngGD/N30Y/hKFVP/8ZSj+VuX4/hvNUP+VLNT//CiQ/5/Q5P7FfMj9eLWo/Lm+YP6BmcT85r4g/cO1SP6/xij/bFYM/wLqPPxf5hz/mfp4/aLF0P1l0Rj9Tpy4/6ItZPxJeOD8Vu2Y/tOOQP7S9iz+2GRs/odU3PyR+Jz+LmRU/69VAPzbngT8d5pc/ksSuP5mzrz8FWpU/+6+HPzafjT8N52Q/FGabPwYajT+y9TU/xz9tP4Rc90ATZsdDAADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADAfwAAwH8AAMB/AADA<KEY>[...]
{'fraction_non_alphanumeric': 0.16601536181107668, 'fraction_numerical': 0.07950410995822665, 'mean_word_length': 4.9376, 'pattern_counts': {'":': 11, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '32326', 'license': 'MIT', 'n_tokens_mistral': 3509, 'n_tokens_neox': 3169, 'n_words': 471, 'path': 'notebooks/Examples.ipynb', 'repo_name': 'alexlenail/higlass-python', 'size': '7563'}