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

Factor out small community detection #51

Open
wants to merge 211 commits into
base: master
Choose a base branch
from

Conversation

ahill187
Copy link
Contributor

@ahill187 ahill187 commented Nov 15, 2024

Description

In this PR, I have factored out the code that merges small communities. There was a lot of duplicated code between fit_predict and run_toobig_subPARC, so this addressed that issue.

I have created three new functions:

  1. small_community_merging: This function runs the merging functionality, with help from the other two functions.
  2. get_small_communities: A helper function to find which communities are too small.
  3. reassign_small_communities: A helper function which iteratively reassigns the small communities to other communities.

I have renamed several of the variables:

original new reason
cluster community_id For consistency, in keeping with graph theory and Leiden algorithm definitions
population community_size population is ambiguous, it could be a single value or a set
small_cluster small_community_indices For consistency, in keeping with graph theory and Leiden algorithm definitions
single_cell sample_id PARC is not only used for cells; it can take any type of data
old_neighbors neighbors Using old as a modifier is poor practice
group_of_old_neighbors node_communities_neighbors This is the same data type as node_communities
best_group community_id Group implies a set, but this is a single ID

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (updated docstrings or README files)
  • Tests (added new tests or modified current test suite)
  • Refactoring (changes in the design of the code that don't change the functionality)

Tests

  • tests/test_parc.py: test_parc_get_small_communities
  • tests/test_parc.py: test_parc_reassign_small_communities
  • tests/test_parc.py: test_parc_small_community_merging

Linked PRs / Issues

ahill187#29

Checklist:

  • I have performed a self-review of my code
  • I have documented my code with appropriate docstrings
  • I have made corresponding changes to the documentation / README files
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@ahill187 ahill187 changed the title Factor out small community reassignment Factor out small community detection Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant