Fix plotting: per-module kME hub selection + working module-topology & preservation-lollipop plots - #5
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.