Issue adding labels and colors on STREAM
0
0
Entering edit mode
4.4 years ago
V ▴ 380

I'm sorry, I'm having a very basic issue and for the life of me can not resolve it. This is what I run:

```
adata = st.read(file_name= 'stem.txt', workdir= './Stream')
adata
```

The above is my count file. Then I pass :

```
st.add_cell_colors(adata, file_name = 'simplecolour.txt')
st.add_cell_labels(adata, file_name = 'lineage.txt')
```

Where 'simplecolour' is a text file (no headers) where column 1 is the name of the cells as they appear in the count file, and column two is the colour that that cell should have (I've used hex codes).

'lineage' is again all the cells, as named in the count file in column 1 and in column 2 is their appropriate lineage. These two commands passed together throw the following error :

```
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2896             try:
-> 2897                 return self._engine.get_loc(key)
   2898             except KeyError:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'label'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
<ipython-input-252-a08df3834e60> in <module>
----> 1 st.add_cell_colors(adata, file_name = 'simplecolour.txt')
      2 st.add_cell_labels(adata, file_name = 'lineage.txt')

~/anaconda3/lib/python3.7/site-packages/stream/core.py in add_cell_colors(adata, file_path, file_name)
    289 
    290     _fp = lambda f:  os.path.join(file_path,f)
--> 291     labels_unique = adata.obs['label'].unique()
    292     if(file_name!=None):
    293         df_colors = pd.read_csv(_fp(file_name),sep='\t',header=None,index_col=None,names=['label','color'],

~/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py in __getitem__(self, key)
   2993             if self.columns.nlevels > 1:
   2994                 return self._getitem_multilevel(key)
-> 2995             indexer = self.columns.get_loc(key)
   2996             if is_integer(indexer):
   2997                 indexer = [indexer]

~/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
   2897                 return self._engine.get_loc(key)
   2898             except KeyError:
-> 2899                 return self._engine.get_loc(self._maybe_cast_indexer(key))
   2900         indexer = self.get_indexer([key], method=method, tolerance=tolerance)
   2901         if indexer.ndim > 1 or indexer.size > 1:

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()

KeyError: 'label'
```

I'm sorry if im being dumb. I tried doing the obvious thing of adding in the header for the appropriate column as 'label' and 'label_color' but that hasnt worked either. Would anyone have a suggestion? or be able to share even a screenshot of how they present their data so I can replicate it? Thanks

stream python pseudotime • 881 views
ADD COMMENT
0
Entering edit mode

Can you post the first ~5 lines of each file so we can replicate?

ADD REPLY
0
Entering edit mode
head -10 lineage.txt

gives me :

    label
S1  Pit1
S2  Pit1
S3  Pit1
S4  Pit1
S5  Pit1
S6  Pit1
S7  SC1
S8  Pit1
S9  SC3

.

head -10 simplecolour.txt

gives:

Pit1    Red
Tpit    Orange
SC1 Green
SC2 Blue
SC3 Grey
PP  Black
SF1 Purple

I also tried a different colour file where I named every sequenced cell individually with a colour based on the group they belong to but that gave the same error too. It looked something like :

    label
S1  Red
S2  Red
S3  Red
S4  Red
S5  Red
S6  Red
S7  Green
S8  Red
S9  Grey

Also tried with hex code colours....same error.

ADD REPLY

Login before adding your answer.

Traffic: 2599 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6