Code Monkey home page Code Monkey logo

Comments (7)

paul-shannon avatar paul-shannon commented on May 22, 2024 1

from clustergrammer.

cornhundred avatar cornhundred commented on May 22, 2024

Hi Paul,

That's great, I'm glad progress is being made. If I understand you correctly you want to be able to get the current rows/columns and set the current rows/columns.

The Clustergrammer.js API (API docs) supports setting the current rows/columns and you can get the current rows/col from the cgm object (I'll build an API for getting rows/columns later).

You can get the current row/column names using

// get current row names
cgm.params.network_data.row_nodes_names

// get current column names
cgm.params.network_data.col_nodes_names

You can set the current rows/columns using

cgm.filter_viz_using_names({'row':['LRRK2','NRK'], 'col':['H2106', 'H23']})

You can leave the row and/or col attributes empty to reset the rows/columns.

You can try running these commands in the developer console of the github.io page: http://maayanlab.github.io/clustergrammer/

Let us know if that is what you are looking for.

Best,
Nick

from clustergrammer.

paul-shannon avatar paul-shannon commented on May 22, 2024

from clustergrammer.

cornhundred avatar cornhundred commented on May 22, 2024

Hi Paul,

Scenario 1
You can interactively select a row or cluster of rows in two ways. You can crop, where you draw out a region of interest that filters out only that area (then you can use the previous command to get the row/col names in JavaScript). You can also use the interactive dendrogram to crop into clusters of different sizes and to get the row/col names of the selected cluster.

Scenario 2
Would the cgm.filter_viz_using_names endpoint work for this? You can use it to programmatically filter the visualization for rows/columns of interest.

Let me know if that helps.

Best,
Nick

from clustergrammer.

cornhundred avatar cornhundred commented on May 22, 2024

Great, I'll close the issue then.

from clustergrammer.

AmirAlavi avatar AmirAlavi commented on May 22, 2024

@cornhundred, I want to report which subset of rows the user has clicked on when they crop the matrix. To do so, I've used matrix_update_callback when constructing the Clustergrammer object. However, the callback doesn't seem to be passed any arguments. So then I called cgm.params.network_data.row_nodes_names from inside the callback as you suggest above. However, the issue is that this list of row_nodes is outdated; it's what the matrix had before the user cropped. I want the new subset of nodes that is the result of the current filtering. How can I get that, as soon as it happens?

/* This is the function I pass as 'matrix_update_callback' */
handleMatrixUpdate(matrix_filter) {
    /* when I set a breakpoint here, 'matrix_filter' is null,
    so this callback isn't passed any info */
    const new_rows = this.cgm.params.network_data.row_nodes_names; /* But this doesn't give
    me what I want, `new_rows` is outdated, it's what was visible before the current matrix update */
}

from clustergrammer.

AmirAlavi avatar AmirAlavi commented on May 22, 2024

After looking at the code that calls the callback, it looks like in order to get the behavior I am looking for, one of these two must be the case:

  1. We need a new optional callback, something like matrix_updated_callback, to be called after the update completes
  2. We need to call the callback function and pass in new_network_data

Either one would require a fork and rebuild of Clustergrammer. However, I'm hoping there's some other way to do this that I'm not aware of.
Thanks!

from clustergrammer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.