Clustering cluster coloring method based on space transcriptome, electronic equipment and storage medium

By constructing a loop map of the cluster label confusion matrix and color visual difference matrix, order-preserved mapping is carried out to determine the target mapping relationship, the problem of indistinguishable cluster coloring in the existing technology is solved, and better Cluster cluster distinction and shading efficiency.

CN119226820APending Publication Date: 2024-12-31SHENZHEN HUADA SANJIAN QIFA TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310792175.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-29
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

The existing cluster cluster shading methods are difficult to effectively distinguish cluster clusters with high similarity, and the optimal shading scheme is inefficient in finding the best coloring scheme, especially when there are a large number of cluster tags.

Method used

By constructing the cluster label confusion matrix and color visual difference matrix, a loop map is generated and sequence-keeping mapping is performed, the target mapping relationship is determined to perform cluster cluster shading processing, and the distinction and coloring efficiency of cluster clusters are improved.

Benefits of technology

The difference between cluster clusters is improved, allowing users to better distinguish cluster clusters with higher similarity, save time, and improve shading quality and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226820A_ABST
    Figure CN119226820A_ABST
Patent Text Reader

Abstract

The invention provides a clustering cluster coloring method based on a space transcriptome, electronic equipment and a storage medium. The method comprises the following steps: constructing a clustering label confusion matrix according to a plurality of clustering labels of a plurality of clustering clusters in spatial transcriptome data, and constructing a color visual difference matrix according to a plurality of preset colors; performing order-preserving mapping on a first loop corresponding to the clustering label confusion matrix and a second loop corresponding to the color visual difference matrix to obtain a plurality of initial mapping relationships; aligning the clustering label confusion matrix and the color vision difference matrix according to each initial mapping relation, and calculating an error of the corresponding initial mapping relation according to the clustering label confusion matrix and the color vision difference matrix after each alignment; and coloring the plurality of clusters according to a target mapping relation determined from the plurality of initial mapping relations according to the plurality of calculated errors. By using the method, the distinction degree between the clustering clusters can be improved, so that the user can better distinguish the clustering clusters with relatively high similarity degree.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the biological field, and in particular to a spatial transcriptome-based cluster coloring method, electronic device and storage medium. Background Art

[0002] In the current cluster coloring scheme, spatial transcriptome data usually have more cluster labels. Software such as Seurat and scanpy tend to assign similar colors in the predefined color palette to adjacent or interlaced cluster labels. The clusters corresponding to adjacent or interlaced cluster labels are usually similar, and the predefined color palette often pursues a relatively average difference between all colors. Therefore, when the number of cluster labels is large, the color difference of the colors assigned to adjacent or interlaced categories will be globally reduced, resulting in clusters with high similarity being difficult to distinguish during visualization.

[0003] In addition, the Palo and other methods use simple neighbor relationships to define the overlap between cluster labels of spatial transcriptome data. This definition method cannot fully express the topological relationship between cluster labels, resulting in poor cluster coloring quality. Moreover, as the number of cluster labels continues to increase, the Palo and other methods use random shuffle coloring to find the optimal coloring scheme, and its time cost increases exponentially, which is inefficient. Summary of the invention

[0004] In view of the above, it is necessary to provide a cluster coloring method based on spatial transcriptome, an electronic device and a storage medium, which can solve the technical problems that clusters with high similarity are difficult to distinguish during visualization and the search efficiency of the optimal coloring scheme is low.

[0005] On the one hand, the present application provides a cluster coloring method based on spatial transcriptome, the method comprising: obtaining spatial transcriptome data, the spatial transcriptome data comprising a plurality of clusters and a cluster label corresponding to each of the plurality of clusters, obtaining a plurality of preset colors according to the number of the plurality of cluster labels, constructing a cluster label confusion matrix according to the plurality of cluster labels, and constructing a color visual difference matrix according to the plurality of preset colors, constructing a cluster label loop diagram of the cluster label confusion matrix, obtaining a first loop of the cluster label loop diagram, and generating a second loop corresponding to the color visual difference matrix, wherein each vertex in the first loop is A cluster label is corresponding to each vertex in the second loop, and a preset color is corresponding to each vertex in the second loop. The first loop and the second loop are mapped in an order-preserving manner to obtain a plurality of initial mapping relationships, and each cluster label in each initial mapping relationship corresponds to a preset color. The cluster label confusion matrix and the color visual difference matrix are aligned according to each initial mapping relationship, and the error of the corresponding initial mapping relationship is calculated according to the cluster label confusion matrix and the color visual difference matrix after each alignment, and a target mapping relationship is determined from the plurality of initial mapping relationships according to the calculated plurality of errors, and the plurality of cluster clusters are colored according to the target mapping relationship.

[0006] In some embodiments, constructing a cluster label confusion matrix based on the multiple cluster labels includes: constructing an initial empty matrix based on the number of the multiple cluster labels, making each row and each column of the initial empty matrix correspond to a cluster label and the cluster labels corresponding to any two rows or any two columns are different, and filling the corresponding element values ​​in the initial empty matrix, including: selecting any element position of the initial empty matrix, determining the row cluster label and column cluster label corresponding to the selected element position, determining the adjacent cluster clusters corresponding to any cluster cluster in the row cluster label based on the column cluster label, counting the total values ​​of the adjacent cluster clusters corresponding to all cluster clusters in the row cluster label, writing the total value of the row cluster label into the selected element position, repeating the step of filling the corresponding element values ​​in the initial empty matrix until all element positions have been written with the corresponding element values, and obtaining the cluster label confusion matrix.

[0007] In some embodiments, determining the adjacent cluster cluster corresponding to any cluster cluster in the row cluster label according to the column cluster label includes: calculating the cluster distance between the remaining cluster clusters in the multiple cluster clusters except the any cluster cluster and the any cluster cluster, sorting the remaining cluster clusters in the multiple cluster clusters except the any cluster cluster according to the multiple cluster distances, selecting a preset number of cluster clusters closest to the any cluster cluster from the sorted cluster clusters, screening the selected cluster clusters according to a preset value, and determining the cluster cluster belonging to the column cluster label among the screened cluster clusters as the adjacent cluster cluster.

[0008] In some embodiments, the cluster label loop graph of the cluster label confusion matrix includes: constructing a corresponding number of vertices according to the number of the multiple cluster labels, and determining whether to connect the two vertices corresponding to any row and any column according to the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix; if any two vertices are connected to each other, the total number of values ​​corresponding to the two connected vertices is used as the edge weight between the two connected vertices to obtain the cluster label loop graph.

[0009] In some embodiments, the order-preserving mapping of the first loop and the second loop to obtain multiple initial mapping relationships includes: keeping the first loop unchanged, staggering all vertices in the second loop to obtain multiple target loops, wherein the preset colors corresponding to the same position in any two target loops are different; establishing a correspondence between the clustering label corresponding to the vertex at each position in the first loop and the preset color corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship, or keeping the second loop unchanged, staggering all vertices in the first loop to obtain multiple target loops, wherein the clustering labels corresponding to the same position in any two target loops are different; establishing a correspondence between the preset color corresponding to the vertex at each position in the second loop and the clustering label corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship.

[0010] In some embodiments, the color visual difference matrix includes color difference values, and aligning the cluster label confusion matrix with the color visual difference matrix according to each initial mapping relationship includes: keeping the color visual difference matrix unchanged, transforming the position of the total value in the cluster label confusion matrix according to each initial mapping relationship, and obtaining the cluster label confusion matrix and the color visual difference matrix after each alignment, or keeping the cluster label confusion matrix unchanged, transforming the position of the color difference value in the color visual difference matrix according to each initial mapping relationship, and obtaining the cluster label confusion matrix and the color visual difference matrix after each alignment.

