omerwe / polyfun

PolyFun (POLYgenic FUNctionally-informed fine-mapping)
MIT License
85 stars 21 forks source link

Flag --n of finemapper.py confused `conda run -n polyfun` #174

Closed lruizcalico closed 9 months ago

lruizcalico commented 9 months ago

Hi, I created a docker image to run finemapper.py. The dockerfile is like this:

FROM condaforge/mambaforge:23.3.1-1

RUN apt-get install -y git

ARG PIP_INDEX_URL
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN git clone https://github.com/omerwe/polyfun
RUN cd polyfun
RUN mamba env create -f polyfun/polyfun.yml

RUN echo "source activate polyfun" > ~/.bashrc
ENV PATH /opt/conda/envs/myenv/bin:$PATH

# Make RUN commands use the new environment:
# SHELL ["conda", "run", "-n", "polyfun", "/bin/bash", "-c"]

ENTRYPOINT ["conda", "run", "-n", "polyfun", "python", "polyfun/finemapper.py"]

finemapper.py has a --n flag, which then confused the conda run -n and resulted in this error: conda run: error: ambiguous option: --n could match --name, --no-capture-output I changed the --n flag into --num_samples flag inside finemapper.py and it ran okay afterward. I was wondering if you could add this as an option instead of --n which can be confusing to conda run. Thank you.

jdblischak commented 9 months ago

Instead of adding "myenv" to PATH, shouldn't you add "polyfun"? That might remove the need to use conda run

ENV PATH /opt/conda/envs/polyfun/bin:$PATH
lruizcalico commented 9 months ago

Ah that's a typo. However, it is still same when I changed it to polyfun. Even without a docker image, if I just run on a console (base) with conda run -n polyfun finemapper.py --n <num_samples> it still would complain.

jdblischak commented 9 months ago

Some ideas to experiment with:

RUN echo "source activate polyfun" > ~/.bashrc
ENV PATH /opt/conda/envs/myenv/bin:$PATH
lruizcalico commented 9 months ago

This is a Dockerfile that worked for me, in case it is of interest to anyone

# Start from a base image that includes Python and R
FROM rocker/verse:4.1.3

# Install Python3 and pip

RUN apt-get -y update && \
         apt-get -y upgrade && \
         apt-get install -y python3-pip python3-dev

RUN apt-get install -y python3 python3-pip
# Update symlink to point to latest

RUN apt-get install -y git

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN git clone https://github.com/omerwe/polyfun
# Install Python dependencies
RUN python3 -m pip install --upgrade pip && \
        python3 -m pip install numpy
RUN python3 -m pip install rpy2 scipy scikit-learn pandas tqdm pyarrow bitarray pandas-plink
# Install R dependencies
RUN R -e "install.packages('remotes', repos='http://cran.rstudio.com/')"
# Install a specific version of susieR
RUN R -e "remotes::install_version('susieR', version='0.11.92', repos='http://cran.rstudio.com/')"

CMD ["/bin/bash"]

I ended up not using conda. It seems to be able to run finemapper.py just fine