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

Weight parameter on network_p2p() does not affect output #181

Closed
AaronArk opened this issue Aug 25, 2021 · 7 comments · Fixed by #179 or #184
Closed

Weight parameter on network_p2p() does not affect output #181

AaronArk opened this issue Aug 25, 2021 · 7 comments · Fixed by #179 or #184
Assignees
Labels
bug Something isn't working

Comments

@AaronArk
Copy link

Describe the bug
When using network_p2p() to create a network plot and setting different values for the weight parameter, eg 'StrongTieScore' and 'DiverseTieScore', the plots produced are exactly the same. When using different community detection algorithms I expect different graphs to be produced has different weights should be used

To Reproduce
Steps to reproduce the behavior:

create a plot using network_p2p() and set weight = 'StrongTieScore' and 'DiverseTieScore' with display = 'leiden

Expected behavior
different plots should be produced with different clusters

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@AaronArk AaronArk added the bug Something isn't working label Aug 25, 2021
@martinctc martinctc self-assigned this Aug 25, 2021
@martinctc
Copy link
Member

Thanks for reporting this @AaronArk! Can confirm that this is an actual bug and this is being resolved in pull request #179. Will aim to push a new patch version to CRAN by the end of this week.

@martinctc martinctc mentioned this issue Aug 25, 2021
3 tasks
@martinctc martinctc linked a pull request Aug 25, 2021 that will close this issue
3 tasks
@martinctc
Copy link
Member

This fix is now live on CRAN in v1.6.1.

@AaronArk
Copy link
Author

AaronArk commented Sep 2, 2021

I have updated my wpa package to v1.6.1 and I am still unable to see a change in my plots when using the weight parameter. Below is the code for the network plot where different values for the weight parameter are used. Even when using a column name that isn't present in my data produces a plot and does not error. When using 'leiden' as the display variable, no change in the communities formed were seen

p2p_2020_2h %>%                                       # my p2p network file name
  network_p2p(hrvar = 'Group_DL',              # my organisation variable name
              display = "hrvar",                            # used 'hrvar' and 'leiden' as display variables
              path = NULL,
              return = "plot",
              legend_pos = 'right',
              algorithm = 'mds',
              seed = 1,
              res = 1,
              weight = NULL)                           # changing this to 'StrongTieScore' or 'DiverseTieScore' yields not change in my plot

@martinctc
Copy link
Member

Unfortunately you are correct @AaronArk - the weight variable is actually not getting pulled through in the edges data frame in the current implementation and needs to be explicitly assigned. This is now being worked on in the latest pull request

@AaronArk
Copy link
Author

AaronArk commented Sep 2, 2021

Okay thanks @martinctc for the update. Do you know when this is likely to be rolled out?

@martinctc
Copy link
Member

Hi @AaronArk - I can have a go and push a version to CRAN before Monday. Would you mind to give this version a test on your data? You can install with:

devtools::install_git(url = "https://github.com/microsoft/wpa.git",
                      branch = "fix/weights-in-network_p2p")

If you run the following, you should notice that the edges will be different:

# Simulate data with different Strong and Diverse Tie Scores as weights
p2p_data <- p2p_data_sim() %>%
  mutate(StrongTieScore = abs(rnorm(n = nrow(.)))) %>%
  mutate(DiverseTieScore = abs(rnorm(n = nrow(.))))

g1 <-
  p2p_data %>%
  network_p2p(
    display = "louvain",
    weight = "StrongTieScore",
    return = "network"
  )

g2 <-
  p2p_data %>%
  network_p2p(
    display = "louvain",
    weight = "DiverseTieScore",
    return = "network"
  )

g1$weight
g2$weight

However, it would be good to confirm that this also applies on the network visualization, and covers your use case.

@martinctc martinctc changed the title Weight parameter on network_p2p() does not effect output Weight parameter on network_p2p() does not affect output Sep 3, 2021
@AaronArk
Copy link
Author

AaronArk commented Sep 3, 2021

Hi @martinctc. Yeah will try it today and let you know how it goes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants