STREAM icon indicating copy to clipboard operation
STREAM copied to clipboard

Issue detecting leaf markers

Open JDKaiser opened this issue 3 years ago • 3 comments

Hello,

After creating my plot stream, I am having trouble using detect_leaf_markers. There seems to be an issue with the keys, but I am not sure how to proceed. Here is the error I receive.

Scanning the specified marker list ... Importing precomputed scaled marker expression matrix ... 2000 markers are being scanned ...

ValueError Traceback (most recent call last) in ----> 1 st.detect_leaf_markers(adata,marker_list=adata.uns['var_genes'],cutoff_zscore=1.0,cutoff_pvalue=0.01,root='S1')

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/stream/core.py in detect_leaf_markers(adata, marker_list, cutoff_zscore, cutoff_pvalue, percentile_expr, n_jobs, min_num_cells, use_precomputed, root, preference) 3849 cand_br = leaf_mean_values.index[0] 3850 cand_zscore = zscores[0] -> 3851 list_br_values = [leaf_br_values[x] for x in leaf_edges] 3852 kurskal_statistic,kurskal_pvalue = stats.kruskal(*list_br_values) 3853 if(kurskal_pvalue<cutoff_pvalue):

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/stream/core.py in (.0) 3849 cand_br = leaf_mean_values.index[0] 3850 cand_zscore = zscores[0] -> 3851 list_br_values = [leaf_br_values[x] for x in leaf_edges] 3852 kurskal_statistic,kurskal_pvalue = stats.kruskal(*list_br_values) 3853 if(kurskal_pvalue<cutoff_pvalue):

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/pandas/core/series.py in getitem(self, key) 906 return self._get_values(key) 907 --> 908 return self._get_with(key) 909 910 def _get_with(self, key):

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/pandas/core/series.py in _get_with(self, key) 921 ) 922 elif isinstance(key, tuple): --> 923 return self._get_values_tuple(key) 924 925 elif not is_list_like(key):

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/pandas/core/series.py in _get_values_tuple(self, key) 956 957 if not isinstance(self.index, MultiIndex): --> 958 raise ValueError("Can only tuple-index with a MultiIndex") 959 960 # If key is contained, would have returned by now

ValueError: Can only tuple-index with a MultiIndex

Thank you for any help

JDKaiser avatar Oct 02 '20 07:10 JDKaiser

Hi,

Sorry about the slow response. It seems the latest version of pandas is causing the issue here.

Can you check the pandas version you are using? (Can you downgrade it to 1.0.5 for now if you are using 1.1 )

We will try to fix it in the upcoming release.

Thanks for the feedback!

huidongchen avatar Oct 05 '20 14:10 huidongchen

Thank you very much for your help! That solved the issue and I was able to get all the data from the rest of the tutorial.

There was an error for st.plot_de_markers(adata) - I tried with the tutorial data and it had an error as well I did notice that for plots: st.plot_flat_tree, st.plot_stream_sc, st.plot_dimension_reduction, and st.plot_visualization_2D the label with the first alphabetical listing was missing. For example, in the tutorial data CMP was not part of the label legend. The dot color showed up on the graph, but not the legend. All labels were present if plotly was True or for st.plot_stream.

I am not sure if that has anything to do with the plot_de_markers error but that is just something I noticed. Overall, the missing graph is not a problem really because I just got the data from the csv file, but I thought I would mention it. I added the value error below.

Great program! And thanks again for the response - Josh

ValueError Traceback (most recent call last) in ----> 1 st.plot_de_markers(adata)

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/stream/core.py in plot_de_markers(adata, num_markers, cutoff_zscore, cutoff_logfc, save_fig, fig_path, fig_size) 3645 "{:.2E}".format(Decimal(str(q))),color='black',size=0.6*mpl.rcParams['font.size'], 3646 **alignment) -> 3647 plt.xticks(pos_greater,dict_de_greater[sub_edges_i].index,rotation=-45) 3648 ax.set_ylabel('z score') 3649 ax.set_title('DE markers between branches ' + sub_edges_i[0][0]+'_'+sub_edges_i[0][1] + ' and ' + \

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/matplotlib/pyplot.py in xticks(ticks, labels, **kwargs) 1657 labels = ax.get_xticklabels() 1658 else: -> 1659 labels = ax.set_xticklabels(labels, **kwargs) 1660 for l in labels: 1661 l.update(kwargs)

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/matplotlib/axes/_base.py in wrapper(self, *args, **kwargs) 61 62 def wrapper(self, *args, **kwargs): ---> 63 return get_method(self)(*args, **kwargs) 64 65 wrapper.module = owner.module

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/matplotlib/cbook/deprecation.py in wrapper(*args, **kwargs) 449 "parameter will become keyword-only %(removal)s.", 450 name=name, obj_type=f"parameter of {func.name}()") --> 451 return func(*args, **kwargs) 452 453 return wrapper

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/matplotlib/axis.py in _set_ticklabels(self, labels, fontdict, minor, **kwargs) 1791 if fontdict is not None: 1792 kwargs.update(fontdict) -> 1793 return self.set_ticklabels(labels, minor=minor, **kwargs) 1794 1795 @cbook._make_keyword_only("3.2", "minor")

~/Documents/Files/coding/anaconda3/envs/env_stream/lib/python3.7/site-packages/matplotlib/axis.py in set_ticklabels(self, ticklabels, minor, **kwargs) 1713 if len(locator.locs) != len(ticklabels) and len(ticklabels) != 0: 1714 raise ValueError( -> 1715 "The number of FixedLocator locations" 1716 f" ({len(locator.locs)}), usually from a call to" 1717 " set_ticks, does not match"

ValueError: The number of FixedLocator locations (15), usually from a call to set_ticks, does not match the number of ticklabels (499).

JDKaiser avatar Oct 05 '20 17:10 JDKaiser

Hi Josh,

I am glad the solution works for you! Thanks for letting us know the error related to the plotting function plot_de_markers(). Unfortunately this is something new to me but I will keep this thread open and look into the issue. You feedbacks are much appreciated!

huidongchen avatar Oct 05 '20 17:10 huidongchen