Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom content example notebook #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
286 changes: 286 additions & 0 deletions custom_content.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "26504a40-3987-4101-b2e8-be06e717269f",
"metadata": {},
"outputs": [],
"source": [
"import multiqc"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "38da2be3-994a-4fe0-b256-c36bcc8b2d4e",
"metadata": {},
"outputs": [],
"source": [
"s = \"\"\"File mlst_scheme 7-gene_ST locus1 locus2 locus3 locus4 locus5 locus6 locus7\n",
"SRR28368091.shovill.skesa.fasta ecoli 21 adk(16) fumC(4) gyrB(12) icd(16) mdh(9) purA(7) recA(7)\n",
"SRR28368090.shovill.skesa.fasta ecoli 993 adk(10) fumC(7) gyrB(154) icd(8) mdh(12) purA(8) recA(2)\n",
"\"\"\"\n",
"data = \"\"\n",
"for line in s.split(\"\\n\"):\n",
" values = line.split()\n",
" data += \"\\t\".join(values) + \"\\n\"\n",
"\n",
"with open(\"data_mqc.tsv\", \"w\") as f:\n",
" print(\"\"\"\\\n",
"#pconfig:\n",
"# only_defined_headers: false\n",
"#headers:\n",
"# 7-gene_ST:\n",
"# scale: false\n",
"# format: \"{:.0f}\"\\\n",
"\"\"\", file=f)\n",
" print(data, file=f)"
]
},
{
"cell_type": "code",
"execution_count": 63,
"id": "1483018c-18bf-42c5-a1a9-bb7c64bb0b24",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#pconfig:\n",
"# only_defined_headers: false\n",
"#headers:\n",
"# 7-gene_ST:\n",
"# scale: false\n",
"# format: \"{:.0f}\"\n",
"File\tmlst_scheme\t7-gene_ST\tlocus1\tlocus2\tlocus3\tlocus4\tlocus5\tlocus6\tlocus7\n",
"SRR28368091.shovill.skesa.fasta\tecoli\t21\tadk(16)\tfumC(4)\tgyrB(12)\ticd(16)\tmdh(9)\tpurA(7)\trecA(7)\n",
"SRR28368090.shovill.skesa.fasta\tecoli\t993\tadk(10)\tfumC(7)\tgyrB(154)\ticd(8)\tmdh(12)\tpurA(8)\trecA(2)\n",
"\n",
"\n",
"\n"
]
}
],
"source": [
"with open(\"data_mqc.tsv\") as f:\n",
" print(f.read())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b40b8ba8-a30b-4735-8a88-0bbeec3096ed",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[38;5;208m///\u001b[0m \u001b[1mhttps://multiqc.info\u001b[0m 🔍 \u001b[2mv1.22.dev0 (8e2a53c)\u001b[0m\n",
"\u001b[34m file_search\u001b[0m | Search path: /Users/vlad/git/example-notebook/data_mqc.tsv\n",
"\u001b[34m custom_content\u001b[0m | data: Found 1 samples (table)\n"
]
}
],
"source": [
"multiqc.reset()\n",
"multiqc.parse_logs(\"data_mqc.tsv\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "384e7b4a-978d-4b11-b5d6-dfe4b55de1f4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Data': {'SRR28368091.shovill.skesa.fasta': {'mlst_scheme': 'ecoli',\n",
" '7-gene_ST': 21.0,\n",
" 'locus1': 'adk(16)',\n",
" 'locus2': 'fumC(4)',\n",
" 'locus3': 'gyrB(12)',\n",
" 'locus4': 'icd(16)',\n",
" 'locus5': 'mdh(9)',\n",
" 'locus6': 'purA(7)',\n",
" 'locus7': 'recA(7)'},\n",
" 'SRR28368090.shovill.skesa.fasta': {'mlst_scheme': 'ecoli',\n",
" '7-gene_ST': 993.0,\n",
" 'locus1': 'adk(10)',\n",
" 'locus2': 'fumC(7)',\n",
" 'locus3': 'gyrB(154)',\n",
" 'locus4': 'icd(8)',\n",
" 'locus5': 'mdh(12)',\n",
" 'locus6': 'purA(8)',\n",
" 'locus7': 'recA(2)'}}}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multiqc.get_module_data()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "c769aae2-0a4b-4932-bbe8-f0dee1ffd2bd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"List of available plots sections, by module. Use multiqc.show_plot(\"<module\">, \"<section>\") to show plot. \n"
]
},
{
"data": {
"text/plain": [
"{'Data': ['data-1']}"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multiqc.list_plots()"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "c9e06347-e34d-4d86-ae53-8b9dcff6ac81",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[38;5;208m///\u001b[0m \u001b[1mhttps://multiqc.info\u001b[0m 🔍 \u001b[2mv1.22.dev0 (8e2a53c)\u001b[0m\n",
"\u001b[34m write_results\u001b[0m | Data : multiqc_data (overwritten)\n",
"\u001b[34m write_results\u001b[0m | Report : multiqc_report.html (overwritten)\n"
]
}
],
"source": [
"multiqc.write_report(force=True)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "12506463-dab2-4587-928c-cbfe73f06249",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>mqc_7_gene_ST</th>\n",
" <th>mlst_scheme</th>\n",
" <th>locus1</th>\n",
" <th>locus2</th>\n",
" <th>locus3</th>\n",
" <th>locus4</th>\n",
" <th>locus5</th>\n",
" <th>locus6</th>\n",
" <th>locus7</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>SRR28368091.shovill.skesa.fasta</th>\n",
" <td>21.0</td>\n",
" <td>ecoli</td>\n",
" <td>adk(16)</td>\n",
" <td>fumC(4)</td>\n",
" <td>gyrB(12)</td>\n",
" <td>icd(16)</td>\n",
" <td>mdh(9)</td>\n",
" <td>purA(7)</td>\n",
" <td>recA(7)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>SRR28368090.shovill.skesa.fasta</th>\n",
" <td>993.0</td>\n",
" <td>ecoli</td>\n",
" <td>adk(10)</td>\n",
" <td>fumC(7)</td>\n",
" <td>gyrB(154)</td>\n",
" <td>icd(8)</td>\n",
" <td>mdh(12)</td>\n",
" <td>purA(8)</td>\n",
" <td>recA(2)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" mqc_7_gene_ST mlst_scheme locus1 locus2 \\\n",
"SRR28368091.shovill.skesa.fasta 21.0 ecoli adk(16) fumC(4) \n",
"SRR28368090.shovill.skesa.fasta 993.0 ecoli adk(10) fumC(7) \n",
"\n",
" locus3 locus4 locus5 locus6 locus7 \n",
"SRR28368091.shovill.skesa.fasta gyrB(12) icd(16) mdh(9) purA(7) recA(7) \n",
"SRR28368090.shovill.skesa.fasta gyrB(154) icd(8) mdh(12) purA(8) recA(2) "
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"multiqc.show_plot('Data', 'data-1')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
230 changes: 101 additions & 129 deletions multiqc_example.ipynb

Large diffs are not rendered by default.