Limour

Limour

临床医学在读。

【记录】安装生信的代码编写环境

安装 vscode-web#

mkdir -p ~/app/vscode && cd ~/app/vscode && nano docker-compose.yml
sudo docker-compose up -d && sudo docker-compose logs
version: "2.1"
services:
  code-server:
    image: linuxserver/code-server:latest
    container_name: code-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Asia/Shanghai
      - PASSWORD=password
      - SUDO_PASSWORD=password
      - PROXY_DOMAIN=code-server.my.domain #optional
      - DEFAULT_WORKSPACE=/config/workspace #optional
    volumes:
      - ./config:/config
    ports:
      - 2441:8443
    restart: unless-stopped

配置代理和中文#

  • 打开 Visual Studio Code,点击管理,在列表中选择设置
  • 在弹出的搜索框中输入 "proxy",即可看到代理的配置项 "Http"
  • 宿主机获取 docker0 的 ip: ip address | grep docker0
  • 然后 docker 内设置代理 http://docker0的ip:port
    拓展内搜索 zh-cn,安装中文界面拓展

安装 conda#

  • 回到工作区,ctrl+~ 调出终端
  • sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
  • sudo apt update
  • sudo apt install wget
  • 安装 conda

安装 nodejs#

conda create -n node -c conda-forge nodejs
conda activate node
npm config set registry https://registry.npmmirror.com

使用 git#

npm create astro@latest
git config --global user.email "youremail"
git config --global user.name "yourname"
git branch -M main && git add . && git commit -m '初始提交'
git remote add origin https://github.com/Limour-dev/chatGPT.git
git push --set-upstream origin main --force # 创建个人访问令牌
git config --global credential.helper cache
git push

hello world#

---
const search = Astro.url.searchParams.get('search')! || '';
---
<h1>{search}</h1>
  • 在您的项目中启用 SSR
  • 编辑 chatGPT/src/pages/index.astro
  • npm run dev
  • 访问 https://vscode.domain/proxy/3000/?search=hello%20world 进行测试

安装 Jupyter#

持久化镜像存储#

mkdir -p ~/datascience && cd ~/datascience
nano docker-compose.yml
sudo docker-compose up -d
sudo docker-compose logs
sudo docker cp -a jupyterR:/opt /home/limour/upload/opt
sudo docker cp -a jupyterR:/home/jovyan /home/limour/upload/home
sudo docker-compose down && sudo docker volume prune
version: '3.3'
services:
    datascience-notebook:
        ports:
            - '57002:8888'
        container_name: jupyterR
        restart: always
        image: 'jupyter/datascience-notebook:r-4.1.3'
        command: start-notebook.sh --NotebookApp.token='***'

启动镜像#

nano docker-compose.yml
sudo chmod 777 -R /home/limour/upload/
sudo docker-compose up -d
sudo docker-compose logs
version: '3.3'
services:
    datascience-notebook:
        ports:
            - '57002:8888'
        container_name: jupyterR
        restart: always
        volumes:
            - '/home/limour/upload:/home/jovyan/upload'
            - '/home/limour/upload/opt/opt:/opt'
            - '/home/limour/upload/home/jovyan:/home/jovyan'
        image: 'jupyter/datascience-notebook:r-4.1.3'
        command: start-notebook.sh --NotebookApp.token='***'

R 包镜像#

nano .Rprofile
options()$repos ## 查看使用install.packages安装时的默认镜像
options()$BioC_mirror ##查看使用bioconductor的默认镜像
options(BioC_mirror="https://mirrors.ustc.edu.cn/bioc/") ##指定镜像,这个是中国科技大学镜像
options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")) ##指定install.packages安装镜像,这个是清华镜像
options(ggrepel.max.overlaps = Inf)

安装 R 内核#

conda create -n seurat -c conda-forge r-seurat=4.1.1 -y
conda activate seurat
conda install -c conda-forge r-tidyverse -y
conda install -c conda-forge r-irkernel -y
Rscript -e "IRkernel::installspec(name='seurat', displayname='r-seurat')"
conda install -c conda-forge r-devtools -y
Rscript -e "BiocManager::install('glmGamPoi')"
wget -e "https_proxy=http://172.17.0.1:8580" https://github.com/chris-mcginnis-ucsf/DoubletFinder/archive/refs/heads/master.zip -O DoubletFinder-master.zip
Rscript -e "devtools::install_local('DoubletFinder-master.zip')"

