cgevans / mixes

BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Tracking samples in gel lanes #33

Closed dave-doty closed 1 year ago

dave-doty commented 1 year ago

It's nice to specify in a protocol in advance which sample goes into which gel lane, so it's written down. Having a command of some sort for this that creates a Markdown table showing sample names in lanes, e.g., image

Write a function that takes as input a list of sample names, along with an optional num_lanes parameter (if missing then the length of the list of sample names is assumed to be the number of lanes).

dave-doty commented 1 year ago

Release notes

Here's an example of using the gel_table function:

from alhambra_mixes import gel_table

sample_names = ['', 'ladder', 's1', 's2', 's3', 's4', 's5', 's6']
table = gel_table(sample_names, num_lanes=10)
print(table)

which prints

| 1   | 2      | 3   | 4   | 5   | 6   | 7   | 8   | 9   | 10   |
|:----|:-------|:----|:----|:----|:----|:----|:----|:----|:-----|
|     | ladder | s1  | s2  | s3  | s4  | s5  | s6  |     |      |

and renders in Jupyter Lab as

image

As with any other tables that use the tabulate package (e.g., when using plate maps), you can also use html_with_borders_tablefmt to add vertical borders to the table when rendered in a Jupyter notebook:

from alhambra_mixes import gel_table, html_with_borders_tablefmt
from IPython.display import display, Markdown

sample_names = ['', 'ladder', 's1', 's2', 's3', 's4', 's5', 's6']
table = gel_table(sample_names, num_lanes=10, tablefmt=html_with_borders_tablefmt)
display(Markdown(table))

which renders as image