Ejemplo n.º 1
0
 def test_writing(self):
     networks_table, networks = read_networks(path.join(TEST_DIR, 'network_random'))
     tmp_dir = path.join(TEST_DIR, 'tmp')
     makedirs(tmp_dir, exist_ok=True)
     write_networks(tmp_dir, networks_table, networks)
     _networks_table, _networks = read_networks(tmp_dir)
     self.assertTrue(networks_table.equals(_networks_table))
     guid = networks_table['GUID'][0]
     self.assertTrue(networks[guid]['node_table'].equals(_networks[guid]['node_table']))
     self.assertTrue(networks[guid]['edge_table'].equals(_networks[guid]['edge_table']))
     rmtree(tmp_dir)
Ejemplo n.º 2
0
from perseuspy import pd
from perseuspy.parameters import *
_, paramfile, infile, outfile = sys.argv # read arguments from the command line
parameters = parse_parameters(paramfile) # parse the parameters file
df = pd.read_perseus(infile) # read the input matrix into a pandas.DataFrame
some_value = doubleParam(parameters, 'some value') # extract a parameter value
df2 = some_value / df.drop('Name', 1)
df2.to_perseus(outfile) # write pandas.DataFrame in Perseus txt format

import sys
from perseuspy import nx, pd, read_networks, write_networks
_, paramfile, infolder, outfolder = sys.argv # read arguments from the command line
networks_table, networks = read_networks(infolder) # networks in tabular form
graphs = nx.from_perseus(networks_table, networks) # graphs as networkx objects
_networks_table, _networks = nx.to_perseus(graphs) # convert back into tabular form
write_networks(tmp_dir, networks_table, networks) # write to folder

import pandas as pd
data = pd.read_table("C:/Users/animeshs/OneDrive - NTNU/OneDrive - NTNU/Jimita/txt48/proteinGroups.txt",sep='\t', index_col=0, header=0, lineterminator='\n')
data.head()


%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
dataLFQlog2=np.log2(dataLFQ+1)
dataLFQlog2.hist()

label = pd.read_table("C:/Users/animeshs/OneDrive - NTNU/OneDrive - NTNU/Jimita/txt48/Groups.txt",sep='\t', index_col=0, header=0, lineterminator='\n')
label
"""
Create random barabasi albert graph

Requires passing n, m as additional arguments
"""
from perseuspy import pd, nx, write_networks
import sys
_, n, m, outfolder = sys.argv
G = nx.random_graphs.barabasi_albert_graph(int(n), int(m))
networks_table, networks = nx.to_perseus([G])
write_networks(outfolder, networks_table, networks)