cellink.tl.external.check_and_patch_ldsc_parse_bug#
- cellink.tl.external.check_and_patch_ldsc_parse_bug(runner)#
Check whether the LDSC installation has the pandas column-sort bug and patch it.
See ldsc issue #342 / PR #341.
The bug:
pd.concatinldscore/parse.pyalphabetically re-sorts annotation columns afterpd.concatacross chromosomes inldscore/parse.py(line ~147), causing_check_variance()to raise anIndexErrorduring--h2 --overlap-annot.The fix (PR #341): reindex the concatenated DataFrame to the column order of the first chromosome file:
pd.concat(chr_ld)[chr_ld[0].columns].Works for local, Docker and Singularity execution modes.
Configuration — add
parse_scriptto your runner config so cellink knows exactly whereparse.pylives, especially for containerised setups:runner = configure_ldsc_runner( config_dict={ "execution_mode": "singularity", "singularity_image": "/path/to/ldsc.sif", "ldsc_command": "ldsc.py", "parse_script": "/ldsc/ldscore/parse.py", # ← explicit path } )
If
parse_scriptis omitted, cellink tries to auto-discover the path fromPATH(works for local installs; may fail for containers).Behaviour by mode#
local — patches
parse.pyon disk and backs up the original asparse.py.bak.docker — patches the file inside the image via
docker cp+docker commit. The image is updated in-place and the patch survives container restarts.singularity — SIF images are read-only, so cellink writes the patched
parse.pyto a host-side shadow directory (default:~/.cellink/ldsc_patch/ldscore/) and injectsPYTHONPATH=<shadow>:$PYTHONPATHinto every subsequentldsc.pycall. Setldsc_patch_shadow_dirin the runner config to override the shadow location.
- type runner:
- param runner:
A configured
LDSCRunnerinstance.- rtype:
- returns:
dict with keys:
"status"—"already_patched","patched","patch_failed"or"not_found""mode"—"local","docker"or"singularity""parse_path"— resolved path toparse.py(or None)"detail"— human-readable explanation