Displays topological representation of the data colored according to the expression of a gene, genes or list of genes, specified by argument 'color'. This can be a gene or a list of one, two or three genes or lists of genes, to be respectively mapped to red, green and blue c
(self, color, connected=True, labels=False, ccmap='jet', weight=8.0, save='', ignore_log=False,
table=False, axis=[], a=0.4)
| 1187 | return numpy.array(mat) |
| 1188 | |
| 1189 | def draw(self, color, connected=True, labels=False, ccmap='jet', weight=8.0, save='', ignore_log=False, |
| 1190 | table=False, axis=[], a=0.4): |
| 1191 | """ |
| 1192 | Displays topological representation of the data colored according to the expression of a gene, genes or |
| 1193 | list of genes, specified by argument 'color'. This can be a gene or a list of one, two or three genes or lists |
| 1194 | of genes, to be respectively mapped to red, green and blue channels. When only one gene or list of genes is |
| 1195 | specified, it uses color map specified by 'ccmap'. If optional argument 'connected' is set to True, only the |
| 1196 | largest connected component of the graph is displayed. If argument 'labels' is True, node id's are also |
| 1197 | displayed. Argument 'weight' allows to set a scaling factor for node sizes. When optional argument 'save' |
| 1198 | specifies a file name, the figure will be save in the file, in the format specified by its extension, and |
| 1199 | no plot will be displayed on the screen. When 'ignore_log' is True, it treat expression values as being in |
| 1200 | natural scale, even if self.log2 is True (used internally). When argument 'table' is True, it displays in |
| 1201 | addition a table with some statistics of the gene or genes. Optional argument 'axis' allows to specify axis |
| 1202 | limits in the form [xmin, xmax, ymin, ymax]. Parameter alpha specifies the alpha value of edges. |
| 1203 | """ |
| 1204 | if connected: |
| 1205 | pg = self.gl |
| 1206 | pos = self.posgl |
| 1207 | else: |
| 1208 | pg = self.g |
| 1209 | pos = self.posg |
| 1210 | fig = pylab.figure() |
| 1211 | networkx.draw_networkx_edges(pg, pos, width=1, alpha=a) |
| 1212 | sizes = numpy.array([len(self.dic[node]) for node in pg.nodes()])*weight |
| 1213 | values = [] |
| 1214 | if type(color) == str: |
| 1215 | color = [color] |
| 1216 | if type(color) == list and len(color) == 1: |
| 1217 | coloru, tol = self.get_gene(color[0], ignore_log=ignore_log, con=connected) |
| 1218 | values = [coloru[node] for node in pg.nodes()] |
| 1219 | networkx.draw_networkx_nodes(pg, pos, node_color=values, node_size=sizes, cmap=pylab.get_cmap(ccmap)) |
| 1220 | polca = values |
| 1221 | elif type(color) == list and len(color) == 2: |
| 1222 | colorr, tolr = self.get_gene(color[0], ignore_log=ignore_log, con=connected) |
| 1223 | rmax = float(max(colorr.values())) |
| 1224 | if rmax == 0.0: |
| 1225 | rmax = 1.0 |
| 1226 | colorb, tolb = self.get_gene(color[1], ignore_log=ignore_log, con=connected) |
| 1227 | bmax = float(max(colorb.values())) |
| 1228 | if bmax == 0.0: |
| 1229 | bmax = 1.0 |
| 1230 | values = [(1.0-colorb[node]/bmax, max(1.0-(colorr[node]/rmax+colorb[node]/bmax), 0.0), |
| 1231 | 1.0-colorr[node]/rmax) for node in pg.nodes()] |
| 1232 | networkx.draw_networkx_nodes(pg, pos, node_color=values, node_size=sizes) |
| 1233 | polca = [(colorr[node], colorb[node]) for node in pg.nodes()] |
| 1234 | elif type(color) == list and len(color) == 3: |
| 1235 | colorr, tolr = self.get_gene(color[0], ignore_log=ignore_log, con=connected) |
| 1236 | rmax = float(max(colorr.values())) |
| 1237 | if rmax == 0.0: |
| 1238 | rmax = 1.0 |
| 1239 | colorg, tolg = self.get_gene(color[1], ignore_log=ignore_log, con=connected) |
| 1240 | gmax = float(max(colorg.values())) |
| 1241 | if gmax == 0.0: |
| 1242 | gmax = 1.0 |
| 1243 | colorb, tolb = self.get_gene(color[2], ignore_log=ignore_log, con=connected) |
| 1244 | bmax = float(max(colorb.values())) |
| 1245 | if bmax == 0.0: |
| 1246 | bmax = 1.0 |
nothing calls this directly
no test coverage detected