[0011] In some embodiments, determining a target mapping relationship from the multiple initial mapping relationships based on the calculated multiple errors, and coloring the multiple cluster clusters according to the target mapping relationship includes: determining the initial mapping relationship corresponding to the smallest error as the target mapping relationship, and coloring the cluster clusters corresponding to the cluster label according to a preset color corresponding to each cluster label in the target mapping relationship.

[0012] In some embodiments, the method further includes: embedding the cluster label confusion matrix into a three-dimensional coordinate space to obtain the three-dimensional coordinates corresponding to each cluster label, adjusting the multiple three-dimensional coordinates to a preset color space to obtain the target color corresponding to each cluster label, and coloring the cluster clusters corresponding to the cluster label according to the target color corresponding to each cluster label.

[0013] On the other hand, the present application provides a cluster coloring device based on spatial transcriptome, the device comprising: an acquisition unit for acquiring spatial transcriptome data, the spatial transcriptome data comprising multiple clusters and cluster labels corresponding to each of the multiple clusters, a construction unit for acquiring multiple preset colors according to the number of multiple cluster labels, constructing a cluster label confusion matrix according to the multiple cluster labels, and constructing a color visual difference matrix according to the multiple preset colors, a generation unit for constructing a cluster label loop diagram of the cluster label confusion matrix, obtaining a first loop of the cluster label loop diagram, and generating a second loop corresponding to the color visual difference matrix, wherein each vertex in the first loop corresponds to a cluster label, each vertex in the second loop corresponds to a preset color, a mapping unit is used to perform order-preserving mapping between the first loop and the second loop to obtain multiple initial mapping relationships, each cluster label in each initial mapping relationship corresponds to a preset color, an alignment unit is used to align the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, a calculation unit is used to calculate the error of the corresponding initial mapping relationship according to the cluster label confusion matrix and the color visual difference matrix after each alignment, a determination unit is used to determine the target mapping relationship from the multiple initial mapping relationships according to the calculated multiple errors, and a coloring unit is used to color the multiple cluster clusters according to the target mapping relationship.

[0014] On the other hand, the present application provides an electronic device, comprising: a memory storing at least one instruction; and a processor executing the at least one instruction to implement the spatial transcriptome-based cluster coloring method.

[0015] On the other hand, the present application provides a computer-readable storage medium, wherein at least one instruction is stored in the computer-readable storage medium, and the at least one instruction is executed by a processor in an electronic device to implement the spatial transcriptome-based cluster coloring method.

[0016] Through the above implementation, each element value in the cluster label confusion matrix represents the similarity between any two different cluster labels (overlapping range size), the larger the element value in the cluster label confusion matrix, the higher the similarity between the corresponding two cluster labels, and each element value in the color visual difference matrix represents the color difference between any two different preset colors, the larger the element value in the color visual difference matrix, the larger the color difference between the corresponding two preset colors. The first loop and the second loop are subjected to order-preserving mapping, and the initial mapping relationship (corresponding relationship) between the cluster labels and the preset colors at the corresponding positions can be established. Since the number of multiple initial mapping relationships obtained by order-preserving mapping is relatively small compared to the number of mapping relationships obtained by random shuffling by methods such as Palo, time can be saved and efficiency can be improved. The present application can accurately express the association relationship between multiple cluster labels by constructing a cluster label confusion matrix and then constructing a loop diagram, instead of using a simple adjacent relationship to define the overlapping relationship between multiple cluster labels in the related art methods such as Palo. By analyzing the accurate association relationship between multiple cluster labels, the quality of cluster coloring can be improved. When the initial mapping relationship with the smallest error is determined as the target mapping relationship, the preset color with the largest color difference in the target mapping relationship can correspond to the cluster label with the highest similarity, or the preset color with the smallest color difference in the target mapping relationship can correspond to the cluster label with the lowest similarity. Using the preset color with the highest color difference to color the cluster clusters corresponding to the cluster labels with the highest similarity can improve the distinguishability of the cluster clusters, so that users can better distinguish between cluster clusters with higher similarity. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a structural diagram of an electronic device provided in one embodiment of the present application.

[0018] Figure 2 This is a flow chart of a cluster coloring method based on spatial transcriptome provided in one embodiment of the present application.

[0019] Figure 3 It is a schematic diagram of a cluster label confusion matrix and a color visual difference matrix provided in an embodiment of the present application.

[0020] Figure 4 It is a schematic diagram of a clustering label loop diagram and a color difference loop diagram provided in an embodiment of the present application.

[0021] Figure 5 This is a schematic diagram of generating multiple target loops provided in an embodiment of the present application.

[0022] Figure 6 It is a schematic diagram of generating multiple initial mapping relationships provided in an embodiment of the present application.

[0023] Figure 7 It is a schematic diagram of aligning a clustering label confusion matrix and a color visual difference matrix according to an initial mapping relationship provided by an embodiment of the present application.

[0024] Figure 8 It is a comparative schematic diagram of the cluster coloring effect provided in an embodiment of the present application.

[0025] Fig. 9 It is a flowchart of a method for constructing a cluster label confusion matrix provided in one embodiment of the present application.

[0026] Fig.10 This is a flowchart of a method for determining adjacent clusters provided in one embodiment of the present application.

[0027] Fig.11 It is a flow chart for constructing a clustering label loop graph provided in an embodiment of the present application.

[0028] Fig.12 This is a flowchart of a spatial transcriptome-based cluster coloring method provided in another embodiment of the present application.

[0029] Fig.13 It is a functional module diagram of a spatial transcriptome-based cluster coloring device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0030] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application is described in detail below with reference to the accompanying drawings and specific embodiments.

[0031] It should be noted that in this application, "at least one" means one or more, and "more than one" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth", etc. (if any) in the specification, claims and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence.

[0032] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0033] In related technologies, spatial transcriptome data usually have many cluster labels, and there are adjacent or interlaced cluster labels. The coloring of spatial transcriptome data is affected by the spatial topological relationship of the cluster labels. Clusters of adjacent or interlaced cluster labels require greater color differences, while clusters of cluster labels with good discrimination do not require greater color differences. However, software such as Seurat easily assigns similar colors in the predefined color palette to adjacent or interlaced cluster labels. The clusters corresponding to adjacent or interlaced cluster labels are usually similar, and the predefined color palette often pursues a relatively average difference between all colors. Therefore, when the number of cluster labels is large, the color difference of the colors assigned to adjacent or interlaced categories will be globally reduced, resulting in clusters with high similarity being difficult to distinguish during visualization.

[0034] In addition, the Palo and other methods use simple neighbor relationships to define the overlap between cluster labels of spatial transcriptome data. This definition method cannot fully express the topological relationship between cluster labels, resulting in poor cluster coloring quality. Moreover, as the number of cluster labels continues to increase, the Palo and other methods use random shuffle coloring to find the optimal coloring scheme, and its time cost increases exponentially, which is inefficient.

[0035] In order to solve the above technical problems, the present application provides a cluster coloring method based on spatial transcriptome, an electronic device and a storage medium, which can improve the distinction between clusters, so that users can better distinguish clusters with high similarity. The cluster coloring method based on spatial transcriptome provided in the embodiment of the present application can be applied to one or more electronic devices.

[0036] like Figure 1 , is a structural diagram of an electronic device provided by an embodiment of the present application. Figure 1 In the present invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program stored in the memory 12 and executable on the processor 13. When the computer program is executed by the processor 13, a cluster coloring method based on spatial transcriptome can be implemented.

[0037] The electronic device 1 is a device that can automatically calculate parameter values ​​and / or process information according to pre-set or stored instructions, and its hardware includes, but is not limited to: a microprocessor, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), an embedded device, etc.

[0038] The electronic device 1 may be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a server, etc.

