broadinstitute / tensorqtl

Ultrafast GPU-enabled QTL mapper
BSD 3-Clause "New" or "Revised" License
160 stars 52 forks source link

Interaction mode #49

Closed Angela-Jones closed 2 years ago

Angela-Jones commented 3 years ago

Hello! I'm running into issues with the interaction model through both Python and CLI. I've successfully run both the cis and cis_nominal versions of tensorQTL with the same exact files I'm attempting to use for interaction.

My interaction file looks like this, where there are two columns (tab-delim) with individuals in the first column and a binary assignment in a second column. The individuals are in the same order as in the phenotype file.

HG01507 0 HG01518 1 HG01519 0 HG01530 1 HG01531 0 NA19379 0 NA19391 0 NA19399 0 NA19430 1

When I run the example command in Python, I get the following error:

Traceback (most recent call last): File "", line 1, in File "/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/cis.py", line 188, in map_nominal mask_s[interaction_s.sort_values(kind='mergesort').index[:interaction_s.shape[0]//2]] = False File "/tensorqtl/venv/lib/python3.8/site-packages/pandas/util/_decorators.py", line 311, in wrapper return func(*args, **kwargs) TypeError: sort_values() missing 1 required positional argument: 'by'

When I run the example command in CLI, I get this error instead:

/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/eigenmt.py:101: UserWarning: torch.symeig is deprecated in favor of torch.linalg.eigh and will be removed in a future PyTorch release. The default behavior has changed from using the upper triangular portion of the matrix by default to using the lower triangular portion. L, _ = torch.symeig(A, upper=upper) should be replaced with L = torch.linalg.eigvalsh(A, UPLO='U' if upper else 'L') and L, V = torch.symeig(A, eigenvectors=True) should be replaced with L, V = torch.linalg.eigh(A, UPLO='U' if upper else 'L') (Triggered internally at ../aten/src/ATen/native/BatchLinearAlgebra.cpp:2499.) eigenvaluest, = torch.symeig(shrunk_cor_t, eigenvectors=False) Traceback (most recent call last): File "/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/core.py", line 164, in calculate_interaction_nominal Xinv = torch.matmul(torch.transpose(X_t, 1, 2), X_t).inverse() # ng x 3 x 3 RuntimeError: inverse_cpu: (Batch element 227): The diagonal element 3 is zero, the inversion could not be completed because the input matrix is singular. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/apps/rhel8/Anaconda3-2021.05/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/apps/rhel8/Anaconda3-2021.05/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/main.py", line 2, in tensorqtl.main() File "/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/tensorqtl.py", line 119, in main cis.map_nominal(genotype_df, variant_df, phenotype_df, phenotype_pos_df, args.prefix, covariates_df=covariates_df, File "/tensorqtl/venv/lib/python3.8/site-packages/tensorqtl/cis.py", line 264, in map_nominal res = calculate_interaction_nominal(genotypes_t, phenotype_t.unsqueeze(0), interaction_t, File "/venv/lib/python3.8/site-packages/tensorqtl/core.py", line 167, in calculate_interaction_nominal i = int(re.findall('For batch (\d+)', str(e))[0]) IndexError: list index out of range

If anyone has any ideas, that would be amazing! I'm very stuck.

francois-a commented 2 years ago

Hi, are you able to share an example dataset that reproduces this issue? Based on the following line in the error message above: The diagonal element 3 is zero, the inversion could not be completed because the input matrix is singular. it looks like this is a problem with the input data, possibly the genotype dosages.