CostaLab / scMEGA

scMEGA: Single-cell Multiomic Enhancer-based Gene regulAtory network inference
https://costalab.github.io/scMEGA
Other
36 stars 2 forks source link

NetCentPlot error #21

Open liyang24 opened 1 year ago

liyang24 commented 1 year ago

Hi! thanks for the jobs I've got the object to build the network on

head(df.grn2) tf gene weights 77 ATF4 GABARAPL1 0.8221601 85 ATF4 GRIK3 0.8021985 100 ATF4 KIT 0.8130254 102 ATF4 KRAS 0.8125377 166 ATF4 SEC22B 0.8518962 223 ATF6 ACAP3 0.8103851 V(netobj)$type <- ifelse(V(V(netobj)$type <- ifelse(V(netobj)$name %in% dfgrn$tf,"TF/Gene","Gene"))$name %in% df.grn2$tf,"TF/Gene","Gene") netobj <- graph_from_data_frame(df.grn2,directed = TRUE)

Looking at the object, it looks normal

netobj IGRAPH 54cba5f DN-B 355 788 --

  • attr: name (v/c), type (v/c), weights (e/n)
  • edges from 54cba5f (vertex names): [1] ATF4 ->GABARAPL1 ATF4 ->GRIK3 ATF4 ->KIT ATF4 ->KRAS [5] ATF4 ->SEC22B ATF6 ->ACAP3 BACH2->ALX1 BACH2->ANKH [9] BACH2->CDKN1C BACH2->CRISPLD1 BACH2->EBF2 BACH2->ETV6 [13] BACH2->GLIPR1 BACH2->HECTD2 BACH2->IGFBP7 BACH2->ITGB8
  • ... omitted several edges However, when I run p <- NetCentPlot(netobj, "RUNX1") Error in layout_with_focus(graph, v = focus, weights = weights, iter = niter, : g must be a connected graph.

I checked netobj

is_connected(netobj, mode = "weak") [1] FALSE

I don't know how do I get the final NetCentPlot, Can you offer any help? thanks a lot!

lzj1769 commented 1 year ago

Hi @liyang24

Are you able to generate the network plot?

The function NetCentPlot is going to plot the network but with different layout, so in theory, it should be working if you can generate the network plot.

@jsnagai Do you have any ideas?

liyang24 commented 1 year ago

Yes, I got the network plot,so i don't know what went wrong

jsnagai commented 1 year ago

@liyang24 sorry for the late reply, would it be possible for to you check the number of components that your graph has? On that you possibly can you is subset the connected component related to the TF/Target that you are selecting.

Best

liyang24 commented 1 year ago

thanks! I did what you said

tf_vertices <- c("RUNX1") V(netobj)$type <- ifelse(1:vcount(netobj) %in% tf_vertices, "TF", "Gene") cc <- components(netobj) tf_cc <- induced_subgraph(netobj, which(cc$membership == cc$membership[tf_vertices[1]])) p <- NetCentPlot(tf_cc,"RUNX1")

and I got this picture image

What should I do if I want to display the TF name of the node?