[0039] The electronic device 1 may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing. Figure 1 It is only an example of the electronic device 1 and does not constitute a limitation of the electronic device 1. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device 1 may also include input and output devices, network access devices, buses, etc.

[0040] The network where the electronic device 1 is located includes but is not limited to: the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), etc.

[0041] like Figure 2 As shown, it is a flow chart of a cluster coloring method based on spatial transcriptome provided by an embodiment of the present application. According to different requirements, the order of each step in the flow chart can be adjusted according to actual requirements, and some steps can be omitted. The execution subject of the method is an electronic device, such as Figure 1 An electronic device 1 is shown.

[0042] S11, obtaining spatial transcriptome data, where the spatial transcriptome data includes a plurality of clusters and a cluster label corresponding to each of the plurality of clusters.

[0043] In some embodiments, the spatial transcriptome data can be data obtained by sequencing tissue sections using sequencing technology. The clusters can be cells or tissues, and the cluster labels are the categories of the clusters. For example, a cluster can be a cell of the same category or a cell group consisting of multiple cells of the same category. The cluster labels can be obtained by unsupervised clustering of the multiple clusters based on the gene expression information of the multiple clusters in advance, or they can be pre-set categories. The spatial transcriptome data also includes data such as gene expression information and the spatial position of the clusters, which is not limited to this in practical applications. For example, 10XVisium sequencing technology can be used to sequence mouse tissue sections placed on a carrier. Since multiple sample points are regularly distributed on the carrier, and each sample point has a corresponding spatial position, the gene expression information corresponding to each sample point can be obtained after sequencing, and one or more sample points corresponding to each cell in the mouse tissue section are determined, and the sum of the gene expression information in the one or more sample points corresponding to each cell is used as the gene expression information of the cell. Then, according to the gene expression information corresponding to each cell, all cells in the mouse tissue section are clustered (clustered), and the multiple cluster clusters (cell groups) and the clustering label (cell group category) of each cluster cluster can be obtained.

[0044] S12, acquiring a plurality of preset colors according to the number of the plurality of cluster labels, constructing a cluster label confusion matrix according to the plurality of cluster labels, and constructing a color visual difference matrix according to the plurality of preset colors.

[0045] In some embodiments, the number of the plurality of preset colors is the same as the number of the plurality of cluster labels, and the plurality of preset colors can be set arbitrarily, and the present application does not limit this. For example, if the number of the plurality of cluster labels is 3, the plurality of preset colors can be purple, red, green, etc.

[0046] In some embodiments, the matrix dimensions of the cluster label confusion matrix and the color visual difference matrix are both related to the number of the multiple cluster labels. For example, if the number of the multiple cluster labels is n, the matrix dimensions of the cluster label confusion matrix and the color visual difference matrix are both n*n. Each row and column in the cluster label confusion matrix corresponds to a cluster label, and the cluster labels corresponding to any two rows or any two columns are different, which can be understood as there are no rows with the same cluster label or columns with the same cluster label in the cluster label confusion matrix. Each row and column in the color visual difference matrix corresponds to a preset color, and the preset colors corresponding to any two rows or any two columns are different, which can be understood as there are no rows with the same color or columns with the same color in the color visual difference matrix.

[0047] Each element value in the cluster label confusion matrix represents the similarity (overlapping range) between any two different cluster labels. The larger the element value in the cluster label confusion matrix, the higher the similarity between the corresponding two cluster labels. Each element value in the color visual difference matrix can be a color difference value. A color difference value can be determined according to the color difference between any two different preset colors. The larger the element value in the color visual difference matrix, the larger the color difference between the corresponding two preset colors. Since the number of the multiple preset colors is the same as the number of the multiple cluster labels, the matrix dimensions of the color visual difference matrix and the cluster label confusion matrix are the same.

[0048] The color difference value can be calculated from each channel value (R, G, B channel value) of each preset color. The calculation method of the color difference value can refer to formulas (1)-(5):

[0049]

[0050]

[0051] ΔR=R i -R j ; (3)

[0052] ΔG=G i -G j ; (4)

[0053] ΔB=B i -B j ; (5)

[0054] Among them, C ij represents the color difference value between the i-th preset color and the j-th preset color, N represents the number of the plurality of preset colors, - i Represents the red signal channel value of the i-th preset color, R j Represents the red signal channel value of the jth preset color, G i Represents the green signal channel value of the i-th preset color, G j Indicates the green signal channel value of the jth preset color, B i Indicates the blue signal channel value of the i-th preset color, B j Indicates the blue signal channel value of the j-th preset color.

[0055] Since each row and each column in the cluster label confusion matrix corresponds to a cluster label, and the cluster labels corresponding to any two rows or any two columns are different, the two element positions corresponding to the main diagonal in the cluster label confusion matrix will correspond to the same pair of cluster labels, and the element values ​​of the same pair of cluster labels at the two element positions corresponding to the main diagonal in the cluster label confusion matrix are the same. For example, the i-th row and j-th column and the j-th row and i-th column in the cluster label confusion matrix are two element positions corresponding to the main diagonal, so the element value corresponding to the i-th row and j-th column in the cluster label confusion matrix is ​​the same as the element value corresponding to the j-th row and i-th column. Since the color visual difference matrix has similar reasons to the cluster label confusion matrix, the element value corresponding to the i-th row and j-th column in the color visual difference matrix is ​​the same as the element value corresponding to the j-th row and i-th column, and both the cluster label confusion matrix and the color visual difference matrix are symmetric matrices based on the symmetry of the main diagonal.

[0056] In some embodiments, if the row and column numbers on the main diagonal of the cluster label confusion matrix are the same, then the positions on the main diagonal of the cluster label confusion matrix are element values ​​corresponding to any two identical cluster labels. Since each element value in the cluster label confusion matrix represents the degree of similarity between any two different cluster labels, the element value corresponding to the position on the main diagonal of the cluster label confusion matrix is ​​zero. If the row and column numbers on the main diagonal of the color visual difference matrix are the same, then the positions on the main diagonal of the color visual difference matrix are element values ​​corresponding to any two identical preset colors. Since each element value in the color visual difference matrix represents the degree of color difference between any two different preset colors, the element value corresponding to the position on the main diagonal of the color visual difference matrix is ​​zero.

[0057] For example, Figure 3 , which is a schematic diagram of a cluster label confusion matrix and a color visual difference matrix provided by an embodiment of the present application. Figure 3 In the example, A1, A2, A3, and A4 represent different cluster labels. Figure 3 It can be seen from the above that each row and column in the cluster label confusion matrix corresponds to a cluster label, and the cluster labels corresponding to any two rows or any two columns are different. B1, B2, B3, and B4 represent different preset colors. Figure 3 It can be seen that each row and each column in the color visual difference matrix corresponds to a preset color, and the preset colors corresponding to any two rows or any two columns are different. The cluster label confusion matrix and the color visual difference matrix are both matrices based on the main diagonal symmetry, and the element values ​​on the main diagonal are zero.

[0058] S13, constructing cluster labels of the cluster label confusion matrix, obtaining the first loop of the cluster label loop diagram, and generating the second loop corresponding to the color visual difference matrix, wherein each vertex in the first loop corresponds to a cluster label, and each vertex in the second loop corresponds to a preset color.

[0059] In one embodiment, the electronic device may use a path planning algorithm to obtain the longest loop in the cluster label loop graph as the first loop, and use the path planning algorithm to obtain the longest loop in the color difference loop graph as the second loop. The path planning algorithm includes, but is not limited to, a heuristic search algorithm and a dynamic programming algorithm. The number of vertices in the first loop and the number of vertices in the second loop are both the same as the number of the plurality of cluster labels.

