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

Results not reproducible with rleiden.community #10

Open
SABiagini opened this issue Jul 27, 2022 · 7 comments
Open

Results not reproducible with rleiden.community #10

SABiagini opened this issue Jul 27, 2022 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@SABiagini
Copy link

Hi,

I've been using the rleiden.community() function for clustering detection. However, I've noticed that when I run the same analysis multiple times, results tend to change. I also tried to set a seed, but even with the same seed results change.

Do you have any suggestion on how to prevent this behavior and make results reproducible?

Thank you.

@evanbiederstedt
Copy link
Contributor

Hi @SABiagini

I need much more information to be helpful here.

Could you show me the code? What are you running and are the results changing?

Thanks, Evan

@SABiagini
Copy link
Author

SABiagini commented Jul 27, 2022

Hi Evan,

my code is pretty simple:

data<-fread(5cM.coef)
edges <- as.data.frame(data)
colnames(edges) <- c("from", "to", "weight")
g <- graph_from_data_frame(edges, directed = FALSE)
leiden<-rleiden.community(g, max.depth = 4, min.community.size = 100)

write.table(leiden$membership,"Leiden_Communities.txt",sep="\t",row.names = T, col.names = F, quote = FALSE)

The input is a three column file (ID1 ID2 weight)

In the list I save at the end of the code, the community assignment to each individual change any time I rerun the code.

Thank you.

Best,

Simone

@evanbiederstedt
Copy link
Contributor

Hi Simone @SABiagini

I'll need to reproduce this myself. I don't have access to 5cM.coef. Please put the outputs of what you see as well, i.e. attach this table in this GitHub issue.

So yes, please give me a reproducible example I can run.

Thanks, Evan

@SABiagini
Copy link
Author

Hi Evan,

The file is 10Mb and it cannot be copy/pasted here.

Also, I'm sorry but I can't publicly share that file. Is it possible to reach you in a different way?

Thank you.

Best,

Simone

@evanbiederstedt
Copy link
Contributor

evanbiederstedt commented Jul 27, 2022

Email me if you could.

But please try to use some publicly available R data as well.

https://github.com/kharchenkolab/leidenAlg/blob/main/tests/testthat/test_functions.R

It would be best if you could replicate this behavior with our unit tests using the data I saved in the package here. If you could show me the behavior here, that would be helpful and save time.

Thanks, Evan

@evanbiederstedt
Copy link
Contributor

Could you try installing the package from this branch? https://github.com/kharchenkolab/leidenAlg/tree/no_cpp

Please check if the problem remains. It looks like the results become stable.

Thanks, Evan

@evanbiederstedt
Copy link
Contributor

@SABiagini

It looks like this existed with previous versions of leidenAlg and igraph (i.e. igraph 1.2.6 from 2020 and leidenAlg 1.0.0)

I'm using this code:

library(data.table)
foobar = '/home/evanb/leidenAlg-1.0.0/5cM.coef' 

library(leidenAlg)

data<-data.table::fread(foobar)

edges <- as.data.frame(data)
colnames(edges) <- c("from", "to", "weight")
g <- igraph::graph_from_data_frame(edges, directed = FALSE)
leiden<-rleiden.community(g, max.depth = 4, min.community.size = 100)

write.table(leiden$membership,"Leiden_CommunitiesC.txt",sep="\t",row.names = T, col.names = F, quote = FALSE)

Are you able to see reproducible clusters using igraph::cluster_leiden()? If so, we could try using this.

@VPetukhov mentioned once in another thread there was some odd behavior, but I think this was fixed with explicitly setting a parameter + fiddling with the resolution parameter.

Best, Evan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants