Positive network:

  • jaccard coefficient
  • adamic adar index
  • closeness vitality
  • page rank

In [13]:
import networkx as nx
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

pd.options.display.max_rows = 20

In [2]:
# read multigraph M
M = nx.read_gml('../output/network/u_Gc_positive2.gml')


# convert multigraph M to simple graph G (remove parallel edges)
G = nx.Graph()
for u,v,data in M.edges_iter(data=True):
    w = data['weight'] if 'weight' in data else 1.0
    if G.has_edge(u,v):
        G[u][v]['weight'] += w
    else:
        G.add_edge(u, v, weight=w)
#print G.edges(data=True)

print nx.info(M), '\n'
print nx.info(G)


Name: undirected Gc
Type: MultiGraph
Number of nodes: 585
Number of edges: 1042
Average degree:   3.5624 

Name: 
Type: Graph
Number of nodes: 585
Number of edges: 935
Average degree:   3.1966

In [3]:
## jaccard coefficient

jc = nx.jaccard_coefficient(G)
jc = list(jc)
for u, v, p in jc:
    '(%s, %s) -> %.4f' % (u, v, p)

In [14]:
df = pd.DataFrame(jc, columns=['u', 'v', 'jaccard'])
subset_df = df.ix[df['jaccard'] != 0, :]
subset_df.sort_values('jaccard', ascending=False)


Out[14]:
u v jaccard
80 neighbors social media 1.000000
101325 Prabhupada Village bad news 1.000000
16639 mild daily activities 1.000000
16687 mild pain 1.000000
16708 mild swelling 1.000000
16755 mild arm 1.000000
16810 mild hardness of the skin 1.000000
16891 mild run down feeling 1.000000
101473 Prabhupada Village models of disease 1.000000
101395 Prabhupada Village ear infections 1.000000
... ... ... ...
97843 United States parents 0.016667
141234 vaccines side effects 0.016667
164998 measles vaccine vaccination 0.016393
37138 studies parents 0.016393
81894 meningococcal vaccine parents 0.016393
130008 autism risk parents 0.015873
151058 measles SB 277 0.015625
69324 Jain study parents 0.015625
47641 meningococcal disease measles 0.013889
47701 meningococcal disease parents 0.012987

8267 rows × 3 columns


In [5]:
# save jaccard
#subset_df.to_csv('jaccard_positive.csv')

In [6]:
## adamic adar index

aa = nx.adamic_adar_index(G)
aa = list(aa)
for u, v, p in aa:
    '(%s, %s) -> %.8f' % (u, v, p)

In [15]:
df = pd.DataFrame(aa, columns=['u', 'v', 'adamic_adar'])
subset_df = df.ix[df['adamic_adar'] != 0, :]
subset_df.sort_values('adamic_adar', ascending=False)


Out[15]:
u v adamic_adar
51539 vaccination coverage measles vaccination 6.205075
130168 autism risk autism 4.418644
103384 genital warts cervical dysplasia 4.335491
69421 Jain study autism 3.583447
141283 vaccines vaccine-autism link 3.266084
141310 vaccines vaccination 3.264423
81799 meningococcal vaccine vaccines 3.188803
167967 HPV vaccine sexually active 3.034899
108527 2014-2015 FLULAVAL QUADRIVALENT flu vaccine flu vaccine recall 2.885390
52923 states herd immunity 2.866833
... ... ... ...
141400 vaccines peers 0.254335
141396 vaccines friends 0.254335
141382 vaccines sense of urgency 0.254335
141380 vaccines daughters 0.254335
141367 vaccines Mina study 0.254335
141355 vaccines Tdap vaccine 0.254335
141342 vaccines vaccine success 0.254335
141339 vaccines scheduled appointment 0.254335
141312 vaccines religious beliefs 0.254335
91821 worried Gardasil 0.254335

8267 rows × 3 columns


In [8]:
# save adamic idar
#subset_df.to_csv('adamic_positive.csv')

In [16]:
# closeness vitality
# of a node is the change in the sum of distances between all node pairs when excluding that node

cv = nx.closeness_vitality(M)

cv_df = pd.DataFrame.from_dict(cv, orient = 'index')
cv_df.columns = ['closeness vitality']
cv_df.sort_values(by = ['closeness vitality'], ascending = False)


