<jupyter_start><jupyter_text>Diffusion Pseudo Time (DPT) is a pseudo time metric based on the transition probability of a diffusion process (Haghverdi et al., 2016).*destiny*  supports `DPT` in addition to its primary function of creating `DiffusionMap`s from data.<jupyter_code>library(destiny)  # load destiny…
data(guo)         # …and sample data<jupyter_output><empty_output><jupyter_text>`DPT` is in practice independent of Diffusion Maps:<jupyter_code>old <- options(repr.plot.height = 2)
par(mar = rep(0, 4))
graph <- igraph::graph_from_literal(
    data -+ 'transition probabilities' -+ DiffusionMap,
    'transition probabilities' -+ DPT)
plot(
    graph, layout = igraph::layout_as_tree,
    vertex.size = 50,
    vertex.color = 'transparent',
    vertex.frame.color = 'transparent',
    vertex.label.color = 'black')
options(old)<jupyter_output><empty_output><jupyter_text>However in order not to overcomplicate things, in *destiny*, you have to create `DPT` objects from `DiffusionMap` objects.  (If you really only need the DPT, skip Diffusion Component creation by specifying `n_eigs = 0`)<jupyter_code>dm <- DiffusionMap(guo)
dpt <- DPT(dm)<jupyter_output><empty_output><jupyter_text>The resulting object of a call like this will have three automatically chosen tip cells. Plotting without parameters results in the DPT of the first root cell:<jupyter_code>plot(dpt, pch = 20)  # “pch” for prettier points<jupyter_output><empty_output><jupyter_text>Other possibilities include the DPT from the other tips or everything supported by `plot.DiffusionMap`:<jupyter_code>old <- options(repr.plot.height = 3)
par(mfrow = c(1,2), pch = 20, mar = c(2,2,0,1))
plot(dpt, col_by = 'DPT3')
plot(dpt, col_by = 'Gata4', pal = viridis::magma)
options(old)<jupyter_output><empty_output><jupyter_text>The `DPT` object also contains a clustering based on the tip cells and DPT, and you can specify where to draw paths from and to:<jupyter_code>plot(dpt, root = 2, paths_to = c(1,3), col_by = 'branch', pch = 20)<jupyter_output><empty_output><jupyter_text>You can further divide branches. First simply plot branch colors like we did above, then identify the number of the branch you intend to plot, and then specify it in a subsequent `plot` call. In order to see the new branches best, we specify a `dcs` argument that visually spreads out out all four branches.<jupyter_code>plot(dpt, col_by = 'branch', divide = 3, dcs = c(-1,3,-2), pch = 20)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10683933630109267, 'fraction_numerical': 0.013759611493322542, 'mean_word_length': 5.681081081081081, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '373598', 'license': 'MIT', 'n_tokens_mistral': 848, 'n_tokens_neox': 806, 'n_words': 266, 'path': 'cytofpipe/v1.3/Rlibs/destiny/doc/DPT.ipynb', 'repo_name': 'UCL-BLIC/myriad-buildscripts', 'size': '2471'}