Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jgould committed Feb 20, 2019
1 parent b89cb19 commit 076beff
Show file tree
Hide file tree
Showing 37 changed files with 118 additions and 1,005 deletions.
2 changes: 1 addition & 1 deletion docs/assets/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ a.nostyle, a.nostyle:hover, a.nostyle:active, a.nostyle:focus {
}

img {
display: block;

margin-left: auto;
margin-right: auto;
}
Expand Down
142 changes: 60 additions & 82 deletions docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,73 @@
permalink: examples/

examples:
- title: Generating data
simu_image: generated_pop.png
real_image: unavailable.png
text: All the data included in the downloadable archive from the documentation can be reproduced from scratch. This example shows how to produce a dataset from gaussian noise around several paths.
link: generating_data
simu_only: true
- title: Plotting cell sets
simu_image: notebook_cell_sets.png
real_image: unavailable.png
text: It is very easy to generate and parse cell sets in python and color each cell set for plotting. This example shows how to parse cell sets files and quickly plot 2 genes from a dataset, coloring every cell set.
link: plotting_cell_sets
- title: Computing transport maps
simu_image: tmaps_46_47_1.png
real_image: tmaps_46_47_1.png
text: This example shows how to compute transport maps from the command line, choosing the OT parameters that best suit your needs before using those maps to compute ancestors and trajectories.
link: computing_transport_maps
- title: Plotting ancestors
simu_image: notebook_ancestors.png
real_image: unavailable.png
text: The time-course data about the cells is then used to infer the evolution of cells over time in gene-expression space. This example shows how to plot infered ancestors and descendants of a given cell set, to show its trajectory.
link: plotting_ancestors
- title: Plotting shared ancestry
simu_image: shared_ancestry.png
real_image: unavailable.png
text: Knowing the trajectory of each cell set, one can then identify the shared ancestors between two cell sets. This example shows how to plot shared ancestry between several cell sets.
link: shared_ancestry
- title: Plotting trajectory trends
simu_image: trajectory_trends_1.png
real_image: unavailable.png
text: While two-dimensional embeddings are fine for vizualizing a whole population, the evolution of each gene can also be more closely monitored over the evolution of a cell set. This example shows how to plot the expression of each gene over time in a cell set.
link: trajectory_trends
- title: Plotting ancestor census
simu_image: ancestor_census.png
real_image: unavailable.png
text: Several files generated by wot can be viewed and plotted as datasets. This example shows how to parse and plot a census file to generate an ancestor census plot. This method can be easily extended to all kinds of dataset files.
link: ancestor_census
- title: Plotting validation summary
simu_image: validation_summary.png
real_image: unavailable.png
text: After using the optimal transport validation tool, a validation summary file is generated. This example show how to parse it and plot the average and standard deviation of the distances between each type of populations (real, random, interpolated) over time.
link: plotting_validation_summary

datasets_simulated:
- true
- false
- title: Generating data
image: generated_pop.png
text: This example shows how to produce a dataset from gaussian noise around several paths.
link: generating_data

- title: Plotting cell sets
image: notebook_cell_sets.png
text: It is very easy to generate and parse cell sets in python and color each cell set for plotting. This example shows how to parse cell sets files and quickly plot 2 genes from a dataset, coloring every cell set.
link: plotting_cell_sets

- title: Computing transport maps
image: tmaps_46_47_1.png
text: This example shows how to compute transport maps from the command line, choosing the OT parameters that best suit your needs before using those maps to compute ancestors and trajectories.
link: computing_transport_maps

- title: Plotting ancestors
image: notebook_ancestors.png
text: The time-course data about the cells is then used to infer the evolution of cells over time in gene-expression space. This example shows how to plot infered ancestors and descendants of a given cell set, to show its trajectory.
link: plotting_ancestors

- title: Plotting shared ancestry
image: shared_ancestry.png
text: Knowing the trajectory of each cell set, one can then identify the shared ancestors between two cell sets. This example shows how to plot shared ancestry between several cell sets.
link: shared_ancestry

- title: Plotting trajectory trends
image: trajectory_trends.png
text: While two-dimensional embeddings are fine for vizualizing a whole population, the evolution of each gene can also be more closely monitored over the evolution of a cell set. This example shows how to plot the expression of each gene over time in a cell set.
link: trajectory_trends

- title: Plotting ancestor census
image: ancestor_census.png
text: Several files generated by wot can be viewed and plotted as datasets. This example shows how to parse and plot a census file to generate an ancestor census plot. This method can be easily extended to all kinds of dataset files.
link: ancestor_census

- title: Plotting validation summary
image: validation_summary.png
text: After using the optimal transport validation tool, a validation summary file is generated. This example show how to parse it and plot the average and standard deviation of the distances between each type of populations (real, random, interpolated) over time.
link: plotting_validation_summary
---