[0060] In some embodiments, the present application constructs the cluster label loop diagram based on the number of the multiple cluster labels and the element values ​​in the cluster label confusion matrix. The generation method of the color difference loop diagram is basically the same as the generation method of the cluster label loop diagram, so this application will not repeat the description.

[0061] For example, following the above embodiment, Figure 4 , which is a schematic diagram of a cluster label loop diagram and a color difference loop diagram provided by an embodiment of the present application. Figure 4 It can be seen that the number of vertices on the cluster label loop graph corresponding to the cluster label confusion matrix is ​​the same as the number of the multiple cluster labels, each vertex on the cluster label loop graph corresponds to a cluster label, the edge weight between vertex A1 and vertex A2 is 6, the edge weight between vertex A2 and vertex A4 is 14, the edge weight between vertex A3 and vertex A4 is 16, the edge weight between vertex A1 and vertex A3 is 12, the edge weight between vertex A1 and vertex A4 is 8, and the edge weight between vertex A2 and vertex A3 is 10. The number of vertices on the color difference loop graph corresponding to the color visual difference matrix is ​​the same as the number of the multiple preset colors, each vertex on the color difference loop graph corresponds to a preset color, the edge weight between vertex B1 and vertex B2 is 2, the edge weight between vertex B2 and vertex B4 is 4, the edge weight between vertex B3 and vertex B4 is 10, the edge weight between vertex B1 and vertex B3 is 6, the edge weight between vertex B1 and vertex B4 is 2, and the edge weight between vertex B2 and vertex B3 is 8, wherein the method for calculating the edge weight and how to determine whether any two vertices are connected will be described in detail in steps S131-S135 below.

[0062] In this embodiment, the present application constructs a cluster label confusion matrix according to the similarity between any two different cluster labels, and constructs a cluster label loop graph according to the cluster label confusion matrix. Instead of using a simple adjacent relationship to define the overlapping relationship between multiple cluster labels as in the related art methods such as Palo, the present application can accurately express the association relationship between multiple cluster labels by constructing a cluster label confusion matrix and then constructing a loop graph. By analyzing the accurate association relationship between multiple cluster labels, the quality of cluster coloring can be improved.

[0063] S14, performing order-preserving mapping on the first loop and the second loop to obtain a plurality of initial mapping relationships, wherein each clustering label in each initial mapping relationship corresponds to a preset color.

[0064] In some embodiments, when the first cycle and the second cycle are completely matched (the corresponding vertices and edges are completely matched), the first cycle and the second cycle can be mapped in an order-preserving manner.

[0065] In some embodiments, the electronic device performs order-preserving mapping on the first loop and the second loop to obtain multiple initial mapping relationships, including: keeping the second loop unchanged, the electronic device performs staggered arrangement on all vertices in the first loop to obtain multiple target loops, wherein the cluster labels corresponding to the same position in any two target loops are different, and then the electronic device establishes a correspondence between a preset color corresponding to the vertex at each position in the second loop and a cluster label corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship.

[0066] In some embodiments, since each vertex in the first loop corresponds to a cluster label, staggering all vertices in the first loop is equivalent to staggering multiple cluster labels corresponding to the first loop. The multiple target loops include the first loop, and the number of the multiple target loops is the same as the number of the multiple cluster labels. The cluster labels corresponding to the same vertex position before and after the staggered arrangement of the first loop are different.

[0067] like Figure 5 , which is a schematic diagram of generating multiple target loops provided in an embodiment of the present application. Figure 4The first loop in contains 4 vertices A1, A2, A3 and A4, wherein the 4 vertices A1, A2, A3 and A4 correspond to a cluster label respectively, vertex A1 is connected to vertex A2, vertex A1 is connected to vertex A3, vertex A2 is connected to vertex A4, vertex A3 is connected to vertex A4, the edge weight between vertex A1 and vertex A2 is 6, the edge weight between vertex A2 and vertex A4 is 14, the edge weight between vertex A3 and vertex A4 is 16, and the edge weight between vertex A1 and vertex A3 is 12. The first loop containing 4 vertices A1, A2, A3 and A4 is arranged in a staggered manner to obtain 3 staggered loops, and the 3 staggered loops and the first loop are all determined as target loops, to obtain 4 target loops. Among them, the cluster labels corresponding to the same vertex positions between any two target loops are different.

[0068] In some embodiments, the number of the multiple initial mapping relationships is the same as the number of cluster labels. For example, if the number of the multiple cluster labels is n, the number of the multiple initial mapping relationships is also n.

[0069] For example, following the above embodiment, Figure 6 FIG. 1 is a schematic diagram of generating multiple initial mapping relationships provided by an embodiment of the present application. Figure 6 In , the second loop is mapped to each target loop in an order-preserving manner, wherein the preset color corresponding to the vertex at each position in the second loop and the cluster label corresponding to the vertex at the same position in any target loop have a mapping relationship (corresponding relationship), in Figure 6 This is indicated by a double arrow. For example, Figure 6 In the second initial mapping relationship shown, there is a corresponding relationship between the preset color B1 corresponding to the vertex at the upper left corner of the second loop and the cluster label A3 corresponding to the vertex at the upper left corner of the second target loop. Figure 6 In the fourth initial mapping relationship shown, there is a corresponding relationship between the preset color B1 corresponding to the vertex at the upper left corner position in the second loop and the cluster label A2 corresponding to the vertex at the upper left corner position of the fourth target loop.

[0070] The embodiment of the present application adopts a method of staggered arrangement of all vertices in the first loop to obtain multiple target loops, rather than the random shuffling method adopted by the Palo and other methods in the related art. Since the multiple target loops in the staggered arrangement are mapped to the second loop respectively, each cluster label can be matched with multiple preset colors, and compared with the random shuffling method, the staggered arrangement method can reduce the number of matches, thereby increasing the speed of obtaining the multiple initial mapping relationships.

[0071] In another embodiment of the present application, the electronic device performs order-preserving mapping on the first loop and the second loop to obtain multiple initial mapping relationships, which also includes: keeping the first loop unchanged, the electronic device performs staggered arrangement on all vertices in the second loop to obtain multiple target loops, wherein the preset colors corresponding to the same position in any two target loops are different, and then the electronic device establishes a correspondence between the cluster label corresponding to the vertex at each position in the first loop and the preset color corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship.

[0072] Among them, the way in which the electronic device staggers all vertices in the second loop is the same as the above-mentioned way of staggering all vertices in the first loop, and the way in which the electronic device establishes the correspondence between the clustering label corresponding to the vertex at each position in the first loop and the preset color corresponding to the vertex at the corresponding position in any target loop is basically the same as the above-mentioned way of establishing the correspondence between the preset color corresponding to the vertex at each position in the second loop and the clustering label corresponding to the vertex at the corresponding position in any target loop, so this application will not repeat the description.

[0073] S15, aligning the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, and calculating the error of the corresponding initial mapping relationship according to the cluster label confusion matrix and the color visual difference matrix after each alignment.

[0074] In some embodiments, the electronic device aligns the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, including: keeping the color visual difference matrix unchanged, the electronic device transforms the position of the total value in the cluster label confusion matrix according to each initial mapping relationship, and obtains the cluster label confusion matrix and color visual difference matrix after each alignment.

[0075] For example, following the above embodiment, Figure 7 , which is a schematic diagram of aligning a clustering label confusion matrix and a color visual difference matrix according to an initial mapping relationship provided by an embodiment of the present application. Figure 7According to the fourth initial mapping relationship mentioned above, the cluster label confusion matrix and the color visual difference matrix are aligned, wherein the fourth initial mapping relationship is that vertex B1 (preset color) corresponds to vertex A2 (cluster label), vertex B2 (preset color) corresponds to vertex A4 (cluster label), vertex B3 (preset color) corresponds to vertex A1 (cluster label), and vertex B4 (preset color) corresponds to vertex A3 (cluster label). Keeping the color visual difference matrix unchanged, first transform the row cluster label corresponding to each row and the column cluster label corresponding to each row in the cluster label confusion matrix according to the fourth initial mapping relationship, and then transform the position of the total value in the cluster label confusion matrix according to the transformed cluster label, so that the total values ​​corresponding to any pair of row cluster labels and column cluster labels in the cluster label confusion matrix before and after the transformation are the same, and obtain the aligned cluster label confusion matrix and color visual difference matrix.

