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

NameError: name 'Tuple' is not defined #123

Open
w1973145618 opened this issue Mar 27, 2024 · 3 comments
Open

NameError: name 'Tuple' is not defined #123

w1973145618 opened this issue Mar 27, 2024 · 3 comments

Comments

@w1973145618
Copy link

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
Copy link
Collaborator

Hi @w1973145618

I fixed this error some days ago, 5416709

Can you try reinstalling pycisTopic?

All the best,

Seppe

@w1973145618
Copy link
Author

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
Copy link
Collaborator

Hi @w1973145618

Yes that was my bad as well. It should be fixed now: 284c5a5.

Can you try reinstalling?

All the best,

Seppe

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