YupingLu / biclique

Maximal Biclique Enumeration in Bipartite Graphs
https://github.com/YupingLu/biclique
GNU General Public License v2.0
21 stars 10 forks source link

Issues running bi.clique #14

Open anieto25 opened 2 years ago

anieto25 commented 2 years ago

Hi!

I have a problem using bi.clique function. I ran the function in my original network (I called it df_x), and it works well. However, after randomly rewiring the network using the function rg_reshuffling_tm (tnet package) and adjusting the resulting edge list using the bi.format() function, it does not. I get the following message: Error in seq.default(1, nelems - 9, 3) : wrong sign in 'by' argument.

This function works well in the original network, and I can't spot any differences in the files that I am using, so I am unsure what is causing this error. Any clues on what might be causing this error? Thank you for taking the time to look into this!

A copy of my code is here and I am also attaching the original edge list (df_x).

#df_x contains the original network

#Assign a unique code to each event
events <- select (df_x, V2) %>% unique () %>% mutate (i = 1:29437)

#Assign a unique code to each individual
individuals <- select (df_x, id_person) %>% unique () %>% mutate (p = 29438:(29437+64041))

# join df's using the newly assigned codes
df_joined_events <- left_join(df_x, events)
df_joined_total <- left_join(df_joined_events, individuals) %>% select (i, p)

# create the net object that aligns with tnet's requirements
net <- as.tnet(df_joined_total)

# randomly rewire the original network 5 times and get the number of bicliques

#create empty df i=iterations and bicliques = number of maximal bicliques
df_simulations <- tibble (i = NA, bicliques = NA)

for (i in 1:5){

# rewire the network at random 
net_simulated <- rg_reshuffling_tm(net, option="links") %>% as.tibble()

## write the tsv file 
write.table(net_simulated, file ='net_simulated.tsv', sep = "\t" ,col.names = F, row.names = F)

## include information required by the biclique package
bi.format('net_simulated.tsv')

## run the bi.clique on the rewired version of the network)
net_bicliques <- bi.clique('net_simulated.tsv', left_least = 2, right_least = 2)

## get the number of bicliques 
bicliques <- length (net_bicliques)

## create df with the results 
df_loop <- tibble (i = i, bicliques = bicliques)

## bind the results to df_simulations
df_simulations <- rbind (df_simulations, df_loop)
}

df_x.csv