[0076] In some embodiments, the electronic device may determine the binary norm error between the cluster label confusion matrix and the color visual difference matrix after each alignment as the error of the corresponding initial mapping relationship. The calculation method of the binary norm error includes: the electronic device calculates the difference between the two element values ​​at the corresponding positions of the cluster label confusion matrix and the color visual difference matrix after each alignment, squares the multiple differences to obtain multiple square results, and then performs a square root operation on the sum of the multiple square results to obtain the binary norm error.

[0077] In other embodiments of the present application, the error may also be other errors calculated based on the cluster label confusion matrix and the color visual difference matrix after each alignment. The error may be set by oneself, and the present application does not impose any limitation on the error.

[0078] In this embodiment, since each error is the difference between the cluster label confusion matrix and the color visual difference matrix after each alignment, the error can reflect the similarity between any cluster labels in each initial mapping relationship, and the difference between the two preset colors corresponding to the any cluster label.

[0079] In another embodiment of the present application, the electronic device aligns the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, and further includes: keeping the cluster label confusion matrix unchanged, the electronic device transforms the position of the color difference value in the color visual difference matrix according to each initial mapping relationship, and obtains the cluster label confusion matrix and color visual difference matrix after each alignment.

[0080] S16, determining a target mapping relationship from the multiple initial mapping relationships according to the calculated multiple errors, and performing coloring processing on the multiple clusters according to the target mapping relationship.

[0081] In some embodiments, determining a target mapping relationship from the multiple initial mapping relationships based on the calculated multiple errors, and coloring the multiple cluster clusters according to the target mapping relationship includes: the electronic device determines the initial mapping relationship corresponding to the smallest error as the target mapping relationship, and then the electronic device colors the cluster clusters corresponding to the cluster label according to the preset color corresponding to each cluster label in the target mapping relationship.

[0082] In this embodiment, since the error can be the difference between the aligned cluster label confusion matrix and the aligned color visual difference matrix, each element value in the cluster label confusion matrix represents the similarity between any two different cluster labels and each element value in the color visual difference matrix represents the color difference between any two different preset colors. Therefore, the minimum error represents that the preset color with the largest color difference in the target mapping relationship corresponds to the cluster label with the highest similarity, or the preset color with the smallest color difference in the target mapping relationship corresponds to the cluster label with the lowest similarity. Therefore, by coloring the cluster clusters corresponding to each cluster label in the target mapping relationship according to the preset color corresponding to each cluster label in the target mapping relationship, the distinction between cluster clusters can be improved, so that users can better distinguish cluster clusters with higher similarity, thereby improving the coloring quality.

[0083] like Figure 8 , which is a comparative schematic diagram of the cluster coloring effect provided by an embodiment of the present application. Figure 8 (a) is a graph obtained by coloring the spatial transcriptome data of mouse brain clusters using relevant coloring software (such as Seurat software). Figure 8 (b) is a diagram after the spatial transcriptome data of the mouse brain cluster is colored using the coloring method in the embodiment of the present application. The spatial transcriptome data of the mouse brain cluster includes brain clusters corresponding to 24 cluster labels, Figure 8 (a) and Figure 8 By comparing with (b) in the figure, we can get: Figure 8 (b) has higher visual clarity and a clearer division of clusters. From the perspective of human vision, Figure 8 (b) identifies more cluster labels.

[0084] Through the above implementation, each element value in the cluster label confusion matrix represents the similarity (overlapping range size) between any two different cluster labels. The larger the element value in the cluster label confusion matrix, the higher the similarity between the corresponding two cluster labels. Each element value in the color visual difference matrix represents the color difference between any two different preset colors. The larger the element value in the color visual difference matrix, the larger the color difference between the corresponding two preset colors. The first loop and the second loop are mapped in an order-preserving manner to establish an initial mapping relationship (corresponding relationship) between the cluster labels and preset colors at corresponding positions. Since the number of multiple initial mapping relationships obtained by order-preserving mapping is relatively small compared to the number of mapping relationships obtained by random scrambling methods such as Palo, it can save time and improve efficiency.

[0085] The embodiment of the present application can accurately express the correlation relationship between multiple cluster labels by constructing a cluster label confusion matrix and then constructing a loop diagram, instead of using a simple adjacent relationship to define the overlapping relationship between multiple cluster labels in the related art methods such as Palo. By analyzing the accurate correlation relationship between multiple cluster labels, the quality of cluster cluster coloring can be improved. When the initial mapping relationship with the smallest error is determined as the target mapping relationship, the preset color with the largest color difference in the target mapping relationship can correspond to the cluster label with the highest similarity, or the preset color with the smallest color difference in the target mapping relationship can correspond to the cluster label with the lowest similarity. The preset color with the highest color difference is used to color the clusters corresponding to the cluster labels with the highest similarity, which can improve the distinguishability of cluster clusters and enable users to better distinguish clusters with higher similarity.

[0086] like Fig. 9 FIG. 1 is a flowchart of a method for constructing a cluster label confusion matrix provided in an embodiment of the present application, comprising the following steps:

[0087] S121, the electronic device constructs an initial empty matrix according to the number of the multiple cluster labels, so that each row and each column of the initial empty matrix corresponds to a cluster label and the cluster labels corresponding to any two rows or any two columns are different.

[0088] In some embodiments, the matrix dimensions of the initial empty matrix are all related to the number of the plurality of cluster labels. For example, if the number of the plurality of cluster labels is n, the matrix dimensions of the initial empty matrix are all n*n.

[0089] S122, the electronic device fills in corresponding element values ​​in the initial empty matrix.

[0090] In some embodiments, the electronic device fills the corresponding element values ​​in the initial empty matrix including: the electronic device selects any element position of the initial empty matrix, determines the row clustering label (for example, the clustering label corresponding to the i-th row) and the column clustering label (for example, the clustering label corresponding to the j-th column) corresponding to the selected element position, and then the electronic device determines the adjacent clustering clusters corresponding to any clustering cluster in the row clustering label according to the column clustering label, counts the total values ​​of the adjacent clustering clusters corresponding to all clustering clusters in the row clustering label, and writes the total value of the row clustering label into the selected element position.

[0091] The cluster label corresponding to the row number of the selected element position is determined as the row cluster label, and the cluster label corresponding to the column number of the selected element position is determined as the column cluster label. The adjacent cluster is a cluster that is close to any cluster and whose cluster label is the column cluster label.

[0092] S123, the electronic device determines whether corresponding element values ​​have been written into all element positions in the initial empty matrix.

[0093] In some embodiments, if any element position in the initial empty matrix has no corresponding element value written in it, the process returns to step S122 to continue to execute the step of filling the initial empty matrix with the corresponding element value.

[0094] If corresponding element values ​​have been written into all element positions in the initial empty matrix, step S124 is executed, and the electronic device determines the completed initial empty matrix as the cluster label confusion matrix.

[0095] For example, if the matrix dimension of the initial empty matrix is ​​n*n, the corresponding element values ​​are written into the n*n element positions to obtain the cluster label confusion matrix.

[0096] In some embodiments, the cluster label confusion matrix is ​​a corresponding total value. Each total value represents the similarity (overlap degree) between any two different cluster labels. The larger the element value in the cluster label confusion matrix, the higher the similarity between the corresponding two cluster labels.

