【Cytoscape網(wǎng)絡(luò)圖繪制】摸索入門(mén)篇

這個(gè)軟件就是為了繪制網(wǎng)絡(luò)關(guān)系圖,圈圖等等酷炫的圖片,例如這樣:

Cytoscape官網(wǎng)

一、配置環(huán)境和安裝

安裝Java 11

Java 11下載地址


Java11安裝教程
無(wú)腦點(diǎn)擊安裝,我這里手動(dòng)改到安裝在D盤(pán),而非默認(rèn)的C盤(pán)

環(huán)境變量配置
進(jìn)入環(huán)境變量配置界面: 電腦->右鍵屬性->高級(jí)系統(tǒng)設(shè)置->環(huán)境變量

添加JAVA_HOME變量:


添加path變量的值:



打開(kāi)cmd界面,輸入java驗(yàn)證

二、安裝Cytoscape

官網(wǎng)下載不了,讓朋友發(fā)了我一個(gè)



安裝成功 打開(kāi):


三、繪圖

3.1 構(gòu)建輸入文件

其實(shí)這種網(wǎng)絡(luò)圖,要的就是一個(gè)邊EDGE,和節(jié)點(diǎn)node的信息(每列按tab分割符分割)

從pySCENIC的regulon打分矩陣中提取需要的信息:

regulons = [r.rename(r.name.replace('(+)','')) for r in regulons]
edge = [{r.name:list(r.gene2weight.items())} for r in regulons]

#尋找score最大的基因和得分
line = []
regulon_dict = dict()
for item in edge:
    regulon = item.keys()
    regulon = list(regulon)[0]
    record = dict()
    best_score = 0
    for group in item[regulon]:
        gene, score = group[0], group[1]
        if score > best_score:
            regulon_dict[regulon] = {gene:score}
            best_score = score
#寫(xiě)入文件
with open('/share/nas1/Data/Users/luohb/Personalization/paper/07.Cytoscape/edge.tsv', 'w') as f:
    f.write('regulons\tgene\tscore\n')
    for item in regulon_dict.items():
        regulon = item[0]
        group = item[1]
        gene, score = list(group.keys())[0], list(group.values())[0]
        row = '{}\t{}\t{}\n'.format(regulon, gene, score)

        f.writelines(row)

導(dǎo)入到R中篩選每個(gè)regulon的top10基因(Python有點(diǎn)麻煩)

edge<-read.table('edge.tsv', sep='\t',header=T)
top10.edge = edge %>% group_by(regulons) %>% top_n(n=10,  wt = score)
write.table(top10.edge, file='top10.edge.tsv', sep='\t',quote=F, col.names=T,row.names=F)

文件1: EDGE文件:記錄 節(jié)點(diǎn)關(guān)系信息 和 邊的寬度信息

列的排列位置不重要,因?yàn)閷?dǎo)入到Cytoscape可以選擇

文件2: Node文件:記錄每個(gè)節(jié)點(diǎn)的分組信息(不同的分組顏色)


3.2 Cytoscape可視化

  1. 導(dǎo)入EDGE文件:




  2. 導(dǎo)入Node文件



參考

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容