安装 python 内核#

conda create -n markdown2pptx -c conda-forge python -y
conda install -n markdown2pptx ipykernel -c conda-forge -y
conda run -n markdown2pptx python -m ipykernel install --user --name markdown2pptx
conda run -n markdown2pptx pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

安装 Golang 内核#

conda create -n golang -c conda-forge go -y
conda activate golang
go env -w GO111MODULE=on
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/
go install github.com/gopherdata/[email protected] #去仓库查看最新版本号
mkdir -p ~/.local/share/jupyter/kernels/golang
cd ~/.local/share/jupyter/kernels/golang
cp "$(go env GOPATH)"/pkg/mod/github.com/gopherdata/[email protected]/kernel/* "."
chmod +w ./kernel.json
sed "s|gophernotes|$(go env GOPATH)/bin/gophernotes|" < kernel.json.in > kernel.json

安装 rstudio#

mkdir -p ~/app/rstudio && cd ~/app/rstudio && nano docker-compose.yml
sudo docker-compose up -d && sudo docker-compose logs
version: '3'
services:
  rstudio:
    image: dceoy/rstudio-server
    container_name: Rstudio
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 500M
        reservations:
          cpus: '0.25'
          memory: 200M
    restart: always
    ports:
      - 57022:8787
    volumes:
      - /home/gene/zl_liu/rstudio:/home/rstudio
      - /home/gene/upload:/home/rstudio/upload
    working_dir: /home/rstudio

更改 R 版本#

# 容器内
conda create -n r_4_1_3 -c conda-forge r-base=4.1.3 -y
conda activate r_4_1_3
whereis R
# /home/rstudio/miniconda3/envs/r_4_1_3/bin/R
# 容器外
docker exec -it Rstudio /bin/bash
chmod 777 -R  /etc/rstudio/
exit 
nano -K /etc/rstudio/rserver.conf
# 服务器配置文件
rsession-which-r=/home/rstudio/miniconda3/envs/r_4_1_3/bin/R
sudo docker-compose restart

安装 seurat#

# 进入终端,以下操作均在终端中进行
export R_LIBS_SITE=""
# 在终端中进入R
.libPaths('/home/rstudio/miniconda3/envs/r_4_1_3/lib/R/library')
.libPaths() 确保没有其他路径
remove.packages("vctrs")
install.packages("vctrs")
install.packages('Seurat')
remove.packages("cli")
install.packages("cli")
install.packages("tidyverse")
install.packages("plotly")
重启R会话
library(tidyverse)
library(Seurat)

绘制 3D-umap#

library(plotly)
library(Seurat)
sample13 <- readRDS("~/upload/zl_liu/work/Prognosis/scRNA/sample13.rds")
sample13 <- RunUMAP(sample13, dims = 1:10, n.components = 3L)
plot.data <- FetchData(object = sample13, vars = c("UMAP_1", "UMAP_2", "UMAP_3", "seurat_clusters"))
plot.data$label <- paste(rownames(plot.data))
# 绘制您的数据,在这个例子中我的Seurat对象有21个簇(0-20)
plot_ly(data = plot.data, 
        x = ~UMAP_1, y = ~UMAP_2, z = ~UMAP_3, 
        color = ~seurat_clusters, 
        colors = c("lightseagreen",
                   "gray50",
                   "darkgreen",
                   "red4",
                   "red",
                   "turquoise4",
                   "black",
                   "yellow4",
                   "royalblue1",
                   "lightcyan3",
                   "peachpuff3",
                   "khaki3",
                   "gray20",
                   "orange2",
                   "royalblue4",
                   "yellow3",
                   "gray80",
                   "darkorchid1",
                   "lawngreen",
                   "plum2",
                   "darkmagenta")[1:7],
        type = "scatter3d", 
        mode = "markers", 
        marker = list(size = 5, width=2), # 控制点的大小
        text=~label, # 这是我们之前为单元ID创建的额外列
        hoverinfo="text") # 当您可视化您的plotly对象时,将鼠标指针悬停在一个点上会显示单元名称
加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。