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,點擊 Manage,在列表中選擇 Settings
  • 在彈出的搜索框中輸入 "proxy",即可看到代理的配置項 "Http"
  • 宿主機獲取 docker0 的 ip: ip address | grep docker0
  • 然後 docker 內設置代理 http://docker0的ip:port
    拓展內搜索 zh-cn,安裝中文界面拓展

安裝 conda#

  • 回到 WORKSPACE,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 'Initial commit'
git remote add origin https://github.com/Limour-dev/chatGPT.git
git push --set-upstream origin main --force # Creating a personal access token
git config --global credential.helper cache
git push

hello world#

---
const search = Astro.url.searchParams.get('search')! || '';
---
<h1>{search}</h1>
  • Enabling SSR in Your Project
  • 編輯 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
# Server Configuration File
rsession-which-r=/home/rstudio/miniconda3/envs/r_4_1_3/bin/R
sudo docker-compose restart

安裝 seurat#

# 進入terminal,以下操作均在terminal中進行
export R_LIBS_SITE=""
# 在terminal中進入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 session
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))
# Plot your data, in this example my Seurat object had 21 clusters (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), # controls size of points
        text=~label, #This is that extra column we made earlier for which we will use for cell ID
        hoverinfo="text") #When you visualize your plotly object, hovering your mouse pointer over a point shows cell names
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。