After starting Python, import Tethne modules with:
>>> import tethne.readers as rd
To parse some data from the Web of Science, use the tethne.readers.wos module. See the Paper class for more information about what Tethne extracts from your WoS data.
>>> papers = rd.wos.read("/Path/To/FirstDataSet.txt")
>>> papers[0]
<tethne.data.Paper instance at 0x1015ed200>
You can either generate a network directly from your data using the methods in tethne.networks.wos , or you can package your data in a DataCollection for comparative or longitudinal analysis. If you want to generate a dynamic network, then use a DataCollection .
To generate a single network directly from your data, use the tethne.networks.wos module. For example, to build a bibliographic coupling network:
>>> import tethne.networks as nt
>>> BC = nt.citations.bibliographic_coupling(papers)
>>> BC
<networkx.classes.graph.Graph object at 0x101b4fe50>
NetworkX provides algorithms for graph analysis. To generate betweenness-centrality values for each node, try:
>>> import networkx as nx
>>> b_centrality = nx.betweenness_centrality(BC)
>>> nx.set_node_attributes(BC, 'betweenness', b_centrality)
>>> BC.nodes(data=True)[0]
('BRADSHAW 1965 ADV GENET', {'betweenness': 0.12345})
You can then export your network for visualization using one of the methods in tethne.writers . For example, to generate a simple interaction file (SIF):
>>> import tethne.writers as wr
>>> wr.graph.to_sif(BC, '/Path/to/Output/File')
Especially if you want to create a dynamic network (a network that changes over time), use a DataCollection to organize your data.
To create a DataCollection :
>>> from tethne.data import DataCollection, GraphCollection
>>> D = DataCollection(papers)
You can then use the tethne.data.DataCollection.slice() method to slice your data, e.g. by publication date. To use a 4-year sliding time-window:
>>> D.slice('date', 'time_window', window_size=4)
Create a GraphCollection to manage your graphs. tethne.builders provides some helpful classes for creating a GraphCollection from a DataCollection . For example authorCollectionBuilder build a GraphCollection using an author-based network (e.g. coauthorship networks) in tethne.networks.authors :
>>> from tethne.builders import authorCollectionBuilder
>>> builder = authorCollectionBuilder(D)
>>> C = builder.build('date', 'coauthors')
To write dynamic XGMML for visualization in Cytoscape, use the writing methods in tethne.writers.collection :
>>> import tethne.writers as wr
>>> wr.collection.to_dxgmml(C, '/Path/to/Network.xgmml')