aertslab / pycisTopic

pycisTopic is a Python module to simultaneously identify cell states and cis-regulatory topics from single cell epigenomics data.
Other
56 stars 11 forks source link

NameError: name 'Tuple' is not defined #123

Open w1973145618 opened 6 months ago

w1973145618 commented 6 months ago

Describe the bug

To Reproduce imputed_acc_obj = impute_accessibility( cistopic_obj, selected_cells=None, selected_regions=None, scale_factor=10**6 )

Error output

NameError Traceback (most recent call last) Cell In[66], line 3 1 from typing import Tuple ----> 3 imputed_acc_obj = impute_accessibility( 4 cistopic_obj, 5 selected_cells=None, 6 selected_regions=None, 7 scale_factor=10**6 8 )

File ~/anaconda3/Git/pycisTopic/src/pycisTopic/diff_features.py:387, in impute_accessibility(cistopic_obj, selected_cells, selected_regions, scale_factor, chunk_size, project) 377 topic_region = topic_region.to_numpy().astype(np.float32) 379 log.info("Imputing region accessibility") 381 def calculate_imputed_accessibility( 382 topic_region: np.ndarray, 383 cell_topic: np.ndarray, 384 region_names: list, 385 scale_factor: Optional[int], 386 chunk_size: int --> 387 ) -> Tuple[np.ndarray, list]: 388 """ 389 Calculate imputed accessibility in chunks of chunk_size. 390 (...) 411 412 """ 413 output_chunk_end = 0

SeppeDeWinter commented 6 months ago

Hi @w1973145618

I fixed this error some days ago, https://github.com/aertslab/pycisTopic/commit/5416709112f7324152591e66474bbc67ac553306

Can you try reinstalling pycisTopic?

All the best,

Seppe

w1973145618 commented 6 months ago

Hi @w1973145618

I fixed this error some days ago, 5416709

Can you try reinstalling pycisTopic?

All the best,

Seppe

Dear Seppe: I am happy for you tell me how to do. I followed your method: I reinstalled pycisTopic from GitHub to fix the bug: NameError: name ‘Tuple’ is not defined.This is work. However, now I’ve encountered new problems. I will show you the new problem I’ve encountered.

New bug1:

Describe the bug NameError: name 'subset_list' is not defined

To Reproduce plot_metadata( cistopic_obj, reduction_name='UMAP', variables=['log10_unique_fragments_count', 'tss_enrichment', 'Doublet_scores_fragments', 'fraction_of_fragments_in_peaks'], target='cell', num_columns=4, text_size=10, dot_size=5)

Error output NameError Traceback (most recent call last) Cell In[48], line 1 ----> 1 plot_metadata( 2 cistopic_obj, 3 reduction_name='UMAP', 4 variables=['log10_unique_fragments_count', 'tss_enrichment', 'Doublet_scores_fragments', 'fraction_of_fragments_in_peaks'], 5 target='cell', num_columns=4, 6 text_size=10, 7 dot_size=5)

File ~/anaconda3/Git/pycisTopic/src/pycisTopic/clust_vis.py:571, in plot_metadata(cistopic_obj, reduction_name, variables, target, remove_nan, show_label, show_legend, cmap, dot_size, text_size, alpha, seed, color_dictionary, figsize, num_columns, selected_features, save) 566 plt.subplot(num_rows, num_columns, i) 567 i = i + 1 568 plt.scatter( 569 embedding.iloc[o, 0], 570 embedding.iloc[o, 1], --> 571 c=subset_list(var_data, o), 572 cmap=cmap, 573 s=dot_size, 574 alpha=alpha, 575 ) 576 plt.xlabel(embedding.columns[0]) 577 plt.ylabel(embedding.columns[1])

NameError: name 'subset_list' is not defined

New bug2:

Describe the bug NameError: name 'sparse' is not defined

To Reproduce plot_imputed_features( cistopic_obj, reduction_name='UMAP', imputed_data=imputed_acc_obj, features=[markers_dict[x].index.tolist()[0] for x in ['BG', 'GC', 'INH_SST', 'COP']], scale=False, num_columns=4 )

Error output NameError Traceback (most recent call last) Cell In[78], line 1 ----> 1 plot_imputed_features( 2 cistopic_obj, 3 reduction_name='UMAP', 4 imputed_data=imputed_acc_obj, 5 features=[markers_dict[x].index.tolist()[0] for x in ['BG', 'GC', 'INH_SST', 'COP']], 6 scale=False, 7 num_columns=4 8 )

File ~/anaconda3/Git/pycisTopic/src/pycisTopic/clust_vis.py:823, in plot_imputed_features(cistopic_obj, reduction_name, imputed_data, features, scale, cmap, dot_size, alpha, selected_cells, figsize, num_columns, save) 821 except BaseException: 822 feature_data = sklearn.preprocessing.scale(feature_data, axis=1) --> 823 if isinstance(feature_data, sparse.csr_matrix): 824 color_data = pd.DataFrame( 825 feature_data.transpose().todense(), index=embedding.index.tolist() 826 ) 827 else:

NameError: name 'sparse' is not defined

SeppeDeWinter commented 6 months ago

Hi @w1973145618

Yes that was my bad as well. It should be fixed now: https://github.com/aertslab/pycisTopic/commit/284c5a53cc7e2f2e85b76f68f0612e0c0a98d29a.

Can you try reinstalling?

All the best,

Seppe