Create Quaternary Simplex (Tetrahedron) Plot#
plot_quaternary shows cell similarity in a quaternary simplex (3-simplex, tetrahedron). The closer a dot, a cell, is to one vertex, the more similar the cell is to the cell cluster(s) the vertex represents. We recommend that users select the top marker genes for each terminal and only use them as the features for calculating the similarity.
For a quaternary simplex, we need one more a vertex of cell group(s). Here, we add the cells annotated as osteoblast-reticular transition cells
("ORT_1"``, shortened as “ORT”`) into the vertex dictionary. We also add the velocity information in this example.
Please see the ternary simplex example for more introduction about the other vertices and the velocity information.
Note
When creating such 3D plots with running Python code in a termnal, Matplotlib should be popping out a window with interactive 3D plot.
If an interactive visualization is desired when working with Jupyter Notebook, users will need to have package “ipympl” pre-installed
and add the line %matplotlib widget at the top of the code block
%matplotlib widget
import CytoSimplex as csx
import scanpy as sc
adata = sc.read(filename='test.h5ad',
backup_url="https://figshare.com/ndownloader/files/41034857")
vertices = {"OS": "Osteoblast_1",
"RE": "Reticular_1",
"CH": "Chondrocyte_1",
"ORT": "ORT_1"}
selected_genes = csx.select_top_features(adata, cluster_var="cluster", vertices=vertices, n_top=30)
csx.plot_quaternary(adata, cluster_var="cluster", vertices=vertices, features=selected_genes,
elev=5, azim=10, roll=0)