scverse / scverse/scanpy

TypeError when using the exporting.spring_project function

Open
#889 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

I've been trying to export my data to SPRING using the external export feature. I do all my processing in Seurat and then export a loom file to be read in scanpy and export to SPRING. I've been however getting the below error.

The notebook with the code and the loom file can be found here: https://github.com/tejas-j/seurat2spring

Is there a better way to achieve what I'm trying to do (data -> Seurat -> scanpy -> SPRING)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-3b0044b18ade> in <module>
      1 import time
      2 t0 = time.time()
----> 3 sce.exporting.spring_project(data, './pbmc3k', 'draw_graph', subplot_name='force1', overwrite=True)
      4 print(time.time() - t0)

~/miniconda2/envs/py36/lib/python3.6/site-packages/scanpy/_exporting.py in spring_project(adata, project_dir, embedding_method, subplot_name, cell_groupings, custom_color_tracks, total_counts_key, overwrite)
    157     # Write continuous colors
    158     continuous_extras['Uniform'] = np.zeros(E.shape[0])
--> 159     write_color_tracks(continuous_extras, subplot_dir / 'color_data_gene_sets.csv')
    160 
    161     # Create and write a dictionary of color profiles to be used by the visualizer

~/miniconda2/envs/py36/lib/python3.6/site-packages/scanpy/_exporting.py in write_color_tracks(ctracks, fname)
    301     out = []
    302     for name,score in ctracks.items():
--> 303         line = name + ',' + ','.join(['%.3f' %x for x in score])
    304         out += [line]
    305     out = sorted(out,key=lambda x: x.split(',')[0])

~/miniconda2/envs/py36/lib/python3.6/site-packages/scanpy/_exporting.py in <listcomp>(.0)
    301     out = []
    302     for name,score in ctracks.items():
--> 303         line = name + ',' + ','.join(['%.3f' %x for x in score])
    304         out += [line]
    305     out = sorted(out,key=lambda x: x.split(',')[0])

TypeError: must be real number, not numpy.str_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scanpy/_exporting.py, focusing on spring_project and write_color_tracks at the failing line. Reproduce the export with the linked seurat2spring notebook and loom file, then inspect which color-track values reach the formatter. Done means the Seurat-to-scanpy-to-SPRING export completes without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
bioinformatics, data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.