Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs v2: custom chrom ordering (bigwig) #108

Open
manzt opened this issue Feb 27, 2023 · 0 comments
Open

docs v2: custom chrom ordering (bigwig) #108

manzt opened this issue Feb 27, 2023 · 0 comments

Comments

@manzt
Copy link
Member

manzt commented Feb 27, 2023

BigWig Files
""""""""""""

In this example, we'll set up a server containing both a chromosome labels
track and a bigwig track. Furthermore, the bigwig track will be ordered
according to the chromosome info in the specified file.

.. code-block:: python


    from higlass.client import View, Track
    from higlass.tilesets import bigwig, chromsizes
    import higlass.tilesets

    chromsizes_fp = '../data/chromSizes_hg19_reordered.tsv'
    bigwig_fp = '../data/wgEncodeCaltechRnaSeqHuvecR1x75dTh1014IlnaPlusSignalRep2.bigWig'

    with open(chromsizes_fp) as f:
        chromsizes_arr = []
        for line in f.readlines():
            chrom, size = line.split('\t')
            chromsizes_arr.append((chrom, int(size)))

    cs = chromsizes(chromsizes_fp)
    ts = bigwig(bigwig_fp, chromsizes=chromsizes_arr)

    tr0 = Track('top-axis')
    tr1 = Track('horizontal-bar', tileset=ts)
    tr2 = Track('horizontal-chromosome-labels', position='top', tileset=cs)

    view1 = View([tr0, tr1, tr2])
    display, server, viewconf = higlass.display([view1])

    display

The client view will be composed such that three tracks are visible. Two of them
are served from the local server.

.. image:: img/jupyter-bigwig.png

We don't currently support custom chromsizes in the top-level hg.bigwig. Should be easy enough to add, but here is the current boilerplate:

import higlass as hg
from higlass.tileset import LocalTileset
from clodius.tiles.bigwig import tiles, tileset_info

chromsizes = [...]
fp = '../data/wgEncodeCaltechRnaSeqHuvecR1x75dTh1014IlnaPlusSignalRep2.bigWig'

ts = hg.server.add(
    LocalTileset(
        tiles=functools.partial(tiles, fp, chromsizes=chromsizes),
        info=functools.partial(tileset_info, fp, chromsizes=chromsizes),
        uid="demo",
    ),
)

hg.view(
    ts.track('chromosome-labels'),
    ts.track('horizontal-bar'),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant