kb_python.report

Module Contents

Functions

dict_to_table(d, column_ratio=[3, 7], column_align=['right', 'left'])

Convert a dictionary to a Plot.ly table of key-value pairs.

knee_plot(n_counts)

Generate knee plot card.

genes_detected_plot(n_counts, n_genes)

Generate genes detected plot card.

elbow_plot(pca_variance_ratio)

Generate elbow plot card.

pca_plot(pc)

Generate PCA plot card.

write_report(stats_path, info_path, inspect_path, out_path, matrix_path=None, barcodes_path=None, genes_path=None, t2g_path=None)

Render the Jupyter notebook report with Jinja2.

execute_report(execute_path, nb_path, html_path)

Execute the report and write the results as a Jupyter notebook and HTML.

render_report(stats_path, info_path, inspect_path, nb_path, html_path, matrix_path=None, barcodes_path=None, genes_path=None, t2g_path=None, temp_dir='tmp')

Render and execute the report.

kb_python.report.logger
kb_python.report.REPORT_DIR
kb_python.report.BASIC_TEMPLATE_PATH
kb_python.report.MATRIX_TEMPLATE_PATH
kb_python.report.MARGIN
kb_python.report.dict_to_table(d, column_ratio=[3, 7], column_align=['right', 'left'])

Convert a dictionary to a Plot.ly table of key-value pairs.

Parameters
  • d (dict) – dictionary to convert

  • column_ratio (list, optional) – relative column widths, represented as a ratio, defaults to [3, 7]

  • column_align (list, optional) – column text alignments, defaults to [‘right’, ‘left’]

Returns

figure

Return type

plotly.graph_objs.Figure

kb_python.report.knee_plot(n_counts)

Generate knee plot card.

Parameters

n_counts (list) – list of UMI counts

Returns

figure

Return type

plotly.graph_objs.Figure

kb_python.report.genes_detected_plot(n_counts, n_genes)

Generate genes detected plot card.

Parameters
  • n_counts (list) – list of UMI counts

  • n_genes (list) – list of gene counts

Returns

figure

Return type

plotly.graph_objs.Figure

kb_python.report.elbow_plot(pca_variance_ratio)

Generate elbow plot card.

Parameters

pca_variance_ratio (list) – list PCA variance ratios

Returns

figure

Return type

plotly.graph_objs.Figure

kb_python.report.pca_plot(pc)

Generate PCA plot card.

Parameters

pc (list) – embeddings

Returns

figure

Return type

plotly.graph_objs.Figure

kb_python.report.write_report(stats_path, info_path, inspect_path, out_path, matrix_path=None, barcodes_path=None, genes_path=None, t2g_path=None)

Render the Jupyter notebook report with Jinja2.

Parameters
  • stats_path (str) – path to kb stats JSON

  • info_path (str) – path to run_info.json

  • inspect_path (str) – path to inspect.json

  • out_path (str) – path to Jupyter notebook to generate

  • matrix_path (str) – path to matrix

  • barcodes_path (str) – list of paths to barcodes.txt

  • genes_path (str, optional) – path to genes.txt, defaults to None

  • t2g_path (str) – path to transcript-to-gene mapping

Returns

path to notebook generated

Return type

str

kb_python.report.execute_report(execute_path, nb_path, html_path)

Execute the report and write the results as a Jupyter notebook and HTML.

Parameters
  • execute_path (str) – path to Jupyter notebook to execute

  • nb_path (str) – path to Jupyter notebook to generate

  • html_path (str) – path to HTML to generate

Returns

tuple containing executed notebook and HTML

Return type

tuple

kb_python.report.render_report(stats_path, info_path, inspect_path, nb_path, html_path, matrix_path=None, barcodes_path=None, genes_path=None, t2g_path=None, temp_dir='tmp')

Render and execute the report.

Parameters
  • stats_path (str) – path to kb stats JSON

  • info_path (str) – path to run_info.json

  • inspect_path (str) – path to inspect.json

  • nb_path (str) – path to Jupyter notebook to generate

  • html_path (str) – path to HTML to generate

  • matrix_path (str) – path to matrix

  • barcodes_path (str) – list of paths to barcodes.txt

  • genes_path (str, optional) – path to genes.txt, defaults to None

  • t2g_path (str) – path to transcript-to-gene mapping

  • temp_dir (str, optional) – path to temporary directory, defaults to tmp

Returns

dictionary containing notebook and HTML paths

Return type

dict