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

Question: how to convert cytoscape.js json to cx2 ? #387

Open
mikekucera opened this issue Jan 8, 2025 · 2 comments
Open

Question: how to convert cytoscape.js json to cx2 ? #387

mikekucera opened this issue Jan 8, 2025 · 2 comments
Assignees

Comments

@mikekucera
Copy link

Hi guys,

I've started working on a Cytoscape Web app that integrates with EnrichmentMap.org. I've managed to get them to talk to each other (locally) but now I'm not sure how to create a network in Cytoscape Web from EM. EM stores the network in cytoscape.js json format, how do I import that into Cytoscape Web. (Note, I'm not worried about styles, just the network and data.)

@GAOChengzhan

This comment has been minimized.

@GAOChengzhan
Copy link
Contributor

GAOChengzhan commented Jan 16, 2025

Hi Mike @mikekucera ,

You can refer to these lines.

Basically, this function receives a list of 'CX2Network object' and tries to extract necessary information(like table, viewModel, visualStyle) out of them and add these networks to the current workspace.

In summary, you can just mimic this function. The only difference might be

  1. Get rid of the for loop, since I guess in your use case there is only one network to add
  2. You can treat the object called item (like here) as the json-format object from EM because
    • item here is a CX2Network object
    • CX2Network object is also in JSON format
  3. By the end of the function I try to set the first network in the list as the current network, you can just set your target network as the current network
      const nextCurrentNetworkId: IdType | undefined = validNetworkIds[0]
      if (nextCurrentNetworkId !== undefined) {
        setCurrentNetworkId(nextCurrentNetworkId)
      }
    
  4. You might also tweak the error handling. The original function is an experimental example for the service app function so I didn't do a lot of error handling work.

Let me know if this can solve your problem or you encounter any other issues.

@GAOChengzhan GAOChengzhan self-assigned this Jan 16, 2025
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

2 participants