API

Import phlower as:

import phlower

tools: tl

difusion map

tl.diffusionGraph(X, roots[, k, npc, ndc, ...])

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")

tl.diffusionGraphDM(dm, roots[, k, ndc, s, ...])

transition matrix is calculate by eigen decomposition outcome

hodge laplacian decomposition to infer trajectory

tl.L1Norm_decomp(adata[, graph_name, ...])

graph hodge laplacian decomposition if sym: call eigsh to for symmetric matrix eigen decomposition

tl.construct_delaunay(adata[, graph_name, ...])

Main function for constructing delaunay graph from a layout to get holes

tl.construct_delaunay_persistence(adata[, ...])

reimplement the function of construct_delaunay by using persistence analysis filtering.

tl.construct_trucated_delaunay(adata[, ...])

Function for only constructing delaunay graph from a layout without creating holes

tl.construct_circle_delaunay(adata[, ...])

Fuction for only connecting start and end points with delaunay triangulation

tl.count_features_at_radius(adata, radius[, ...])

Count Topological data analysis, 0-dimensional and 1-dimensional features at a given radius

tl.random_climb_knn(adata[, graph_name, A, ...])

Randomly climb the graph from the roots cells to the leaves cells using the knn_edges.

tl.trajs_matrix(adata[, graph_name, ...])

tl.trajs_dm(adata[, evector_name, ...])

adata: AnnData

tl.trajs_clustering(adata[, embedding, ...])

adata: AnnData

tl.harmonic_stream_tree(adata[, graph_name, ...])

create a pseudo tree based on the grouped trajectories using cumulative trajectory embedding to decide branching

clustering

tl.leiden([embedding, distance_matrix, ...])

tl.louvain(embedding[, distance_matrix, ...])

tl.dbscan(embedding[, distance, eps, ...])

tl.gaussianmixture(embedding[, ...])

tl.spectralclustering(embedding[, ...])

tl.agglomerativeclustering(embedding[, ...])

dimensionality reduction

tl.run_pca(mtx[, n_components, random_state])

tl.run_umap(mtx[, random_state])

tl.run_mds(mtx[, n_components, random_state])

tl.run_kernelpca(mtx[, n_components, ...])

tl.run_lda(mtx, y[, n_components, random_state])

tl.run_isomap(mtx[, n_components, n_neighbors])

tl.run_fdl(mtx[, affinity_k, random_state, ...])

adjusted from: https://github.com/dpeerlab/Harmony/blob/master/src/harmony/plot.py ForceAtlas2 input dm to calculate affinity matrix

tl.run_palantir_fdl(mtx[, cell_names, ...])

" 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

tl.run_tsne(mtx[, n_components, random_state])

tree analysis

tl.tree_2branch_markers(adata, branch_1, ...)

if compare_position is start:

tl.tree_mbranch_markers(adata, branches_1, ...)

if compare_position is start:

tl.find_branch_start([tree, current_node])

find the leaf from current

tl.find_branch_end([tree, current_node])

find the leaf from current

tl.find_a_branch_all_predecessors([...])

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.

tl.helping_merged_tree(adata[, fate_tree, ...])

from tree:

tl.helping_submerged_tree(adata[, ...])

from tree:

tl.find_samelevel_daugthers([fate_tree, ...])

give a node, find it's first branching node for each sub-branch

tl.TF_gene_correlation(adata, tfadata[, name])

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

tl.branch_TF_gene_correlation(tf_df, gene_df)

calculate the correlation between TF and genes using pseudo time matrix return list of tuples recording the correlations ordered by correlation descendingly.

tl.tree_branches_smooth_window(adata[, ...])

|--O-----------O-----a

tl.branch_heatmap_matrix(tf_df[, ...])

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)

tl.print_stream_labels(adata[, tree, attr])

tl.change_stream_labels(adata[, tree, attr, ...])

Change the labels of the stream tree nodes.

tl.fate_tree_full_dataframe(adata[, tree, ...])

tl.assign_graph_node_attr_to_adata(adata[, ...])

