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

input file format #7

Open
skytguuu opened this issue Sep 7, 2024 · 13 comments
Open

input file format #7

skytguuu opened this issue Sep 7, 2024 · 13 comments

Comments

@skytguuu
Copy link

skytguuu commented Sep 7, 2024

Hi,

I met a problem when I tried to use the flowsig. I used my own datasets:
image
When I used the data to run fs.pp.construct_gems_using_pyliger(adata,n_gems = 10,layer_key = 'counts',condition_key = condition_key), it reported an error that:
#########
Traceback (most recent call last):
File "", line 1, in
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/flowsig/preprocessing/_gem_construction.py", line 18, in construct_gems_using_pyliger
ad = adata.copy()
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/anndata/_core/anndata.py", line 1525, in copy
return self._mutated_copy()
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/anndata/_core/anndata.py", line 1461, in _mutated_copy
new["uns"] = deepcopy(self._uns)
File "/home/dell/anaconda3/envs/flow/lib/python3.8/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/home/dell/anaconda3/envs/flow/lib/python3.8/copy.py", line 295, in _reconstruct
value = deepcopy(value, memo)
File "/home/dell/anaconda3/envs/flow/lib/python3.8/copy.py", line 146, in deepcopy
y = copier(x, memo)
File "/home/dell/anaconda3/envs/flow/lib/python3.8/copy.py", line 229, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/home/dell/anaconda3/envs/flow/lib/python3.8/copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: cannot pickle 'module' object
#############
It is probabally caused by my own data. If I used the tutorial datasets, it worked well.

Could you provide the detail of the input format and what is the error meaning for?

Thanks!

@axelalmet
Copy link
Owner

axelalmet commented Sep 7, 2024

Hello,

The input is just a standard AnnData object. It seems the issue comes when FlowSig tries to make a copy of your inputted AnnData object.

I'm not fully sure what's going on, but it seems the error happens when your adata.uns key is copied. Do you mind showing me what your adata.uns and adata.uns['cellchat_output_key'] look like?

Thanks!

Best wishes,
Axel.

@skytguuu
Copy link
Author

skytguuu commented Sep 8, 2024

Thanks for your help. The followed is my adata information:
image
I have three conditions in my cellchat_output_key, is it the problem here?

Thank you!

@axelalmet
Copy link
Owner

The problem isn't the three conditions, that's fine, as long as you specify which will be the control condition!

Rather, the issue is that I suspect you have written something like

import pandas as pd

and then accidentally set something equivalent to

adata.uns['cellchat_output_key']['PD'] = pd

and thus you've set one of the cellchat output values as the imported Pandas module. What I would do is just define the cellchat output corresponding to the 'PD' condition using a different variable.

@skytguuu
Copy link
Author

skytguuu commented Sep 8, 2024

Thanks for your quick response. I have revised the pd to pdgroup to avoid the conflict to the pandas. However, the error was changed:

image
It seemed my counts data was no colnames and rownames. Because I used my seuratobject to transfer to the h5ad data format, I don't know what's happened?

Thanks!

@axelalmet
Copy link
Owner

Please see the suggestion in #6. This is an artefact of FlowSig using pyliger to construct the GEMs. Basically, the obs and var indices both need to have a name.

@skytguuu
Copy link
Author

skytguuu commented Sep 8, 2024

Thanks for your help. As your advise, it worked. However, when I tried to run: fs.pp.determine_informative_variables(adata, flowsig_expr_key = 'X_flow',flowsig_network_key = 'flowsig_network',spatial = False,condition_key = condition_key,qval_threshold = 0.1,logfc_threshold = 0.25), it reported another error that:
##############
... storing 'Type' as categorical
... storing 'Downstream_TF' as categorical
WARNING: It seems you use rank_genes_groups on the raw count data. Please logarithmize your data before calling rank_genes_groups.
WARNING: It seems you use rank_genes_groups on the raw count data. Please logarithmize your data before calling rank_genes_groups.
Traceback (most recent call last):
File "", line 1, in
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/flowsig/preprocessing/_flow_preprocessing.py", line 209, in determine_informative_variables
determine_differentially_flowing_vars(adata,
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/flowsig/preprocessing/_flow_preprocessing.py", line 100, in determine_differentially_flowing_vars
sc.tl.rank_genes_groups(adata_outflow, key_added=condition_key, groupby=condition_key, method='wilcoxon')
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/scanpy/tools/_rank_genes_groups.py", line 610, in rank_genes_groups
test_obj.compute_statistics(
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/scanpy/tools/_rank_genes_groups.py", line 406, in compute_statistics
_, pvals_adj, _, _ = multipletests(
File "/home/dell/anaconda3/envs/flow/lib/python3.8/site-packages/statsmodels/stats/multitest.py", line 156, in multipletests
alphacSidak = 1 - np.power((1. - alphaf), 1./ntests)
ZeroDivisionError: float division by zero
###############
It seemed the zero value in p.adjust. Could you give me a hand?

Thanks!

@axelalmet
Copy link
Owner

Seems like FlowSig isn't detecting any outflow variables from your data.

Do you mind showing me the output when you run the following code?

fs_var_info = adata.uns['flow_var_info']

print(fs_var_info[fs_var_info['Type'] == 'outflow'])

Thanks!

@skytguuu
Copy link
Author

skytguuu commented Sep 9, 2024

It is the information:

image

Thanks!

@axelalmet
Copy link
Owner

My bad, I meant to ask you to print:

fs_var_info = adata.uns['flowsig_network']['flow_var_info']

print(fs_var_info[fs_var_info['Type'] == 'outflow'])

@skytguuu
Copy link
Author

skytguuu commented Sep 10, 2024

Thanks, it is the information:

image

@axelalmet
Copy link
Owner

Hi skytuguuu,

Apologies for the late response. Looking at another issue, I realise what the issue is that in the tutorial specified by the README.md file gives the wrong command to use—I only realised this looking at issue #12 . Please could you try running the command instead:

fs.pp.determine_differentially_flowing_vars(adata,
                                        condition_key = condition_key,
                                        control_key = 'CON',
                                        flowsig_expr_key = 'X_flow',
                                        flowsig_network_key = 'flowsig_network',
                                        qval_threshold = 0.05,
                                        logfc_threshold = 0.5)

But replace 'CON' with the condition key you used to specify the control condition, presumably one of 'PD', 'RD', or 'TN'.

I updated the README.md to reflect this.

Let me know if this works!

@skytguuu
Copy link
Author

Hi,

Thank you for your help. I tried to use the command "fs.pp.determine_differentially_flowing_vars". But it seemed no this function.

Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'flowsig.preprocessing' has no attribute 'determine_differentially_flowing_vars'

It seemed I need to update the package, however, I tried but it failed.
Could you give me a hand?

Thanks!

@yixudong
Copy link

Hi,

Thank you for your help. I tried to use the command "fs.pp.determine_differentially_flowing_vars". But it seemed no this function.

Traceback (most recent call last): File "", line 1, in AttributeError: module 'flowsig.preprocessing' has no attribute 'determine_differentially_flowing_vars'

It seemed I need to update the package, however, I tried but it failed. Could you give me a hand?

Thanks!

Hi, I had the same problem. Did you solve it?

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

3 participants