API
Import phlower as:
import phlower
tools: tl
difusion map
|
Parameters X: numpy array column observations,row features roots: list list of bool values if they are root nodes k: int number of nearest neighbors for diffusion map npc: int number of principal components using ndc: int number of diffusion components using s: int number of stepes for diffusion map random walk(default 1) lmda: float regularization parameter for ddhodge(default 1e-4) sigma: float sigma for gaussian kernel(default None) verbose: bool print out progress(default False) lstsq_method: str method for least square solver, "lstsq" or "lsqr", "lsmr" (default "lstsq") |
|
transition matrix is calculate by eigen decomposition outcome |
hodge laplacian decomposition to infer trajectory
|
graph hodge laplacian decomposition if sym: call eigsh to for symmetric matrix eigen decomposition |
|
Main function for constructing delaunay graph from a layout to get holes |
|
reimplement the function of construct_delaunay by using persistence analysis filtering. |
|
Function for only constructing delaunay graph from a layout without creating holes |
|
Fuction for only connecting start and end points with delaunay triangulation |
|
Count Topological data analysis, 0-dimensional and 1-dimensional features at a given radius |
|
Randomly climb the graph from the roots cells to the leaves cells using the knn_edges. |
|
|
|
adata: AnnData |
|
adata: AnnData |
|
create a pseudo tree based on the grouped trajectories using cumulative trajectory embedding to decide branching |
clustering
|
|
|
|
|
|
|
|
|
|
|
dimensionality reduction
|
|
|
|
|
|
|
|
|
|
|
|
|
adjusted from: https://github.com/dpeerlab/Harmony/blob/master/src/harmony/plot.py ForceAtlas2 input dm to calculate affinity matrix |
|
" Function to compute force directed layout from the affinity_matrix adjusted from: https://github.com/dpeerlab/Harmony/blob/master/src/harmony/plot.py :param affinity_matrix: Sparse matrix representing affinities between cells :param cell_names: pandas Series object with cell names :param verbose: Verbosity for force directed layout computation :param iterations: Number of iterations used by ForceAtlas :return: Pandas data frame representing the force directed layout |
|
tree analysis
|
if compare_position is start: |
|
if compare_position is start: |
|
find the leaf from current |
|
find the leaf from current |
find all predecessors of a node of same family, i.e. all nodes with the same prefix return list starts with the most grand father node. |
|
|
from tree: |
|
from tree: |
|
give a node, find it's first branching node for each sub-branch |
|
calculate the correlation between TF and genes for a comparison of markers This is only calculate the correlation without caring about the order of cells |
|
calculate the correlation between TF and genes using pseudo time matrix return list of tuples recording the correlations ordered by correlation descendingly. |
|
|--O-----------O-----a |
|
order, filtering and scaling by rows of a pseudo time matrix select maximum max_features genes by variance if label_markers is offered, then the genes in label_markers would be selected first scale by rows and cutoff the valuse by abs(2) |
|
|
|
Change the labels of the stream tree nodes. |
|
|
|
assign the node attributes of a graph to adata.obs |
|
the implementation of fate tree merge is using the tuple for each node, thus, the tuple lengths are only 1 for the leaf nodes. |
|
return all the attribute names of the tree nodes |
|
stream_tree: from_&to_ candidate: node_name, original, label fate_tree: from_&to_ candidate: node_name, original |
|
Given a node original name like '27-PODO' or ('27-PODO',) or ('27-PODO', "9-PT/LOH"), find all the original names in the path return a dict {node_name: original_name} |
|
for adata.obs.branch_id_alias, return a dict {branch_id_alias: original_name} like: {('S15', 'S14'): 'Stromal-4', ('S10', 'S7'): 'Tubular', ('S11', 'S8'): 'Stromal-1', ('S13', 'S12'): 'Stromal-2', ('S9', 'S7'): 'Podocytes', ('S5', 'S2'): 'Neuron-3', ('S16', 'S14'): 'Stromal-3', ('S6', 'S3'): 'root', ('S1', 'S0'): 'Neuron-1', ('S4', 'S2'): 'Neuron-2'} |
|
Encapsulate the step of regulator finding 1. |
|
Merged branches to main branches regulators detection. |
adata
|
Run MAGIC on AnnData object |
external: ext
|
ddhodge implementation for dimension reduction. |
|
Generate stream plot at single cell level (aka, subway map plots) |
|
Generate stream plot at density level |
plotting: pl
plots
|
networkx plot groups |
|
networkx plot continous values |
|
plot holes from eigen decomposition of L1 |
|
plot holes from eigen decomposition of L1 |
|
plot the trajectory on the graph |
|
Plot trjactories edges embeddings in umap or original t-map space |
|
plot triangle density values of the trianglulated graph |
|
plot density grid of clusters |
|
re-calcuate layout of a tree and plot |
|
Plot the fate tree embedding. |
|
Plot stream tree embedding. |
|
Plot the trajectory lines in harmonic ct-map in 2D space |
Plot the trajectory lines in harmonic ct-map in 3D space |
|
|
Plot the trajectory groups in harmonic t-map in 2D space |
Plot the trajectory groups in harmonic t-map in 3D space |
|
|
plot eigen values line to check the elbow of them |
|
Parameters :2: (WARNING/2) Title underline too short. Parameters --------- cluster_list: list cluster labels for each point embedding: np.ndarray embeddings, shape should be nx2 color_palette: list color palette, default is sns.color_palette(cc.glasbey, n_colors=50).as_hex() retain_clusters: list which clusters to plot node_size: int node size label: bool if add labels labelsize: int size of labels labelstyle: str options: color,text, box. same color as nodes if use color, black if use text, white color with box if use box ax: matplotlib axis matplotlib ax show_legend: bool if show_legend legend_loc: str legend location bbox_to_anchor: tuple tune of legend position markerscale: int legend markerscale facecolor: str plt background **args: :31: (WARNING/2) Inline strong start-string without end-string. parameters of ax.scatter |
|
Piechart show cell type proportions along Trajectory tree in 2d space |
|
plot backbone in cumsum sapce |
|
plot backbone in cumsum sapce 1. |
|
Selected regulator shown in dot plot ordered by the correlation along a trajectory branch |
|
Plot heatmap of regulators calculated by phlower |
|
Plot the simplex tree barcodes |
|
Plot the persistence birth death diagram |
velocity like plots
|
Plot fate velocity on a fate tree. |
|
Plot fate velocity on a fate tree. |