<ul class="nav nav-pills my-5 mx-5 float-right" role="tablist">
<li class="nav-item"><a href="#simulated" class="mx-2 py-3 nav-link active" data-toggle="pill">Simulated data</a></li>
<li class="nav-item"><a href="#real" class="mx-2 py-3 nav-link" data-toggle="pill">Real data</a></li>
</ul>

<div class="tab-content">
{% for simulated in page.datasets_simulated %}
<div class="container my-5 tab-pane {% if forloop.first %}show active{% endif %}"
{% if simulated %} id="simulated" {% else %} id="real" {% endif %}>
<h3 class="text-center mt-5">Running example on how to use <b>wot</b> on {% if simulated %} simulated data {% else %} real data <br/>(currently unavailable){% endif %}</h3>
<div class="container my-5 tab-pane {% if forloop.first %}show active{% endif %}">
<h3 class="text-center mt-5">Examples on how to use <b>wot</b> on simulated data</h3>

<h5 class="text-center mb-5">These examples are also available as a <a class="nounderline" href="{{site.baseurl}}/notebook">python notebook</a></h5>
<hr class="featurette-divider">

<hr class="featurette-divider">
{% for example in page.examples %}

{% for example in page.examples %}
{% if example['simu_only'] != true or simulated %}
<a href="{{ example['link'] }}" class="nostyle">
<a href="{{ example['link'] }}" class="nostyle">
<div class="row featurette my-2">
<div class="col-md-5 {% cycle('order-1', 'order-3') %}">
<img class="featurette-image img-responsive mx-auto d-block"
{% if simulated %}
src="{{site.baseurl}}/images/{{ example['simu_image'] }}"
{% else %}
src="{{site.baseurl}}/images/{{ example['real_image'] }}"
{% endif %}
width=300 height=300 alt="Generic placeholder image">
</div>

<div class="col-md-7 order-2 my-5">
<h2 class="featurette-heading my-3">
{{ example['title'] }}
</h2>
<p class="lead my-3">{{ example['text'] }}</p>
</div>
</div>
</a>
<div class="col-md-5 {% cycle('order-1', 'order-3') %}">
<img class="featurette-image img-responsive mx-auto d-block"
src="{{site.baseurl}}/images/{{ example['image'] }}"
width=300 height=300>
</div>

<hr class="featurette-divider">
{% endif %}
{% endfor %}
<div class="col-md-7 order-2 my-5">
<h2 class="featurette-heading my-3">
{{ example['title'] }}
</h2>
<p class="lead my-3">{{ example['text'] }}</p>
</div>
</div>
</a>

<hr class="featurette-divider">
{% endfor %}
</div>
{% endfor %}
</div>

28 changes: 2 additions & 26 deletions docs/examples/ancestor_census.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can compute an ancestor census for your cell sets with:
```sh
wot census --tmap tmaps \
--cell_set cell_sets.gmt \
--out census --time 15
--out census --time 7
```

