maximilianh / cellBrowser

main repo: https://github.com/ucscGenomeBrowser/cellBrowser/ - Python pipeline and Javascript scatter plot library for single-cell datasets, http://cellbrowser.rtfd.org
https://github.com/ucscGenomeBrowser/cellBrowser/
GNU General Public License v3.0
104 stars 40 forks source link

UMAP and tSNE not picked up on AnnData with multiple embeddings #179

Closed pcm32 closed 4 years ago

pcm32 commented 4 years ago

I have the current AnnData object:

AnnData object with n_obs × n_vars = 8397 × 19981 
    obs: 'sample_id', 'CellType', 'BroadCellType', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'n_counts', 'n_genes', 'louvain', '__is_in_cluster__', 'louvain_0', 'louvain_1'
    var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'n_counts', 'n_cells', 'mito'
    uns: 'leiden', 'louvain', 'louvain_0', 'louvain_1', 'neighbors', 'neighbors_hm', 'pca', 'rank_genes_groups', 'rank_genes_groups_filtered'
    obsm: 'X_pca', 'X_pca_hm', 'X_umap_hm', 'X_umap_hm_0', 'X_umap_hm_1', 'X_tsne_0', 'X_tsne_1', 'X_tsne_2'
    varm: 'PCs'

When I try to do an import from Scanpy/AnnData CellBrowser gives me:

Traceback (most recent call last):
  File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/bin/cbImportScanpy", line 10, in <module>
    sys.exit(cbImportScanpyCli())
  File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/lib/python3.7/site-packages/cellbrowser/convert.py", line 522, in cbImportScanpyCli
    markerField=markerField)
  File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/lib/python3.7/site-packages/cellbrowser/cellbrowser.py", line 3281, in scanpyToCellbrowser
    raise ValueError("No valid embeddings were found in anndata.obsm but at least one array of coordinates is required. Keys that were tried: %s" % (coordFields))
ValueError: No valid embeddings were found in anndata.obsm but at least one array of coordinates is required. Keys that were tried: {'fa': 'ForceAtlas2', 'fr': 'Fruchterman Reingold', 'grid_fr': 'Grid Fruchterman Reingold', 'kk': 'Kamadi Kawai', 'lgl': 'Large Graph Layout', 'drl': 'DrL Distributed Recursive Layout', 'rt': 'Reingold Tilford tree', 'tsne': 't-SNE', 'umap': 'UMAP', 'pagaFa': 'PAGA/ForceAtlas2', 'pagaFr': 'PAGA/Fruchterman-Reingold', 'phate': 'PHATE'}

do you have in newer versions more flexible ways of picking up the tSNEs and UMAPs on that AnnData? If that is the case, could you do a new release, as I need one that includes a defensive fix for #177 . Thanks!

maximilianh commented 4 years ago

Yes, you can either provide the names with the argument coordFields of scanpyToCellbrowser yourself or let the new version do the job, it autodetects fields and uses all keys of the obsm object. (you may remember that this was a problem before in with older scanpy versions, due to the breaking changes in scanpy, but we've found a way around that, I think we talked about that in a previous discussion). The code for this is now in cellbrowser.py / writeAnndataCoords.

What is "_hm" ? Or "_1" and "_2" ? I've never seen these before.

Hm... are you on the current release...? I thought we had released this code...

On Mon, Jun 8, 2020 at 12:39 AM Pablo Moreno notifications@github.com wrote:

I have the current AnnData object:

AnnData object with n_obs × n_vars = 8397 × 19981

obs: 'sample_id', 'CellType', 'BroadCellType', 'n_genes_by_counts', 'log1p_n_genes_by_counts', 'total_counts', 'log1p_total_counts', 'n_counts', 'n_genes', 'louvain', '__is_in_cluster__', 'louvain_0', 'louvain_1'

var: 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'n_cells_by_counts', 'mean_counts', 'log1p_mean_counts', 'pct_dropout_by_counts', 'total_counts', 'log1p_total_counts', 'n_counts', 'n_cells', 'mito'

uns: 'leiden', 'louvain', 'louvain_0', 'louvain_1', 'neighbors', 'neighbors_hm', 'pca', 'rank_genes_groups', 'rank_genes_groups_filtered'

obsm: 'X_pca', 'X_pca_hm', 'X_umap_hm', 'X_umap_hm_0', 'X_umap_hm_1', 'X_tsne_0', 'X_tsne_1', 'X_tsne_2'

varm: 'PCs'

When I try to do an import from Scanpy/AnnData CellBrowser gives me:

Traceback (most recent call last):

File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/bin/cbImportScanpy", line 10, in

sys.exit(cbImportScanpyCli())

File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/lib/python3.7/site-packages/cellbrowser/convert.py", line 522, in cbImportScanpyCli

markerField=markerField)

File "/Users/pmoreno/miniconda3/envs/__ucsc-cell-browser@0.5.43/lib/python3.7/site-packages/cellbrowser/cellbrowser.py", line 3281, in scanpyToCellbrowser

raise ValueError("No valid embeddings were found in anndata.obsm but at least one array of coordinates is required. Keys that were tried: %s" % (coordFields))

ValueError: No valid embeddings were found in anndata.obsm but at least one array of coordinates is required. Keys that were tried: {'fa': 'ForceAtlas2', 'fr': 'Fruchterman Reingold', 'grid_fr': 'Grid Fruchterman Reingold', 'kk': 'Kamadi Kawai', 'lgl': 'Large Graph Layout', 'drl': 'DrL Distributed Recursive Layout', 'rt': 'Reingold Tilford tree', 'tsne': 't-SNE', 'umap': 'UMAP', 'pagaFa': 'PAGA/ForceAtlas2', 'pagaFr': 'PAGA/Fruchterman-Reingold', 'phate': 'PHATE'}

do you have in newer versions more flexible ways of picking up the tSNEs and UMAPs on that AnnData? If that is the case, could you do a new release, as I need one that includes a defensive fix for #177 https://github.com/maximilianh/cellBrowser/issues/177 . Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/maximilianh/cellBrowser/issues/179, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACL4TKNOEJRANFYZP7THLDRVQJKHANCNFSM4NXW3WUQ .

pcm32 commented 4 years ago

There is no release yet that covers #177. I will try first with your dev version with what I'm trying and see if it doesn't require any further changes and let you know.

maximilianh commented 4 years ago

That will be extremely helpful, thanks!

On Tue, Jun 9, 2020 at 5:15 PM Pablo Moreno notifications@github.com wrote:

There is no release yet that covers #177 https://github.com/maximilianh/cellBrowser/issues/177. I will try first with your dev version with what I'm trying and see if it doesn't require any further changes and let you know.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/maximilianh/cellBrowser/issues/179#issuecomment-641363213, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACL4TLA3TIWGZYW43YDUVLRVZGYHANCNFSM4NXW3WUQ .

pcm32 commented 4 years ago

Ok, this seems to be working on the latest version. Could you please do a release that includes #177 and then I can use that? Thanks @maximilianh!

maximilianh commented 4 years ago

OK, will try to release today or early next week.

On Thu, Jun 11, 2020 at 6:16 PM Pablo Moreno notifications@github.com wrote:

Ok, this seems to be working on the latest version. Could you please do a release that includes #177 https://github.com/maximilianh/cellBrowser/issues/177 and then I can use that? Thanks @maximilianh https://github.com/maximilianh!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/maximilianh/cellBrowser/issues/179#issuecomment-642783489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACL4TLKLYSFN6URDKEFXV3RWD7O5ANCNFSM4NXW3WUQ .

maximilianh commented 4 years ago

This should be fixed now.