aristoteleo / dynamo-release

Inclusive model of expression dynamics with conventional or metabolic labeling based scRNA-seq / multiomics, vector field reconstruction and differential geometry analyses
https://dynamo-release.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
418 stars 59 forks source link

Missing arguments for dyn.tl.dynamics #118

Closed TJonCooper closed 3 years ago

TJonCooper commented 3 years ago
Python 3.8.5 (default, Sep  4 2020, 07:30:14) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dynamo as dyn
>>> adata = dyn.read('/home/tjcooper/Projects/MDSC_Project/mouseBM.h5ad')
>>> dyn.pp.recipe_monocle(adata)
/home/tjcooper/dynamo-release/dynamo/preprocessing/utils.py:439: UserWarning: `total_szfactor` is not `None` and it is not in adata object.
  warnings.warn("`total_szfactor` is not `None` and it is not in adata object.")
AnnData object with n_obs × n_vars = 2865 × 14836
    obs: 'orig.ident', 'nCount_spliced', 'nFeature_spliced', 'nCount_unspliced', 'nFeature_unspliced', 'nCount_ambiguous', 'nFeature_ambiguous', 'nCount_RNA', 'nFeature_RNA', 'nCount_SCT', 'nFeature_SCT', 'seurat_clusters', 'nGenes', 'nCounts', 'pMito', 'use_for_pca', 'Size_Factor', 'initial_cell_size', 'unspliced_Size_Factor', 'initial_unspliced_cell_size', 'spliced_Size_Factor', 'initial_spliced_cell_size', 'ntr', 'cell_cycle_phase'
    var: 'features', 'ambiguous_features', 'spliced_features', 'unspliced_features', 'nCells', 'nCounts', 'pass_basic_filter', 'log_cv', 'score', 'log_m', 'use_for_pca', 'ntr'
    uns: 'pp', 'velocyto_SVR', 'PCs', 'explained_variance_ratio_', 'pca_fit', 'feature_selection'
    obsm: 'X_umap', 'X_pca', 'X', 'cell_cycle_scores'
    layers: 'ambiguous', 'spliced', 'unspliced', 'X_unspliced', 'X_spliced'
>>> dyn.tl.dynamics(adata)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tjcooper/dynamo-release/dynamo/tools/dynamics.py", line 303, in dynamics
    moments(adata, genes=valid_bools, group=tkey)
  File "/home/tjcooper/dynamo-release/dynamo/tools/moments.py", line 99, in moments
    kNN, knn_indices, knn_dists, _ = umap_conn_indices_dist_embedding(
  File "/home/tjcooper/dynamo-release/dynamo/tools/connectivity.py", line 227, in umap_conn_indices_dist_embedding
    embedding_ = simplicial_set_embedding(
TypeError: simplicial_set_embedding() missing 3 required positional arguments: 'densmap', 'densmap_kwds', and 'output_dens'

I'm using the PyPi release of Dynamo, and receiving the above error message when attempting to run it on this file:

https://e.pcloud.link/publink/show?code=XZuibkZCBtw4neJ5Q8wpFqcCoHUKjBx2dTX

Preprocessing was originally performed with Seurat and the h5ad file was created via SeuratDisk.

I've also tried reading in the original, unprocessed .loom file via scanpy.read_loom but encounter an identical error:

https://e.pcloud.link/publink/show?code=XZvvbkZfK2Q2yvHnhS8YA0NCtXDWLzqQwh7

What could be causing this?

TJonCooper commented 3 years ago

Also happening on the latest git version of Dynamo - so I'm sure it's due to the file structure of the input itself.

Xiaojieqiu commented 3 years ago

Hi @TJonCooper thanks for using our tool. this seems like a umap version mismatch. What umap version are you using? try this builtin dynamo function: dyn.get_all_dependencies_version()

TJonCooper commented 3 years ago
>>> dyn.get_all_dependencies_version()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tjcooper/.local/lib/python3.8/site-packages/dynamo/get_version.py", line 178, in get_all_dependencies_version
    _package = pkg_resources.working_set.by_key[_package_name]
KeyError: 'dynamo-release'

I have some issues running that function (see above).

I installed dynamo within a fresh conda environment, dedicated to it.

Xiaojieqiu commented 3 years ago

@TJonCooper sorry for this. This is certainly a bug. Let me fix this for you today!

TJonCooper commented 3 years ago

Great, thanks! :)

Xiaojieqiu commented 3 years ago

Hi @TJonCooper the bug results from recent changes in umap. Could you please pull the new changes from github and see how it goes with your data (It works on my end now).

Also we have fully worked the theory for dynamo, validated its predictions by a few experiments, and introduced new concepts in dynamical systems and differential geometry to gain deep insights of biological systems. You may find our fully rewritten preprint helpful: https://www.biorxiv.org/content/10.1101/696724v2

For a 3 minute digest of our paper, see my Twitter thread here: https://twitter.com/Xiaojie_Qiu/status/1359183325198512132

(welcome retweet)

TJonCooper commented 3 years ago

dyn.tl.dynamics now correctly runs! Thank you!

As a lot of people work with Seurat, I'd also like to bring your attention to SeuratDisk: https://github.com/mojaveazure/seurat-disk

Which may allow an easy route for the integration of Seurat with Dynamo.

library(SeuratDisk)
library(SeuratWrappers)
ldat<-ReadVelocity(file = "example.loom")
bm<-as.Seurat(x=ldat)
bm[["RNA"]] <- bm[["spliced"]]
DefaultAssay(bm) <- "RNA"
*any Seurat processing here*
SaveH5Seurat(bm, filename = "mouseBM.h5Seurat")
Convert("mouseBM.h5Seurat", dest = "h5ad")

Is all that is needed to produce an AnnData file that is immediately compatible with scvelo - and so far - Dynamo too :)

Also see:

https://htmlpreview.github.io/?https://github.com/satijalab/seurat-wrappers/blob/master/docs/scvelo.html

Thanks for the awesome package!

Xiaojieqiu commented 3 years ago

dynamo is compatible with loom or adata objects thanks to AnnData package. I think that is also what you need to move data from R world to dynamo.

We will have a few exciting tutorials demonstrating RNA velocity, acceleration, curvature vector field, RNA divergence, curl and potential landscape, etc soon. Please stayed tuned!