Repository navigation
Mantpy 1.2.0
Added
Helpers for the patch-encoder, composition and classifier steps of a cohort
analysis. Every addition is opt-in: existing defaults, outputs, stored keys and
provenance logs are unchanged when the new names and options are not used.
mt.pp.ecm_patch_tilesreturns the pixel block of every ECM patch as one
float32 array of shape(patches, ECM channels, patch_size, patch_size), in
cohort and patch-table row order, ready forPatchEncoder. With
subset="signal"it returns only the patches with a non-negative label. It
reads the patch tables and the images and writes nothing.mt.pp.cluster_ecm_patchesacceptsembedding=, a patch-by-feature matrix
(for example the output ofPatchEncoder.transform) that is clustered in
place of the patch-table features, andorder_by=, where"size"numbers
the clusters from the largest to the smallest. Both default toNone, which
keeps the previous labels, results and provenance exactly. The provenance
keysfeature_sourceandlabel_mapping, andlabel_orderfor K-means, are
recorded only when one of the two options is used.mt.tl.ecm_patch_tablestacks the patch tables of a cohort into one long
table withsample_idandnode_idcolumns, optionally joined to sample
metadata.node_idis the name of the patch in the ECM graph, so the table
joins to component membership and to node-level classifier results. It writes
nothing.ClusterCompositionDetails.contrast, on the result of
mt.tl.compute_cluster_composition(..., return_details=True), compares the
mean per-unit cluster fractions of case groups against control groups and
returns a table accepted bymt.tl.top_enriched_cluster. The fields of the
result and the default two-item return are unchanged.NodeClassifier.composition_baselinereturns the held-out predictions of a
logistic regression that sees only per-graph cluster fractions (or supplied
features), evaluated on the folds the classifier was fitted with. It stores
nothing on the classifier, and the existing methods are unchanged.NodeClassifier.attribution_tablereturns the integrated-gradient node
importance of many graphs as one long table with sample, group, fold, node,
coordinate and cluster columns.integrated_gradientsand its defaults are
unchanged.mt.tl.cluster_membership_correlationreports, for every sample and cluster,
the Pearson correlation between a node score and membership of that cluster.
It is a new function and changes no existing output.
Helpers for cell-ECM context models and label-reconstruction benchmarks. All
are new functions; no existing output changes.
mt.gr.graph_layersreturns the cell-cell, ECM-ECM and cell-ECM layers of a
built cell-ECM graph as sparse matrices aligned to the cells and to the patch
table, with matching matrices of edge lengths.mt.gr.distance_weightsturns edge lengths into edge weights (uniform,
inverse, inverse square, or Gaussian with a fixed or median width).mt.tl.context_featuresdescribes each ECM patch by the cell types and ECM
clusters of its graph neighbours (cell, ECM or joint context; one or two hops).mt.tl.corrupt_labelsreplaces a seeded fraction of labels in square blocks
and as isolated units, for label-reconstruction benchmarks.mt.tl.label_anomaly_scoresscores how unexpected each observed label is,
with an optional adjustment for the training label frequencies.mt.tl.score_label_reconstructionreports detection and correction metrics
against the true labels, overall and per class.