Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add coverage operator to flagship example with DSL operator documentation#952

Merged
SkBlaz merged 3 commits intomasterSkBlaz/py3plex:masterfrom
copilot/add-flagship-example-codeSkBlaz/py3plex:copilot/add-flagship-example-codeCopy head branch name to clipboard
Dec 26, 2025
Merged

Add coverage operator to flagship example with DSL operator documentation#952
SkBlaz merged 3 commits intomasterSkBlaz/py3plex:masterfrom
copilot/add-flagship-example-codeSkBlaz/py3plex:copilot/add-flagship-example-codeCopy head branch name to clipboard

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 26, 2025

The flagship example needed additional DSL operators to demonstrate multilayer-specific functionality. Added .coverage() operator and documented 8 other available operators.

Changes

  • README.md: Added .coverage(mode="at_least", k=2) operator to flagship example

    • Filters nodes appearing in top-k of ≥2 layers for robust master regulator identification
    • Positioned after .end_grouping(), before .mutate()
    • Added note section documenting 8 additional operators: distinct(), select(), drop(), rename(), zscore(), rank_by(), summarize(), aggregate()
  • tests/test_readme_flagship_example.py: Added test_flagship_with_coverage_operator()

    • Validates coverage filtering with multilayer network test case
    • Verifies uncertainty quantification, grouping, and derived column creation

Example

master_regulators = (
    Q.nodes()
     .node_type("gene")
     .where(degree__gt=3)
     .uq(method="perturbation", n_samples=100, ci=0.95, seed=42)
     .per_layer()
        .compute("degree_centrality", "betweenness_centrality")
        .top_k(20, "betweenness_centrality__mean")
     .end_grouping()
     .coverage(mode="at_least", k=2)  # Keep genes that are hubs in ≥2 layers
     .mutate(
         influence_score=lambda row: (
             row.get("degree_centrality__mean", 0) * 0.4 +
             row.get("betweenness_centrality__mean", 0) * 0.6
         )
     )
     .sort(by="influence_score", descending=True)
     .limit(20)
     .execute(network)
)

The .coverage() operator reduces false positives from single-layer analysis by requiring nodes to be important across multiple layers.

Original prompt

This section details on the original issue you should resolve

<issue_title>flagship</issue_title>
<issue_description>see flagship example in readme.

from py3plex.core import datasets
from py3plex.dsl import Q, UQ
from py3plex.algorithms.community_detection import multilayer_louvain

1. Load a built-in multilayer biological network (~500 nodes, 4 layers)

network = datasets.fetch_multilayer("human_ppi_gene_disease_drug")

2. Run multilayer community detection

partition_vector, Q_modularity = multilayer_louvain(network, gamma=1.2, random_state=42)
network.assign_partition(partition_vector)

3. Find master regulator candidates with uncertainty quantification

master_regulators = (
Q.nodes()
.node_type("gene") # Filter by node type
.where(degree__gt=3) # Remove peripheral genes
.uq(method="perturbation", n_samples=100, ci=0.95, seed=42) # Quantify confidence
.per_layer() # Group by layer
.compute("degree_centrality", "betweenness_centrality")
.top_k(20, "betweenness_centrality__mean") # Top 20 per layer by mean
.end_grouping()
.mutate( # Create derived influence score
influence_score=lambda row: (
row.get("degree_centrality__mean", 0) * 0.4 +
row.get("betweenness_centrality__mean", 0) * 0.6
)
)
.sort(by="influence_score", descending=True)
.limit(20) # Final top 20 candidates
.execute(network)
)

df = master_regulators.to_pandas(expand_uncertainty=True)
print(df[["id", "layer", "betweenness_centrality", "betweenness_centrality_std",
"betweenness_centrality_ci95_low", "betweenness_centrality_ci95_high",
"influence_score"]].head(10))

which other operator can we include in this example to make it even more comprehensive? (and is supported by dsl)</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 26, 2025 00:14
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add flagship example to documentation Add coverage operator to flagship example with DSL operator documentation Dec 26, 2025
Copilot AI requested a review from SkBlaz December 26, 2025 00:19
@SkBlaz SkBlaz marked this pull request as ready for review December 26, 2025 00:56
@SkBlaz SkBlaz merged commit 4379bd3 into master Dec 26, 2025
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.

flagship

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.