Skip to content

Commit

Permalink
More tweaks to module10 notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyale committed Nov 1, 2023
1 parent 4b5e5f3 commit c3318e2
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions modules/module10/notebooks/Module10-scRNA-Seq_with_scanpy.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
#%% [markdown]
# # Module 10 - Single Cell RNA-Seq analysis with Scanpy
#
# ## Introduction

#%% [markdown]
#
# ## Load required modules
#%%
import numpy as np
import pandas as pd
import plotnine as pn
import anndata as ad
import scanpy as sc

#%%
# Download dataset
#matrix_url = "https://cf.10xgenomics.com/samples/cell-exp/3.0.0/neuron_10k_v3/neuron_10k_v3_filtered_feature_bc_matrix.tar.gz"
h5_url = "https://cf.10xgenomics.com/samples/cell-exp/3.0.0/neuron_10k_v3/neuron_10k_v3_filtered_feature_bc_matrix.h5"
#%% [markdown]
# ## Download dataset

#%% [bash]
%%bash
mkdir -p data
wget -P data/ https://cf.10xgenomics.com/samples/cell-exp/3.0.0/neuron_10k_v3/neuron_10k_v3_filtered_feature_bc_matrix.h5

#%%
#%% [markdown]
# ## Set some scanpy defaults for feedback and logging
# Some default settings

#%%
sc.settings.verbosity = 3 # verbosity: errors (0), warnings (1), info (2), hints (3)
sc.logging.print_header()
sc.settings.set_figure_params(dpi=80, facecolor='white')
Expand Down Expand Up @@ -58,6 +67,20 @@
#%%
adata.obs

#%%
p = (
pn.ggplot(adata.obs,pn.aes(x='total_counts'))
+ pn.geom_histogram()
)
p.draw()

#%%
p = (
pn.ggplot(adata.obs,pn.aes(x='n_genes_by_counts'))
+ pn.geom_histogram()
)
p.draw()

# %%
sc.pl.violin(adata, ['n_genes_by_counts', 'total_counts', 'pct_counts_mt'],
jitter=0.4, multi_panel=True)
Expand Down Expand Up @@ -86,7 +109,7 @@
sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)

# %%
sc.pl.highly_variable_genes(adata)
sc.pl.highly_variable_genes(adata,)

# %%
adata.raw = adata
Expand Down Expand Up @@ -164,7 +187,13 @@
ranked_genes_by_cluster = pd.DataFrame(adata.uns['rank_genes_groups']['names'])

# %%
sc.pl.rank_genes_groups_violin(adata, groups=["0","1","2"], n_genes=3, )
sc.pl.rank_genes_groups_violin(adata, groups=["0"], n_genes=3, )

#%%
sc.pl.rank_genes_groups_heatmap(adata,n_genes=3)

#%%
sc.pl.rank_genes_groups_matrixplot(adata,n_genes=3,standard_scale='var')

# %%
sc.pl.violin(adata, ['Snap25','Slc17a6','Pax6','Gad1'], groupby='leiden')
Expand Down

0 comments on commit c3318e2

Please sign in to comment.