RNA velocity in spermatogenesis#
RNA velocity analysis with the EM and steady-state models using data preprocessed with dropest
.
Requires
adata_generation.ipynb
velocyto_var_names.csv
fromvelocyto_vi.ipynb
Output
DATA_DIR/spermatogenesis/velocities/dropest_steady_state.pickle
DATA_DIR/spermatogenesis/velocities/dropest_em.pickle
Library imports#
import sys
import pandas as pd
import scanpy as sc
import scvelo as scv
sys.path.insert(0, "../../../")
from paths import DATA_DIR
sc.logging.print_version_and_date()
Running Scanpy 1.9.1, on 2022-07-21 16:56.
General settings#
# set verbosity levels
sc.settings.verbosity = 2
scv.settings.verbosity = 3
scv.settings.set_figure_params('scvelo', dpi_save=400, dpi=80, transparent=True, fontsize=20, color_map='viridis')
scv.settings.plot_prefix = ""
Constants#
N_JOBS = 8
VELOCYTO_VAR_NAMES = pd.read_csv('velocyto_var_names.csv', index_col=0, header=None).index.tolist()
Data loading#
adata = sc.read(DATA_DIR / 'spermatogenesis' / "dropest.h5ad")
adata
AnnData object with n_obs × n_vars = 1829 × 54144
obs: 'cell_index', 'clusters_coarse', 'clusters'
layers: 'spliced', 'unspliced'
scv.pl.proportions(adata)
Data pre-processing#
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000, retain_genes=VELOCYTO_VAR_NAMES)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
Filtered out 45039 genes that are detected 20 counts (shared).
Normalized count data: X, spliced, unspliced.
Extracted 2231 highly variable genes.
Logarithmized X.
computing PCA
on highly variable genes
with n_comps=30
finished (0:00:09)
computing neighbors
finished (0:00:33) --> added
'distances' and 'connectivities', weighted adjacency matrices (adata.obsp)
computing moments based on connectivities
finished (0:00:02) --> added
'Ms' and 'Mu', moments of un/spliced abundances (adata.layers)
Model fitting#
Steady state#
scv.tl.velocity(adata, mode="steady_state")
adata = adata[:, VELOCYTO_VAR_NAMES].copy()
computing velocities
finished (0:00:00) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
pd.DataFrame(
adata.layers['velocity'],
index=adata.obs_names,
columns=adata.var_names
).to_pickle(
DATA_DIR / 'spermatogenesis' / 'velocities' / 'dropest_steady_state.pickle'
)
EM#
scv.tl.recover_dynamics(adata, var_names='all', n_jobs=N_JOBS)
scv.tl.velocity(adata, mode='dynamical')
recovering dynamics (using 8/64 cores)
finished (0:02:02) --> added
'fit_pars', fitted parameters for splicing dynamics (adata.var)
computing velocities
finished (0:00:01) --> added
'velocity', velocity vectors for each individual cell (adata.layers)
pd.DataFrame(
adata[:, ~adata.var['fit_alpha'].isnull()].layers['velocity'],
index=adata.obs_names,
columns=adata.var_names[~adata.var['fit_alpha'].isnull()]
).to_pickle(
DATA_DIR / 'spermatogenesis' / 'velocities' / 'dropest_em.pickle'
)
WARNING: Gm15935 not recoverable due to insufficient samples.
WARNING: Lrrc18 not recoverable due to insufficient samples.
WARNING: 1700006F04Rik not recoverable due to insufficient samples.
WARNING: AC117700.1 not recoverable due to insufficient samples.
WARNING: Odf3b not recoverable due to insufficient samples.
WARNING: 4930413F20Rik not recoverable due to insufficient samples.
WARNING: 1700015H07Rik not recoverable due to insufficient samples.
WARNING: Gm41325 not recoverable due to insufficient samples.
WARNING: Gm6569 not recoverable due to insufficient samples.
WARNING: Gm49428 not recoverable due to insufficient samples.
WARNING: Gm15743 not recoverable due to insufficient samples.
WARNING: Gm15657 not recoverable due to insufficient samples.
WARNING: Efcab1 not recoverable due to insufficient samples.
WARNING: Gm15350 not recoverable due to insufficient samples.
WARNING: Gm16351 not recoverable due to insufficient samples.
WARNING: Lncbate1 not recoverable due to insufficient samples.
WARNING: Ankrd11 not recoverable due to insufficient samples.
WARNING: Ccsap not recoverable due to insufficient samples.
WARNING: 1700047A11Rik not recoverable due to insufficient samples.
WARNING: 1700125H03Rik not recoverable due to insufficient samples.
WARNING: 1700030M09Rik not recoverable due to insufficient samples.
WARNING: 4921509A06Rik not recoverable due to insufficient samples.
WARNING: Gm4665 not recoverable due to insufficient samples.
WARNING: Gm31497 not recoverable due to insufficient samples.
WARNING: Iqcf5 not recoverable due to insufficient samples.
WARNING: Gm27002 not recoverable due to insufficient samples.
WARNING: Trp53tg5 not recoverable due to insufficient samples.
WARNING: 1700029I15Rik not recoverable due to insufficient samples.
WARNING: Alkbh3os1 not recoverable due to insufficient samples.
WARNING: Gm29010 not recoverable due to insufficient samples.
WARNING: 1700020A23Rik not recoverable due to insufficient samples.
WARNING: 1700003F12Rik not recoverable due to insufficient samples.
WARNING: Gm42609 not recoverable due to insufficient samples.
WARNING: 4930509J09Rik not recoverable due to insufficient samples.
WARNING: 4930503B20Rik not recoverable due to insufficient samples.
WARNING: Fhl5 not recoverable due to insufficient samples.
WARNING: 1700095A21Rik not recoverable due to insufficient samples.
WARNING: Gm15904 not recoverable due to insufficient samples.
WARNING: AI507597 not recoverable due to insufficient samples.
WARNING: Ube4bos2 not recoverable due to insufficient samples.
WARNING: Speer4b not recoverable due to insufficient samples.
WARNING: 1700010H22Rik not recoverable due to insufficient samples.
WARNING: Gm17660 not recoverable due to insufficient samples.
WARNING: Diablo not recoverable due to insufficient samples.
WARNING: Tmem132cos not recoverable due to insufficient samples.
WARNING: Speer3 not recoverable due to insufficient samples.
WARNING: Prkag2os1 not recoverable due to insufficient samples.
WARNING: Usp46os1 not recoverable due to insufficient samples.
WARNING: Gm16226 not recoverable due to insufficient samples.
WARNING: Gtf3a not recoverable due to insufficient samples.
WARNING: 1700042O10Rik not recoverable due to insufficient samples.
WARNING: Lrrc75aos1 not recoverable due to insufficient samples.
WARNING: 4930544D05Rik not recoverable due to insufficient samples.
WARNING: Dbil5 not recoverable due to insufficient samples.
WARNING: Gm11655 not recoverable due to insufficient samples.
WARNING: Gm47376 not recoverable due to insufficient samples.
WARNING: Fkbp3 not recoverable due to insufficient samples.
WARNING: Gm48140 not recoverable due to insufficient samples.
WARNING: 4930549C15Rik not recoverable due to insufficient samples.
WARNING: Gm36756 not recoverable due to insufficient samples.
WARNING: Spata31d1d not recoverable due to insufficient samples.
WARNING: Gm48837 not recoverable due to insufficient samples.
WARNING: Pard3bos1 not recoverable due to insufficient samples.
WARNING: Tnp1 not recoverable due to insufficient samples.
WARNING: 4930527J03Rik not recoverable due to insufficient samples.
WARNING: Lypla1 not recoverable due to insufficient samples.
WARNING: Gm7568 not recoverable due to insufficient samples.
WARNING: 4930486I03Rik not recoverable due to insufficient samples.
WARNING: 4930556I23Rik not recoverable due to insufficient samples.
WARNING: 4930444A19Rik not recoverable due to insufficient samples.
WARNING: 4930444F02Rik not recoverable due to insufficient samples.
WARNING: 4930455C13Rik not recoverable due to insufficient samples.
WARNING: 4930545H06Rik not recoverable due to insufficient samples.
WARNING: 4930404N11Rik not recoverable due to insufficient samples.
WARNING: Atxn7l3b not recoverable due to insufficient samples.
WARNING: Gm19395 not recoverable due to insufficient samples.
WARNING: Pln not recoverable due to insufficient samples.
WARNING: Gm32872 not recoverable due to insufficient samples.
WARNING: 1700094J05Rik not recoverable due to insufficient samples.
WARNING: Sycp3 not recoverable due to insufficient samples.
WARNING: Gm45604 not recoverable due to insufficient samples.
WARNING: Gm29585 not recoverable due to insufficient samples.
WARNING: Ube2b not recoverable due to insufficient samples.
WARNING: 1700124L16Rik not recoverable due to insufficient samples.
WARNING: 4930587E11Rik not recoverable due to insufficient samples.
WARNING: Sox5os3 not recoverable due to insufficient samples.
WARNING: Lipe not recoverable due to insufficient samples.
WARNING: Gapdhs not recoverable due to insufficient samples.
WARNING: Gm15412 not recoverable due to insufficient samples.
WARNING: Rsf1os1 not recoverable due to insufficient samples.
WARNING: Nsmce4a not recoverable due to insufficient samples.
WARNING: 6430531B16Rik not recoverable due to insufficient samples.
WARNING: Gm29638 not recoverable due to insufficient samples.
WARNING: Gm26891 not recoverable due to insufficient samples.
WARNING: Etfb not recoverable due to insufficient samples.
WARNING: Klk1b7-ps not recoverable due to insufficient samples.
WARNING: Klk1b8 not recoverable due to insufficient samples.
WARNING: Gm15517 not recoverable due to insufficient samples.
WARNING: Prc1 not recoverable due to insufficient samples.
WARNING: Gm44649 not recoverable due to insufficient samples.
WARNING: Gm44570 not recoverable due to insufficient samples.
WARNING: Prss23os not recoverable due to insufficient samples.
WARNING: Gm5901 not recoverable due to insufficient samples.
WARNING: Gm4275 not recoverable due to insufficient samples.
WARNING: 1700029B22Rik not recoverable due to insufficient samples.
WARNING: Fam24a not recoverable due to insufficient samples.
WARNING: Acadsb not recoverable due to insufficient samples.
WARNING: Gm10578 not recoverable due to insufficient samples.
WARNING: AC154538.1 not recoverable due to insufficient samples.
WARNING: Rab40c not recoverable due to insufficient samples.
WARNING: Itpr3os not recoverable due to insufficient samples.
WARNING: Gm16555 not recoverable due to insufficient samples.
WARNING: AC165153.2 not recoverable due to insufficient samples.
WARNING: AC126942.1 not recoverable due to insufficient samples.
WARNING: Spdya not recoverable due to insufficient samples.
WARNING: Gm36368 not recoverable due to insufficient samples.
WARNING: AC164010.1 not recoverable due to insufficient samples.
WARNING: AC142100.4 not recoverable due to insufficient samples.
WARNING: 4930471G03Rik not recoverable due to insufficient samples.
WARNING: Malat1 not recoverable due to insufficient samples.
WARNING: AC100726.1 not recoverable due to insufficient samples.
WARNING: Rbm4b not recoverable due to insufficient samples.
WARNING: 1700092M07Rik not recoverable due to insufficient samples.
WARNING: AC137605.3 not recoverable due to insufficient samples.
WARNING: 1700080N15Rik not recoverable due to insufficient samples.
WARNING: Ccdc183 not recoverable due to insufficient samples.
WARNING: 4930533B01Rik not recoverable due to insufficient samples.