Skip to content
Snippets Groups Projects
Commit ccd96b4c authored by Kedi Cao's avatar Kedi Cao
Browse files

clear notebook output

parent 0b5ebc9d
No related merge requests found
%% Cell type:code id:e346a6bb-0831-404d-9a4c-b7e8fa48c426 tags:
``` python
pip show ipython
```
%% Output
Name: ipython
Version: 9.0.0
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev@python.org
License: BSD-3-Clause
Location: /home/kedic/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages
Requires: decorator, ipython-pygments-lexers, jedi, matplotlib-inline, pexpect, prompt_toolkit, pygments, stack_data, traitlets
Required-by: ipykernel, ipywidgets, jupyter-console
Note: you may need to restart the kernel to use updated packages.
%% Cell type:code id:8f2c7f1e tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Output
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/extensions.py:62, in ExtensionManager.load_extension(self, module_str)
61 try:
---> 62 return self._load_extension(module_str)
63 except ModuleNotFoundError:
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/extensions.py:77, in ExtensionManager._load_extension(self, module_str)
76 if module_str not in sys.modules:
---> 77 mod = import_module(module_str)
78 mod = sys.modules[module_str]
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/importlib/__init__.py:90, in import_module(name, package)
89 level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1324, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'autoreload'
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 get_ipython().run_line_magic('load_ext', 'autoreload')
2 get_ipython().run_line_magic('autoreload', '2')
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2478, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
2476 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2477 with self.builtin_trap:
-> 2478 result = fn(*args, **kwargs)
2480 # The code below prevents the output from being displayed
2481 # when using magics with decorator @output_can_be_silenced
2482 # when the last Python token in the expression is a ';'.
2483 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/magics/extension.py:33, in ExtensionMagics.load_ext(self, module_str)
31 if not module_str:
32 raise UsageError('Missing module name.')
---> 33 res = self.shell.extension_manager.load_extension(module_str)
35 if res == 'already loaded':
36 print("The %s extension is already loaded. To reload it, use:" % module_str)
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/extensions.py:66, in ExtensionManager.load_extension(self, module_str)
64 if module_str in BUILTINS_EXTS:
65 BUILTINS_EXTS[module_str] = True
---> 66 return self._load_extension("IPython.extensions." + module_str)
67 raise
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/core/extensions.py:77, in ExtensionManager._load_extension(self, module_str)
75 with self.shell.builtin_trap:
76 if module_str not in sys.modules:
---> 77 mod = import_module(module_str)
78 mod = sys.modules[module_str]
79 if self._call_load_ipython_extension(mod):
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/importlib/__init__.py:90, in import_module(name, package)
88 break
89 level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:999, in exec_module(self, module)
File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)
File ~/workflow_dev/popinSnake/.snakemake/conda/69c6e6c50cd0e118bb8c803e51bd5c48_/lib/python3.12/site-packages/IPython/extensions/autoreload.py:110
108 from IPython.core import magic_arguments
109 from IPython.core.magic import Magics, magics_class, line_magic
--> 110 from IPython.extensions.deduperreload.deduperreload import DeduperReloader
112 __skip_doctest__ = True
114 # -----------------------------------------------------------------------------
115 # Copyright (C) 2000 Thomas Heller
116 # Copyright (C) 2008 Pauli Virtanen <pav@iki.fi>
(...) 127 # Imports
128 # -----------------------------------------------------------------------------
ModuleNotFoundError: No module named 'IPython.extensions.deduperreload'
%% Cell type:code id:5ebc1c0a-0d55-430e-988f-ea6521abcfdb tags:
``` python
```
%% Cell type:code id:e9cb92ab-fc91-4311-a745-3a03e0fbde3c tags:
``` python
import os
import sys
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
```
%% Cell type:code id:f9489982 tags:
``` python
# If executing with snakemake, use the path below
sys.path.append(snakemake.config["WORKFLOW_PATH"]+'/snakemodules/notebooks/src/')
# If executing directly with jupyter notebook from the commandline, use the path below
# sys.path.append(os.getcwd()+'/src/')
from stat_func import calculator
from stat_func import visualization
%matplotlib inline
```
%% Cell type:code id:6d70671b tags:
``` python
fastq1 = snakemake.input.paired1
#fastq2 = snakemake.input.paired2
single = snakemake.input.single
```
%% Cell type:code id:48567039 tags:
``` python
read_paired_fq,sample_names = visualization.fastq_read_num(fastq1)
read_single_fq,sample_names = visualization.fastq_read_num(single)
```
%% Cell type:code id:93a00353-0770-4e90-8cd5-a916b9d08625 tags:
``` python
```
%% Cell type:code id:2dc4651c tags:
``` python
df = pd.DataFrame()
df['samples']=sample_names
df['read_number_paired']=calculator.double(read_paired_fq)
df['read_number_single']=read_single_fq
df['total'] = df['read_number_paired']+df['read_number_single']
read_data = df.sort_values(by=['samples'])
```
%% Cell type:code id:d9b63e80 tags:
``` python
```
%% Cell type:code id:80f28248 tags:
``` python
sns.set_theme(style="whitegrid")
# Initialize the matplotlib figure
f, ax = plt.subplots(figsize=(3, 6))
# Plot the total reads
sns.set_color_codes("pastel")
sns.barplot(x="samples", y="total", data=read_data,
label="paired reads", color="b")
# Plot the total single reads
sns.set_color_codes("muted")
sns.barplot(x="samples", y="read_number_single", data=read_data,
label="single reads", color="b")
sns.set(font_scale = 1)
# Add a legend and informative axis label
ax.legend(bbox_to_anchor=(1.02, 1),loc="upper left", borderaxespad=0)
plt.xticks(rotation=90)
ax.set(ylabel="read numbers",
xlabel="genomes")
sns.despine(left=True, bottom=True)
plt.savefig(snakemake.output[0], dpi=300, format="pdf", bbox_inches = 'tight')
read_data.to_csv(snakemake.output[1], sep='\t', index=False)
# plt.show()
```
%% Cell type:code id:d18c4eaa tags:
``` python
```
%% Cell type:code id:4913e41e tags:
``` python
```
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment