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

Easier Way to Use Custom LD? #204

Open
ttbek opened this issue Jan 2, 2023 · 6 comments
Open

Easier Way to Use Custom LD? #204

ttbek opened this issue Jan 2, 2023 · 6 comments

Comments

@ttbek
Copy link

ttbek commented Jan 2, 2023

If I'm reading the code correctly, in order to use my own LD I would need to actually change the source passed to locuszoom.js, find the calls used while populating in locuszoom.js, and then set up our own restful API server to give the json response?

Does the following match the call format used in locuszoom.js? That is, does it use the region call like that?
https://portaldev.sph.umich.edu/ld/genome_builds/GRCh37/references/1000G/populations/AFR/regions?correlation=r&chrom=X&start=67544032&stop=67544350

Is there an easier way to load from a local precalculated LD file?

Maybe customize the locuszoom.js (means loading the changed version from our server instead of the currently set source) by changing their populate function?

I'm a bit unsure what the best approach would be here. Preferably we would also still be able to load the 1000 genomes LD values but we want to also display some custom ones.

@abought
Copy link
Member

abought commented Jan 2, 2023 via email

@ttbek
Copy link
Author

ttbek commented Feb 27, 2023

Sorry for taking so long to get back to this. I'm attempting to setup the server and I'm getting some output from the Raremetal one, but the ld server is just giving: "The connection was reset"

Output is looking like this:

sudo docker-compose down && sudo docker-compose up
Removing ldserver_ldserver_1 ... done
Removing ldserver_raremetal_1 ... done
Removing ldserver_redis_1 ... done
Creating ldserver_redis_1 ... done
Creating network "ldserver_default" with the default driver
Creating ldserver_redis_1 ...
Creating ldserver_ldserver_1 ... done
Creating ldserver_raremetal_1 ... done
Attaching to ldserver_redis_1, ldserver_raremetal_1, ldserver_ldserver_1
ldserver_1 | Running startup flask add commands...
raremetal_1 | [2023-02-27 15:42:11,078] INFO in model: Added genotype file: var/ALL.chr22.phase3_shapeit2_mvncall_integrated_v5.20130502.genotypes.bcf
raremetal_1 | [2023-02-27 15:42:11 +0000] [1] [INFO] Starting gunicorn 20.1.0
raremetal_1 | [2023-02-27 15:42:11 +0000] [1] [INFO] Listening at: http://0.0.0.0:4545 (1)
raremetal_1 | [2023-02-27 15:42:11 +0000] [1] [INFO] Using worker: gthread
raremetal_1 | [2023-02-27 15:42:11 +0000] [12] [INFO] Booting worker with pid: 12
raremetal_1 | [2023-02-27 15:42:12 +0000] [13] [INFO] Booting worker with pid: 13

So the only think coming from the LD container is that it is running the startup commands. I'm not seeing anything problematic in the gunicorn or Redis logs (I think at least). Do we expect the startup commands to take a long time? That is, am I just being too impatient and I'll probably get different output when it is ready, or is there probably a problem?

@ttbek
Copy link
Author

ttbek commented Feb 28, 2023

Is gunicorn supposed to be running on 8000? The .env I have says 4546 and docker is mapping 4546, but the gunicorn log has this:

[2023-02-27 15:42:24 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2023-02-27 15:42:24 +0000] [1] [INFO] Using worker: gevent
[2023-02-27 15:42:24 +0000] [32] [INFO] Booting worker with pid: 32
[2023-02-27 15:42:24 +0000] [33] [INFO] Booting worker with pid: 33

My .env file:

LDSERVER_PORT=4546
LDSERVER_CONFIG_SCRIPT=/home/ldserver/startup.sh
LDSERVER_WORKERS=2
RAREMETAL_CONFIG_DATA=var/config.yaml
RAREMETAL_WORKERS=2
RAREMETAL_PORT=4545
OMP_NUM_THREADS=2
OPENBLAS_NUM_THREADS=2

@ttbek
Copy link
Author

ttbek commented Feb 28, 2023

Ah... the example docker override file wasn't putting the port even though they showed modifying the command, so changing from this:

  gunicorn -b 0.0.0.0 -w $$LDSERVER_WORKERS -k gevent \
    --access-logfile /data/logs/gunicorn.access.log \
    --error-logfile /data/logs/gunicorn.error.log \
    --pythonpath rest 'ldserver:create_app()'"

to this:

  gunicorn -b 0.0.0.0:4546 -w $$LDSERVER_WORKERS -k gevent \
    --access-logfile /data/logs/gunicorn.access.log \
    --error-logfile /data/logs/gunicorn.error.log \
    --pythonpath rest 'ldserver:create_app()'"

Allows me to reach the endpoints http://localhost:8084/correlations (8084 is the locally mapped ssh forwarded port, it is localhost:4546 on the server side) and http://localhost:8084/genome_builds with the expected results. However, something like http://localhost:8084/genome_builds/GRCh37/references/1000G/populations/AFR/regions?correlation=r&chrom=20&start=60343&stop=65000 gives me "Internal Server Error" and looking in the gunicorn log on the server shows:

[2023-02-28 10:07:15,376] ERROR in app: Exception on /genome_builds/GRCh37/references/1000G/populations/AFR/regions [GET]
Traceback (most recent call last):
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ldserver/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/ldserver/rest/ldserver/api.py", line 165, in get_region_ld
ldserver.compute_region_ld(str(args['chrom']), args['start'], args['stop'], correlation_type(args['correlation']), result, str(population_name))
RuntimeError: Error while reading a cell from Redis cache

The Redis log shows:

1:C 28 Feb 2023 10:19:52.343 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 28 Feb 2023 10:19:52.343 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 28 Feb 2023 10:19:52.343 # Configuration loaded
1:M 28 Feb 2023 10:19:52.346 * Running mode=standalone, port=6379.
1:M 28 Feb 2023 10:19:52.346 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 28 Feb 2023 10:19:52.346 # Server initialized
1:M 28 Feb 2023 10:19:52.347 * DB loaded from disk: 0.000 seconds
1:M 28 Feb 2023 10:19:52.347 * Ready to accept connections

I did take a shot at fixing that warning earlier and currently if I:

cat /proc/sys/net/core/somaxconn
512

Well, it looks fixed there. Maybe this parameter needs to be done inside the container? I thought it was a kernel parameter and would be outside though. It was originally 128 as the message suggests, but it has been changed to 512 and Redis has been restarted several times since then. I don't think that would be the issue, but it's all the Redis log is complaining about.

@ttbek
Copy link
Author

ttbek commented Feb 28, 2023

Turns out the container may be more restricted than the kernel value, but it can be set in the dockerfile, so I added:

sysctls:
  net.core.somaxconn: 512

To the section for the alpine Redis image. It fixes that last warning in the Redis log... but no dice on the error in the gunicorn log, still get it.

@ttbek
Copy link
Author

ttbek commented Feb 28, 2023

Ah, ok, ok,

warning For docker, you must change CACHE_REDIS_HOSTNAME to redis.

For some reason I read this as changing the left side, to redis, that is the text 'CACHE_REDIS_HOSTNAME' to the text 'redis'. I know, makes no sense. Fixed now. So I guess the next step is that I need to move my Pheweb over to the production server and... point it to this new LD server somehow.

Regarding available LD Panels, true indeed. Unfortunately we aren't putting out a new data set with this. The population in our Pheweb is Arab and not well represented in 1KG, so even though it is small we wanted to also show the LD from the 108 Qatari genomes published here: https://genome.cshlp.org/content/26/2/151.full.html They're publicly available on the Sequence Read Archive, just need to use the toolkit to download them due to the size.

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