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

fix missing reverse-complement in reference sequence fetching for APARENT #336

Merged
merged 3 commits into from
Jul 4, 2022

Conversation

Hoeze
Copy link
Member

@Hoeze Hoeze commented Jun 12, 2022

Ensure that the ref-sequence is reverse-complemented

@Hoeze Hoeze requested a review from Karollus June 12, 2022 16:44
@Hoeze Hoeze self-assigned this Jun 12, 2022
@Hoeze
Copy link
Member Author

Hoeze commented Jun 24, 2022

@haimasree should we just merge this?
I guess it will change the testing predictions as well.

@haimasree
Copy link
Contributor

haimasree commented Jun 24, 2022

By all means! I did not intervene since Alex was assigned. The tests are passing so completely fine by me. I just merged the master branch. Lets see if the tests are still passing.

@haimasree
Copy link
Contributor

haimasree commented Jun 24, 2022

Tests are passing it seems. Do you think this is wrong?

@Hoeze
Copy link
Member Author

Hoeze commented Jun 24, 2022

Hm, this is super strange:
Depending on whether I run the tests in pycharm or in the terminal I get different results.

Running the test in pycharm fails:

image

/opt/anaconda/envs/kipoi-env/bin/python -m kipoi test . --batch_size=10 --source=dir
INFO [kipoi.data] Using user specified dataloader from LocalSource(local_path='/home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff')
INFO [kipoi.data] successfully loaded the dataloader ././ from /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/dataloader.py::Kipoi_APARENT_DL
INFO [kipoi.model] Downloading model arguments weights from https://github.com/johli/aparent/raw/8a884f0bc4073ed0edd588f71b61a5be4a37e831/saved_models/aparent_large_lessdropout_all_libs_no_sampleweights.h5
Using downloaded and verified file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/weights/31902fb40125679e655b8b6d2747ada7
2022-06-24 14:58:13.115952: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO [kipoi.pipeline] dataloader.output_schema is compatible with model.schema
INFO [kipoi.pipeline] Initialized data generator. Running batches...
INFO [kipoi.specs] Example file for argument fasta_file already exists
INFO [kipoi.specs] Example file for argument gtf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file_tbi already exists
0it [00:00, ?it/s]INFO [kipoi.pipeline] Returned data schema correct
42it [00:01, 35.43it/s]
  0%|          | 0/41 [00:00<?, ?it/s]INFO [kipoi.pipeline] predict_example done!
Using downloaded and verified file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/test.expect.h5
INFO [kipoi.cli.main] Testing if the predictions match the expected ones in the file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/test.expect.h5
INFO [kipoi.cli.main] Desired precision (number of matching decimal places): 4
ERROR [kipoi.cli.main] Model predictions don't match the expected predictions.expected: {'delta_logit_distal_prop': array([-0.19702771,  0.02928352, -0.3722965 , -0.56518483, -0.01937383,
        0.23025364,  0.00450336, -0.01738143,  0.14959788, -0.08235216],
      dtype=float32), 'delta_logit_proximal_prop': array([ 0.19702804, -0.02928317,  0.37229604,  0.5651839 ,  0.01937395,
       -0.23025393, -0.00450304,  0.01738191, -0.14959908,  0.08235168],
      dtype=float32)}
observed: {'delta_logit_distal_prop': array([-0.19702801,  0.02928424, -0.372297  , -0.56518483, -0.01937269,
        0.2302545 ,  0.00450469, -0.01738   ,  0.14959931, -0.08235478],
      dtype=float32), 'delta_logit_proximal_prop': array([ 0.19702807, -0.02928376,  0.37229654,  0.5651847 ,  0.01937279,
       -0.23025477, -0.00450442,  0.01738119, -0.14960003,  0.08235312],
      dtype=float32)}. Exception: 
Arrays are not almost equal to 7 decimals