assign the node attributes of a graph to adata.obs

tl.get_tree_leaves_attr(tree[, attr])

the implementation of fate tree merge is using the tuple for each node, thus, the tuple lengths are only 1 for the leaf nodes.

tl.get_all_attr_names(tree)

return all the attribute names of the tree nodes

tl.tree_label_dict(adata[, tree, from_, ...])

stream_tree: from_&to_ candidate: node_name, original, label fate_tree: from_&to_ candidate: node_name, original

tl.tree_original_dict(tree, leaf_name)

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}

tl.end_branch_dict(adata[, branch_id_alias, ...])

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'}

tl.branch_regulator_detect(adata, tfadata, ...)

Encapsulate the step of regulator finding 1.

tl.mbranch_regulator_detect(adata, tfadata)

Merged branches to main branches regulators detection.

adata

tl.magic_adata(adata[, random_state, ...])

Run MAGIC on AnnData object

external: ext

ext.ddhodge(adata[, basis, roots, k, npc, ...])

ddhodge implementation for dimension reduction.

ext.plot_stream_sc(adata[, root, color, ...])

Generate stream plot at single cell level (aka, subway map plots)

ext.plot_stream(adata[, root, color, ...])

Generate stream plot at density level

plotting: pl

plots

pl.nxdraw_group(adata[, graph_name, ...])

networkx plot groups

pl.nxdraw_score(adata[, graph_name, ...])

networkx plot continous values

pl.nxdraw_holes(adata[, graph_name, ...])

plot holes from eigen decomposition of L1

pl.nxdraw_harmonic(adata[, graph_name, ...])

plot holes from eigen decomposition of L1

pl.plot_traj(adata[, graph_name, ...])

plot the trajectory on the graph

pl.plot_trajs_embedding(adata[, embedding, ...])

Plot trjactories edges embeddings in umap or original t-map space

pl.plot_triangle_density(adata[, ...])

plot triangle density values of the trianglulated graph

pl.plot_density_grid(adata[, graph_name, ...])

plot density grid of clusters

pl.plot_fate_tree(adata[, fate_tree, ...])

re-calcuate layout of a tree and plot

pl.plot_fate_tree_embedding(adata[, ...])

Plot the fate tree embedding.

pl.plot_stream_tree_embedding(adata[, ...])

Plot stream tree embedding.

pl.plot_trajectory_harmonic_lines(adata[, ...])

Plot the trajectory lines in harmonic ct-map in 2D space

pl.plot_trajectory_harmonic_lines_3d(adata)

Plot the trajectory lines in harmonic ct-map in 3D space

pl.plot_trajectory_harmonic_points(adata[, ...])

Plot the trajectory groups in harmonic t-map in 2D space

pl.plot_trajectory_harmonic_points_3d(adata)

Plot the trajectory groups in harmonic t-map in 3D space

pl.plot_eigen_line(adata[, evalue_name, ...])

plot eigen values line to check the elbow of them

pl.plot_embedding([cluster_list, embedding, ...])

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

pl.plot_pie_fate_tree(adata[, graph_name, ...])

Piechart show cell type proportions along Trajectory tree in 2d space

pl.harmonic_backbone(adata[, fate_tree, ...])

plot backbone in cumsum sapce

pl.harmonic_backbone_3d(adata[, fate_tree, ...])

plot backbone in cumsum sapce 1.

pl.regulator_dot_correlation(tfadata, branch)

Selected regulator shown in dot plot ordered by the correlation along a trajectory branch

pl.regulator_heatmap(adata, tfadata, branch)

Plot heatmap of regulators calculated by phlower

pl.persisitence_barcodes(adata[, ...])

Plot the simplex tree barcodes

pl.persisitence_birth_death(adata[, ...])

Plot the persistence birth death diagram

velocity like plots

pl.fate_velocity_plot_cumsum(adata[, ...])

Plot fate velocity on a fate tree.

pl.fate_velocity_plot(adata[, fate_tree, ...])

Plot fate velocity on a fate tree.