Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

same notebook gives different stream plots #131

Closed
crazyhottommy opened this issue Dec 2, 2021 · 9 comments
Closed

same notebook gives different stream plots #131

crazyhottommy opened this issue Dec 2, 2021 · 9 comments

Comments

@crazyhottommy
Copy link

Hi,
I installed STREAM1.0 on a different computer via conda. I ran the same notebook but the stream plots are different. I am wondering what could be the reason?

Thanks!

@crazyhottommy
Copy link
Author

also, I am getting this error with the same notebook on my other computer:

st.plot_stream(adata,root='S2',color=['FCGR3A','PRF1'], factor_num_win=5)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/2p/3c16s7dd5y9cmg7k8gkb9x800000gp/T/ipykernel_14386/2839065876.py in <module>
----> 1 st.plot_stream(adata,root='S2',color=['FCGR3A','PRF1'], factor_num_win=5)

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/stream/core.py in plot_stream(adata, root, color, preference, dist_scale, factor_num_win, factor_min_win, factor_width, factor_nrow, factor_ncol, log_scale, factor_zoomin, fig_size, fig_legend_order, fig_legend_ncol, vmin, vmax, pad, w_pad, h_pad, save_fig, fig_path, fig_format)
   3138                                    factor_num_win=factor_num_win,factor_min_win=factor_min_win,factor_width=factor_width,
   3139                                    factor_nrow=factor_nrow,factor_ncol=factor_ncol,
-> 3140                                    log_scale=log_scale,factor_zoomin=factor_zoomin)     
   3141         dict_plot['numeric'] = [verts,extent,ann_order,dict_ann_df,dict_im_array]
   3142 

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/stream/extra.py in cal_stream_polygon_numeric(adata, dict_ann, root, preference, dist_scale, factor_num_win, factor_min_win, factor_width, factor_nrow, factor_ncol, log_scale, factor_zoomin)
   1514         if x in nx.get_edge_attributes(flat_tree,'id').values():
   1515             id_cells = np.where(df_stream['branch_id']==x)[0]
-> 1516             df_stream.loc[df_stream.index[id_cells],'edge'] = [x]
   1517             df_stream.loc[df_stream.index[id_cells],'lam_ordered'] = df_stream.loc[df_stream.index[id_cells],'branch_lam']
   1518         else:

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/indexing.py in __setitem__(self, key, value)
    721 
    722         iloc = self if self.name == "iloc" else self.obj.iloc
--> 723         iloc._setitem_with_indexer(indexer, value, self.name)
    724 
    725     def _validate_key(self, key, axis: int):

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value, name)
   1728         if take_split_path:
   1729             # We have to operate column-wise
-> 1730             self._setitem_with_indexer_split_path(indexer, value, name)
   1731         else:
   1732             self._setitem_single_block(indexer, value, name)

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer_split_path(self, indexer, value, name)
   1767 
   1768             elif np.ndim(value) == 2:
-> 1769                 self._setitem_with_indexer_2d_value(indexer, value)
   1770 
   1771             elif len(ilocs) == 1 and lplane_indexer == len(value) and not is_scalar(pi):

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer_2d_value(self, indexer, value)
   1828         if len(ilocs) != value.shape[1]:
   1829             raise ValueError(
-> 1830                 "Must have equal len keys and value when setting with an ndarray"
   1831             )
   1832 

ValueError: Must have equal len keys and value when setting with an ndarray

@crazyhottommy
Copy link
Author

any help on this?

@huidongchen
Copy link
Collaborator

Hi Ming, sorry about the delay. It has been quite hectic lately.

This seems an issue related to the version of pandas #115 . Can you try to downgrade pandas to v1.0 and see if it works for you? (I noticed this did not solve a similar issue mentioned by another user but it's still worth a try for now)

@crazyhottommy
Copy link
Author

Yeah. the pandas version is tricky.
I downgraded it to v1.0, now a different error


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/2p/3c16s7dd5y9cmg7k8gkb9x800000gp/T/ipykernel_59461/2817862961.py in <module>
      1 st.plot_stream_sc(adata,root='S2',color=['label','FCGR3A', 'PRF1'],
----> 2                   dist_scale=0.3,show_graph=True,show_text=True)

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/stream/core.py in plot_stream_sc(adata, root, color, dist_scale, dist_pctl, preference, fig_size, fig_legend_ncol, fig_legend_order, vmin, vmax, alpha, pad, w_pad, h_pad, show_text, show_graph, save_fig, fig_path, fig_format, plotly)
   2894         raise ValueError("There is no root '%s'" % root)
   2895 
-> 2896     add_stream_sc_pos(adata,root=root,dist_scale=dist_scale,dist_pctl=dist_pctl,preference=preference)
   2897     stream_nodes = adata.uns['stream_'+root]['nodes']
   2898     stream_edges = adata.uns['stream_'+root]['edges']

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/stream/extra.py in add_stream_sc_pos(adata, root, dist_scale, dist_pctl, preference)
    398     dict_edge_shift_dist = calculate_shift_distance(adata,root=root,dist_pctl=dist_pctl,preference=preference)
    399     dict_path_len = nx.shortest_path_length(flat_tree,source=root_node,weight='len')
--> 400     df_cells_pos = pd.DataFrame(index=adata.obs.index,columns=['cells_pos'])
    401     dict_edge_pos = {}
    402     dict_node_pos = {}

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    433             )
    434         elif isinstance(data, dict):
--> 435             mgr = init_dict(data, index, columns, dtype=dtype)
    436         elif isinstance(data, ma.MaskedArray):
    437             import numpy.ma.mrecords as mrecords

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/internals/construction.py in init_dict(data, index, columns, dtype)
    237             else:
    238                 nan_dtype = dtype
--> 239             val = construct_1d_arraylike_from_scalar(np.nan, len(index), nan_dtype)
    240             arrays.loc[missing] = [val] * missing.sum()
    241 

/opt/anaconda3/envs/stream1.0/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in construct_1d_arraylike_from_scalar(value, length, dtype)
   1447     else:
   1448         if not isinstance(dtype, (np.dtype, type(np.dtype))):
-> 1449             dtype = dtype.dtype
   1450 
   1451         if length and is_integer_dtype(dtype) and isna(value):

AttributeError: type object 'object' has no attribute 'dtype'

@crazyhottommy
Copy link
Author

downgrade to v1.0.5 solved the problem.

@huidongchen
Copy link
Collaborator

Thanks Ming for the feedback. I'm glad you found a solution.

I will keep the issue open for now. I'm hoping to release a quick fix in the next few days.

@crazyhottommy
Copy link
Author

is stream 1.1 on conda?

@huidongchen
Copy link
Collaborator

Hi Ming, yes, it will be available on bioconda soon! bioconda/bioconda-recipes#32071

@huidongchen
Copy link
Collaborator

stream v1.1 is available now. The issues caused by the latest version of pandas have been fixed in the new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants