Hello!
for some reason, strength(g) returns NAs when is used in permutation test. In each iteration an induced_subgraph is produced. then degree and strength for all nodes are calculated. The script worked well before but not anymore. I dont know why and If you have any way you can help or guide me to resolve this it would be much appreciated!
The script:
#Iterating
for (i in c(1:iterations)){
#Sub-network:
# 1.1 sample the feature table n from each group.
features.subset.2 <- features %>%
group_by(core) %>% #Group by core \ no core
sample_n(n, replace = F) #Sample eachgroup n times with no replacment
# 1.2 use the names of the genomes (nodes) to sample the original graph object to create an induced sub-graph.
#sub.g1 <- induced_subgraph(g1, which(V(g1)$name %in% features.subset.2$sample)) %>%
# set_vertex_attr("Label", value = ifelse(features.subset.2$core == 1,"Core","NonCore")) #Set core\noncore attributes
sub.g1 <- igraph::induced_subgraph(g1, which(V(g1)$name %in% features.subset.2$sample)) %>%
set_vertex_attr("Label", value = ifelse(features.subset.2$core == 1,"Core","NonCore")) #Set core\noncore attributes
#Even if I resample the matrix it dosnot work.
#adj_matrix.sub = adj_matrix[features.subset.2$sample,features.subset.2$sample]
#sub.g1 <- graph.adjacency(adj_matrix.sub, weighted = T, mode = "directed")
# 1.3 get the directed features of all the nodes:
Indegree <- degree(sub.g1, mode= "in")
Outdegree <- degree(sub.g1, mode = "out")
Instrength <- strength(sub.g1, mode = "in")
Outstrength <- strength(sub.g1, mode = "out")