[0097] like Fig.10 FIG. 1 is a flowchart of a method for determining adjacent clusters provided in an embodiment of the present application, comprising the following steps:

[0098] S1221: The electronic device calculates a cluster distance between the remaining clusters among the plurality of clusters except the any cluster and the any cluster.

[0099] In some embodiments, the cluster distance may be Euclidean distance, Manhattan distance, or Chebyshev distance, etc. The calculation method of the cluster distance may specifically refer to the calculation formulas of Euclidean distance, Manhattan distance, or Chebyshev distance in the related art.

[0100] S1222: The electronic device sorts the remaining clusters among the multiple clusters except the any cluster according to the multiple cluster distances, and selects a preset number of clusters closest to the any cluster from the sorted clusters.

[0101] In some embodiments, the preset number can be set arbitrarily, and the present application does not limit this. For example, the preset number is 10, and any cluster is determined to be cluster K, and the 10 clusters closest to cluster K are selected from the sorted clusters.

[0102] S1223: The electronic device screens the selected clusters according to a preset value, and determines the clusters belonging to the column clustering label among the screened clusters as the adjacent clusters.

[0103] In some embodiments, the electronic device determines the cluster corresponding to the cluster distance less than the preset value in the selected clusters as the screened cluster, wherein the preset value can be set voluntarily and the present application does not limit this. For example, the preset value can be 90 microns.

[0104] like Fig.11 As shown, it is a flow chart of constructing a cluster label loop graph provided by an embodiment of the present application, which includes the following steps:

[0105] S131: The electronic device constructs a corresponding number of vertices according to the number of the multiple cluster labels.

[0106] In some embodiments, the number of constructed vertices is the same as the number of the plurality of cluster labels, and each vertex corresponds to a cluster label.

[0107] S132: The electronic device determines whether the total value corresponding to any row and any column in the cluster label confusion matrix is ​​zero.

[0108] In some embodiments, the electronic device determines whether to connect two vertices corresponding to any row and any column according to whether the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix is ​​zero. If the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix is ​​not zero, step S133 is executed. If the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix is ​​zero, step S135 is executed.

[0109] S133: The electronic device connects two vertices corresponding to any row and any column.

[0110] In some embodiments, since the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix corresponds to two cluster labels, and each vertex corresponds to one cluster label, the two cluster labels corresponding to any row and any column in the cluster label confusion matrix correspond to two vertices. When the total number of values ​​corresponding to any row and any column in the cluster label confusion matrix is ​​not zero, it means that the two cluster labels corresponding to any row and any column are similar, so the two vertices corresponding to any row and any column are connected to analyze the association relationship between the two vertices.

[0111] S134: If any two vertices are connected to each other, the total number of values ​​corresponding to the two connected vertices is used as the edge weight between the two connected vertices to obtain the cluster label loop graph.

[0112] In some embodiments, if there are multiple total values ​​corresponding to the two mutually connected vertices, the electronic device determines the sum of the multiple total values ​​as the edge weight between the two mutually connected vertices.

[0113] In another embodiment of the present application, if there are multiple total values ​​corresponding to the two interconnected vertices, the electronic device uses the maximum value, minimum value or average value among the multiple total values ​​as the edge weight between the two interconnected vertices.

[0114] In other embodiments of the present application, if there are multiple total values ​​corresponding to the two interconnected vertices, the electronic device can determine the edge weight between the two interconnected vertices according to a preset method and multiple total values. The preset method can be set according to actual needs, and the present application does not limit this.

[0115] In this embodiment, the size of the edge weight between the two interconnected vertices can represent the strength of the association relationship between the two interconnected vertices. A larger edge weight represents a stronger association relationship between the two interconnected vertices, and a smaller edge weight represents a weaker association relationship between the two interconnected vertices.

[0116] S135: The electronic device does not connect the two vertices corresponding to any row and any column.

[0117] In this embodiment, if the total value corresponding to any row and any column in the cluster label confusion matrix is ​​zero, it means that the two cluster labels corresponding to any row and any column are not similar.

[0118] like Fig.12 FIG. 1 is a flow chart of a cluster coloring method based on spatial transcriptome provided in another embodiment of the present application, comprising the following steps:

[0119] S21, the electronic device embeds the cluster label confusion matrix into a three-dimensional coordinate space to obtain a three-dimensional coordinate corresponding to each cluster label.

[0120] In some embodiments, the electronic device can reduce the dimension of the cluster label confusion matrix by a dimensionality reduction algorithm (such as the UMAP dimensionality reduction algorithm) to obtain a point cloud map, wherein each point in the point cloud map corresponds to each cluster label (matrix row / column label) in the cluster label confusion matrix, and the three-dimensional Euclidean distance (straight-line distance in three-dimensional space) between any two points in the point cloud map conforms to the element values ​​corresponding to the two points in the cluster label confusion matrix (the element value in the row corresponding to the first point in the matrix and the column corresponding to the second point).

[0121] S22, the electronic device adjusts the multiple three-dimensional coordinates to a preset color space to obtain a target color corresponding to each cluster label.

[0122] In some embodiments, the color space can be a CIELab color space, and the X, Y and Z in each three-dimensional coordinate correspond to the L, A, and B channels of the CIELab color space respectively. The X, Y and Z in each three-dimensional coordinate are normalized to the ranges corresponding to the L, A, and B channels respectively, and the values ​​corresponding to the L, A, and B channels of each three-dimensional coordinate are obtained, and the values ​​corresponding to the L, A, and B channels of each three-dimensional coordinate are determined as the target colors corresponding to each clustering label.

[0123] Among them, the range corresponding to the L channel is usually (-90, 90), and the range corresponding to the A and B channels is usually (-100, 100).

[0124] In this embodiment, since the three-dimensional Euclidean distance (straight-line distance in three-dimensional space) of any two points in the point cloud image can represent the similarity (overlap degree) between any two different cluster labels, adjusting the multiple three-dimensional coordinates to a preset color space can match target colors with large color differences for cluster labels with high similarity.

[0125] S23, the electronic device performs coloring processing on the clusters corresponding to the cluster labels according to the target color corresponding to each cluster label.

[0126] In this embodiment, since the color difference degree of the target color matches the similarity degree of the clustering labels, the clustering clusters corresponding to the clustering labels are colored according to the target color corresponding to each clustering label. This can improve the distinction of the clustering clusters corresponding to the clustering labels with high similarity, so that users can better distinguish the clustering clusters with high similarity.

[0127] like Fig.13 , is a functional module diagram of a cluster coloring device based on spatial transcriptomes provided in one embodiment of the present application. The cluster coloring device based on spatial transcriptomes 11 includes an acquisition unit 110, a construction unit 111, a generation unit 112, a mapping unit 113, an alignment unit 114, a calculation unit 115, a determination unit 116, and a coloring unit 117. The module / unit referred to in this application refers to a device that can be Figure 1 A series of computer-readable instruction segments acquired by the processor 13 in the embodiment and capable of completing fixed functions, which are stored in Figure 1 In the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.

[0128] In an embodiment of the present application, the acquisition unit 110 is used to acquire spatial transcriptome data, where the spatial transcriptome data includes multiple clusters and a cluster label corresponding to each of the multiple clusters.

[0129] In one embodiment of the present application, the construction unit 111 is used to obtain multiple preset colors according to the number of multiple cluster labels, construct a cluster label confusion matrix according to the multiple cluster labels, and construct a color visual difference matrix according to the multiple preset colors.