Mismatched elements: 9 / 10 (90%)
Max absolute difference: 2.6226044e-06
Max relative difference: 0.00029449
 x: array([-0.197028 ,  0.0292842, -0.372297 , -0.5651848, -0.0193727,
        0.2302545,  0.0045047, -0.01738  ,  0.1495993, -0.0823548],
      dtype=float32)
 y: array([-0.1970277,  0.0292835, -0.3722965, -0.5651848, -0.0193738,
        0.2302536,  0.0045034, -0.0173814,  0.1495979, -0.0823522],
      dtype=float32)
  0%|          | 0/41 [00:00<?, ?it/s]

Process finished with exit code 1

Running it in the terminal works:

(kipoi-env) █▓▒░hoelzlwimmerf@desktop01░▒▓██▓▒░ Fr Jun 24 02:57:50
/home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff> /opt/anaconda/envs/kipoi-env/bin/python -m kipoi test . --batch_size=10 --source=dir
INFO [kipoi.data] Using user specified dataloader from LocalSource(local_path='/home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff')
INFO [kipoi.data] successfully loaded the dataloader ././ from /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/dataloader.py::Kipoi_APARENT_DL
INFO [kipoi.model] Downloading model arguments weights from https://github.com/johli/aparent/raw/8a884f0bc4073ed0edd588f71b61a5be4a37e831/saved_models/aparent_large_lessdropout_all_libs_no_sampleweights.h5
Using downloaded and verified file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/weights/31902fb40125679e655b8b6d2747ada7
2022-06-24 14:58:24.009335: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO [kipoi.pipeline] dataloader.output_schema is compatible with model.schema
INFO [kipoi.pipeline] Initialized data generator. Running batches...
INFO [kipoi.specs] Example file for argument fasta_file already exists
INFO [kipoi.specs] Example file for argument gtf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file_tbi already exists
INFO [kipoi.pipeline] Returned data schema correct
42it [00:01, 35.64it/s]
INFO [kipoi.pipeline] predict_example done!
Using downloaded and verified file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/test.expect.h5
INFO [kipoi.cli.main] Testing if the predictions match the expected ones in the file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/test.expect.h5
INFO [kipoi.cli.main] Desired precision (number of matching decimal places): 4
  0%|                                                                                                                                                                                                                                                                                                                                                                 | 0/41 [00:00<?, ?it/s]false for key =  delta_logit_distal_prop
  2%|████████▍                                                                                                                                                                                                                                                                                                                                                | 1/41 [00:00<00:12,  3.30it/s]false for key =  delta_logit_distal_prop
  5%|████████████████▊                                                                                                                                                                                                                                                                                                                                        | 2/41 [00:00<00:11,  3.38it/s]false for key =  delta_logit_distal_prop
  7%|█████████████████████████▏                                                                                                                                                                                                                                                                                                                               | 3/41 [00:00<00:11,  3.42it/s]false for key =  delta_logit_distal_prop
 10%|█████████████████████████████████▋                                                                                                                                                                                                                                                                                                                       | 4/41 [00:01<00:10,  3.44it/s]false for key =  delta_logit_distal_prop
 12%|██████████████████████████████████████████                                                                                                                                                                                                                                                                                                               | 5/41 [00:01<00:10,  3.41it/s]false for key =  delta_logit_distal_prop
 15%|██████████████████████████████████████████████████▍                                                                                                                                                                                                                                                                                                      | 6/41 [00:01<00:10,  3.43it/s]false for key =  delta_logit_distal_prop
 17%|██████████████████████████████████████████████████████████▉                                                                                                                                                                                                                                                                                              | 7/41 [00:02<00:10,  3.39it/s]false for key =  delta_logit_distal_prop
 20%|███████████████████████████████████████████████████████████████████▎                                                                                                                                                                                                                                                                                     | 8/41 [00:02<00:09,  3.39it/s]false for key =  delta_logit_distal_prop
 22%|███████████████████████████████████████████████████████████████████████████▋                                                                                                                                                                                                                                                                             | 9/41 [00:02<00:09,  3.37it/s]false for key =  delta_logit_distal_prop
 24%|███████████████████████████████████████████████████████████████████████████████████▉                                                                                                                                                                                                                                                                    | 10/41 [00:02<00:09,  3.33it/s]false for key =  delta_logit_distal_prop
 27%|████████████████████████████████████████████████████████████████████████████████████████████▎                                                                                                                                                                                                                                                           | 11/41 [00:03<00:08,  3.35it/s]false for key =  delta_logit_distal_prop
 29%|████████████████████████████████████████████████████████████████████████████████████████████████████▋                                                                                                                                                                                                                                                   | 12/41 [00:03<00:08,  3.38it/s]false for key =  delta_logit_distal_prop
 32%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                                                                                                                                                                                                           | 13/41 [00:03<00:08,  3.33it/s]false for key =  delta_logit_distal_prop
 34%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                                                                                                                                                                                                                                  | 14/41 [00:04<00:08,  3.35it/s]false for key =  delta_logit_distal_prop
 37%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                                                                                                                                                                                                          | 15/41 [00:04<00:07,  3.30it/s]false for key =  delta_logit_distal_prop
 39%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                                                                                                                                                                                                 | 16/41 [00:04<00:07,  3.31it/s]false for key =  delta_logit_distal_prop
 41%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋                                                                                                                                                                                                         | 17/41 [00:05<00:07,  3.36it/s]false for key =  delta_logit_distal_prop
 44%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                                                                                                                                                                 | 18/41 [00:05<00:06,  3.37it/s]false for key =  delta_logit_distal_prop
 46%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                                                                                                                                                                                        | 19/41 [00:05<00:06,  3.37it/s]false for key =  delta_logit_distal_prop
 49%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                                                                                                                                                                | 20/41 [00:05<00:06,  3.38it/s]false for key =  delta_logit_distal_prop
 51%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                                                                                                                                                       | 21/41 [00:06<00:05,  3.39it/s]false for key =  delta_logit_distal_prop
 54%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                                                                                                                               | 22/41 [00:06<00:05,  3.37it/s]false for key =  delta_logit_distal_prop
 56%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉                                                                                                                                                       | 23/41 [00:06<00:05,  3.40it/s]false for key =  delta_logit_distal_prop
 59%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎                                                                                                                                              | 24/41 [00:07<00:05,  3.38it/s]false for key =  delta_logit_distal_prop
 61%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                                                                                                                                      | 25/41 [00:07<00:04,  3.40it/s]false for key =  delta_logit_distal_prop
 63%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                                                                                                             | 26/41 [00:07<00:04,  3.42it/s]false for key =  delta_logit_distal_prop
 66%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌                                                                                                                     | 27/41 [00:07<00:04,  3.43it/s]false for key =  delta_logit_distal_prop
 68%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉                                                                                                             | 28/41 [00:08<00:03,  3.44it/s]false for key =  delta_logit_distal_prop
 71%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎                                                                                                    | 29/41 [00:08<00:03,  3.45it/s]false for key =  delta_logit_distal_prop
 73%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋                                                                                            | 30/41 [00:08<00:03,  3.45it/s]false for key =  delta_logit_distal_prop
 76%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                                                                    | 31/41 [00:09<00:02,  3.45it/s]false for key =  delta_logit_distal_prop
 78%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                                                                           | 32/41 [00:09<00:02,  3.37it/s]false for key =  delta_logit_distal_prop
 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉                                                                   | 33/41 [00:09<00:02,  3.35it/s]false for key =  delta_logit_distal_prop
 83%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎                                                          | 34/41 [00:10<00:02,  3.36it/s]false for key =  delta_logit_distal_prop
 85%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋                                                  | 35/41 [00:10<00:01,  3.36it/s]false for key =  delta_logit_distal_prop
 88%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████                                          | 36/41 [00:10<00:01,  3.37it/s]false for key =  delta_logit_distal_prop
 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                                 | 37/41 [00:10<00:01,  3.35it/s]false for key =  delta_logit_distal_prop
 93%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊                         | 38/41 [00:11<00:00,  3.39it/s]false for key =  delta_logit_distal_prop
 95%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                | 39/41 [00:11<00:00,  3.40it/s]false for key =  delta_logit_distal_prop
 98%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌        | 40/41 [00:11<00:00,  3.41it/s]false for key =  delta_logit_distal_prop
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 41/41 [00:12<00:00,  3.39it/s]false for key =  delta_logit_distal_prop
42it [00:12,  3.38it/s]                                                                                                                                                                                                                                                                                                                                                                      
INFO [kipoi.cli.main] All predictions match
INFO [kipoi.cli.main] Successfully ran test_predict

