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

AttributeError: 'tuple' object has no attribute 'dim' #6

Open
Himanshu-at-bayer opened this issue Feb 4, 2025 · 0 comments
Open

AttributeError: 'tuple' object has no attribute 'dim' #6

Himanshu-at-bayer opened this issue Feb 4, 2025 · 0 comments

Comments

@Himanshu-at-bayer
Copy link

I am currently runnine the disease critical netwrok analysis using the sample code. I have already modified the code for the group function in torch.geometric/nn/conv/hetero_conv.py

import sys from kgwas import KGWAS, KGWAS_Data

data = KGWAS_Data(data_path= "./data/")
All required data files are present.

data.load_kg()
--loading KG---
--using enformer SNP embedding--
--using random go embedding--
--using ESM gene embedding--

data.process_gwas_file()

Using ldsc weight...
ldsc_weight mean: 0.9999999999999993

run= KGWAS(data, exp_name="KGWAS")

run.load_pretrained('./data/model/KGWAS/')

df_network_weight, df_variant_interpretation, disease_critical_network = run.get_disease_critical_network( variant_threshold = 5e-8, magma_path = None, magma_threshold = 0.05, program_threshold = 0.05, K_neighbors = 3, num_cpus = 1)

Retrieving weights...

AttributeError Traceback (most recent call last)
Cell In[17], line 1
----> 1 df_network_weight, df_variant_interpretation, disease_critical_network = run.get_disease_critical_network(variant_threshold = 5e-8, magma_path = None, magma_threshold = 0.05, program_threshold = 0.05,
2 K_neighbors = 3, num_cpus = 1)

File ~/.local/lib/python3.10/site-packages/kgwas/kgwas.py:271, in KGWAS.get_disease_critical_network(self, variant_threshold, magma_path, magma_threshold, program_threshold, K_neighbors, num_cpus)
268 def get_disease_critical_network(self, variant_threshold = 5e-8,
269 magma_path = None, magma_threshold = 0.05, program_threshold = 0.05,
270 K_neighbors = 3, num_cpus = 1):
--> 271 df_network_weight = get_network_weight(self, self.data)
272 df_variant_interpretation, disease_critical_network = generate_viz(self, df_network_weight, self.data_path, variant_threshold, magma_path, magma_threshold, program_threshold, K_neighbors, num_cpus)
273 return df_network_weight, df_variant_interpretation, disease_critical_network

File ~/.local/lib/python3.10/site-packages/kgwas/utils.py:453, in get_network_weight(run, data)
450 x_dict['MolecularFunction'] = model.go_feat_mlp(x_dict['MolecularFunction'])
452 for conv in model.convs:
--> 453 x_dict = conv(x_dict, edge_index_dict,
454 return_attention_weights_dict = dict(zip(list(graph_data.edge_index_dict.keys()),
455 [True] * len(list(graph_data.edge_index_dict.keys())))),
456 return_raw_attention_weights_dict = dict(zip(list(graph_data.edge_index_dict.keys()),
457 [True] * len(list(graph_data.edge_index_dict.keys())))),
458 )
459 attention_layer = {i: j[1] for i,j in x_dict.items()}
460 attention_all_layers.append(attention_layer)

File ~/.local/lib/python3.10/site-packages/torch/nn/modules/module.py:1736, in Module._wrapped_call_impl(self, *args, **kwargs)
1734 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1735 else:
-> 1736 return self._call_impl(*args, **kwargs)

File ~/.local/lib/python3.10/site-packages/torch/nn/modules/module.py:1747, in Module._call_impl(self, *args, **kwargs)
1742 # If we don't have any hooks, we want to skip the rest of the logic in
1743 # this function, and just call forward.
1744 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1745 or _global_backward_pre_hooks or _global_backward_hooks
1746 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1747 return forward_call(*args, **kwargs)
1749 result = None
1750 called_always_called_hooks = set()

File ~/.local/lib/python3.10/site-packages/torch_geometric/nn/conv/hetero_conv.py:160, in HeteroConv.forward(self, *args_dict, **kwargs_dict)
157 if not has_edge_level_arg:
158 continue
--> 160 out = conv(*args, **kwargs)
162 if dst not in out_dict:
163 out_dict[dst] = [out]

File ~/.local/lib/python3.10/site-packages/torch/nn/modules/module.py:1736, in Module._wrapped_call_impl(self, *args, **kwargs)
1734 return self._compiled_call_impl(*args, **kwargs) # type: ignore[misc]
1735 else:
-> 1736 return self._call_impl(*args, **kwargs)

File ~/.local/lib/python3.10/site-packages/torch/nn/modules/module.py:1747, in Module._call_impl(self, *args, **kwargs)
1742 # If we don't have any hooks, we want to skip the rest of the logic in
1743 # this function, and just call forward.
1744 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks
1745 or _global_backward_pre_hooks or _global_backward_hooks
1746 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1747 return forward_call(*args, **kwargs)
1749 result = None
1750 called_always_called_hooks = set()

File ~/.local/lib/python3.10/site-packages/kgwas/conv.py:141, in GATConv.forward(self, x, edge_index, edge_attr, size, pheno_emb, return_attention_weights, return_raw_attention_weights)
139 else: # Tuple of source and target node features:
140 x_src, x_dst = x
--> 141 assert x_src.dim() == 2, "Static graphs not supported in 'GATConv'"
142 x_src = self.lin_src(x_src).view(-1, H, C)
143 if x_dst is not None:

AttributeError: 'tuple' object has no attribute 'dim'

Any idea what could be wrong here? I have modified the codes as mentioned in the previous issues but still no luck :(

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

1 participant