Skip to content

Fix plotting: per-module kME hub selection + working module-topology & preservation-lollipop plots - #5

Merged
Zac-lzh merged 4 commits into
omicverse:mainfrom
ChrisMao0325:main
Jul 14, 2026
Merged

Fix plotting: per-module kME hub selection + working module-topology & preservation-lollipop plots#5
Zac-lzh merged 4 commits into
omicverse:mainfrom
ChrisMao0325:main

Conversation

@ChrisMao0325

Copy link
Copy Markdown
Contributor

No description provided.

ChrisMao0325 and others added 4 commits July 12, 2026 12:31
…r-module kME

Both functions ranked every module's genes by a single fixed kME column
(kme_cols[0]) instead of each module's own kME_<module>. As a result, for all
modules except the one matching kme_cols[0], the kME barplot and the inner/outer
rings of the module network plot showed the wrong module's hub genes.

Now each module is ranked by its own kME_<module> column (falling back to the
first kME column only if a per-module one is absent). hub_gene_network_plot and
compute_module_umap were already correct and are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…thon port

plot_module_preservation_lollipop previously expected the R-style
wd['module_preservation'][name] = {'Z': df} object with Zsummary.pres/moduleSize
columns, which this port never produces (module_preservation() returns a flat
DataFrame and does not store it), and it used an invalid matplotlib color
('grey75'). It now consumes the DataFrame returned by module_preservation()
directly (module / Zsummary / n_genes), shades the Z<2 (not preserved) and
2<=Z<10 (moderate) regions, sizes points by gene count, and colours by module.

module_topology_heatmap / module_topology_barplot relied on wd['degrees'], which
nothing in this port populates, so order_by/features='degree'/'weighted_degree'
failed. They now compute intramodular connectivity (degree, weighted_degree)
from the TOM on the fly. The heatmap also blanks the lower triangle via NaN
(with cmap.set_bad) instead of clipping it into the color range.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ectly

The kME columns were detected with `"kME" in c.lower()`, but lowercasing the
column name means the mixed-case literal "kME" can never match — so the list was
always empty. In module_network_plot this skipped the top-N hub selection
entirely and plotted every gene in the module (hundreds) instead of
n_inner+n_outer. Fixed to a case-consistent check ("kme" in c.lower()) in all
seven occurrences.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
scipy 1.18 changed rankdata(method="ordinal") to return float64 ranks,
which NumPy 2 rejects as array indices, crashing cutreeHybrid deep inside
dynamicTreeCut (clusts[rnk[0] - 1]) and breaking the Python 3.12 CI job.

Inject an integer-coercing rankdata into dynamicTreeCut's module globals
(alongside the existing df_apply shim) so ordinal ranks stay integer-typed.
The cast is lossless (ordinal ranks are whole numbers) and a no-op on older
scipy, so the passing 3.9-3.11 jobs are unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Zac-lzh
Zac-lzh merged commit c08cca4 into omicverse:main Jul 14, 2026
4 checks passed
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.

2 participants