<jupyter_start><jupyter_text>Read in rownames and colnames of both spliced mtarix and unspliced matrix<jupyter_code>e2n = dict([ l.rstrip().split() for l in open(e2n_path).readlines()])
spliced_var_names = [ l.rstrip() for l in open(os.path.sep.join([kbdir, "spliced.genes.txt"])).readlines()]
spliced_var_names = [e2n[e.split(".")[0]] for e in spliced_var_names]
unspliced_var_names = [ l.rstrip() for l in open(os.path.sep.join([kbdir, "unspliced.genes.txt"])).readlines()]
unspliced_var_names = [e2n[e.split(".")[0]] for e in unspliced_var_names]
spliced_obs_names = [ l.rstrip() for l in open(os.path.sep.join([kbdir, "spliced.barcodes.txt"])).readlines() ]
unspliced_obs_names = [ l.rstrip() for l in open(os.path.sep.join([kbdir, "unspliced.barcodes.txt"])).readlines() ]<jupyter_output><empty_output><jupyter_text>Read in count matrices and intersect with example dataset<jupyter_code>example_adata = scv.datasets.pancreas()
spliced = sc.read_mtx(os.path.sep.join([kbdir, "spliced.mtx"]))
spliced.var_names = spliced_var_names
spliced.obs_names = spliced_obs_names
spliced.var_names_make_unique()
spliced = spliced[example_adata.obs_names, example_adata.var_names]

unspliced = sc.read_mtx(os.path.sep.join([kbdir, "unspliced.mtx"]))
unspliced.var_names = unspliced_var_names
unspliced.obs_names = unspliced_obs_names
unspliced.var_names_make_unique()
unspliced = unspliced[example_adata.obs_names, example_adata.var_names]<jupyter_output><empty_output><jupyter_text>Define adata and write it<jupyter_code>adata = spliced
adata.layers["spliced"] = adata.X
adata.layers["unspliced"] = unspliced.X
subset_adata.obs = example_adata.obs
subset_adata.obsm['X_umap'] = example_adata.obsm['X_umap']
subset_adata.write('anndata/pancreas_kb_trimmed.h5ad', compression='gzip')<jupyter_output><empty_output><jupyter_text>Get some statistic<jupyter_code>spliced = subset_adata.layers['spliced']
unspliced = subset_adata.layers['unspliced']
spliced.sum().sum() / (spliced.sum().sum()+unspliced.sum().sum())
unspliced.sum().sum() / (spliced.sum().sum()+unspliced.sum().sum())<jupyter_output><empty_output><jupyter_text>Run scVelo<jupyter_code>adata = scv.read("anndata/pancreas_kb_trimmed.h5ad")

sc.tl.pca(adata)
sc.pp.neighbors(adata)
sc.tl.tsne(adata)
# housekeeping
matplotlib.use('AGG')
scv.settings.set_figure_params('scvelo')

# get the proportion of spliced and unspliced count
scv.utils.show_proportions(adata)

# filter cells and genes, then normalize expression values
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000,enforce=True)

# scVelo pipeline
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
scv.tl.recover_dynamics(adata, n_jobs = 11)
scv.tl.velocity(adata, mode = 'dynamical')
scv.tl.velocity_graph(adata)
scv.pl.velocity_embedding_stream(adata, basis='umap', save="umap_pancreas_kb.pdf")
scv.pl.velocity_embedding_stream(adata, basis='tsne', save="tsne_pancreas_kb.pdf")
scv.tl.latent_time(adata)
scv.pl.scatter(adata, color='latent_time', color_map='gnuplot', size=80, save = "latent_time_pancreas_kb.png")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14889466840052015, 'fraction_numerical': 0.007152145643693108, 'mean_word_length': 8.35258358662614, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '543161', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1220, 'n_words': 167, 'path': 'analysis_scripts/mouse_pancreas_velocity/mouse_pancreas_kb_velocity_analysis.ipynb', 'repo_name': 'COMBINE-lab/alevin-fry-paper-scripts', 'size': '3076'}