How is that possible?


@haimasree can we somehow obtain the testing predictions?
Adding -o /tmp/APARENT.veff.predictions.hdf5 skips the prediction comparison:

/opt/anaconda/envs/kipoi-env/bin/python -m kipoi test . --batch_size=10 --source=dir -o /tmp/APARENT.veff.predictions.hdf5
INFO [kipoi.data] Using user specified dataloader from LocalSource(local_path='/home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff')
INFO [kipoi.data] successfully loaded the dataloader ././ from /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/dataloader.py::Kipoi_APARENT_DL
INFO [kipoi.model] Downloading model arguments weights from https://github.com/johli/aparent/raw/8a884f0bc4073ed0edd588f71b61a5be4a37e831/saved_models/aparent_large_lessdropout_all_libs_no_sampleweights.h5
Using downloaded and verified file: /home/hoelzlwimmerf/Projects/kipoi/kipoi-models/APARENT/veff/downloaded/model_files/weights/31902fb40125679e655b8b6d2747ada7
2022-06-24 15:08:11.312341: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
INFO [kipoi.pipeline] dataloader.output_schema is compatible with model.schema
INFO [kipoi.pipeline] Initialized data generator. Running batches...
INFO [kipoi.specs] Example file for argument fasta_file already exists
INFO [kipoi.specs] Example file for argument gtf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file already exists
INFO [kipoi.specs] Example file for argument vcf_file_tbi already exists
INFO [kipoi.pipeline] Returned data schema correct
42it [00:01, 34.07it/s]
INFO [kipoi.pipeline] predict_example done!
INFO [kipoi.cli.main] Successfully ran test_predict

