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

getSelectedRowNames, getSelectedColnames, selectRows, selectCols? #7

Closed
paul-shannon opened this issue Aug 3, 2017 · 7 comments
Closed

Comments

@paul-shannon
Copy link

Hi Nick,

We are making pretty good progress on the RClustergrammer package. It's a pleasure working with what you have created.

Here are a few requests, all regarding selections: either retrieving the currently selected rows or column names for use in R, or making Clustergrammer selections from R - the programmatic equivalent, say, of clicking on a subcluster, after which the other rows (or columns) are grayed out.

All we need in either case is the equivalent functions in your javascript API. Maybe they already exist?

To sketch out some pseudo-code:

cg = Clustergrammer(args);
var nodeNames = cg.getSelectedRowNames()
var colNames = cg.getSelectedColumnNames()
cg.selectRows(["A", "B", "C"])
cg.selectColumns(["X", "Y", "Z"])

Possible?

@cornhundred
Copy link
Contributor

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

@paul-shannon
Copy link
Author

paul-shannon commented Aug 4, 2017 via email

@cornhundred
Copy link
Contributor

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

@paul-shannon
Copy link
Author

paul-shannon commented Aug 4, 2017 via email

@cornhundred
Copy link
Contributor

Great, I'll close the issue then.

@AmirAlavi
Copy link

@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 */
}

@AmirAlavi
Copy link

AmirAlavi commented Mar 27, 2019

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!

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

3 participants