greenelab / connectivity-search-backend

Django backend for hetnet connectivity search
https://search-api.het.io
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

DegreeGroupedPermutation table contains NaN values #63

Open dhimmel opened 5 years ago

dhimmel commented 5 years ago
from dj_hetmech_app.models import DegreeGroupedPermutation
instance = DegreeGroupedPermutation.objects.get(pk=23633958)
instance.__dict__

returns:

{'_state': <django.db.models.base.ModelState at 0x7f39aeb78550>,
 'id': 23633958,
 'metapath_id': 'CrCuGaD',
 'source_degree': 0,
 'target_degree': 540,
 'n_dwpcs': 54200,
 'n_nonzero_dwpcs': 0,
 'nonzero_mean': nan,
 'nonzero_sd': nan}

Notice how nonzero_mean and nonzero_sd are nan. I was expecting missing values to be None here, which would help with JSON encoding.

We double checked this occurs in the database:

SELECT * FROM dj_hetmech_app_degreegroupedpermutation WHERE id=23633958;
    id    | source_degree | target_degree | n_dwpcs | n_nonzero_dwpcs | nonzero_mean | nonzero_sd | metapath_id 
----------+---------------+---------------+---------+-----------------+--------------+------------+-------------
 23633958 |             0 |           540 |   54200 |               0 |          NaN |        NaN | CrCuGaD
(1 row)

Related to the following API call http://localhost:8000/v1/query-paths/?target=17054&source=6602&metapath=DaGuCrC

dhimmel commented 4 years ago

Current API call https://search-api.het.io/v1/paths/source/6602/target/17054/metapath/DaGuCrC/ returns:

        "dgp_nonzero_mean": null,
        "dgp_nonzero_sd": null,

So this is fixed in terms of the backend API response, but not sure if we updated the database to replace the NaN with null.

dhimmel commented 3 years ago

After repopulating the database in #79, this issue is still present:

PGPASSWORD=tm8ut9uzqx7628swwkb9 psql \
  --username=read_only_user \
  --dbname=connectivity_db \
  --host=search-db.het.io --port=5432 \
  --command "SELECT * FROM dj_hetmech_app_degreegroupedpermutation WHERE id=23633958;"
    id    | metapath_id | source_degree | target_degree | n_dwpcs | n_nonzero_dwpcs | nonzero_mean | nonzero_sd 
----------+-------------+---------------+---------------+---------+-----------------+--------------+------------
 23633958 | CrCuGaD     |             0 |           540 |   54200 |               0 |          NaN |        NaN
(1 row)