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

Support for combinations of gene activation and repression #12

Closed
giladmishne opened this issue Mar 25, 2023 · 4 comments
Closed

Support for combinations of gene activation and repression #12

giladmishne opened this issue Mar 25, 2023 · 4 comments

Comments

@giladmishne
Copy link

Hi,

Thanks for releasing this package! One addition that would be great would be support for datasets that contain combinations of activations and repressions, including within the same perturbation. My understanding from @yhr91 is that this is not currently supported, but is not complex to add.

Thanks again!

@yhr91
Copy link
Collaborator

yhr91 commented Mar 25, 2023

Hi @giladmishne,

Thanks for raising this issue. Sharing below a quick solution to this problem but feel free to try other ideas.

First allow perturbation embeddings to be added or subtracted. This is currently the line where each perturbation's embedding is added together:

GEARS/gears/model.py

Lines 159 to 160 in aa1e003

if j.item() in pert_track:
pert_track[j.item()] = pert_track[j.item()] + pert_global_emb[pert_index[1][i]]

pert_index[1][i] is just the index of the gene that is being perturbed. One simple solution could be to include a sign in that index which indicates whether the perturbation is an activation or a repression and then change the sign of the operation in line 160 accordingly. Perhaps something like:

pert_track[j.item()] = pert_track[j.item()] + (torch.sign(pert_index[1][i]) * pert_global_emb[pert_index[1][i]])

Then change how the signed indices are generated. Somewhere around this function, we would need to check the input adata to see if the perturbation is an activation or a repression and change the index accordingly:

GEARS/gears/pertdata.py

Lines 285 to 289 in aa1e003

def get_pert_idx(self, pert_category, adata_):
try:
pert_idx = [np.where(p == self.pert_names)[0][0]
for p in pert_category.split('+')
if p != 'ctrl']

@giladmishne
Copy link
Author

giladmishne commented Jun 7, 2023

Thanks! I have a sketch of this at https://github.com/giladmishne/GEARS/tree/pert_magnitude.

(Many of the changes are just trimmed whitespace by the editor I'm using -- apologies for the noise).

@yhr91
Copy link
Collaborator

yhr91 commented Jun 13, 2023

Thanks a lot! Would you mind opening a PR as well so we it's easier to track the discussion and compare changes

@giladmishne
Copy link
Author

Done - see #17 .

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