Bridge the use of Windows conda through the reticulate package in R

When using conda in Windows operating system, it is easy to fall into a misunderstanding of visual interface, that is, installing Anaconda, an interface software in exe format.

However, our regular tutorials are based on Linux conda tutorials. For example, each user installs his own conda, and each user operates independently. The installation method code is as follows:

# First, download the file. It takes a few seconds for 20M/S
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# Next, use the bash command to run the file we downloaded. Remember to yes all the way
bash Miniconda3-latest-Linux-x86_64.sh 
#  After successful installation, the system environment variable file needs to be updated
source ~/.bashrc

Next, use conda to install aspera. You can download fastq files of different data sets at high speed. The code is as follows:

conda create -n download 
conda activate download 
conda install -y -c hcc aspera-cli 
which ascp 
## Be sure to find out where your software is installed by conda
ls -lh ~/miniconda3/envs/download/etc/asperaweb_id_dsa.openssh

However, when using conda in Windows operating system, we installed Anaconda, an interface software in exe format. We couldn't find it at all, and there was no way to enter the terminal interface that can input commands interactively.

So here, we recommend using Windows conda through the reticulate package in R:

Official documents of reticulate: https://rstudio.github.io/reticulate/articles/python_packages.html Next, enter the familiar Rstudio and enter the code:

install.packages("reticulate")
reticulate::install_miniconda()
library(reticulate)
conda_list() 

Use conda to install a small environment named scMLnet, and then activate the environment:

conda_create("scMLnet",python_version = '3.7')
use_condaenv("scMLnet")

The above code is equivalent to inputting the following command on the terminal interface of interactive input command:

conda create -y -n scMLnet python=3.7
conda activate scMLnet 
conda install -y scMLnet

In this way, even if you install Anaconda, an interface software in exe format, you can't find it at all and don't know how to input commands. You can also enter the familiar Rstudio and input code to replace it.

Then install relevant software in this environment:

# Equivalent to 
# conda install Networkx
conda_install("scMLnet", "scipy")
conda_install("scMLnet", "matplotlib")
conda_install("scMLnet", "Networkx")

Among them, when installing scipy, a large number of related packages are installed:

Downloading and Extracting Packages
m2w64-gcc-libs-5.3.0 | 520 KB    | ########## | 100% 
intel-openmp-2022.0. | 3.6 MB    | ########## | 100% 
m2w64-gcc-libgfortra | 342 KB    | ########## | 100% 
tbb-2021.5.0         | 148 KB    | ########## | 100% 
liblapack-3.9.0      | 5.3 MB    | ########## | 100% 
libcblas-3.9.0       | 5.3 MB    | ########## | 100% 
numpy-1.21.5         | 5.6 MB    | ########## | 100% 
msys2-conda-epoch-20 | 3 KB      | ########## | 100% 
libblas-3.9.0        | 5.3 MB    | ########## | 100% 
mkl-2022.0.0         | 181.9 MB  | ########## | 100% 
m2w64-libwinpthread- | 31 KB     | ########## | 100% 
scipy-1.7.3          | 24.4 MB   | ########## | 100% 
m2w64-gcc-libs-core- | 214 KB    | ########## | 100% 
m2w64-gmp-6.1.0      | 726 KB    | ########## | 100% 

When installing matplotlib, a large number of related packages are also installed:

