Skip to content

Commit

Permalink
added RELATIVE_ANNOTATE_RESOLUTION as a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ptajvar committed Oct 22, 2024
1 parent 8db21e2 commit 98da20f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/pixelator/graph/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@

MIN_PIXELS_TO_REFINE = 100
LEIDEN_RESOLUTION = 0.01
RELATIVE_ANNOTATE_RESOLUTION = (
0.5 # A lower resolution is used for annotation of potential doublets
)
9 changes: 6 additions & 3 deletions src/pixelator/pixeldataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from graspologic.partition import leiden

from pixelator.graph import components_metrics
from pixelator.graph.constants import LEIDEN_RESOLUTION
from pixelator.graph.constants import LEIDEN_RESOLUTION, RELATIVE_ANNOTATE_RESOLUTION
from pixelator.statistics import (
clr_transformation,
log1p_transformation,
Expand Down Expand Up @@ -233,7 +233,7 @@ def _compute_sub_communities(
)
component_communities_dict = leiden(
edgelist_tuple,
resolution=0.5 * LEIDEN_RESOLUTION,
resolution=RELATIVE_ANNOTATE_RESOLUTION * LEIDEN_RESOLUTION,
random_seed=42,
)
component_communities = pd.Series(component_communities_dict)
Expand All @@ -246,7 +246,10 @@ def _assess_doublet(component_edgelist: pd.DataFrame) -> tuple[bool, int]:
A component is a potential doublet if a) it has more than one community and
b) the second largest community is at least 20% of the size of the largest
community. (If the other communities are smaller they are assumed to be debries.)
community. A lower resolution is to be used for annotation of potential doublets
compared to the component recovery in the graph phase. The reduction factor in
annotate resolution is set by RELATIVE_ANNOTATE_RESOLUTION (default is 0.5).
"""
component_communities = _compute_sub_communities(component_edgelist)
component_community_sizes = component_communities.value_counts().sort_values(
Expand Down

0 comments on commit 98da20f

Please sign in to comment.