[0130] In some embodiments, the construction unit 111 is also used to construct a cluster label confusion matrix based on the multiple cluster labels, including: constructing an initial empty matrix based on the number of the multiple cluster labels, so that each row and each column of the initial empty matrix corresponds to a cluster label and the cluster labels corresponding to any two rows or any two columns are different; filling the initial empty matrix with corresponding element values, including: selecting any element position of the initial empty matrix, determining the row cluster label and column cluster label corresponding to the selected element position; determining the adjacent cluster clusters corresponding to any cluster cluster in the row cluster label based on the column cluster label, and counting the total values ​​of the adjacent cluster clusters corresponding to all cluster clusters in the row cluster label; writing the total value of the row cluster label into the selected element position; repeating the step of filling the initial empty matrix with corresponding element values ​​until all element positions have been written with corresponding element values ​​to obtain the cluster label confusion matrix.

[0131] In some embodiments, the construction unit 111 is also used to determine the adjacent cluster clusters corresponding to any cluster cluster in the row cluster label according to the column cluster label, including: calculating the cluster distances between the remaining cluster clusters in the multiple cluster clusters except the any cluster cluster and the any cluster cluster, sorting the remaining cluster clusters in the multiple cluster clusters except the any cluster cluster according to the multiple cluster distances, selecting a preset number of cluster clusters closest to the any cluster cluster from the sorted cluster clusters, screening the selected cluster clusters according to preset values, and determining the cluster cluster belonging to the column cluster label among the screened cluster clusters as the adjacent cluster cluster.

[0132] In one embodiment of the present application, the generation unit 112 is used to construct a cluster label loop diagram of the cluster label confusion matrix, obtain the first loop of the cluster label loop diagram, and generate a second loop corresponding to the color visual difference matrix, each vertex in the first loop corresponds to a cluster label, and each vertex in the second loop corresponds to a preset color.

[0133] In some embodiments, the generation unit 112 is also used to construct a cluster label loop graph of the cluster label confusion matrix, including: constructing a corresponding number of vertices according to the number of the multiple cluster labels, and determining whether to connect the two vertices corresponding to any row and any column according to the total number values ​​corresponding to any row and any column in the cluster label confusion matrix; if any two vertices are connected to each other, the total number values ​​corresponding to the two connected vertices are used as the edge weight between the two connected vertices to obtain the cluster label loop graph.

[0134] In an embodiment of the present application, the mapping unit 113 is used to perform order-preserving mapping on the first loop and the second loop to obtain a plurality of initial mapping relationships, in which each cluster label corresponds to a preset color.

[0135] In some embodiments, the mapping unit 113 is also used to perform order-preserving mapping on the first loop and the second loop to obtain multiple initial mapping relationships, including: keeping the first loop unchanged, staggering all vertices in the second loop to obtain multiple target loops, wherein the corresponding preset colors at the same position in any two target loops are different; establishing a correspondence between the clustering label corresponding to the vertex at each position in the first loop and the preset color corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship, or keeping the second loop unchanged, staggering all vertices in the first loop to obtain multiple target loops, wherein the corresponding clustering labels at the same position in any two target loops are different; establishing a correspondence between the preset color corresponding to the vertex at each position in the second loop and the clustering label corresponding to the vertex at the corresponding position in any target loop to obtain any initial mapping relationship.

[0136] In an embodiment of the present application, the color visual difference matrix includes color difference values, and the alignment unit 114 is used to align the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship.

[0137] In some embodiments, the alignment unit 114 is also used to align the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, including: keeping the color visual difference matrix unchanged, transforming the position of the total value in the cluster label confusion matrix according to each initial mapping relationship, and obtaining the cluster label confusion matrix and the color visual difference matrix after each alignment, or keeping the cluster label confusion matrix unchanged, transforming the position of the color difference value in the color visual difference matrix according to each initial mapping relationship, and obtaining the cluster label confusion matrix and the color visual difference matrix after each alignment.

[0138] In an embodiment of the present application, the calculation unit 115 is used to calculate the error of the corresponding initial mapping relationship according to the cluster label confusion matrix and the color visual difference matrix after each alignment.

[0139] In an embodiment of the present application, the determining unit 116 is configured to determine a target mapping relationship from the multiple initial mapping relationships according to the calculated multiple errors.

[0140] In some embodiments, the determining unit 116 is further configured to determine an initial mapping relationship corresponding to a minimum error as the target mapping relationship.

[0141] In an embodiment of the present application, the coloring unit 117 is used to perform coloring processing on the multiple clusters according to the target mapping relationship.

[0142] In some embodiments, the coloring unit 117 is further configured to color the clusters corresponding to the cluster labels according to a preset color corresponding to each cluster label in the target mapping relationship.

[0143] In some embodiments of the present application, the construction unit 111 further includes an embedding subunit and an adjustment subunit. The embedding subunit is used to embed the cluster label confusion matrix into a three-dimensional coordinate space to obtain the three-dimensional coordinates corresponding to each cluster label, the adjustment subunit is used to adjust the multiple three-dimensional coordinates to a preset color space to obtain the target color corresponding to each cluster label, and the coloring unit 117 is also used to color the cluster clusters corresponding to the cluster labels according to the target color corresponding to each cluster label.

[0144] Through the above implementation, each element value in the cluster label confusion matrix represents the similarity between any two different cluster labels (overlapping range size), the larger the element value in the cluster label confusion matrix, the higher the similarity between the corresponding two cluster labels, and each element value in the color visual difference matrix represents the color difference between any two different preset colors, the larger the element value in the color visual difference matrix, the larger the color difference between the corresponding two preset colors. The first loop and the second loop are subjected to order-preserving mapping, and the initial mapping relationship (corresponding relationship) between the cluster labels and the preset colors at the corresponding positions can be established. Since the number of multiple initial mapping relationships obtained by order-preserving mapping is relatively small compared to the number of mapping relationships obtained by random shuffling by methods such as Palo, time can be saved and efficiency can be improved. The present application can accurately express the association relationship between multiple cluster labels by constructing a cluster label confusion matrix and then constructing a loop diagram, instead of using a simple adjacent relationship to define the overlapping relationship between multiple cluster labels in the related art methods such as Palo. By analyzing the accurate association relationship between multiple cluster labels, the quality of cluster coloring can be improved. When the initial mapping relationship with the smallest error is determined as the target mapping relationship, the preset color with the largest color difference in the target mapping relationship can correspond to the cluster label with the highest similarity, or the preset color with the smallest color difference in the target mapping relationship can correspond to the cluster label with the lowest similarity. The preset color with the highest color difference is used to color the cluster clusters corresponding to the cluster labels with the highest similarity. This can improve the distinction between cluster clusters, allowing users to better distinguish clusters with higher similarity.

[0145] In one embodiment, if Figure 1The processor 13 shown can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor, etc. The processor 13 is the computing core and control center of the electronic device 1, and uses various interfaces and lines to connect various parts of the entire electronic device 1, and obtain the operating system of the electronic device 1 and various installed applications, program codes, etc.

[0146] The processor 13 obtains the operating system of the electronic device 1 and various installed applications. The processor 13 obtains the application to implement the steps in the above-mentioned embodiments of the cluster coloring method based on the spatial transcriptome, for example Figure 2 , Fig. 9 , Fig.10 , Fig.11 and Fig.12 Steps shown.

[0147] Exemplarily, the computer program may be divided into one or more modules / units, such as an acceleration unit, and one or more modules / units are stored in the memory 12 and acquired by the processor 13 to complete the present application. One or more modules / units may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the acquisition process of the computer program in the electronic device 1.

[0148] The memory 12 can be used to store computer programs and / or modules. The processor 13 implements various functions of the electronic device 1 by running or acquiring computer programs and / or modules stored in the memory 12, and calling data stored in the memory 12. The memory 12 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the server, etc. In addition, the memory 12 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.

[0149] The memory 12 may be an external memory and / or an internal memory of the electronic device 1. Furthermore, the memory 12 may be a memory in a physical form, such as a memory stick, a TF card (Trans-flash Card), and the like.

