Installation of R and rstudio server in the server, etc

1, Installation and environment configuration of conda

1. conda can install miniconda or anaconda

$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
 $ bash Miniconda3-latest-Linux-x86_64.sh #### run to activate conda

2. After that, you can add different channel s to create an independent conda environment. The following is an example of the MAESTRO environment I need to configure.

$ conda config --add channels defaults
$ conda config --add channels liulab-dfci
$ conda config --add channels bioconda
$ conda config --add channels conda-forge
# To make the installation faster, we recommend using mamba
$ conda install mamba -c conda-forge
$ mamba create -n MAESTRO maestro=1.5.0 -c liulab-dfci
# Activate the environment
$ conda activate MAESTRO  
###When running MAESTRO, you need to activate the environment first, and then enter R. you can directly enter the library("MAESTRO"), because MAESTRO is not only an environment, but also an R package, which contains many functions.

3. Some common conda commands

conda --version
# Display conda version
conda info --envs
# View the current existing environment
conda create -n your_env_name python=X.X
conda create --name new_name clone old_name
# Create a new virtual environment (clone the old name)
conda activate your_env_name 
# Activate virtual environment
conda remove -n your_env_name --all
# Delete virtual environment
 Add Ali source
#Set the channel address to be displayed when searching   
conda config --add channels https://mirrors.aliyun.com/pypi/simple/  
# Current cofig
conda config --set show_channel_urls yes
# To view the added mirror:    
conda config --show    
# Current channels file
conda config --get channels  
# Delete source     
conda config --remove-key channels

2, Install R in conda

1. First of all, it seems that the server administrator of our school installed R and Rstudio server in advance, so I actually installed miniconda and configured its environment. For R, enter r directly on the Xshell command line and enter the R interface.

2. Install R program with conda

conda info --envs # View environment
conda create -n R4.1  # Create a file named R4 1 environment
source activate R4.1  ####4.1 indicates that R version is 4.1
conda list            #View currently installed software
conda install r-base  #Install R language
conda install r-stringi # r package starts with r - 
conda deactivate # Exit the current environment

3. If you want to install R package, you can also enter the R interface and directly use the R command to install it. By default, the server will create an R folder under the current path and place R package below.

(1) R command: install packages("devtools")

library("devtools")

install_ GitHub ("liulab dfci / Maestro") #### download the R package from GitHub with the previous details

3, Installing Rstudio Server in conda

1. The installation of Rstudio server requires administrator privileges, so it is generally good to install one server.

2. For some commands commonly used by Rstudio server, sudo can be added in front of each command to indicate super permission, but because I am not a super administrator, sudo cannot be added.

www@mercury:~$ rstudio-server verify-installation
Server is running and must be stopped before running verify-installation
########This result indicates that the RStudio server has been installed.
www@mercury:~$ rstudio-server start
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'rstudio-server.service'.
Multiple identities can be used for authentication:
 1.  ******
 2.  **
 3.  ***
 4.  ***
Choose identity to authenticate as (1-4): 
#####Indicates that to start the RStudio server, you need to apply to someone with permission.

systemctl status rstudio-server.service
rstudio-server status
####Both commands are used to view the status of the studio server in the server.

www@mercury:~$ rstudio-server stop           ###Stop operation
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to stop 'rstudio-server.service'.
Multiple identities can be used for authentication:
 1.  ******
 2.  **
 3.  ***
 4.  ***
Choose identity to authenticate as (1-4): 
#####Administrator authentication is also required to stop the Rstudio server.

rstudio-server restart   ####Restart Rstudio server

3. Manage Rstudio server on server

Manage RStudio Server

1. Login method: after installing and starting RStudioServer, you can access it through ip address and port number. The format is http: / / < server ip >: 8787. Server ip is the ip address of the server login. By default, the port of the RStudio Server is 8787. To log in, you need to enter the user name and password of the server.

——In this way, you can run Rstudio on the web page and write R script code, so you don't have to input line by line on the terminal.
2. View some common commands of rstudio server on the terminal:

sudo rstudio-server verify-installation #Check whether the installation is normal
sudo rstudio-server start               #Start rstudio server
sudo rstudio-server status              #View rstudio server
sudo rstudio-server stop                #Close rstudio server
sudo rstudio-server restart             #Restart rstudio server

3. Switch between different versions of R

sudo vim /etc/rstudio/rserver.conf

Change the following two to switch the R version under anaconda2/bin and / usr/bin /
rsession-which-r=~/biotools/anaconda2/bin/R
rsession-which-r=/usr/bin/R

4, Some other commonly used commands for Linux or server

Where is R #### view software installation location

History ###### view history command

Keywords: Linux xshell

Added by trp on Tue, 25 Jan 2022 18:31:30 +0200