最近在學(xué)習(xí)cellphoneDB,順便寫一個(gè)學(xué)習(xí)記錄吧件豌。
簡(jiǎn)介
CellPhoneDB是一個(gè)可公開獲取的受體疮方、配體及其相互作用的存儲(chǔ)庫(kù)。配體和受體都包含亞基結(jié)構(gòu)茧彤,準(zhǔn)確表征異質(zhì)配合物骡显。這是至關(guān)重要的,因?yàn)榧?xì)胞與細(xì)胞之間的交流依賴于多亞基蛋白復(fù)合物曾掂,而這些復(fù)合物超越了大多數(shù)數(shù)據(jù)庫(kù)和研究中使用的二元表述惫谤。
CellPhoneDB集成了與蜂窩通信有關(guān)的現(xiàn)有數(shù)據(jù)集和新的手動(dòng)審查信息。CellPhoneDB獲取信息的數(shù)據(jù)庫(kù)有: UniProt, Ensembl, PDB, the IMEx consortium, IUPHAR珠洗。CellPhoneDB可用于搜索特定的配體/受體溜歪,或查詢您自己的單細(xì)胞轉(zhuǎn)錄組學(xué)數(shù)據(jù)。
安裝
注意: 可以使用Python v3.5或更高版本许蓖。建議使用python虛擬環(huán)境痹愚,但是您當(dāng)然可以省略這些步驟,并立即通過pip進(jìn)行安裝蛔糯。
#創(chuàng)建cpdb-venv環(huán)境
python -m venv cpdb-venv
#激活環(huán)境
source cpdb-venv/bin/activate
#安裝cellphonedb
pip install cellphonedb
CellPhoneDB的運(yùn)行方法
(1)如果之前沒有激活cpdb-venv環(huán)境拯腮,請(qǐng)先激活
source cpdb-venv/bin/activate
(2)要使用示例數(shù)據(jù),請(qǐng)下載meta/counts測(cè)試數(shù)據(jù)蚁飒。即
curl https://raw.githubusercontent.com/Teichlab/cellphonedb/master/in/example_data/test_counts.txt --output test_counts.txt
curl https://raw.githubusercontent.com/Teichlab/cellphonedb/master/in/example_data/test_meta.txt --output test_meta.txt
(3) 運(yùn)行statistical method的例子
cellphonedb method statistical_analysis test_meta.txt test_counts.txt
(4) 沒有使用statistical method的例子
cellphonedb method analysis test_meta.txt test_counts.txt
可選參數(shù):
~ Optional Method parameters:
--counts-data: [ensembl | gene_name | hgnc_symbol] counts data 中的基因標(biāo)識(shí)符類型
--project-name: 項(xiàng)目名稱动壤,在輸出文件夾中創(chuàng)建具有此名稱的子文件夾
--iterations: 統(tǒng)計(jì)分析迭代次數(shù)[1000]
--threshold: 表達(dá)特定的配體/受體的細(xì)胞%
--result-precision: 結(jié)果中保留的小數(shù)位數(shù)[3]
--output-path: 輸出文件路徑 [out]
--output-format: 結(jié)果文件的輸出格式(如果沒有擴(kuò)展名,將添加到文件名中) [txt]
--means-result-name: Means結(jié)果文件名[means]
--significant-means-result-name: 有顯著意義的means 結(jié)果文件名 [significant_means]
--deconvoluted-result-name: Deconvoluted 結(jié)果文件名 [deconvoluted]
--verbose/--quiet: 打印或隱藏CellPhoneDB日志 [verbose]
--subsampling: 使二次抽樣
--subsampling-log: 啟用非對(duì)數(shù)轉(zhuǎn)換數(shù)據(jù)輸入的子采樣log1p !!強(qiáng)制!!
--subsampling-num-pc: 子抽樣NumPC參數(shù)(要使用的pc數(shù)量) [100]
--subsampling-num-cells: 要取樣到的細(xì)胞數(shù) [1/3 of cells]
~ Optional Method Statistical parameters
--pvalues-result-name: P-values 結(jié)果文件名 [pvalues]
--pvalue: P-value閾值 [0.05]
--debug-seed: 調(diào)試隨機(jī)種子-1淮逻,要禁用它琼懊,請(qǐng)使用一個(gè)值>=0 [-1]
--threads: 要使用的線程數(shù) >=1 [-1]
示例:
(1)設(shè)置迭代和線程的數(shù)量
cellphonedb method statistical_analysis yourmetafile.txt yourcountsfile.txt --iterations=10 --threads=2
(2)子項(xiàng)目文件夾
cellphonedb method analysis yourmetafile.txt yourcountsfile.txt --project-name=new_project
(3)設(shè)置輸出路徑
mkdir custom_folder
cellphonedb method statistical_analysis yourmetafile.txt yourcountsfile.txt --output-path=custom_folder
(4) 二次抽樣
cellphonedb method analysis yourmetafile.txt yourcountsfile.txt --subsampling --subsampling-log false --subsampling-num-cells 3000
結(jié)果解讀
(1)P-value (pvalues.txt), Mean (means.txt), Significant mean (significant_means.txt)
id_cp_interaction: 存儲(chǔ)在數(shù)據(jù)庫(kù)中的每個(gè)交互的唯一CellPhoneDB標(biāo)識(shí)符阁簸。
interacting_pair: 由“|”分隔的交互對(duì)的名稱。
partner A or B: 第一個(gè)交互伙伴(A)或第二個(gè)交互伙伴(B)的標(biāo)識(shí)符哼丈。它可以是:UniProt(前綴 simple:)或復(fù)合物complex(前綴 complex:)
gene A or B: 第一個(gè)交互伙伴(A)或第二個(gè)交互伙伴(B)的基因標(biāo)識(shí)符启妹。該標(biāo)識(shí)符將取決于輸入用戶列表。
secreted: True 如果其中一個(gè)伴侶是secreted醉旦。
Receptor A or B: True 如果第一個(gè)交互伙伴(A)或第二個(gè)交互伙伴(B)被注釋為數(shù)據(jù)庫(kù)中的一個(gè)受體饶米,則為真。
annotation_strategy: 如果CellPhoneDB開發(fā)人員對(duì)交互進(jìn)行了注釋车胡,則進(jìn)行策劃檬输。否則,就是從其中下載交互的數(shù)據(jù)庫(kù)的名稱匈棘。
is_integrin: True 如果其中一個(gè)是整合素
rank: 每個(gè)交互作用的有效p值的總數(shù)除以細(xì)胞類型-細(xì)胞類型比較的數(shù)量丧慈。(只有在significant_means.txt)
means: 所有相互作用伙伴的平均值:平均值是指相應(yīng)的細(xì)胞類型相互作用對(duì)中每個(gè)伙伴的平均表達(dá)值的總平均值。如果其中一個(gè)平均值為0主卫,那么總平均值為0逃默。(只有在mean.txt)
p.values: p 所有交互伙伴的p-值: p-值是指在每一對(duì)相互作用的細(xì)胞類型中相互作用的配體-受體對(duì)的富集。(只有在pvalues.txt)
significant_mean: 所有交互伙伴的有效平均值計(jì)算簇搅。如果p-值< 0.05完域,即為平均值♀勺剩或者將值設(shè)置為0。(只有在significant_means.txt)
重要的是关噪,相互作用不是對(duì)稱的鸟蟹。在第一個(gè)集群上考慮合作伙伴A表達(dá)式,在第二個(gè)集群上考慮合作伙伴B表達(dá)式使兔。換句話說:
clusterA_clusterB = clusterA expressing partner A and clusterB expressing partner B.
clusterA_clusterB 和 clusterB_clusterA 值是不同的建钥。
(2)Deconvoluted (deconvoluted.txt)
gene_name: 參與所定義的相互作用的一個(gè)亞單位的基因標(biāo)識(shí)符。標(biāo)識(shí)符將取決于用戶列表的輸入虐沥。
uniprot: means.csv 文件中 參與定義的交互的子單元之一的UniProt標(biāo)識(shí)符熊经。
is_complex: 如果子單元是復(fù)合物的一部分,則為真欲险。如果不是 Single 的镐依,就是復(fù)合物的。
protein_name: means.csv 文件中參與所定義的相互作用的一個(gè)亞基的蛋白名稱
complex_name: 如果子單元是復(fù)合物的一部分天试,則稱為復(fù)合物槐壳。如果不是空的。
id_cp_interaction: 存儲(chǔ)在數(shù)據(jù)庫(kù)中的每個(gè)交互的唯一CellPhoneDB標(biāo)識(shí)符喜每。
mean: 各組相應(yīng)基因的平均表達(dá)量务唐。
繪制統(tǒng)計(jì)方法結(jié)果
為了繪制統(tǒng)計(jì)方法的結(jié)果雳攘,您需要首先運(yùn)行統(tǒng)計(jì)分析。目前有兩種可用的繪制類型: dot_plot和heatmap_plot枫笛。
一旦你有了所需的文件( means和 pvaluess)吨灭,你可以進(jìn)行如下操作:
cellphonedb plot dot_plot
cellphonedb plot heatmap_plot yourmeta.txt
(1)dot_pot
這種plot類型需要安裝ggplot2 R包
你可以使用以下參數(shù)調(diào)整plot選項(xiàng):
--means-path: The means output file [./out/means.txt]
--pvalues-path: The pvalues output file [./out/pvalues.txt]
--output-path: Output folder [./out]
--output-name: Filename of the output plot [plot.pdf]
--rows: File with a list of rows to plot, one per line [all available]
--columns: File with a list of columns to plot, one per line [all available]
--verbose / --quiet: Print or hide CellPhoneDB logs [verbose]
可用的輸出格式是R的ggplot2包支持的輸出格式,其中包括:
pdf
png
jpeg
該格式將從 --output-name參數(shù)中推斷出來
只繪制所需的行/列(基于示例數(shù)據(jù)文件中的行和列示例):
cellphonedb plot dot_plot --rows in/rows.txt --columns in/columns.txt
(2)heatmap_plot
這個(gè)plot類型需要安裝pheatmap R包刑巧,使用這個(gè)plot類型包括兩個(gè)特性count和log_count
你可以使用以下參數(shù)調(diào)整plot選項(xiàng):
--pvalues-path: The pvalues output file [./out/pvalues.txt]
--output-path: Output folder [./out]
--count-name: Filename of the output plot [heatmap_count.pdf]
--log-name: Filename of the output plot using log-count of interactions [heatmap_log_count.pdf]
--count-network-name: Filename of the output network file [count_network.txt]
--interactions-count-name: Filename of the output interactions-count file [interactions_count.txt]
--pvalue: pvalue threshold to consider when plotting [0.05]
--verbose / --quiet: Print or hide cellphonedb logs [verbose]
可用的輸出格式是R的pheatmap包支持的輸出格式喧兄,其中包括
pdf
png
jpeg
這種格式將從--count-name和--log-name參數(shù)中推斷出來。
使用不同的數(shù)據(jù)庫(kù)版本
(1)CellPhoneDB數(shù)據(jù)庫(kù)可以通過我們的工具從遠(yuǎn)程存儲(chǔ)庫(kù)更新海诲。此外繁莹,還可以列出和下載可用的版本以供使用。
要使用其中一個(gè)版本特幔,用戶必須為要執(zhí)行的方法提供參數(shù) --database <version_or_file>咨演。
如果給定的參數(shù)是可讀的數(shù)據(jù)庫(kù)文件,則按原樣使用蚯斯。否則薄风,它將使用一些與所選版本匹配的版本。
如果所選版本在本地環(huán)境中不存在拍嵌,則將從遠(yuǎn)程存儲(chǔ)庫(kù)下載該版本遭赂。(見下文)。如果沒有 --database參數(shù)在方法執(zhí)行中給出横辆,它將使用最新可用的本地版本撇他。
下載的版本將存儲(chǔ)在 ~/.cpdb/releases下的用戶文件夾中
(2)列出可用的遠(yuǎn)程版本
從遠(yuǎn)程存儲(chǔ)庫(kù)中列出可用版本的命令是:
cellphonedb database list_remote
(3) 列出本地可用的版本
從本地存儲(chǔ)庫(kù)中列出可用版本的命令是:
cellphonedb database list_local
(4)下載
從遠(yuǎn)程存儲(chǔ)庫(kù)下載版本的命令是:
cellphonedb database download
##OR
cellphonedb database download --version <version_spec|latest>
其中version_spec必須是數(shù)據(jù)庫(kù)list_remote命令中列出的命令之一。如果沒有指定版本狈蚤,或者使用最新版本作為version_spec困肩,則下載最新可用的版本
cellphonedb應(yīng)用于自己的單細(xì)胞轉(zhuǎn)錄組數(shù)據(jù)
library(Seurat)
library(tidyverse)
#提取腫瘤樣本03T
scRNA <- sce
sp1 <- scRNA[,str_detect(colnames(scRNA),'03T')]
sp1_counts <- as.matrix(sp1@assays$RNA@data)
sp1_counts <- data.frame(Gene=rownames(sp1_counts), sp1_counts)
sp1_meta <- data.frame(Cell=rownames(sp1@meta.data), cell_type=sp1@meta.data$new.cluster.ids)
write.table(sp1_counts, "test_counts.txt", row.names=F, sep='\t')
write.table(sp1_meta, "test_meta.txt", row.names=F, sep='\t')