<jupyter_start><jupyter_text>Exploring BioGRID COVID-19 datasetIn this notebook I explore the dataset, filter it by species and create a graph object for visualization in d3.js<jupyter_code>import pandas as pd
import networkx as nx
from networkx.readwrite import json_graph
import json
import re
import warnings
warnings.filterwarnings('ignore')
interact = pd.read_table("./data/BIOGRID-CORONAVIRUS-3.5.185.tab3.txt")
interact.columns
interact.head()
interest = ['9606', '2697049']
interact_subset = interact.query("`Organism ID Interactor A`=='2697049' & `Organism ID Interactor B`.isin(@interest)")
interact_subset.shape
cols = ['Organism ID Interactor A', 'Official Symbol Interactor A']
interact_subset['Protein_A'] = interact_subset[cols].apply(lambda row: '_'.join(row.values.astype(str)), axis=1)

cols = ['Organism ID Interactor B', 'Official Symbol Interactor B']
interact_subset['Protein_B'] = interact_subset[cols].apply(lambda row: '_'.join(row.values.astype(str)), axis=1)
onlyInter = interact_subset[['Protein_A', 'Protein_B']]
onlyInter
G=nx.from_pandas_edgelist(onlyInter, 'Protein_A', 'Protein_B')
degrees = dict(nx.degree(G))
for key, value in degrees.items():
    degrees[key] = value*1.5
data = json_graph.node_link_data(G)
for i in data['nodes']:
    i['species'] = int(re.sub('\_.*', '', i['id']))
    accessor = i['id']
    i['degree'] = degrees[accessor]
    
    
with open('./data/biogrid.json', 'w') as fp:
    json.dump(data, fp)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14929388029589777, 'fraction_numerical': 0.020847343644922665, 'mean_word_length': 6.119617224880383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '629708', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 537, 'n_tokens_neox': 507, 'n_words': 122, 'path': 'exploring_biogrid.ipynb', 'repo_name': 'jvfe/covidppi', 'size': '1487'}