Repository navigation
Added
Helpers for scoring and controlling a single-image patch analysis. Both are new
functions; no existing output changes.
mt.tl.score_patch_labelsscores patch labels, or a pixel label image,
against a pixel annotation of the same image. Every annotated pixel inside an
analysed patch counts once. It returns the pixel contingency table, its
adjusted Rand index, a one-to-one matching of clusters to annotated classes,
the matched class of every patch (ready formt.pl.patch_map), the recovery
of each class and the annotated class of every patch.mt.gr.patch_graph_controlderives a negative-control graph from a stored
patch graph:"shuffled_edges"permutes the edge destinations with a seed,
"no_edges"removes every edge. The source graph is left in place.mt.pl.patch_maptakeslegend=True(or a mapping ofAxes.legendoptions) to
add one entry per drawn category. The default, no legend, is unchanged.
Group contrasts and plot options for a cohort analysis. The defaults are unchanged.
mt.tl.cluster_cooccurrencetakesgroup_col, the column ofsample_metawith
the experimental group of each sample. The returned details then holdunit_meta
and acontrast(case=..., control=...)method: the mean enrichment of the case
units minus that of the control units, each unit counted once, as a table of
cluster pairs. It parallelscontraston the composition details.mt.pl.plot_mean_compositiontakestitle(Nonefor no title) and
group_labels(write the group names, or labels of your own, under the bars). Rows
ofgroup_meanare now matched togroup_orderby label when the index holds
those labels.mt.pl.plot_delta_maskedtakesshow_values=Trueto write the value in every cell
of the unmasked heat map, accepts a table as well as an array, and leaves undefined
(NaN) cells white instead of failing to set the colour range.mt.pl.ecm_centroid_heatmaptakescolorbar_label(default"z").mt.pp.renumber_ecm_clustersgives the ECM clusters of a cohort new numbers from a
{current: new}mapping, for example to keep the numbers of an earlier run when two
clusters of similar size swap. Every patch stays in its cluster. The patch tables and
the stored clustering record are updated.
Per-sample marker contrasts, repeated label reconstruction and per-sample points on two bar
plots. The defaults of existing functions are unchanged.
mt.tl.cell_ecm_marker_contrastcompares, in every sample of a cohort, the ECM marker
profile of the patches that touch a cell type with that of the other patches, optionally
inside one ECM cluster. It reads the stored cell-ECM graph and the patch table, calls
mt.tl.contact_marker_contrastonce per sample and returns the per-sample contrasts, their
mean with every sample counted once, the patch counts and the contacted patches
(CellECMMarkerContrastResult). A sample in which one of the two groups is empty has no
contrast and is left out of the mean.mt.pl.marker_contrast_barsdraws that result: one horizontal bar per marker for the mean
and one point per sample, withsample_groupsto give the samples of each group (for
example each mouse) their own marker shape.mt.pl.cell_ecm_enrichment_barstakesshow_samples=Trueto draw one point per sample
on each bar, withsample_groups,sample_sizeandlegend. A sample with no observed
contact is drawn as an open grey marker below the bars, not at its ratio.annotate="none"
draws the bars without text (for example when no permutation test was run), and the details
object ofmt.tl.cell_ecm_enrichment(..., return_details=True)is accepted in place of
the AnnData.mt.tl.fit_temperaturechooses, from a grid, the temperature that gives the observed labels
the lowest mean negative log-probability under a classifier's class probabilities. The
result is thetemperatureargument ofmt.tl.label_anomaly_scoresand
mt.tl.reconstruct_labels.mt.tl.reconstruct_labels_iterativelyrepeatsmt.tl.reconstruct_labelsfor up to
max_passespasses. It takes a function that returns the class probabilities for a set of
labels, so context that depends on the labels is recomputed after every pass, and it stops
when a pass changes no label. It returns the final labels, the rows that changed and the
result of every pass (IterativeLabelReconstructionResult).mt.pl.ecm_centroid_heatmaptakesvalues="mean_intensity"to show the cluster means
themselves in place of their z-scores across the clusters, for patch features that are
already on a common scale.
Fixed
GraphMAE.fiton a graph without edges (for example the"no_edges"control) no longer
emits NumPyMean of empty slicewarnings or storesNaNedge statistics. The embeddings
are unchanged.mt.pl.ecm_centroid_heatmapno longer raisesTypeErrorwhenK_ecmis left out;
the number of clusters is taken from the patch table, as documented.