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

Clarification of handling multiple samples in cell2cell #61

Open
georginaalbadri opened this issue Aug 8, 2024 · 1 comment
Open

Clarification of handling multiple samples in cell2cell #61

georginaalbadri opened this issue Aug 8, 2024 · 1 comment

Comments

@georginaalbadri
Copy link

Hello,

I have used tensor-cell2cell but currently using a dataset that doesn't have a clear context/condition to set, hence I have reverted to the previous cell2cell. I wanted to clarify whether cell2cell automatically does the interaction calculation on a per-sample basis, or if not, how it might be best to do this manually.

I believe it is not considering samples separately, since I cannot find something like 'sample_col' to feed into the SingleCellInteractions function. However this line in the tutorial is slightly ambiguous (https://github.com/earmingol/cell2cell/blob/master/examples/cell2cell/Toy-Example-SingleCellPipeline.ipynb): "It generates an interaction space containing an instance for each sample/cell type". Is this referring to the selection of a single sample in the toy example, and should I be hence running cell2cell for each sample manually? How would be best to reintegrate the sample interaction info afterwards?

Thanks a lot for any advice

@earmingol
Copy link
Owner

Hello @georginaalbadri,

In Tensor-cell2cell you can treat each sample as a context if you want to, it doesn't necessarily have to be a condition like a disease for example.

If you decide to go with cell2cell, you need to create an interaction space for each sample separately, then run the permutation for each interaction space independently. You can do this by iterating the code for each sample:

result_dict = dict()
for sample, df in adata.obs.groupby('sample_id'): # Instead of sample_id use the column name for locating your samples.
    cells = df.index.tolist()
    adata_sample = adata[cells]
    # Continue with the normal code of cell2cell, you can create a dictionary to store your interaction spaces and save the results
    # For example:
    result_dict[sample] = interactions

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