cytoscape 基因网络图网络图怎么做成三个同心圆

cytoscape简单操作_图文_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
cytoscape简单操作
上传于||文档简介
&&本​人​在​一​次​网​络​实​验​中​用​到​了​c​y​t​o​s​c​a​p​e​绘​图​,​做​了​一​些​简​单​的​小​结​,​适​合​初​学​者
阅读已结束,如果下载本文需要使用1下载券
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,查找使用更方便
还剩12页未读,继续阅读
定制HR最喜欢的简历
你可能喜欢cytoscape绘制网络图,导入数据的要求有哪些?
想用cytoscape绘制基因调控网络图,描述基因与基因之间的拓扑关系,现有一张行为基因名,列为样本单元,主体内容为基因之间相关程度指数的excel表格,不知道如何用cytoscape绘制。或者该用什么工具实现基因调控网络的可视化
cytoscape可以处理多种格式的文本文件。你把你的数据转成这些文件,然后就可以在cytoscape里打开了。最简单的是.sif格式(),格式是:nodeA &interaction& nodeB
nodeC &interaction& nodeD
就是说文件分三列,第一列和第三列是相互作用的基因名,第二列是相互作用的名称。.sif格式的好处是简单,容易处理。不过它不能规定每个节点的位置、大小、形状等。另一种是xgmml格式,它是一种xml格式,可以规定节点和边的许多信息,但也更复杂。我在网上查了很久都没有查到xgmml格式的详细信息,没办法只好随便画个网络,让cytoscape导出成xgmml,然后一行一行看,花了一晚上搞明白了。于是写了几个python小函数来专门写这种格式。代码附在最后。然后要画网络的时候写小脚本就行了:(假设这几个小函数的文件名叫xgmml.py)from xgmml import *
fid = open('test.xml', 'w')
addHead(fid, 'hehe')
addNode(fid, 'A', 'A')
addNode(fid, 'B', 'B')
addEdge(fid, 'A', 'B', 'A to B')
fid.write('&/graph&\n')
fid.close()
代码应该很好理解吧?导入包,打开文件,用addHead写文件头,addNode加结点,addEdge加边,补一句文件结尾,然后关闭文件。最后把test.xml在cytoscape里打开就行啦:==========================================吐槽一下。其实我觉得cytoscape很不好用,各种操作反人类,还经常打不开关不掉。但似乎没有更好的选择。曾经有个叫gephi的软件,还上过nature genetics的封面,找过了用了一下,摸了半天感觉比cytoscape还反人类,遂弃之。==========================================附画xgmml的python代码:# xgmml.py
def addHead(fid, GraphID):
''' addHead
Add the head content of an XGMML file to a file handle.
The file handle of the XGMML file.
The name of the graph. '''
import time;
fid.write('&?xml version="1.0" encoding="UTF-8" standalone="yes"?&\n')
fid.write('&graph id="423" label="436" directed="1" cy:documentVersion="3.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/-rdf-syntax-ns#" xmlns:cy="http://www.cytoscape.org" xmlns="http://www.cs.rpi.edu/XGMML"&\n')
fid.write('\t&att name="networkMetadata"&\n')
fid.write('\t\t&rdf:RDF&\n')
fid.write('\t\t\t&rdf:Description rdf:about="http://www.cytoscape.org/"&\n')
fid.write('\t\t\t\t&dc:type&Protein-Protein Interaction&/dc:type&\n')
fid.write('\t\t\t\t&dc:description&N/A&/dc:description&\n')
fid.write('\t\t\t\t&dc:identifier&N/A&/dc:identifier&\n')
fid.write('\t\t\t\t&dc:date&%d-%d-%d %d:%d:%d&/dc:date&\n' % time.localtime()[:6])
fid.write('\t\t\t\t&dc:title&436&/dc:title&\n')
fid.write('\t\t\t\t&dc:source&http://www.cytoscape.org/&/dc:source&\n')
fid.write('\t\t\t\t&dc:format&Cytoscape-XGMML&/dc:format&\n')
fid.write('\t\t\t&/rdf:Description&\n')
fid.write('\t\t&/rdf:RDF&\n')
fid.write('\t&/att&\n')
fid.write('\t&att name="shared name" value="%s" type="string"/&\n' % GraphID)
fid.write('\t&att name="selected" value="1" type="boolean"/&\n')
fid.write('\t&att name="name" value="%s" type="string"/&\n' % GraphID)
fid.write('\t&att name="__Annotations" type="list"&\n')
fid.write('\t&/att&\n')
fid.write('\t&graphics&\n')
fid.write('\t\t&att name="NETWORK_WIDTH" value="1000.0" type="string"/&\n')
# Network_Width to be specified.
fid.write('\t\t&att name="NETWORK_NODE_SELECTION" value="true" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_CENTER_X_LOCATION" value="500.0" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_TITLE" value="" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_EDGE_SELECTION" value="true" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_DEPTH" value="0.0" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_CENTER_Z_LOCATION" value="0.0" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_SCALE_FACTOR" value="1.0" type="string"/&\n')
fid.write('\t\t&att name="NETWORK_BACKGROUND_PAINT" value="#ffffff" type="string"/&\n')
# Background_Color to be specified.
fid.write('\t\t&att name="NETWORK_HEIGHT" value="500.0" type="string"/&\n')
# Network_Height to be specified.
fid.write('\t\t&att name="NETWORK_CENTER_Y_LOCATION" value="0.0" type="string"/&\n')
fid.write('\t&/graphics&\n')
return True
def addNode(fid, Label, ID, fill='#ff0000', shape='ELLIPSE', x=0.0, y=0.0, w=35.0, h=35.0, FontSize=15, LabelColor='#000000', Transparency=255, LabelPosition='C,C,c,0,0'):
''' addNode
Add the content of a new node to an XGMML file.
The file handle of the XGMML file.
The label of the node.
ID of the node.
The color of the node.
The shape of the node.
{'ELLIPSE','ROUND_RECTANGLE','TRIANGLE','DIAMOND',
'PARALLELOGRAM','HEXAGON','RECTANGLE','OCTAGON','V'}
The coordinates of the node.
The width and height of the node.
The font size of the label.
LabelColor
The color of the label.
Transparency
The transparency of the node.
LabelPosition
The label position.
fid.write('\t&node id="%s" label="%s"&\n' % (ID,Label) )
fid.write('\t\t&att name="shared name" value="%s" type="string"/&\n' % Label)
fid.write('\t\t&att name="selected" value="0" type="boolean"/&\n')
fid.write('\t\t&att name="name" value="%s" type="string"/&\n' % Label)
fid.write('\t\t&graphics fill="%s" x="%f" type="%s" z="0.0" outline="#333333" width="3.0" y="%f" h="%f" w="%f"&\n' % (fill,x,shape,y,h,w))
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_4" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_3" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_TRANSPARENCY" value="%d" type="string"/&\n' % Transparency)
fid.write('\t\t\t&att name="NODE_LABEL_TRANSPARENCY" value="255" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_6" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_BORDER_TRANSPARENCY" value="255" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_4" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_2" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_7" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_5" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_5" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_6" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_9" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_7" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL" value="%s" type="string"/&\n' % Label)
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_4" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_5" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_BORDER_STROKE" value="SOLID" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_8" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_VISIBLE" value="true" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL_FONT_FACE" value="Dialog.plain,plain,12" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_DEPTH" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_2" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_8" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_4" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL_WIDTH" value="200.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL_FONT_SIZE" value="%d" type="string"/&\n' % FontSize)
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_3" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_1" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL_COLOR" value="%s" type="string"/&\n' % LabelColor)
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_1" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_TOOLTIP" value="" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_SELECTED_PAINT" value="#ffff00" type="string"/&\n')
# Seleted_Paint to be specified.
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_9" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_2" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_LABEL_POSITION" value="%s" type="string"/&\n' % LabelPosition)
fid.write('\t\t\t&att name="NODE_SELECTED" value="false" type="string"/&\n')
# is_Selected to be specified.
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_7" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_9" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_8" value="org.cytoscape.ding.customgraphics.NullCustomGraphics,0,[ Remove Graphics ]," type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_SIZE_3" value="0.0" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_NESTED_NETWORK_IMAGE_VISIBLE" value="true" type="string"/&\n')
fid.write('\t\t\t&att name="NODE_CUSTOMGRAPHICS_POSITION_1" value="C,C,c,0.00,0.00" type="string"/&\n')
fid.write('\t\t&/graphics&\n')
fid.write('\t&/node&\n')
return True
def addEdge(fid, source, target, ID, Label='', directed='1', SourceArrowShape='ARROW', TargetArrowShape='ARROW', SourceArrowColor='#000000', TargetArrowColor='#000000',\
LineType='SOLID', LineWidth=2.0, LineColor='#333333'):
''' addEdge
Add the content of a new edge to an XGMML file.
The file handle of the XGMML file.
The start node of the edge.
The end node of the edge.
The ID of the edge, which must be special.
The label of the edge, which will be present on the graph but not necessarily special.
Whether the edge is directed.
SourceArrowShape
The shape of the source arrow. {'ARROW','DELTA','CIRCLE','HALF_BOTTOM','DIAMOND','HALF_TOP','NONE','T'}
TargetArrowShape
The shape of the target arrow. {'ARROW','DELTA','CIRCLE','HALF_BOTTOM','DIAMOND','HALF_TOP','NONE','T'}
SourceArrowColor
The color of the source arror. (unselected)
TargetArrowColor
The color of the target arrow. (unselected)
The presented type of the line. {'SOLID','DASHDOT','ZIGZAG','FORWARD_SLASH','SINEWAVE','SEPARATE_ARROW',
'BACKWARD_SLASH','EQUAL_DASH','PARALLEL_LINES','DASH','VERTICAL_SLASH',
'CONTIGUOUS_ARROW','DOTS'}
The width of the line.
The color of the line. '''
fid.write('\t&edge id="%s" label="%s (interaction) %s" source="%s" target="%s" cy:directed="%s"&\n' % (ID,source,target,source,target,directed))
fid.write('\t\t&att name="interaction" value="interaction" type="string"/&\n')
fid.write('\t\t&att name="shared name" value="%s (interaction) %s" type="string"/&\n' % (source,target))
fid.write('\t\t&att name="selected" value="0" type="boolean"/&\n')
fid.write('\t\t&att name="name" value="%s (interaction) %s" type="string"/&\n' % (source,target))
fid.write('\t\t&att name="shared interaction" value="interaction" type="string"/&\n')
fid.write('\t\t&graphics width="%f" fill="%s"&\n' % (LineWidth,LineColor))
fid.write('\t\t\t&att name="EDGE_TRANSPARENCY" value="255" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_SOURCE_ARROW_SHAPE" value="%s" type="string"/&\n' % SourceArrowShape)
fid.write('\t\t\t&att name="EDGE_SELECTED" value="false" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_TOOLTIP" value="" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_TARGET_ARROW_UNSELECTED_PAINT" value="%s" type="string"/&\n' % TargetArrowColor)
fid.write('\t\t\t&att name="EDGE_LABEL_FONT_FACE" value="Dialog.plain,plain,10" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_TARGET_ARROW_SELECTED_PAINT" value="#ffff00" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_CURVED" value="true" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_LABEL_FONT_SIZE" value="10" type="string"/&\n')
# Label_Font_Size to be specified.
fid.write('\t\t\t&att name="EDGE_LINE_TYPE" value="%s" type="string"/&\n' % LineType)
fid.write('\t\t\t&att name="EDGE_VISIBLE" value="true" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_SOURCE_ARROW_UNSELECTED_PAINT" value="%s" type="string"/&\n' % SourceArrowColor)
fid.write('\t\t\t&att name="EDGE_STROKE_SELECTED_PAINT" value="#ff0000" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_SOURCE_ARROW_SELECTED_PAINT" value="#ffff00" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_LABEL" value="%s" type="string"/&\n' % Label)
fid.write('\t\t\t&att name="EDGE_LABEL_TRANSPARENCY" value="255" type="string"/&\n')
fid.write('\t\t\t&att name="EDGE_TARGET_ARROW_SHAPE" value="%s" type="string"/&\n' % TargetArrowShape)
fid.write('\t\t\t&att name="EDGE_LABEL_COLOR" value="#000000" type="string"/&\n') # Label color to be specified.
fid.write('\t\t\t&att name="EDGE_BEND" value="" type="string"/&\n')
fid.write('\t\t&/graphics&\n')
fid.write('\t&/edge&\n')
return True
最简单的方法:用tab分割的纯文本文件。描述边的文件可以是每行一个边,tab分割的两个token分别是from顶点和to顶点。注意导入的时候选择正确的列映射。并且去掉“第一行是属性标题”这一选项,不然它会认为你第一行是标题而不是内容,你会凭空少一个边。然后再弄几个tab分割的纯文本描述顶点属性和边属性,ID对上就行。
各位兄弟,我想请教一个问题,如何通过两个点去选择它们之间的边呢,要能批量操作的那种
第一个答主一看就是编程底子深厚啊,我提供一种简单的方式。我的数据一般是txt文件,做成两列,每一列都是基因名称,同一行表示有互作关系(这是准备画无方向网络图的,如果是要画有方向网络图则第一列是上游基因,第二列是被调控的基因)。如果是有调控强弱系数,就放在第三列。然后file-&import-&network-&file..选择你的txt文件,打开后如图(图片上传失败,,,)就是从弹出来的窗口选择,source interaction选择第一列基因,targets interaction选择第二列基因,(中间的interaction type选择调控系数)然后点击导入,选择有向网络或者无项网络,初步的网络图就做出来了。可以通过cytoscape自带的network analysis包,或者安装其他的包来对这个网络进行一定的分析或者形状改变,这点挺像R的。最后,调控关系并没有显示,而是作为边的属性存在,所以可以根据这个属性值,显示成粗细不同,或者做一个筛选,等等。(这个我没做过,但是属性值看到过,肯定有包是可以的。)好,就是这样,欢迎批评指正,新手,求轻拍!
兄弟,你现在弄好了吗?我愁死了,该怎么用cytoscape去打开xgmml文件
已有帐号?
无法登录?
社交帐号登录君,已阅读到文档的结尾了呢~~
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
Cytoscape使用方法(正式版本)
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

我要回帖

更多关于 cytoscape下载 的文章

 

随机推荐