[0150] If the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware to complete it through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is obtained by the processor, it can implement the steps of each of the above-mentioned method embodiments.

[0151] The computer program includes computer program code, which may be in source code form, object code form, accessible file or some intermediate form, etc. Computer readable media may include: any entity or device capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).

[0152] Combination Figure 2 The memory 12 in the electronic device 1 stores multiple instructions to implement a cluster coloring method based on the spatial transcriptome, and the processor 13 can obtain multiple instructions to achieve: obtaining spatial transcriptome data, the spatial transcriptome data includes multiple clusters and cluster labels corresponding to each of the multiple clusters; obtaining multiple preset colors according to the number of multiple cluster labels, constructing a cluster label confusion matrix according to the multiple cluster labels, and constructing a color visual difference matrix according to the multiple preset colors; constructing a cluster label loop diagram of the cluster label confusion matrix, obtaining a first loop of the cluster label loop diagram, and generating a second loop corresponding to the color visual difference matrix, Each vertex in the first loop corresponds to a cluster label, and each vertex in the second loop corresponds to a preset color; the first loop and the second loop are mapped in an order-preserving manner to obtain multiple initial mapping relationships, and each cluster label in each initial mapping relationship corresponds to a preset color; the cluster label confusion matrix and the color visual difference matrix are aligned according to each initial mapping relationship, and the error of the corresponding initial mapping relationship is calculated according to the cluster label confusion matrix and the color visual difference matrix after each alignment; the target mapping relationship is determined from the multiple initial mapping relationships according to the calculated multiple errors, and the multiple cluster clusters are colored according to the target mapping relationship.

[0153] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 2 The description of the relevant steps in the corresponding embodiments will not be repeated here.

[0154] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation.

[0155] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0156] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0157] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present application is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0158] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in this application can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. A cluster coloring method based on spatial transcriptome, characterized in that: The method comprises: Acquire spatial transcriptome data, wherein the spatial transcriptome data includes a plurality of clusters and a cluster label corresponding to each of the plurality of clusters; Acquire a plurality of preset colors according to the number of the plurality of cluster labels, construct a cluster label confusion matrix according to the plurality of cluster labels, and construct a color visual difference matrix according to the plurality of preset colors; Constructing a cluster label loop diagram of the cluster label confusion matrix, obtaining a first loop of the cluster label loop diagram, and generating a second loop corresponding to the color visual difference matrix, wherein each vertex in the first loop corresponds to a cluster label, and each vertex in the second loop corresponds to a preset color; Performing order-preserving mapping on the first loop and the second loop to obtain a plurality of initial mapping relationships, wherein each cluster label in each initial mapping relationship corresponds to a preset color; Aligning the cluster label confusion matrix and the color visual difference matrix according to each initial mapping relationship, and calculating the error of the corresponding initial mapping relationship according to the cluster label confusion matrix and the color visual difference matrix after each alignment; A target mapping relationship is determined from the multiple initial mapping relationships according to the calculated multiple errors, and the multiple clusters are colored according to the target mapping relationship.

2. The method for coloring clusters based on spatial transcriptome according to claim 1, characterized in that: The step of constructing a cluster label confusion matrix according to the plurality of cluster labels comprises: Constructing an initial empty matrix according to the number of the plurality of cluster labels, so that each row and each column of the initial empty matrix corresponds to a cluster label and the cluster labels corresponding to any two rows or any two columns are different; Filling the initial empty matrix with corresponding element values ​​includes: Select any element position of the initial empty matrix and determine the selected element position The corresponding row cluster labels and column cluster labels; Determine the cluster corresponding to any cluster in the row cluster label according to the column cluster label Adjacent clusters, counting the total values ​​of adjacent clusters corresponding to all clusters in the row cluster label; Writing the total value of the row cluster label into the selected element position; Repeat the step of filling the initial empty matrix with corresponding element values ​​until all element positions have been written with corresponding element values, thereby obtaining the cluster label confusion matrix.

3. The method for coloring clusters based on spatial transcriptome according to claim 2, characterized in that: The step of determining, according to the column clustering labels, an adjacent cluster corresponding to any cluster in the row clustering labels comprises: Calculating the cluster distance between the remaining clusters in the plurality of clusters except the any cluster and the any cluster; Sorting the remaining clusters among the multiple clusters except the any cluster according to the multiple cluster distances, and selecting a preset number of clusters closest to the any cluster from the sorted clusters; The selected clusters are screened according to preset values, and the clusters belonging to the column cluster labels among the screened clusters are determined as the adjacent clusters.

4. The method for coloring clusters based on spatial transcriptome according to claim 2, characterized in that: The cluster label loop diagram for constructing the cluster label confusion matrix includes: Constructing a corresponding number of vertices according to the number of the plurality of cluster labels; Determine whether to connect two vertices corresponding to any row and any column according to the total number values ​​corresponding to any row and any column in the cluster label confusion matrix; If any two vertices are connected to each other, the total values ​​corresponding to the two connected vertices are used as the edge weight between the two connected vertices to obtain the cluster label loop graph.

5. The method for coloring clusters based on spatial transcriptome according to claim 1, characterized in that: The first loop and the second loop are mapped in order to obtain a plurality of initial mapping relationships, including: Keeping the first loop unchanged, all vertices in the second loop are arranged in a staggered manner to obtain multiple target loops, wherein the preset colors corresponding to the same position in any two target loops are different; establishing a correspondence between the cluster label corresponding to the vertex at each position in the first loop and the preset color corresponding to the vertex at the corresponding position in any target loop, to obtain any initial mapping relationship; or Keeping the second loop unchanged, all vertices in the first loop are arranged in a staggered manner to obtain multiple target loops, wherein the cluster labels corresponding to the same position in any two target loops are different; establishing a correspondence between the preset color corresponding to the vertex at each position in the second loop and the cluster label corresponding to the vertex at the corresponding position in any target loop, to obtain any initial mapping relationship.

6. The method for coloring clusters based on spatial transcriptome according to claim 1, characterized in that: The color visual difference matrix includes color difference values, and the aligning the cluster label confusion matrix with the color visual difference matrix according to each initial mapping relationship includes: Keeping the color visual difference matrix unchanged, transforming the position of the total value in the cluster label confusion matrix according to each initial mapping relationship, to obtain the cluster label confusion matrix and color visual difference matrix after each alignment; or The cluster label confusion matrix is ​​kept unchanged, and the positions of the color difference values ​​in the color visual difference matrix are transformed according to each initial mapping relationship to obtain the cluster label confusion matrix and the color visual difference matrix after each alignment.

7. The method for coloring clusters based on spatial transcriptome according to claim 1, characterized in that: The step of determining a target mapping relationship from the multiple initial mapping relationships according to the calculated multiple errors, and coloring the multiple clusters according to the target mapping relationship includes: Determine the initial mapping relationship corresponding to the minimum error as the target mapping relationship; The cluster clusters corresponding to the cluster labels in the target mapping relationship are colored according to the preset colors corresponding to the cluster labels.

8. The method for coloring clusters based on spatial transcriptome according to claim 1, characterized in that: The method further comprises: Embed the cluster label confusion matrix into a three-dimensional coordinate space to obtain the three-dimensional coordinates corresponding to each cluster label; Adjust multiple three-dimensional coordinates to a preset color space to obtain the target color corresponding to each cluster label; The clusters corresponding to each cluster label are colored according to the target color corresponding to the cluster label.

9. An electronic device, characterized in that: The electronic device comprises: a memory storing at least one instruction; and A processor executes the at least one instruction to implement the spatial transcriptome-based cluster coloring method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in an electronic device to implement the spatial transcriptome-based cluster coloring method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Fabric classification method and device based on color characteristics and storage medium

    CN121167528A