Downloading and Extracting Packages
xz-5.2.5             | 211 KB    | ########## | 100% 
xorg-libxau-1.0.9    | 57 KB     | ########## | 100% 
libxcb-1.13          | 1.3 MB    | ########## | 100% 
pthread-stubs-0.4    | 6 KB      | ########## | 100% 
pyparsing-3.0.7      | 79 KB     | ########## | 100% 
lcms2-2.12           | 882 KB    | ########## | 100% 
libbrotlidec-1.0.9   | 33 KB     | ########## | 100% 
packaging-21.3       | 36 KB     | ########## | 100% 
pyqtwebengine-5.12.1 | 143 KB    | ########## | 100% 
tk-8.6.12            | 3.5 MB    | ########## | 100% 
jpeg-9e              | 373 KB    | ########## | 100% 
unicodedata2-14.0.0  | 498 KB    | ########## | 100% 
fonttools-4.29.1     | 1.5 MB    | ########## | 100% 
icu-68.2             | 16.4 MB   | ########## | 100% 
munkres-1.1.4        | 12 KB     | ########## | 100% 
python-dateutil-2.8. | 240 KB    | ########## | 100% 
tornado-6.1          | 649 KB    | ########## | 100% 
kiwisolver-1.3.2     | 58 KB     | ########## | 100% 
zstd-1.5.2           | 1010 KB   | ########## | 100% 
libbrotlienc-1.0.9   | 721 KB    | ########## | 100% 
pyqt5-sip-4.19.18    | 298 KB    | ########## | 100% 
libzlib-1.2.11       | 63 KB     | ########## | 100% 
python-3.7.12        | 17.9 MB   | ########## | 100% 
libpng-1.6.37        | 724 KB    | ########## | 100% 
freetype-2.10.4      | 489 KB    | ########## | 100% 
pyqt-5.12.3          | 22 KB     | ########## | 100% 
brotli-1.0.9         | 18 KB     | ########## | 100% 
lerc-3.0             | 140 KB    | ########## | 100% 
libwebp-base-1.2.2   | 393 KB    | ########## | 100% 
matplotlib-3.5.1     | 7 KB      | ########## | 100% 
lz4-c-1.9.3          | 135 KB    | ########## | 100% 
libtiff-4.3.0        | 1.1 MB    | ########## | 100% 
zlib-1.2.11          | 106 KB    | ########## | 100% 
jbig-2.1             | 45 KB     | ########## | 100% 
libbrotlicommon-1.0. | 67 KB     | ########## | 100% 
libwebp-1.2.2        | 11 KB     | ########## | 100% 
libclang-11.1.0      | 20.8 MB   | ########## | 100% 
openjpeg-2.4.0       | 238 KB    | ########## | 100% 
qt-5.12.9            | 106.1 MB  | ########## | 100% 
pillow-9.0.1         | 44.3 MB   | ########## | 100% 
fribidi-1.0.10       | 63 KB     | ########## | 100% 
xorg-libxdmcp-1.1.3  | 66 KB     | ########## | 100% 
libdeflate-1.10      | 69 KB     | ########## | 100% 
certifi-2021.10.8    | 145 KB    | ########## | 100% 
matplotlib-base-3.5. | 7.3 MB    | ########## | 100% 
cycler-0.11.0        | 10 KB     | ########## | 100% 
pyqtchart-5.12       | 211 KB    | ########## | 100% 
pyqt-impl-5.12.3     | 4.3 MB    | ########## | 100% 
brotli-bin-1.0.9     | 21 KB     | ########## | 100% 

Finally, install Networkx together with some attached packages:

Downloading and Extracting Packages
networkx-2.6.3       | 1.5 MB    | ########## | 100% 
pytz-2021.3          | 242 KB    | ########## | 100% 
bottleneck-1.3.2     | 114 KB    | ########## | 100% 
pandas-1.3.4         | 8.4 MB    | ########## | 100% 
numexpr-2.8.0        | 126 KB    | ########## | 100% 

In fact, it can also be installed at one time:

reticulate::py_install (packages = c ("numpy", "pandas", "matplotlib"))

Use conda again_ List (), you can see that you have an additional conda environment named scMLnet, and there is a Python in it:

   C:\\Users\\win10\\miniconda3\\envs\\scMLnet\\python.exe

This Python path can be used for many subsequent uses. There are more uses for this reticulate. You can go to the official document by yourself: https://rstudio.github.io/reticulate/articles/python_packages.html

Added by kumaran on Thu, 03 Mar 2022 08:06:22 +0200