See the [CLI documentation]({{site.baseurl}}/cli_documentation#ancestor-census)
Expand All @@ -28,31 +28,7 @@ Note : You need to have a transport maps computed for this to work. Please refer
This will create several census files, that you can then plot as follows :

```python
import wot.graphics
from matplotlib import pyplot

picture_title = "Ancestor census of cells from Tip 1 at day 10"

# Change this to the name of census file you want to plot
census_file = 'census_tip1.txt'

# Choose a color and a name to display for each cell set in the census
legend = [
[ "#e00000", "Tip 1" ],
[ "#00e000", "Tip 2" ],
[ "#0000e0", "Tip 3" ]
]

ds = wot.io.read_dataset(census_file)

wot.graphics.legend_figure(pyplot, legend)
for i in range(ds.X.shape[1]):
pyplot.plot(ds.X[:,i], color=legend[i][0])

pyplot.title(picture_title)
pyplot.xlabel("time")
pyplot.ylabel("Proportion of ancestors per cell set")
pyplot.show()
{% include_relative code/07_plotting_ancestor_census.py %}
```

### Result ###
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import numpy as np
import wot.simulate
from numpy.random import randint
from numpy.random import random

import wot.simulate

# ------ Configuration variables -------
matrix_file = 'matrix.txt'
days_file = 'days.txt'
covariate_file = 'covariate.txt'
gene_sets_file = 'gene_sets.gmt'

number_of_timepoints = 51
covariates_count = 5
average_cell_count_per_timepoint = 3000
number_of_timepoints = 8
covariates_count = 2
average_cell_count_per_timepoint = 1000
np.random.seed(1234)

gene_sets = {
'Stem cells': ['Stem_gene'],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
pyplot.figure(figsize=(5, 5))
pyplot.axis('off')
wot.graphics.plot_2d_dataset(pyplot, ds,
x=gene_x_plot, y=gene_y_plot)
x=gene_x_plot, y=gene_y_plot, colors=ds.obs['color'].values)
pyplot.autoscale(enable=True, tight=True)
pyplot.tight_layout(pad=0)
pyplot.savefig(destination_file)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
from matplotlib import pyplot

import wot.graphics
Expand Down Expand Up @@ -33,17 +34,17 @@
wot.io.write_gene_sets(cell_sets, cell_sets_file, "gmt")

# Plot the cell sets

wot.set_cell_metadata(ds, 'color', bg_color)
colors = np.array([bg_color] * len(ds.obs))

for color, cset_name in cell_sets_to_color:
wot.set_cell_metadata(ds, 'color', color,
indices=cell_sets[cset_name])
cell_ids = cell_sets[cset_name]
indices = ds.obs.index.get_indexer_for(cell_ids)
colors[indices] = color

pyplot.figure(figsize=(5, 5))
pyplot.axis('off')
wot.graphics.plot_2d_dataset(pyplot, ds,
x=gene_x_plot, y=gene_y_plot)
x=gene_x_plot, y=gene_y_plot, s=1, colors=colors)
wot.graphics.legend_figure(pyplot, cell_sets_to_color)
pyplot.autoscale(enable=True, tight=True)
pyplot.tight_layout(pad=0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
gene_y_plot = 1
cell_sets_file = 'cell_sets.gmt'
target_cell_set = "Red blood cells"
target_timepoint = 50
target_timepoint = 7
destination_file = "ancestors.png"
# --------------------------------------

Expand All @@ -33,6 +33,7 @@ def color_cells(population):
pyplot.figure(figsize=(5, 5))
pyplot.axis('off')
wot.set_cell_metadata(ds, 'color', bg_color)

wot.graphics.plot_2d_dataset(pyplot, ds, x=gene_x_plot, y=gene_y_plot)

cell_sets = wot.io.read_sets(cell_sets_file, as_dict=True)
Expand All @@ -46,7 +47,7 @@ def color_cells(population):
color_cells(population)

wot.graphics.plot_2d_dataset(pyplot, ds,
x=gene_x_plot, y=gene_y_plot)
x=gene_x_plot, y=gene_y_plot, s=1, colors=ds.obs['color'].values)
wot.graphics.legend_figure(pyplot,
[["#316DA2", "Ancestors of {}".format(target_cell_set)]])
pyplot.autoscale(enable=True, tight=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
cell_set_1 = "Red blood cells"
cell_set_2 = "Granulocytes"
cell_sets_file = 'cell_sets.gmt'
target_timepoint = 50
target_timepoint = 7
destination_file = "shared_ancestry.png"
# --------------------------------------

Expand All @@ -38,7 +38,7 @@
for i in range(len(t))]
ds.obs.loc[:, 'color'] = colors

wot.graphics.plot_2d_dataset(pyplot, ds)
wot.graphics.plot_2d_dataset(pyplot, ds, s=1, colors=ds.obs['color'].values)
wot.graphics.legend_figure(pyplot,
[["#A00000", "Ancestors of " + cell_set_1],
["#0000A0", "Ancestors of " + cell_set_2]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
days_file = 'days.txt'
cell_sets_file = 'cell_sets.gmt'
target_cell_set = 'Red blood cells'
target_timepoint = 50
target_timepoint = 7
skip_first_n_genes = 2
destination_file = "trajectory_trends.png"
# --------------------------------------
Expand All @@ -22,7 +22,8 @@

# timepoints, means, variances = tmap_model.compute_trajectory_trends(ds, population)
trajectory_ds = tmap_model.compute_trajectories({target_cell_set: all_populations[target_cell_set]})
results = wot.ot.compute_trajectory_trends_from_trajectory(trajectory_ds, ds)

results = wot.tmap.compute_trajectory_trends_from_trajectory(trajectory_ds, ds)
means, variances = results[0]
timepoints = means.obs.index.values
pyplot.figure(figsize=(5, 5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
matrix_file = 'matrix.txt'
cell_sets_file = 'cell_sets.gmt'
target_cell_set = 'Red blood cells'
target_timepoint = 50
target_timepoint = 7
destination_file = "ancestor_census.png"
# --------------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import wot.commands
import wot.graphics

# ------ Configuration variables -------
matrix_file = 'matrix.txt'
days_file = 'days.txt'
Expand All @@ -11,11 +12,9 @@
# --------------------------------------

ot_model = wot.ot.initialize_ot_model(matrix_file, days_file,
covariate=covariate_file, growth_iters=1, tmap_prefix='val')
covariate=covariate_file, growth_iters=1, tmap_out='val')
vs = wot.commands.compute_validation_summary(ot_model)
vs['time'] = (vs['interval_start'] + vs['interval_end']) / 2
vs['type'] = vs['pair0'].astype(str).str[0]
res = vs.groupby(['time', 'type'])['distance'] \
res = vs.groupby(['interval_mid', 'name'])['distance'] \
.agg([np.mean, np.std])

legend = {
Expand Down
Loading

0 comments on commit 076beff

Please sign in to comment.