gosling-lang / gosling.js

Grammar of Scalable Linked Interactive Nucleotide Graphics
https://gosling.js.org
MIT License
166 stars 27 forks source link

How to load local data file for a track #572

Open zhangzhen opened 3 years ago

zhangzhen commented 3 years ago

I've put the tsv file RD2109054FFP.blockData.tsv into the public folder, and then set the data url in the spec as follows: "url": "./RD2109054FFP.blockData.tsv" Nothing is displayed in the corresponding track. To shorten the data loading time, I want to fetch the local file instead of the remote one. How can I do this?

Zhen

sehilyi commented 3 years ago

This is not possible in the javascript libraries (including Gosling.js) by a security policy of browsers. You will need to have a server that serves your local data since the browser cannot access your local files directly.

sehilyi commented 3 years ago

Can I ask how large the data is? Also, is the same data used multiple times in your specification? Would the use of a HiGlass server not be feasible in your case?

zhangzhen commented 3 years ago

Can I ask how large the data is?

There are about 1 million lines in the data file.

Also, is the same data used multiple times in your specification?

Yes, because there are multiple value columns in that file.

Would the use of a HiGlass server not be feasible in your case?

I'm trying to use a HiGlass server to solve this issue. However, it is a bit tricky because I created a synthetic genome which has only chromosome 1 by removing regions that are not covered by probes. The coverage data file of a sample in the bedgraph format was converted to a hitile file using the following command:

clodius aggregate bedgraph          \
    RD2118193FFP.coverageData2.tsv    \
    --output-file RD2118193FFP.coverageData2.hitile \
    --chromosome-col 1              \
    --from-pos-col 2                \
    --to-pos-col 3                  \
    --value-col 4                   \
    --assembly grch37               \
    --nan-value NA                  \
    --transform exp2                \
    --has-header

The data is for only about 350 genes, attached below: RD2118193FFP.coverageData2.csv

And then the hitile file was uploaded to the higlass server. By viewing the coverage data in browser I find the converted data looks something goes wrong , but I don't figure out what step goes wrong. image

@sehilyi A question about zoom levels: how can I know what the current zoom level is in gosling?

Zhen

zhangzhen commented 2 years ago

A question about zoom levels: how can I know what the current zoom level is in gosling?

@sehilyi I've already found the answer to this question in the source code for higlass:

  1. https://github.com/higlass/higlass/blob/54f5aae61d3474f9e868621228270f0c90ef9343/app/scripts/HorizontalTiled1DPixiTrack.js#L60
  2. https://github.com/higlass/higlass/blob/54f5aae61d3474f9e868621228270f0c90ef9343/app/scripts/services/tile-proxy.js#L330
sehilyi commented 2 years ago

I've already found the answer to this question in the source code for higlass:

Sorry that my response was late but great to hear that you found the answer!

Just curious -- since those are HiGlass code-bases, are you using those functions in your custom local Gosling.js on your machine?

zhangzhen commented 2 years ago

Just curious -- since those are HiGlass code-bases, are you using those functions in your custom local Gosling.js on your machine?

No, I've not used those functions yet, but just read the code. To other questions I still have not found answers. Is there a way to view the content of a hitile file just like the way to view a csv file? I want to make sure if hitile files that are created by us are in right form and meet our requirements.

Zhen

sehilyi commented 2 years ago

@zhangzhen Sorry for the late response.

When I test your file (i.e., aggregate and ingest to the server), I see the following view, which seems to look fine for me. Could you elaborate on the issue you are confronting?

Screen Shot 2021-11-19 at 5 17 31 PM

Demo: http://higlass.io/l/?d=BOXopZfFS9-LTYLijCVekA

Also, you would want to use a --chromsizes-filename TEXT parameter of clodius to specify what chromosome you want to use and how large it is since you seem to be interested in custom-sized chromosome 1 only.

Since Hitile is based on HDF5, you can use HDF5 viewers, such as HDFView to browse metadata (e.g., chromosome sizes, assembly, ...) as well as raw values.