SCP探索單細(xì)胞宇宙的魔法工具,加速生物信息學(xué)研究
在之前,小云為大家介紹了popsicleR這個(gè)令人驚嘆的R包,它提供了從單細(xì)胞分析質(zhì)控到細(xì)胞注釋的整套流程。這種類型的R包被稱為single-cell pipeline,為我們提供了俯瞰整個(gè)單細(xì)胞分析流程的便捷途徑,讓我們能夠站在R包的肩膀上,輕松應(yīng)對單細(xì)胞數(shù)據(jù)的挑戰(zhàn)。 而今天,小云要向大家介紹一款更進(jìn)階的R包——SCP(single-cell pipeline),它不僅提供了高級的單細(xì)胞分析功能,例如擬時(shí)序分析、速率分析等,還擁有各種美觀大氣的數(shù)據(jù)可視化圖。這款R包是由南京醫(yī)科大學(xué)生殖醫(yī)學(xué)博士親自編寫,可見其專業(yè)性與實(shí)用性。 SCP R包是一套強(qiáng)大的單細(xì)胞數(shù)據(jù)處理和分析工具,提供了全面的解決方案。其功能之強(qiáng)大,涵蓋了眾多生物信息學(xué)常用工具和函數(shù),旨在簡化單細(xì)胞數(shù)據(jù)分析的復(fù)雜性,使研究者能夠更專注于科學(xué)探索,而無需花費(fèi)過多時(shí)間在繁瑣的數(shù)據(jù)處理上。 對于初學(xué)者而言,學(xué)習(xí)這樣一個(gè)功能強(qiáng)大,匯集了大量函數(shù)的R包,最初的難點(diǎn)往往在于如何成功安裝。因此,接下來,我將向大家展示如何在服務(wù)器和本地電腦兩個(gè)不同的終端上順利下載SCP,讓大家輕松邁入單細(xì)胞數(shù)據(jù)的精彩世界。 溫馨提醒:R 版本 >= 4.1.0哦
Linux終端
在服務(wù)器中進(jìn)行安裝,首先我們得新建一個(gè)conda的虛擬環(huán)境
# 創(chuàng)建新的虛擬環(huán)境
conda create
-
n SCP_env r=4.1.3
# 進(jìn)入創(chuàng)建的新環(huán)境中
conda activate SCP_env
# 隨后進(jìn)行conda官網(wǎng)對所需要的R包進(jìn)行下載
## https://anaconda.org/anaconda/conda
conda install
-
c conda
-
forge r
-
devtools
# 我們先需要安裝devtools,下載在GitHub上的SCP包
# 也可以選擇在R環(huán)境中進(jìn)行下載,小云比較偏向于conda安裝哦~ 這個(gè)選擇并沒有對錯(cuò)之分,哪種方法更適合你,下載速度更快,使用便是啦!以結(jié)果為導(dǎo)向??!
if
?(
!require
("devtools", quietly =?TRUE)) { ??
install.packages
("devtools") }
options
(timeout =?999)
# 在使用devtools::install_github()函數(shù)時(shí),都要設(shè)置好這個(gè)參數(shù)哦,它可以幫助我們順利的從GitHub上下載R包
devtools
::install_github
("zhanghao-njmu/SCP")
# 在安裝SCP的過程中可能會(huì)出現(xiàn)某一包無法安裝的情況,我們可以使用conda進(jìn)行安裝,安裝方法與安裝devtools一致,在這小云就不贅述啦。
Windows終端
env_dir <-?"D:/SCP_env/"
dir.create
(env_dir,recursive =?TRUE)
setwd
(env_dir)
# 使用小云曾經(jīng)教過大家的renv包,在本地創(chuàng)建一個(gè)新的環(huán)境
if
(
!require
("renv"))
install.packages
(renv) renv
::init
(project =?env_dir) 在成功創(chuàng)建環(huán)境后,我們可以看到這樣的輸出
在進(jìn)入環(huán)境中,我們便可以開始安裝R包,和Linux終端一樣,我們首先需要下載的是devtools和BiocManager兩個(gè)R包,對后續(xù)的R包進(jìn)行安裝操作。
if
?(
!require
("devtools", quietly =?TRUE)) { ??
install.packages
("devtools") }
options
(timeout =?999) devtools
::install_github
("zhanghao-njmu/SCP") 在安裝的過程中,我們可能會(huì)遇到這種情況??
小伙伴們,遇到報(bào)錯(cuò)我們不要害怕哦,這個(gè)報(bào)錯(cuò)只是因?yàn)槲覀兊囊蕾嚊]有安裝成功呢!我們只需要把報(bào)錯(cuò)上的手動(dòng)的安裝好就可以繼續(xù)運(yùn)行啦
if
?(
!require
("BiocManager", quietly =?TRUE)) { ??
install.packages
("BiocManager") } BiocManager
::install
("R_names")
# 如果碰上網(wǎng)絡(luò)不穩(wěn)定也可以進(jìn)bioconductor官網(wǎng)(https://www.bioconductor.org/)下載安裝包后進(jìn)行本地下載哦
install.packages
(".tar.gz_dir", repos =?NULL, type =?"source")
# 安裝好R語言環(huán)境下的R包后,我們便可以載入SCP包,準(zhǔn)備配置python環(huán)境下的包啦,這是因?yàn)閱渭?xì)胞分析的過程中,如:速率分析等是需要python環(huán)境的,因此我們在本地中也需要下載conda,配置基礎(chǔ)的python環(huán)境。
options
(reticulate.conda_binary =?"D:/conda/envs/SCP_env")
# 在這一步我們需要指定好conda的環(huán)境,切記切記!路徑最后不要加“/”哦,不然會(huì)出現(xiàn)報(bào)錯(cuò)
# 在Windows的安裝過程中,我們還需要額外在conda中安裝一個(gè)包
conda install jaxlib-0.1.70
-
cp38
-
none
-
win_amd64.whl
# 可以從這個(gè)網(wǎng)址中下載適合自己電腦的安裝包哦 https://whls.blob.core.windows.net/unstable/index.html
# 安裝python包我們使用一下命令
SCP
::PrepareEnv
()
# 但這步是有可能報(bào)錯(cuò)的,部分包因?yàn)榘姹静粚?yīng)的或是無法正常加載的,我們都可以根據(jù)報(bào)錯(cuò)單獨(dú)的進(jìn)行下載,使用以下的命令(這邊小云使用了pip的臨時(shí)清華源進(jìn)行下載哦)
pip install
-
i https
://
pypi.tuna.tsinghua.edu.cn
/
simple packages_names 無論是Linux還是Windows,當(dāng)能成功運(yùn)行以下代碼的時(shí)候就證明我們基本已經(jīng)成功啦!為什么說是基本呢?小云在這先賣個(gè)關(guān)子哦
library
(SCP)
data
("pancreas_sub")
pancreas_sub <- RunPAGA(srt = pancreas_sub, group_by = "SubCellType", linear_reduction = "PCA", nonlinear_reduction = "UMAP")
## 'misc' slot is not converted.
## 'tools' slot is not converted.
CellDimPlot(pancreas_sub, group.by = "SubCellType", reduction = "draw_graph_fr")
##細(xì)胞聚類
CellDimPlot(
??srt = pancreas_sub, group.by = c("CellType", "SubCellType"),
??reduction = "UMAP", theme_use = "theme_blank"
)
##細(xì)胞周期注釋
CellDimPlot(
??srt = pancreas_sub, group.by = "SubCellType", stat.by = "Phase",
??reduction = "UMAP", theme_use = "theme_blank"
)
##特征注釋
FeatureDimPlot(
??srt = pancreas_sub, features = c("Sox9", "Neurog3", "Fev", "Rbp4"),
??reduction = "UMAP", theme_use = "theme_blank"
)
FeatureDimPlot(
??srt = pancreas_sub, features = c("Ins1", "Gcg", "Sst", "Ghrl"),
??compare_features = TRUE, label = TRUE, label_insitu = TRUE,
??reduction = "UMAP", theme_use = "theme_blank"
)
##細(xì)胞類型、百分比和細(xì)胞周期
ht <- GroupHeatmap(
??srt = pancreas_sub,
??features = c(
????"Sox9", "Anxa2", # Ductal
????"Neurog3", "Hes6", # EPs
????"Fev", "Neurod1", # Pre-endocrine
????"Rbp4", "Pyy", # Endocrine
????"Ins1", "Gcg", "Sst", "Ghrl" # Beta, Alpha, Delta, Epsilon
??),
??group.by = c("CellType", "SubCellType"),
??heatmap_palette = "YlOrRd",
??cell_annotation = c("Phase", "G2M_score", "Cdh2"),
??cell_annotation_palette = c("Dark2", "Paired", "Paired"),
??show_row_names = TRUE, row_names_side = "left",
??add_dot = TRUE, add_reticle = TRUE
)
print(ht$plot)
##質(zhì)控
## conda install -c bioconda bioconductor-scdblfinder 依賴不適配
# 安裝路徑
pancreas_sub <- RunCellQC(srt = pancreas_sub)
CellDimPlot(srt = pancreas_sub, group.by = "CellQC", reduction = "UMAP")
CellStatPlot(srt = pancreas_sub, stat.by = "CellQC", group.by = "CellType", label = TRUE)
CellStatPlot(
??srt = pancreas_sub,
??stat.by = c(
????"db_qc", "outlier_qc", "umi_qc", "gene_qc",
????"mito_qc", "ribo_qc", "ribo_mito_ratio_qc", "species_qc"
??),
??plot_type = "upset", stat_level = "Fail"
)
##標(biāo)準(zhǔn)流程
pancreas_sub <- Standard_SCP(srt = pancreas_sub)
CellDimPlot(
??srt = pancreas_sub, group.by = c("CellType", "SubCellType"),
??reduction = "StandardUMAP2D", theme_use = "theme_blank"
)
在這之后還有非常多進(jìn)階且美觀的代碼,小云的筆記本有所限制就不一一展示啦,把代碼展示給大家,后續(xù)的結(jié)果圖小云會(huì)打包成壓縮文件夾在文章結(jié)尾分享給大家哦!