特別感謝作者的答疑
一浆熔、簡(jiǎn)介
??DESC是用于對(duì)scRNA-seq數(shù)據(jù)進(jìn)行聚類的無(wú)監(jiān)督深度學(xué)習(xí)算法。該算法通過(guò)基于深度神經(jīng)網(wǎng)絡(luò)的迭代學(xué)習(xí)cluster特定基因表達(dá)表示和cluster分配潮针,構(gòu)造了從原始scRNA-seq數(shù)據(jù)空間到低維特征空間的非線性映射函數(shù)暖哨。此迭代過(guò)程將每個(gè)細(xì)胞移至最接近的cluster畏吓,平衡cluster之間的生物學(xué)和技術(shù)差異,并減少分批效應(yīng)的影響图筹。DESC還可以通過(guò)為每個(gè)細(xì)胞分配特定于cluster的概率來(lái)實(shí)現(xiàn)軟聚類帅刀,這有助于以較高的置信度識(shí)別聚類的細(xì)胞并解釋結(jié)果。
使用desc的作用
- 預(yù)處理各種格式的單細(xì)胞基因表達(dá)數(shù)據(jù)远剩。
- 建立單細(xì)胞基因表達(dá)數(shù)據(jù)的低維表示扣溺。
- 獲取細(xì)胞的軟cluster分配。
- 可視化細(xì)胞聚類結(jié)果和基因表達(dá)模式民宿。
二娇妓、文獻(xiàn):
- Deep learning enables accurate clustering and batch effect removal in single-cell RNA-seq analysis
- 開(kāi)源實(shí)現(xiàn) https://eleozzr.github.io/desc/
為了防止影響到正常生產(chǎn)用的服務(wù)器環(huán)境,所有操作都在Docker容器中進(jìn)行
docker run -it -p 8785:8787 -v /share/nas1/Data/Users/luohb/Docker:/root/luohb 17077ba23c0d /bin/bash
adduser --home /home/luohb1 luohb1
rstudio-server start #開(kāi)啟Rstudio的服務(wù)器版本
su - luohb1 #切換用戶
sh Miniconda3-latest-Linux-x86_64.sh # 安裝miniconda
添加清華conda鏡像源:
luohb1@dff49a57f49a:~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
luohb1@dff49a57f49a:~$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
luohb1@dff49a57f49a:~$ conda config --set show_channel_urls yes
創(chuàng)建Python3.6 conda環(huán)境
conda create -n DESC python=3.5.3
# activate your environment
luohb1@dff49a57f49a:~$ conda activate DESC
(DESC) luohb1@dff49a57f49a:~$ which python
/home/luohb1/miniconda3/envs/DESC/bin/python
(DESC) luohb1@dff49a57f49a:~$ python --version
Python 3.5.3 :: Continuum Analytics, Inc.
三活鹰、安裝desc的Python庫(kù)
- 確保python版本為 3.5.x或3.6.x
- 增加當(dāng)前用戶的sudo權(quán)限
- 查看pip的版本哈恰、添加多個(gè)pip國(guó)內(nèi)鏡像(推薦豆瓣鏡像)
https://www.cnblogs.com/night-xing/p/12094099.html
(DESC) luohb1@dff49a57f49a:~$ which python
/home/luohb1/miniconda3/envs/DESC/bin/python
(DESC) luohb1@dff49a57f49a:~$ which pip
/home/luohb1/miniconda3/envs/DESC/bin/pip
(DESC) luohb1@dff49a57f49a:~$ pip --version
(DESC) luohb1@dff49a57f49a:~$ pip 9.0.1 from /home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages (python 3.5)
(DESC) luohb1@dff49a57f49a:~$ vim ~/.pip/pip.conf
(DESC) luohb1@dff49a57f49a:~$ sudo apt-get install llvm
安裝desc的Python庫(kù)
(DESC) luohb1@dff49a57f49a:~$ pip install --upgrade pip
(DESC) luohb1@dff49a57f49a:~$ pip install desc
默認(rèn)的國(guó)外鏡像會(huì)很慢,而且很容易失敗
遇到的報(bào)錯(cuò)
Collecting tables
Downloading http://pypi.doubanio.com/packages/2b/32/847ee3f521aae6a0be380d923a736162d698586f444df1ac24b98c65025c/tables-3.6.1.tar.gz (4.6 MB)
|████████████████████████████████| 4.6 MB 4.7 MB/s
ERROR: Command errored out with exit status 1:
collect2: error: ld returned 1 exit status
* Using Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 11:58:13)
* USE_PKGCONFIG: False
* Found conda env: ``/home/luohb1/miniconda3/envs/DESC``
.. ERROR:: Could not find a local HDF5 installation.
You may need to explicitly state where your local HDF5 headers and
library can be found by setting the ``HDF5_DIR`` environment
variable or by using the ``--hdf5`` command-line option.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解決:
#重新安裝這個(gè)HDF5這個(gè)庫(kù)
conda install HDF5
檢查
(DESC) luohb1@dff49a57f49a:~$ python
Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 11:58:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform
>>> platform.python_version()
'3.5.3'
>>> import tensorflow as tf
>>> tf.__version__
'1.15.2'
載入desc這個(gè)包發(fā)生的報(bào)錯(cuò):
>>> import desc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages/desc/__init__.py", line 2, in <module>
from . import tools
File "/home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages/desc/tools/__init__.py", line 2, in <module>
from scanpy.api.pp import normalize_per_cell, highly_variable_genes, log1p, scale
File "/home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages/scanpy/__init__.py", line 3, in <module>
from .utils import check_versions, annotate_doc_types
File "/home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages/scanpy/utils.py", line 18, in <module>
from ._settings import settings
File "/home/luohb1/miniconda3/envs/DESC/lib/python3.5/site-packages/scanpy/_settings.py", line 351
f'{k} = {v!r}'
解決:
由于desc依賴scanpy志群,而scanpy又依賴anndata着绷,需要scanpy和anndata的版本相匹配,為此找到另外一篇簡(jiǎn)書文章:【簡(jiǎn)書】scanpy分析單細(xì)胞數(shù)據(jù) 查看包的版本
(DESC) luohb1@dff49a57f49a:~$ pip install scanpy==1.4 #讓它自己自動(dòng)尋找匹配的anndata庫(kù)
保存鏡像锌云,以作遷移
docker commit -m "desc_integrated_analysis" -a "luohb" dff49a57f49a desc_rstudio
重新啟動(dòng)進(jìn)入Docker的方法
$docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb9848f16fa0 c5d48e81b986 "/bin/bash" 2 days ago Exited (0) 2 days ago elegant_wilbur
8f92805510be c5d48e81b986 "/bin/bash" 2 days ago Up 2 days hardcore_lovelace
dc65d1fa43cc c5d48e81b986 "/bin/bash" 2 days ago Up 2 days friendly_johnson
dff49a57f49a 17077ba23c0d "/bin/bash" 5 days ago Up 3 days 0.0.0.0:8785->8787/tcp silly_gagarin
c2cef88ff61b 17077ba23c0d "/bin/bash" 9 days ago Exited (0) 6 days ago condescending_booth
565ff6a9f91d 093105f858b4 "/bin/bash" 10 days ago Up 10 days kind_curie
e506a9842fbc 17077ba23c0d "/bin/bash" 11 days ago Exited (130) 9 days ago sweet_einstein
$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cellassign_rstudio_debian latest 17077ba23c0d 11 days ago 6.71GB
centos/cellassign-rvm-rstudio latest cf5394785a34 2 weeks ago 6.55GB
centos_sshd latest d1923b501fa4 2 weeks ago 365MB
matlab_robustclone_v1 latest 093105f858b4 3 weeks ago 84.2GB
rocker/rstudio latest ff5a9f0a1d1b 3 weeks ago 1.46GB
centos latest 470671670cac 3 months ago 237MB
gregoryschwartz/too-many-cells 0.2.2.0 997aeeb90727 6 months ago 1.28GB
centos 7.3.1611 c5d48e81b986 13 months ago 192MB
$docker run -i -t -v /share/nas1/Data/Users/luohb/Personalization/result2/DESC:/home/luohb1/desc -p 8785:8787 08e3683cab26 /bin/bash
$docker attach dff49a57f49a
(base) luohb1@dff49a57f49a:~/.local/lib/python3.5/Python-3.5.6$
- 根據(jù)教程測(cè)試:
>>> import desc
>>> desc.run_desc_test()
遇到缺失的依賴包的話荠医,conda安裝回去就好
最開(kāi)始遇到的報(bào)錯(cuò):
(base) luohb1@dff49a57f49a:~/.local/lib/python3.5/Python-3.5.6/bin$ which python
/home/luohb1/miniconda3/bin/python
(base) luohb1@dff49a57f49a:~/.local/lib/python3.5/Python-3.5.6/bin$ which pip
/home/luohb1/miniconda3/bin/pip
(base) luohb1@dff49a57f49a:~/.local/lib/python3.5/Python-3.5.6/bin$ python
Python 3.6.10 |Anaconda, Inc.| (default, Jan 7 2020, 21:14:29)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> importdesc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'importdesc' is not defined
>>> import desc
/home/luohb1/miniconda3/lib/python3.6/site-packages/anndata/_core/anndata.py:21: FutureWarning: pandas.core.index is deprecated and will be removed in a future version. The public classes are available in the top-level namespace.
from pandas.core.index import RangeIndex
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/luohb1/miniconda3/lib/python3.6/site-packages/desc/__init__.py", line 2, in <module>
from . import tools
File "/home/luohb1/miniconda3/lib/python3.6/site-packages/desc/tools/__init__.py", line 2, in <module>
from scanpy.api.pp import normalize_per_cell, highly_variable_genes, log1p, scale
File "/home/luohb1/miniconda3/lib/python3.6/site-packages/scanpy/__init__.py", line 27, in <module>
check_versions()
File "/home/luohb1/miniconda3/lib/python3.6/site-packages/scanpy/utils.py", line 37, in check_versions
if anndata.__version__ < LooseVersion('0.6.10'):
File "/home/luohb1/miniconda3/lib/python3.6/distutils/version.py", line 64, in __gt__
c = self._cmp(other)
File "/home/luohb1/miniconda3/lib/python3.6/distutils/version.py", line 335, in _cmp
if self.version == other.version:
AttributeError: 'Version' object has no attribute 'version'
解決方案
- 根據(jù)這篇文章 【CSDN】distutils 'module' object has no attribute 'version' 發(fā)現(xiàn)不行
- 發(fā)現(xiàn)是conda環(huán)境問(wèn)題
四、安裝啟動(dòng)Jupyter Notebook
安裝與啟動(dòng)
(DESC) luohb1@dff49a57f49a:~$ conda install jupyter
- 教程、出現(xiàn)的報(bào)錯(cuò)和解決方法:
后面發(fā)現(xiàn)因?yàn)閐ocker的映射端口被占用了彬向,沒(méi)辦法分給Jupyter Notebook 8888端口,于是只能改用Rstudio-server運(yùn)行Python腳本
其實(shí)為什么我不想直接寫Python腳本的原因是因?yàn)槲蚁M芸吹矫恳徊降淖兓头奖鉪ebug
解決:
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root &
五兼贡、啟動(dòng)Rstudio-server,運(yùn)行Python
- 教程、報(bào)錯(cuò)與解決:
當(dāng)然其實(shí)也可以用VScode的服務(wù)器版本里烦,但是今天不想折騰了凿蒜。
$rstudio-server start &