ups
This commit is contained in:
parent
e06eeb6d17
commit
6ba8c6eb67
@ -1,6 +1,7 @@
|
||||
import pylab
|
||||
import matplotlib
|
||||
import networkx as nx
|
||||
import scipy
|
||||
|
||||
def plot_corrloads(R, pc1=0,pc2=1,s=20, c='b', zorder=5,expvar=None,ax=None,drawback=True, labels=None):
|
||||
""" Correlation loading plot."""
|
||||
@ -56,3 +57,31 @@ def plot_dag(edge_dict, node_color='b', node_size=30,labels=None,nodelist=None,p
|
||||
|
||||
nx.draw_networkx(G,pos, with_labels=with_labels, node_size=node_size, node_color=node_color, nodelist=nodelist)
|
||||
|
||||
|
||||
def plot_ZXcorr(gene_ids, term_ids, gene2go, X, D, scale=True):
|
||||
""" Plot correlation/covariance between genes as a function of
|
||||
semantic difference.
|
||||
|
||||
input: X (n, p) data matrix
|
||||
D (p, p) gene-gene sematic similarity matrix
|
||||
"""
|
||||
D = scipy.corrcoef(X)
|
||||
term2ind = dict(enumerate(term_ids))
|
||||
for i, gene_i in enumerate(gene_ids):
|
||||
for j, gene_j in enumerate(gene_ids):
|
||||
if j<i:
|
||||
r2 = D[i,j]
|
||||
terms_i = gene2go[gene_i]
|
||||
terms_j = gene2go[gene_j]
|
||||
for ti, term in enumerate(term_ids):
|
||||
if term in terms_i:
|
||||
pass
|
||||
|
||||
|
||||
def clustering_index(T, Yg):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
|
||||
def smdb_annot(orflist=None, input_fname='registry.genenames.tab', output_fname='yeast.annot'):
|
||||
|
||||
"""Reads registry.genenames.tab from the Stanford yeast
|
||||
microarray database.
|
||||
|
||||
Available from:
|
||||
ftp://genome-ftp.stanford.edu/pub/yeast/data_download/gene_registry/registry.genenames.tab
|
||||
|
||||
input: orf -- list of orfs (open reading frames)
|
||||
file -- (optional) file to fetch info from
|
||||
|
||||
registry.genames contains:
|
||||
|
||||
0 = Locus name
|
||||
1 = Other name
|
||||
2 = Description
|
||||
3 = Gene product
|
||||
4 = Phenotype
|
||||
5 = ORF name
|
||||
6 = SGDID
|
||||
|
||||
NB! Other name, Gene product and Phenotype may have more
|
||||
than one mapping. These are separated by |
|
||||
|
||||
Output: writes an annotation file
|
||||
|
||||
"""
|
||||
outfile = open(output_fname, 'w')
|
||||
header = "Orf\tLocus_id\tOther_name\tDescription\tGene_product\tPhenotype\tSGD_ID\n"
|
||||
outfile.write(header)
|
||||
text = open(input_fname, 'r').read().splitlines()
|
||||
for line in text:
|
||||
els = line.split('\t')
|
||||
orf_name = els.pop(5)
|
||||
if orf_name!='': # we dont care about non-named orfs
|
||||
if orflist and orf_name not in orflist:
|
||||
break
|
||||
for e in els:
|
||||
if e !='':
|
||||
outfile.write(str(e) + "\t")
|
||||
else:
|
||||
outfile.write("NA")
|
||||
f.write("\n")
|
Reference in New Issue
Block a user