sc.external.exporting.cellbrowser: cellbrowser_raw_data\sample_colors.tsv does not exist, skipping it An exception has occurred, use %tb to see the full traceback.
Open
Nobody has claimed this yet.
Triage 🩺
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
Please make sure these conditions are met
- I have checked that this issue has not already been reported.
- I have confirmed this bug exists on the latest version of scanpy.
- (optional) I have confirmed this bug exists on the main branch of scanpy.
What happened?
Hi:
I would like to exporting the adata file to cellbrowser:
import numpy as np
import pandas as pd
import scanpy as sc
# Getting back the objects:
with open('../adata_umap_leiden_r1.pkl', 'rb') as f: # Python 3: open(..., 'rb')
adata = pickle.load(f)
# Natively export to the exact format used by your example website
sc.external.exporting.cellbrowser(
adata,
data_dir="cellbrowser_raw_data", # Raw text file generation directory
data_name="my_cluster_dataset",
embedding_keys=["X_umap"], # Pull coordinates
annot_keys=["CellType", "sample"], # Pull categorical data
html_dir="my_interactive_portal" # Generates a folder with a ready index.html file
)
print(sc.__version__)
1.10.4
But the program can not locate the "sample_colors.tsv" file it created already. How should I fix this problem?
Thanks a lot
INFO:root:Matrix has size (92371 cells, 19448 genes)
INFO:root:Writing scanpy matrix (92371 cells, 19448 genes) to cellbrowser_raw_data\exprMatrix.tsv.gz
INFO:root:Transposing matrix
INFO:root:Writing gene-by-gene, without using pandas
INFO:root:Writing 19448 genes in total
INFO:root:Wrote 0 genes
INFO:root:Wrote 2000 genes
INFO:root:Wrote 4000 genes
INFO:root:Wrote 6000 genes
INFO:root:Wrote 8000 genes
INFO:root:Wrote 10000 genes
INFO:root:Wrote 12000 genes
INFO:root:Wrote 14000 genes
INFO:root:Wrote 16000 genes
INFO:root:Wrote 18000 genes
INFO:root:These obsm entries were dropped, too many columns: []
INFO:root:Writing UMAP coords to cellbrowser_raw_data\umap_coords.tsv
WARNING:root:Couldnt find list of cluster marker genes in the h5ad file in adata.uns with the key 'rank_genes_groups'. In the future, from Python, try running sc.tl.rank_genes_groups(adata) to create the cluster annotation and write the h5ad file then.
INFO:root:Filtering for >5 cells then do sc.tl.rank_genes_groups for meta field 'louvain'
INFO:root:Cluster field 'louvain' not in adata.obs, trying ['CellType', 'cell_type', 'Celltypes', 'Cell_type', 'celltype', 'annotated_cell_identity.text', 'BroadCellType', 'Class']
INFO:root:Found field 'CellType', using it as the cell cluster field.
INFO:root:Looks like expression matrix has already been log2-ed before
INFO:root:Loading Scanpy libraries
C:\Users\lidan\miniconda311\Lib\site-packages\cellbrowser\cellbrowser.py:5209: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
clusterCellCounts = list(adata.obs.groupby([clusterField]).apply(len).items())
INFO:root:Calculating 100 marker genes for each cluster
INFO:root:Writing cellbrowser_raw_data\markers.tsv
INFO:root:Writing colors of field sample to cellbrowser_raw_data\sample_colors.tsv
INFO:root:Generating cellbrowser_raw_data\quickGenes.tsv from cellbrowser_raw_data\markers.tsv
INFO:root:Assuming non-Seurat marker file format (cluster, gene, score) + any other fields
INFO:root:Wrote cellbrowser_raw_data\cellbrowser.conf
WARNING:root:The directory my_interactive_portal does not exist. Making a new directory now.
INFO:root:dataRoot is not set in ~/.cellbrowser or via $CBDATAROOT. Dataset hierarchies are not supported.
INFO:root:dataRoot not set in ~/.cellbrowser, no need to rebuild hierarchy
INFO:root:Creating my_interactive_portal\my_cluster_dataset
INFO:root:Determining if my_interactive_portal\my_cluster_dataset\exprMatrix.tsv.gz needs to be created
INFO:root:my_interactive_portal\my_cluster_dataset\exprMatrix.tsv.gz does not exist. Must build matrix now.
INFO:root:Loading old config from my_interactive_portal\my_cluster_dataset\dataset.json
INFO:root:Creating my_interactive_portal\my_cluster_dataset\metaFields
INFO:root:Checking and reordering meta data to my_interactive_portal\my_cluster_dataset\meta.tsv
INFO:root:Reading sample names from D:\R\seurat\T2AR_2\cb_workspace\cellbrowser_raw_data\meta.tsv
INFO:root:Reading headers from file D:\R\seurat\T2AR_2\cb_workspace\cellbrowser_raw_data\exprMatrix.tsv.gz
INFO:root:Data contains 92371 samples/cells
INFO:root:Converting to numbers and compressing meta data fields
ERROR:root:Color file D:\R\seurat\T2AR_2\cb_workspace\cellbrowser_raw_data\cellbrowser_raw_data\sample_colors.tsv does not exist, skipping it
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
C:\Users\lidan\miniconda311\Lib\site-packages\IPython\core\interactiveshell.py:3441: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the sc.external.exporting.cellbrowser entry point and trace how data_dir is passed into the generated portal build. Compare the logged output path for sample_colors.tsv with the later path lookup under cellbrowser_raw_data\cellbrowser_raw_data. Done means the export completes without looking for the generated color file in a duplicated directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100