gosling-lang / gos

A declarative interactive genomics visualization library for Python.
https://gosling-lang.github.io/gos
MIT License
218 stars 14 forks source link

How can you check which version of gos is compatible with given version of gosling? #141

Closed sapoudel closed 1 year ago

sapoudel commented 1 year ago

I am trying to use python gos to create specs that I can then plug into a react app. The react app uses gosling 0.9.30 and react ^18.2.0 and the python gos I am using is pip installed gosling-0.0.11. So far, I can create simple visualization that works perfectly within the app with this "hand made" spec:

  tracks: [
    {
      assembly: [["NC_010079.1", 2873728]],
      data: {
        url: "http://localhost:5000/gene",
        type: "csv",
        separator: "\t",
      },
      mark: "rect",
      x: { field: "start", type: "genomic" },
      color: { field: "start", type: "quantitative", legend: true },
      width: 600,
      height: 130,
    },
  ],
};

I can also create a visualization within jupyter notebook using gos and save it as a HTML file. But, when I plug in a spec created with gos into the react, I get all the components but none of the data is displayed. I tried upgrading the python gos to the latest version, but the exported spec from that causes the app to crash. So what is the best way to figure out compatible versions without trying all of them?

sapoudel commented 1 year ago

Was able to figure out the issues without changing any of the versions. My input looked like this:

mutation_data = gos.csv(
    url='http://localhost:5000/gene',
    chromosomeField="chrom:N",
    genomicFields=["start", "end"],
    separator=',',
)

Using this data works within jupyter notebook (and I can save as HTML) and creates the figures I want. When I export to json using .to_json() it keeps the :N field which breaks it when using it as the spec in react. The json looks like this:

data: {
                chromosomeField: "chrom:N",
                genomicFields: ["start", "end"],
                separator: ",",
                type: "csv",
                url: "http://localhost:5000/gene",
              }

Removing the :N from the original python input fixes it for both. I am not sure if this should be a bug or not.

Additionally, prettier was also changing seperator: "\t" to seperator: "\\t" which was also causing problems.

manzt commented 1 year ago

Hi there, we probably need to make a release of gos with the latest Gosling.js #143

sapoudel commented 1 year ago

Perfect! I think the schema validation should throw an error if you add :N (or any other data type marker) field to chromosomeField since it breaks the code downstream. If don't think this is a bug, feel free to close this issue.

manzt commented 1 year ago

I think the schema validation should throw an error if you add :N (or any other data type marker) field to chromosomeField since it breaks the code downstream. If don't think this is a bug, feel free to close this issue.

This is not part of the schema that accepts the data type shorthand (e.g., :N or :Q). Instead this is part of the data definition and you are telling Gosling which header of the CSV corresponds to the chromosome names. There is no way for the Python library to validate this is a column name in your CSV, since the CSV parsing is done in the front end (after the schema has been compiled).