gosling-lang / streamlit-gosling

Gosling custom component for Streamlit
MIT License
10 stars 2 forks source link

assembly #2

Closed violacimatti closed 4 months ago

violacimatti commented 4 months ago

Hi, I'm currently using streamlit-gosling to display a visualization of a bigwig file, however I would like it to have a customized assembly. The problem is that if I try this gosling code in colab: import gosling as gos

data = gos.bigwig(url="/Users/violacimatti/Desktop/gosling/MB12_H3K27me3_2.bw", column="position", value="peak")

track1 = gos.Track(data).mark_area().encode(
        x='position:G',
        y=gos.Y('peak:Q', axis='right'),
        color=gos.value('royalblue'),
        tooltip=[gos.Tooltip('position:G'), gos.Tooltip('peak:Q')])

track1.view(assembly=[
        ("chr6", 1267782),('chr6_2',40009),('chr7',1267784)]).properties(width=500)

Then the assembly displayed is the right one I specified. Instead, when using the streamlit-gosling with this code:

import streamlit as st
import gosling as gos
import streamlit_gosling as st_gos

def create_gosling_chart():
    data = gos.bigwig(url="/Users/violacimatti/Desktop/gosling/MB12_H3K27me3_2.bw", column="position", value="peak")

    track1 = gos.Track(data).mark_area().encode(
        x='position:G',
        y=gos.Y('peak:Q', axis='right'),
        color=gos.value('royalblue'),
        tooltip=[gos.Tooltip('position:G'), gos.Tooltip('peak:Q')])

    return track1.view(assembly=[
                        ("chr6", 1267782),('chr6_2',40009),('chr7',1267784)]).properties(width=500)

st.set_page_config(layout="wide") 
def main():
    st.title("BigWig Visualizer")

    # Create a gosling chart
    chart = create_gosling_chart()

    # Display the gosling chart with Streamlit-Gosling
    result = st_gos.from_gos(spec=chart, id='id_chart')
    st.write(result)

if __name__ == "__main__":
    main()

I don't get the specified assembly but the 'normal' one, it looks like when using this package it is already specifying the assembly.

wangqianwen0418 commented 4 months ago

Hi @violacimatti, thanks for letting us know about this issue! It looks like it's related to the version of Gosling currently used in streamlit-gosling. The older version doesn't support custom assemblies.

We're planning to update to the latest version of Gosling this month, which should resolve this issue. We'll keep you posted on the progress!

wangqianwen0418 commented 4 months ago

Thanks to @etowahadams, we've updated streamlit-gosling to v0.1.4, incorporating the latest gosling.js v0.17.0 that supports custom assemblies. I'm closing this issue now.