Asa12138 / MetaNet

Network analysis for multi-omics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dplyr error during zp_analyse()

ErinneStirling opened this issue · comments

Using zp_analyse as directed gives the following error:

Error in if (dplyr::between(as.numeric(x), backs$x1[i], backs$x2[i]) & :
missing value where TRUE/FALSE needed

This error does not occur for all networks processed in the same pipeline, only one network that is relatively sparse (~500 nodes, ~1,000 edges).

Tracing the error gives the following information:

4: deter_role(x["Pi"], x["Zi"], backs)
3: FUN(newX[, i], ...)
2: apply(v_index, 1, function(x) deter_role(x["Pi"], x["Zi"], backs))
1: zp_analyse(net.modu)

Thank you for your question:
Sometimes Zi or Pi are NA, and this error would come up.

I fixed this issue in the developmental version, please install it using:

# install.packages("devtools")
devtools::install_github("Asa12138/MetaNet")

I have updated as directed. zp_analyse() now does not work for any network, and gives error:

Error in dplyr::left_join():
! Can't join x$name with y$name due to incompatible types.
ℹ x$name is a <double>.
ℹ y$name is a <character>.
---
Backtrace:

1. ├─MetaNet::zp_analyse(whole_natt_net.modu)
2. │ ├─... %>% suppressMessages()
3. │ └─MetaNet::anno_vertex(...)
4. │ ├─dplyr::left_join(...)
5. │ └─dplyr:::left_join.data.frame(v_atr, anno_tab, by = "name", suffix = c(".x", ""))
6. └─base::suppressMessages(.)
7. └─base::withCallingHandlers(...)

This can happen if your input network is a igraph object:

g <- erdos.renyi.game(1000, 1 / 1000)
class(g)
module_detect(g)->g_m
zp_analyse(g_m)

Please convert the network into a metanet object before analysis:

g <- erdos.renyi.game(1000, 1 / 1000)
g=as.metanet(g)
class(g)
module_detect(g)->g_m
zp_analyse(g_m)

I will improve object compatibility in future releases

It works now, however the zipi outputs are completely different to those before the update. Different numbers of hub nodes and different node labels. This brings into question the accuracy of the results... what do you think might be going on there?

Also the 'roles' for the sparse network have lost their names - instead of "Network Hub", etc, it returns numerals ("1","2","3","4").

You mean your results have changed?

I checked the calculation results of zp_analyse are stable in both versions:

data("c_net")
module_detect(co_net) -> co_net_modu
zp_analyse(co_net_modu) -> co_net_modu
get_v(co_net_modu)

I can't reproduce your question, if you can give me access to your input object in some way, I may be able to better locate the problem:
For example, save it as rda and upload it to your github:

saveRDS(yournetwork,file = "network_for_zp_analyse.RDS")

It works now, however the zipi outputs are completely different to those before the update. Different numbers of hub nodes and different node labels. This brings into question the accuracy of the results... what do you think might be going on there?

Also the 'roles' for the sparse network have lost their names - instead of "Network Hub", etc, it returns numerals ("1","2","3","4").

@ErinneStirling, I double checked the results of zp_analyse and it is OK.
Please use V(yournetwork)$name to ensure the input network (igraph object) already have the right name, as a simple igraph object do not have the name attribute.

The source code to calculate the Zi-Pi is refer to https://github.com/cwatson/brainGraph/blob/master/R/vertex_roles.R, If you are not sure about your result, you can try the brainGraph package.

Thanks again for using MetaNet.