@haimasree
Copy link
Contributor

haimasree commented Jun 24, 2022

Okay this is indeed strange.
To answer @haimasree can we somehow obtain the testing predictions?
Do you mean how you can test /tmp/APARENT.veff.predictions.hdf5 with kipoi test cli? If yes simply do the following
Modify the test snippet to this

test: 
      expect: /tmp/APARENT.veff.predictions.hdf5
      precision_decimal: 4 (or whatever)

and kipoi test <model-name> --source=dir

@haimasree
Copy link
Contributor

haimasree commented Jun 24, 2022

@Hoeze in your pycharm version - precision_decimal is 7 which is the default value. So, somehow precision_decimal:4 is not getting honored but in your terminal version it is.

So:

Terminal: INFO [kipoi.cli.main] Desired precision (number of matching decimal places): 4
Pycharm: Arrays are not almost equal to 7 decimals

Now I dont why its like that. Any thoughts?

@haimasree
Copy link
Contributor

@Hoeze Any update on this? Shall I just merge?

@Hoeze
Copy link
Member Author

Hoeze commented Jul 4, 2022

I'll merge now, but this definitely needs more debugging.
I dont get why the predictions seem to be the same.

Still, I'm limited on time and I dont know when I can come back to this issue...

@Hoeze Hoeze merged commit ae8cf12 into kipoi:master Jul 4, 2022
@haimasree
Copy link
Contributor

haimasree commented Jul 4, 2022

Same upto 4 decimal places but not 7 ;)

bytewife pushed a commit that referenced this pull request Feb 1, 2024
fix missing reverse-complement in reference sequence fetching for APARENT
bytewife pushed a commit that referenced this pull request Feb 1, 2024
fix missing reverse-complement in reference sequence fetching for APARENT
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

Successfully merging this pull request may close these issues.

2 participants