Skip to content
Open

Skat #64

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ RUN git clone https://github.com/froelich/sf-relate . && \
rm -rf .git


# -------------------- sf-skat -------------------- #
FROM go AS sf-skat

RUN git clone https://github.com/swanhong/secure-skat . && \
git checkout b79ed20 && \
go build -o secure-rvas secure-rvas.go && \
rm -rf .git


# -------------------- sfkit-proxy -------------------- #
FROM go AS sfkit-proxy

Expand Down Expand Up @@ -201,7 +210,7 @@ RUN microdnf install -y proxychains-ng && \

ENV HOME=${WORK} \
OPENSSL_FORCE_FIPS_MODE=1 \
PATH="${WORK}/.venv/bin:$PATH:${WORK}:${WORK}/sfgwas:${WORK}/sf-relate:${WORK}/sfgwas-lmm/scripts" \
PATH="${WORK}/.venv/bin:$PATH:${WORK}:${WORK}/sfgwas:${WORK}/sf-relate:${WORK}/sfgwas-lmm/scripts:${WORK}/sf-skat" \
PYTHONPATH="${WORK}/.venv/lib/python3.12/site-packages:${WORK}/.venv/lib64/python3.12/site-packages" \
PYTHONUNBUFFERED=TRUE \
PYTHONWARNINGS="ignore:pkg_resources is deprecated as an API:UserWarning" \
Expand All @@ -215,6 +224,7 @@ COPY --from=secure-gwas --chown=$USER ${WORK} ./secure-gwas/
COPY --from=sfgwas --chown=$USER ${WORK} ./sfgwas/
COPY --from=sfgwas-lmm --chown=$USER ${WORK} ./sfgwas-lmm/
COPY --from=sf-relate --chown=$USER ${WORK} ./sf-relate/
COPY --from=sf-skat --chown=$USER ${WORK}/*-rvas ./sf-skat/
COPY --from=sfkit-proxy --chown=$USER ${WORK}/*-proxy ./

COPY --from=sfkit --chown=$USER ${WORK}/dist/sfkit*.whl ./
Expand Down
4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ rm -rf ~/.local/sf-relate && mv sf-relate ~/.local/
rm -rf ~/.local/secure-dti && mv secure-dti ~/.local/
rm -rf ~/.local/secure-gwas && mv secure-gwas ~/.local/
rm -rf ~/.local/sfgwas-lmm && mv sfgwas-lmm ~/.local/
rm -rf ~/.local/sf-skat && mv sf-skat ~/.local/
echo

# check if ldd version is at least 2.34
glibc_minor_ver=$(ldd --version | awk 'NR==1{print $NF}' | cut -d. -f2)
if [ "${glibc_minor_ver}" -lt 34 ]; then
echo Patching sfkit binaries...
mkdir -p ~/.local/lib/ && mv lib/* ~/.local/lib/
for p in ~/.local/bin/sfkit-proxy ~/.local/sfgwas/sfgwas ~/.local/sf-relate/sf-relate ~/.local/secure-dti/mpc/code/bin/* ~/.local/secure-gwas/code/bin/* ; do
for p in ~/.local/bin/sfkit-proxy ~/.local/sfgwas/sfgwas ~/.local/sf-relate/sf-relate ~/.local/sf-skat/secure-rvas ~/.local/secure-dti/mpc/code/bin/* ~/.local/secure-gwas/code/bin/* ; do
patchelf --set-interpreter ~/.local/lib/ld-linux-x86-64.so.2 "$p"
done
echo
Expand All @@ -90,6 +91,7 @@ $PWD/.venv/bin:\
\$HOME/.local/sfgwas:\
\$HOME/.local/sfgwas-lmm:\
\$HOME/.local/sf-relate:\
\$HOME/.local/sf-skat:\
\$HOME/.local/secure-dti/mpc/code/bin:\
\$HOME/.local/secure-gwas/code/bin\
\"" >> "$rc"
Expand Down
57 changes: 57 additions & 0 deletions sfkit/protocol/register_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def register_data(
data_path = validate_sfrelate(doc_ref_dict, username, data_path, role)
elif study_type == "Secure-DTI":
data_path = validate_dti(doc_ref_dict, username, data_path, role)
elif study_type == "SF-SKAT":
data_path = validate_skat(doc_ref_dict, username, data_path, role)
else:
raise ValueError(f"Unknown study type: {study_type}")

Expand Down Expand Up @@ -288,6 +290,61 @@ def validate_dti(doc_ref_dict: dict, username: str, data_path: str, role: str) -
return data_path


def validate_skat(
doc_ref_dict: dict, username: str, data_path: str, role: str
) -> str:
"""
Validate data for the SF-SKAT workflow.

SF-SKAT does not run data preparation itself: data_path must already contain
a `prepared/` directory tree produced by running `secure-rvas prepare`
out-of-band (see https://github.com/swanhong/secure-skat). data_path is the
directory that *contains* `prepared/` (i.e. secure-rvas's `run_dir`).

Only called for roles 1 (Cohort A) and 2 (Cohort B) -- role 0 (auxiliary)
holds no data and never reaches this function.
"""
data_path = validate_data_path(data_path)

if data_path == "demo" or (constants.IS_DOCKER and doc_ref_dict["demo"]):
using_demo()

ancestries = [
a.strip()
for a in doc_ref_dict["parameters"]["ancestries"]["value"].split(",")
if a.strip()
]
chromosomes = [
c.strip()
for c in doc_ref_dict["parameters"]["chromosomes"]["value"].split(",")
if c.strip()
]
cohort = "A" if role == "1" else "B"

for ancestry in ancestries:
for chromosome in chromosomes:
chr_dir = os.path.join(data_path, "prepared", ancestry, f"chr{chromosome}")
condition_or_fail(
os.path.isfile(os.path.join(chr_dir, "genes.txt")),
f"Could not find {chr_dir}/genes.txt",
)
condition_or_fail(
os.path.isfile(os.path.join(chr_dir, "block_sizes.txt")),
f"Could not find {chr_dir}/block_sizes.txt",
)
cohort_dir = os.path.join(chr_dir, cohort)
condition_or_fail(
os.path.isfile(os.path.join(cohort_dir, "cov.txt")),
f"Could not find {cohort_dir}/cov.txt",
)
condition_or_fail(
os.path.isfile(os.path.join(cohort_dir, "pheno.txt")),
f"Could not find {cohort_dir}/pheno.txt",
)

return data_path


def validate_geno_binary_file_prefix(geno_binary_file_prefix: str) -> str:
if not geno_binary_file_prefix:
if constants.IS_DOCKER and os.path.exists("/data/geno"):
Expand Down
3 changes: 3 additions & 0 deletions sfkit/protocol/run_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from sfkit.utils.sfgwas_lmm_protocol import run_sfgwas_lmm_protocol
from sfkit.utils.sfgwas_protocol import run_sfgwas_protocol
from sfkit.utils.sfrelate_protocol import run_sfrelate_protocol
from sfkit.utils.sfskat_protocol import run_sfskat_protocol


def run_protocol(
Expand Down Expand Up @@ -93,6 +94,8 @@ def run_protocol(
run_sfrelate_protocol(role, demo)
elif study_type == "Secure-DTI":
run_dti_protocol(role, demo)
elif study_type == "SF-SKAT":
run_sfskat_protocol(role, demo)
else:
raise ValueError(f"Unknown study type: {study_type}")
else:
Expand Down
2 changes: 1 addition & 1 deletion sfkit/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_installed(binary: str) -> bool:
if os.environ.get("PATH"):
os.environ[
"PATH"
] += f":{EXECUTABLES_PREFIX}bin:{EXECUTABLES_PREFIX}sfgwas:{EXECUTABLES_PREFIX}sf-relate:{EXECUTABLES_PREFIX}secure-gwas/code/bin"
] += f":{EXECUTABLES_PREFIX}bin:{EXECUTABLES_PREFIX}sfgwas:{EXECUTABLES_PREFIX}sf-relate:{EXECUTABLES_PREFIX}sf-skat:{EXECUTABLES_PREFIX}secure-gwas/code/bin"

SFKIT_PREFIX = "sfkit: "
OUT_FOLDER = os.path.join(os.environ.get("SFKIT_DIR", ""), "out")
Expand Down
Loading
Loading