Out[16]:
closeness vitality
meningococcal disease 79948.0
vaccination 77396.0
polio vaccine opposition 74438.0
Wakefield study 64018.0
HPV vaccine 63748.0
vaccines 61934.0
autism 61016.0
orthodox Hasidic Jews 55846.0
measles 47038.0
hepatitis A vaccine 44804.0
... ...
danger 1236.0
herd immunity 634.0
Muslim fundamentalists -1110.0
children -2862.0
Gardasil -4322.0
community -4596.0
religious groups -4596.0
United States -7886.0
CDC -8612.0
parents -16162.0

585 rows × 1 columns


In [10]:
# save closeness vitality
#cv_df.to_csv('cv_positive.csv')

In [11]:
# link analysis: page rank
# PageRank computes a ranking of nodes based on structure of incoming links

pr = nx.pagerank_numpy(M)

pr_df = pd.DataFrame.from_dict(pr, orient = 'index')
pr_df.columns = ['page rank']
pr_df.sort_values(by = ['page rank'], ascending = False)


Out[11]:
page rank
vaccines 0.024877
parents 0.022525
measles 0.022306
vaccination 0.019813
meningococcal disease 0.015175
HPV vaccine 0.013251
autism 0.012680
vaccine-autism link 0.012336
anti-vaccination 0.011657
measles vaccine 0.009861
children 0.009341
religious groups 0.008965
side effects 0.008354
SB 277 0.008267
MMR vaccine 0.008120
meningococcal vaccine 0.007755
vaccination exemption 0.006934
disease 0.006723
Jain study 0.006621
rubella 0.006596
community 0.006381
autism risk 0.006217
studies 0.006041
parents who refuse to vaccinate their children 0.005919
personal belief exemption 0.005737
polio vaccine opposition 0.005656
Gardasil 0.005575
herd immunity 0.005097
vaccine refusal 0.005055
states 0.005012
Wakefield study 0.004983
vaccine delay 0.004297
unvaccinated children 0.004208
cervical dysplasia 0.004110
Tdap vaccine 0.004075
United States 0.004031
schools 0.003904
low vaccination rates 0.003874
2014-2015 FLULAVAL QUADRIVALENT flu vaccine 0.003781
protective effect of vaccines 0.003777
families 0.003764
children at higher risk for autism 0.003745
vaccine mandates 0.003731
infants 0.003684
health benefits 0.003632
infection 0.003595
genital warts 0.003484
religious exemption 0.003462
vaccine-preventable diseases 0.003438
vaccinated 0.003392
vaccination rate 0.003381
vaccinated children 0.003361
vaccine-free day care centres 0.003359
multi-site protection 0.003335
girls 0.003211
long-term disabilities 0.003185
HPV 0.003137
childhood mortality 0.003103
anti-vaxxer 0.003100
immune system 0.003098
public health 0.003059
medical exemption 0.003055
NIH 0.002993
measles vaccination 0.002986
cervical cancer 0.002971
measles outbreak 0.002971
decrease in exemption rates 0.002961
money 0.002929
outbreaks 0.002920
policy makers 0.002917
meningococcal outbreak 0.002902
sexually active 0.002900
Mina study 0.002894
JAMA study 0.002786
religion 0.002767
vaccine requirements 0.002761
vaccination coverage 0.002718
environmental factors 0.002710
minor symptoms 0.002679
conspiracy 0.002607
measles resurgence 0.002593
cancer 0.002589
children with autism 0.002584
research 0.002573
meningococcal disease symptoms 0.002573
Disneyland measles outbreak 0.002563
eliminated virus 0.002534
vaccine message 0.002529
Andrew Wakefield 0.002516
misguided claims 0.002515
vaccines do not cause autism 0.002505
protection 0.002503
teens 0.002490
parents of autistic children 0.002419
carrier 0.002419
immunity 0.002413
evidence 0.002385
pregnant women 0.002335
William Moss 0.002322
infectious disease 0.002315
myth 0.002314
Dutch reformed churches 0.002262
whooping cough 0.002204
women 0.002175
women previously exposed to HPV 0.002165
state vaccination rates 0.002158
fence-sitters 0.002145
young adults 0.002135
American Medical Association 0.002097
church 0.002086
unvaccinated-friendly day care centres 0.002083
polio 0.002066
Jews 0.002061
cluster 0.002052
California 0.002052
fear of autism 0.002050
pro-vaccination 0.002047
mystery 0.002043
opposed 0.002041
financial forces 0.002035
hepatitis A vaccine 0.002035
controversial bill 0.002013
Muslim fundamentalists 0.001999
health officials 0.001998
high-risk types of HPV 0.001977
vaccine alternatives 0.001973
high vaccination rates 0.001968
birth defects 0.001962
infectious disease mortality 0.001952
vaccine hesitancy 0.001939
orthodox Hasidic Jews 0.001932
CDC 0.001929
close contacts 0.001916
hypotheses 0.001905
Dr. Adams 0.001889
vaccine safety 0.001869
what we already knew 0.001861
people 0.001844
genetic predisposition 0.001839
developing countries 0.001831
physicians 0.001830
immune response 0.001827
promising news 0.001806
withholding vaccines 0.001805
children with autistic sibling 0.001776
reassurance 0.001775
deaths 0.001752
right to personal exemptions 0.001749
Early Childhood Australia 0.001745
triple hit 0.001716
scientists 0.001709
Dr. Mark Schleiss 0.001707
rubella elimination 0.001705
pediatricians 0.001696
sexually transmitted virus 0.001683
boys 0.001669
ideas 0.001658
health care 0.001645
childhood disease 0.001632
findings 0.001625
MMR vaccine does not cause autism 0.001624
varicella vaccine 0.001624
rubella vaccine 0.001624
spread of infectious diseases 0.001624
HPV vaccine recommendations 0.001623
celebrities 0.001618
cultured cells 0.001609
aborted fetuses 0.001609
Catholic parents 0.001609
we 0.001603
immune amnesia 0.001591
Senator Rand Paul 0.001586
Dr. Bill Adams 0.001581
HPV vaccine benefits 0.001564
immunosuppression 0.001560
vaccine debate 0.001555
California Coalition for Health Choice 0.001554
Neisseria meningitidis bacteria 0.001535
developmental disability 0.001533
MMR vaccine safety 0.001531
social issues 0.001523
overseas 0.001492
religious doctrine 0.001492
vaccinated high-risk children 0.001483
ages 11 or 12 0.001470
vaccinated children and unvaccinated children 0.001465
flu vaccine recall 0.001455
fraud 0.001440
hesitant parents 0.001433
antibiotics 0.001429
Institute of Medicine 0.001426
adult vaccination program 0.001418
GlaxoSmithKline 0.001411
vaccine potency 0.001411
doctors 0.001387
flu shots 0.001382
Jill Hennessy 0.001381
preventable disease 0.001373
Amish 0.001373
government policy 0.001371
variation 0.001368
opponent of sanity-oriented legislation 0.001363
minority views 0.001363
Cervarix 0.001360
HPV strains 0.001354
influenza 0.001339
driving factors 0.001336
daughters 0.001326
new version of Gardasil 0.001321
decline in vaccination rates 0.001318
at risk 0.001316
Waldorf School of Princeton 0.001315
private schools 0.001315
immune protection 0.001307
vaccination schedule 0.001295
republicans 0.001293
symptoms 0.001285
state-level policies 0.001277
HPV infection 0.001276
free vaccine eligible 0.001273
Islamic principles 0.001270
teen girls 0.001270
Eagle Mountain International Church 0.001268
mental disorders 0.001267
prevention 0.001261
Jehovah's Witnesses 0.001260
fever 0.001259
personal belief reasons 0.001252
religious beliefs 0.001252
childcare 0.001251
headache 0.001247
West Virginia 0.001242
Mississippi 0.001242
sterilize Muslims 0.001234
harmful association 0.001226
interventions 0.001220
presidential candidates 0.001193
resources 0.001189
danger 0.001177
brain damage 0.001125
children with neurodevelopmental issues 0.001125
nausea 0.001116
respiratory secretions 0.001107
adults 0.001098
World Health Organization 0.001095
vaccine 0.001093
recommended vaccines 0.001091
miscarriage 0.001085
preteens 0.001080
reduction in child mortality 0.001072
Tanzania 0.001065
Colorado 0.001065
Ohio 0.001065
Libya 0.001065
meningitis 0.001062
wealthy regions 0.001049
Los Angeles 0.001049
activism 0.001038
Robert F. Kennedy Jr. 0.001035
unvaccinated workers 0.001034
vaccines cause autism 0.001033
environmental trigger 0.001030
reduction in mortality 0.001026
Washington State public-private pilot program 0.001022
parental rights 0.001017
Disneyland 0.001014
anti-vaccine eugenics community 0.001014
California governor 0.001014
vaccine delivery 0.001010
world 0.001005
safe 0.001004
risk of fainting 0.001004
behavioral research 0.000998
distrust of medical establishment 0.000998
populations 0.000997
repetitive behaviors 0.000989
unable to speak 0.000989
National Infant Immunization Week 0.000985
vaccine campaign 0.000981
vaccine information sources 0.000977
unvaccinated clusters 0.000976
shame 0.000969
former gastroenterologist 0.000969
Federal Circuit 0.000966
The Lancet 0.000966
vaccine efficacy 0.000966
partial protection 0.000966
recommended vaccine schedule 0.000965
parents who choose to delay vaccination 0.000963
delaying Gardasil 0.000962
Age of Autism 0.000962
lower rate of autism in vaccinated children 0.000956
kindergarten 0.000954
threat 0.000949
non-medical reasons for exemption 0.000949
argument 0.000949
careers 0.000944
pig 0.000942
gelatin 0.000942
social network 0.000942
issue 0.000939
state legislatures 0.000938
vaccinated girls 0.000935
Governor Jerry Brown 0.000935
vaccinations should be voluntary 0.000930
science 0.000930
hospitalizations 0.000930
medical issue 0.000929
Department of Public Health Immunization Program 0.000928
health care providers 0.000928
philosophical exemption 0.000928
Hinduism 0.000928
Catholics 0.000925
Muslims 0.000925
vaccinated students 0.000920
responsibility 0.000918
autism rate 0.000917
home-school 0.000917
legitimate reasons 0.000917
uninformed 0.000912
compromise 0.000912
Netherlands Reformed Congregation 0.000910
imitation infection 0.000903
children with immunosuppressive diseases 0.000903
children with cancer 0.000903
parental responsibility 0.000901
new strategies 0.000894
behavioral interventions 0.000892
genetic risk factors for ASD 0.000892
pharmacological interventions 0.000892
part of the story 0.000868
Caribbean 0.000859
Victoria's health minister 0.000843
supporters 0.000827
approval 0.000827
resurgence in potentially fatal childhood infectious diseases 0.000816
public schools 0.000815
tuition 0.000815
best-sellers 0.000815
partners 0.000814
programs 0.000814
education 0.000806
stiff neck 0.000803
deafness 0.000798
loss of limb 0.000798
nervous system problems 0.000798
Muslim leaders 0.000796
reduced effectiveness 0.000792
safety concern 0.000792
Pakistan 0.000791
Afghanistan 0.000791
political issues 0.000791
theological issues 0.000791
Nigeria 0.000791
MMR vaccine doesn't trigger autism 0.000784
commitment 0.000783
true-believer cohort 0.000783
bacteria 0.000771
Pan American Health Organization 0.000768
good news 0.000760
Arizona Department of Health Services 0.000760
fluke 0.000760
family tax benefit 0.000760
childcare rebate 0.000760
tax benefits 0.000760
childcare benefits 0.000760
met the bar 0.000760
conscientious objectors 0.000760
siblings 0.000759
universities 0.000754
projects 0.000754
National Institutes of Health 0.000754
controversy 0.000752
early childcare advocacy group 0.000751
epidemiologist 0.000750
Johns Hopkins University 0.000750
Senator Jeff Stone 0.000748
false concerns 0.000748
theory 0.000743
University of Minnesota 0.000740
vast amounts of time 0.000727
debunked 0.000727
ill effects 0.000727
retracted 0.000727
vast amounts of money 0.000727
virus 0.000726
three-dose course 0.000719
one dose of vaccine 0.000719
role 0.000717
brain development 0.000717
field 0.000717
age 26 0.000716
make plans ahead of time 0.000712
expected 0.000712
normal 0.000712
true cause of autism 0.000711
magnitude of benefits 0.000710
Americans 0.000709
strong-arm tactics 0.000709
democrat 0.000709
backfire 0.000709
testing 0.000707
run down feeling 0.000700
tenderness 0.000700
mild 0.000700
swelling 0.000700
pain 0.000700
arm 0.000700
hardness of the skin 0.000700
daily activities 0.000700
Sydney, Australia 0.000699
senators 0.000697
Catholic Church 0.000691
mortality rate decrease 0.000691
absolute objection 0.000690
unconscionable 0.000689
severe symptoms 0.000688
new transmission 0.000688
Western Hemisphere 0.000688
German measles 0.000688
smallpox 0.000687
elite list 0.000687
social media 0.000686
neighbors 0.000686
vaccines cause neurological problems 0.000684
booster dose 0.000680
small nudges 0.000679
prohibits vaccinating members 0.000679
unvaccinated high-risk children 0.000676
rubella outbreak 0.000673
random cases 0.000673
early diagnosis 0.000673
vomiting 0.000673
household 0.000673
increased sensitivity to light 0.000673
confusion 0.000673
early treatment 0.000673
cases 0.000673
anyone 0.000673
other meningococcal disease cases 0.000673
healthy people 0.000673
serogroups 0.000673
rash 0.000673
serogroup Y 0.000668
11-18 year olds 0.000668
serogroup B 0.000668
serogroup C 0.000668
prisons 0.000668
colleges 0.000668
mumps vaccine 0.000667
computer models 0.000666
data 0.000666
non-judgmental environment 0.000664
prophylaxis 0.000664
cervix 0.000661
anus 0.000661
mouth 0.000661
vaccination policy 0.000658
vaccines are safe 0.000651
vaccines are effective 0.000651
thimerosal is safe 0.000651
insurance claims 0.000651
Journal of the American Medical Association 0.000651
employees 0.000648
vaccination of pregnant women 0.000648
whooping cough vaccine 0.000648
one dose Gardasil 0.000646
three doses Gardasil 0.000646
vaccine benefits 0.000645
tetanus/diphtheria/pertussis 0.000641
caregivers 0.000641
gift from God 0.000641
unethical 0.000640
sales 0.000637
long-term benefits 0.000637
transient 0.000637
diarrhea deaths 0.000637
Merck 0.000637
benefits 0.000637
pneumonia deaths 0.000637
opportunistic infections 0.000637
Gardasil 9 0.000637
Gardasil 4 0.000637
one child 0.000631
immune system disorder 0.000627
allergies 0.000627
body 0.000622
medical conditions 0.000617
revaccinated 0.000617
free vaccine 0.000617
Nepal 0.000616
India 0.000616
unlikely 0.000613
alternative explanation 0.000613
answers 0.000612
vaccine fear 0.000611
fast 0.000611
consequences 0.000610
Vaccine Free Family Day Care 0.000610
time 0.000610
ages 14 to 17 0.000609
observational 0.000608
large 0.000608
results 0.000608
law 0.000608
party lines 0.000608
California Senate 0.000608
abnormal cells 0.000606
girls who received Gardasil 0.000606
Los Angeles County 0.000603
preschoolers 0.000603
important message 0.000599
sex 0.000598
infection at multiple sites 0.000598
women without previous HPV 0.000598
reduction in HPV 0.000598
preventing cancer 0.000598
health professionals 0.000595
variety of medical conditions 0.000595
fear 0.000595
exist 0.000595
children with family history of autism 0.000595
scientific paper 0.000595
social norms 0.000593
infant mortality 0.000593
infant disability 0.000593
risk 0.000593
protect the kid next to you 0.000593
voluntary 0.000593
Hilary Clinton 0.000593
sibling 0.000593
state-level policy 0.000593
no brainer 0.000593
vaccinated individuals 0.000592
written down 0.000592
risk of cervical dysplasia 0.000592
neurological problems 0.000592
medical advancement 0.000592
risk of infection 0.000592
link 0.000592
saved lives 0.000592
medical law 0.000592
efficacious 0.000592
population health 0.000592
funds 0.000592
Jewish dietary laws 0.000592
choice 0.000592
formal advice 0.000588
members 0.000588
risk of mumps 0.000587
risk of rubella 0.000587
scheduled appointment 0.000587
potential risks 0.000587
friends 0.000587
worried 0.000587
vaccine success 0.000587
sense of urgency 0.000587
peers 0.000587
childcare services 0.000584
bad news 0.000583
measles experience 0.000583
immune memory cells 0.000583
models of disease 0.000583
victims 0.000583
ear infections 0.000583
Dutch Bible belt 0.000583
seizures 0.000583
Orthodox Jewish communities 0.000583
pneumonia 0.000583
Prabhupada Village 0.000583
government rebates 0.000582
risk to pregnant women 0.000582
reasons 0.000582
sibling with autism 0.000575
complications 0.000574
Victorian government 0.000574
at-risk vaccinated children 0.000567
at-risk unvaccinated children 0.000567
children without autistic sibling 0.000567
mothers with pregnancy-related diabetes 0.000567
early education 0.000562
severity 0.000556
genetic component 0.000556
genes 0.000556
challenge 0.000556

In [12]:
# save page rank
#pr_df.to_csv('pr_positive.csv')

In [ ]: