Aim: find genes appear in overlapping modules of the 66 and 57b libraries.

before we continue to explore the genes in Magenta module (in the 66 analysis), we need to be sure that they overlap those in the matching module in the female-only analysis (57 libraries).

Finding matching modules (66 all libraries vs. 57 female libraries)

#over lap the two modules tables, to check if the modules contain the same genes
# to avoid confusion, i used the module colors for the 66 libs ("moduleColors" 15 modules + grey=genes with no module), and the modules numbers for the 57 libs ("moduleLabels_57" 14 modules + "zero" = genes with no module):
compareModules <- overlapTable(
    moduleColors, moduleLabels_57, 
    na.rm = FALSE, ignore = NULL, 
    levels1 = NULL, levels2 = NULL)
compareModules
## $countTable
##               0    1   2   3   4   5   6   7  8   9 10 11 12 13 14
## black         7   10   1   5   5   0   1   1  9 108  0 18  0  0  6
## blue          9 2100  56 106   1 183  37  16  3   0  7  0 66  0  0
## brown        87  288 108  65 558  31  46  38 15  40 15 10  5  7  7
## cyan          2    3   0   3   6   0   0   2  1   9  0  7  0  0  2
## green         5   36 411   3   0   0  16   0  0   0  2  0  0  1  0
## greenyellow   0    0   0   0   0   0   0   1  1   4  0 59  0  0  0
## grey         82   21  24  17   4   6   7   8  8   1  5  5  4  2  1
## magenta       2    2   8  15   0   0   0  40  0   0 15  0  1  3  0
## midnightblue  0   31   0   0   0   0   0   0  0   0  0  0  0  0  0
## pink          0    1   0   0   1   0   1   0 95   0  0  1  0  1  0
## purple        0    1   3   1   0   0   6   0  0   0 30  0  0 45  0
## red           3    0   2  11   0   1   2 163  0   0  0  2  2  0  0
## salmon        0   10   3   0   0   0   0   0  0   0 24  0  0  0  0
## tan           0    0   0   0   0   0   0   0 46   0  0  2  0  0  0
## turquoise     6 3022 127 404   1   0  10  26  8   0 15  4  2  0  0
## yellow       80  384  50  73  48 131 212  33 72  16 24 26 23  6 26
## 
## $pTable
##                         0             1          2            3          4
## black        1.944931e-01  1.000000e+00 0.99999908 9.928061e-01 0.98120013
## blue         1.000000e+00 1.997788e-186 1.00000000 1.000000e+00 1.00000000
## brown        1.120000e-15  1.000000e+00 0.27505652 9.992095e-01 0.00000000
## cyan         2.517280e-01  1.000000e+00 1.00000000 4.344484e-01 0.01779718
## green        9.972806e-01  1.000000e+00 0.00000000 1.000000e+00 1.00000000
## greenyellow  1.000000e+00  1.000000e+00 1.00000000 1.000000e+00 1.00000000
## grey         1.153730e-78  1.000000e+00 0.01562078 1.834318e-01 0.99810637
## magenta      6.916210e-01  1.000000e+00 0.34764024 6.781161e-04 1.00000000
## midnightblue 1.000000e+00  3.749102e-08 1.00000000 1.000000e+00 1.00000000
## pink         1.000000e+00  1.000000e+00 1.00000000 1.000000e+00 0.99819000
## purple       1.000000e+00  1.000000e+00 0.96723093 9.978422e-01 1.00000000
## red          8.919785e-01  1.000000e+00 0.99999543 7.383876e-01 1.00000000
## salmon       1.000000e+00  9.999615e-01 0.55401504 1.000000e+00 1.00000000
## tan          1.000000e+00  1.000000e+00 1.00000000 1.000000e+00 1.00000000
## turquoise    1.000000e+00  0.000000e+00 1.00000000 3.034538e-35 1.00000000
## yellow       1.600954e-14  1.000000e+00 0.99999997 8.912700e-01 0.99975378
##                         5             6             7             8
## black        1.000000e+00  9.969253e-01  9.963410e-01  2.889056e-02
## blue         5.951636e-28  1.000000e+00  1.000000e+00  1.000000e+00
## brown        9.939640e-01  3.667367e-01  7.849680e-01  9.999474e-01
## cyan         1.000000e+00  1.000000e+00  3.091547e-01  5.909919e-01
## green        1.000000e+00  4.992165e-01  1.000000e+00  1.000000e+00
## greenyellow  1.000000e+00  1.000000e+00  8.801336e-01  8.103921e-01
## grey         6.655179e-01  4.645189e-01  2.870394e-01  1.193793e-01
## magenta      1.000000e+00  1.000000e+00  2.191298e-37  1.000000e+00
## midnightblue 1.000000e+00  1.000000e+00  1.000000e+00  1.000000e+00
## pink         1.000000e+00  9.656359e-01  1.000000e+00 3.006307e-153
## purple       1.000000e+00  6.429146e-02  1.000000e+00  1.000000e+00
## red          9.985872e-01  9.862464e-01 3.329534e-236  1.000000e+00
## salmon       1.000000e+00  1.000000e+00  1.000000e+00  1.000000e+00
## tan          1.000000e+00  1.000000e+00  1.000000e+00  4.684758e-73
## turquoise    1.000000e+00  1.000000e+00  1.000000e+00  1.000000e+00
## yellow       1.291603e-36 1.276331e-115  8.544321e-01  6.949936e-13
##                          9           10            11           12           13
## black        2.012823e-161 1.000000e+00  7.056549e-12 1.000000e+00 1.000000e+00
## blue          1.000000e+00 1.000000e+00  1.000000e+00 7.451910e-17 1.000000e+00
## brown         2.564125e-04 7.874644e-01  9.838230e-01 9.981624e-01 7.489749e-01
## cyan          5.631826e-09 1.000000e+00  2.769478e-07 1.000000e+00 1.000000e+00
## green         1.000000e+00 9.887437e-01  1.000000e+00 1.000000e+00 9.544245e-01
## greenyellow   2.622762e-02 1.000000e+00 1.779790e-110 1.000000e+00 1.000000e+00
## grey          9.682592e-01 1.203230e-01  1.123483e-01 1.330191e-01 3.517466e-01
## magenta       1.000000e+00 3.483424e-13  1.000000e+00 5.820796e-01 1.715613e-02
## midnightblue  1.000000e+00 1.000000e+00  1.000000e+00 1.000000e+00 1.000000e+00
## pink          1.000000e+00 1.000000e+00  7.336032e-01 1.000000e+00 4.724209e-01
## purple        1.000000e+00 1.487365e-35  1.000000e+00 1.000000e+00 6.969258e-84
## red           1.000000e+00 1.000000e+00  7.033302e-01 5.611040e-01 1.000000e+00
## salmon        1.000000e+00 3.985004e-37  1.000000e+00 1.000000e+00 1.000000e+00
## tan           1.000000e+00 1.000000e+00  1.299666e-01 1.000000e+00 1.000000e+00
## turquoise     1.000000e+00 1.000000e+00  1.000000e+00 1.000000e+00 1.000000e+00
## yellow        9.020444e-01 2.877257e-02  6.584196e-03 1.641330e-03 7.911932e-01
##                        14
## black        6.305832e-05
## blue         1.000000e+00
## brown        2.928756e-01
## cyan         8.957763e-03
## green        1.000000e+00
## greenyellow  1.000000e+00
## grey         5.545167e-01
## magenta      1.000000e+00
## midnightblue 1.000000e+00
## pink         1.000000e+00
## purple       1.000000e+00
## red          1.000000e+00
## salmon       1.000000e+00
## tan          1.000000e+00
## turquoise    1.000000e+00
## yellow       1.321401e-14
# using this function i was able to match modules from the analysis including all 66 libraries, and the analysis of females only (57 libraries). 
# matching modules of the two analyses
#                       66 all  == in 57 females:
# (module number 0)  MM.grey == MM.grey (module number 0)
# (module number 1)  MM.turquoise == MM.turquoise (module number 1)
# (module number 2)  MM.blue == MM.turquoise (module number 1)
# (module number 3)  MM.brown == MM.grey (module number 0)
# (module number 4)  MM.yellow == MM.red (module number 6)
# (module number 5)  MM.green == MM.blue (module number 2)
# (module number 6)  MM.red == MM.black (module number 7)
# (module number 7)  MM.black == MM.magenta (module number 9)
# (module number 8)  MM.pink == MM.pink (module number 8)
# (module number 9)  MM.magenta == MM.black (module number 7)
# (module number 10) MM.purple == MM.salmon (module number 13)
# (module number 11) MM.greenyellow == MM.greenyellow (module number 11)
# (module number 12) MM.tan == MM.pink (module number 8)ma
# (module number 13) MM.salmon == MM.purple (module number 10)
# (module number 14) MM.cyan == MM.magenta (module number 9)

according to “Module-Trait interaction”, Magenta module looks interesting, as it have a negative correlation with DWVa, and positive correlation with VDV2. the matching module of Magenta (66libs) is black (57libs). So we gonna overlap the black module from 57, to magenta genes, from 66, using inner_join(),to get a table containing the overlapping genes, their geneTraitSignificance (for DWVa, ARV_2 and VDV2), geneModuleMembership, and Intramodular connectivity

geneInfoMagenta_66 = data.frame(
  module = moduleColors,
  geneTraitSignificance_66,
  geneModuleMembership_66,
  IntraModCon = Alldegrees1_66$kWithin) %>%
  dplyr::select(c(module, IntraModCon, MMmagenta, GS.DWVa, GS.VDV2, GS.ARV_2)) %>%
  dplyr::filter(module == "magenta") %>%
  rownames_to_column("genes")
  
geneInfoBlack_57 = data.frame(
  module = moduleColors_57,
  geneTraitSignificance_57,
  geneModuleMembership_57,
  IntraModCon = Alldegrees1_57$kWithin) %>%
  dplyr::select(c(module, IntraModCon, MMblack, GS.DWVa, GS.VDV2, GS.ARV_2)) %>%
  dplyr::filter(module%in% c("black")) %>%
  rownames_to_column("genes")

# make a table of the overlapping genes 
overlap <- inner_join(geneInfoMagenta_66, geneInfoBlack_57, by = "genes")
 #change the columns names to specify from which analysis it was taken (66libs or 57libs)
 overlap <- overlap %>%
   dplyr::rename(module_66 = module.x,
                 module_57 = module.y,
                 IntraModCon_66 = IntraModCon.x,
                 IntraModCon_57 = IntraModCon.y,
                 GS.DWVa_66 = GS.DWVa.x,
                 GS.DWVa_57 = GS.DWVa.y,
                 GS.VDV2_66 = GS.VDV2.x,
                 GS.VDV2_57 = GS.VDV2.y,
                 GS.ARV_2_66 = GS.ARV_2.x,
                 GS.ARV_2_57 = GS.ARV_2.y)
nrow(overlap)  
## [1] 40
# we have 40 overlapping genes in the magenat and balck modules, as the "overlapTable()" function computed.

# add gene annotation:
# load the annotation file:
annot_varroa <- read_csv("/Users/nuriteliash/Documents/GitHub/varroa-virus-networks/data/annot_varroa.csv", col_names = TRUE, )
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   Name = col_character(),
##   Accession = col_character(),
##   Start = col_double(),
##   Stop = col_double(),
##   Strand = col_character(),
##   GeneID = col_double(),
##   Locus = col_character(),
##   `Locus tag` = col_character(),
##   `Protein product` = col_character(),
##   Length = col_double(),
##   `Protein Name` = col_character()
## )
# remove the "LOC" from the gene name
annot_varroa$Locus <- str_replace(annot_varroa$Locus, "LOC", '')
# and change the col name to "genes", so it will the same as in the "overlap" table
colnames(annot_varroa)[which(names(annot_varroa) == "Locus")] <- "genes"
head(annot_varroa)
## # A tibble: 6 x 11
##   Name  Accession  Start   Stop Strand GeneID genes `Locus tag` `Protein produc…
##   <chr> <chr>      <dbl>  <dbl> <chr>   <dbl> <chr> <chr>       <chr>           
## 1 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672900.1  
## 2 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672902.1  
## 3 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672903.1  
## 4 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672904.1  
## 5 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672905.1  
## 6 Un    NW_01921… 3.38e7 3.39e7 -      1.11e8 1112… -           XP_022672908.1  
## # … with 2 more variables: Length <dbl>, `Protein Name` <chr>
#now join by "genes" name (INNER JOIN: returns rows when there is a match in both tables)
overlap_annot <- inner_join(overlap, annot_varroa, by = "genes") %>% 
  dplyr::select(c(genes, module_66, module_57,
                 IntraModCon_66, 
                 IntraModCon_57, 
                 GS.DWVa_66,  
                 GS.DWVa_57, 
                 GS.VDV2_66,
                 GS.VDV2_57, 
                 GS.ARV_2_66,
                 GS.ARV_2_57, Name, Accession, 'Protein product', Length, 'Protein Name'))

# and filter out duplicated genes
overlap_annot <-overlap_annot[!duplicated(overlap_annot[,'genes']),] 

nrow(overlap_annot)
## [1] 40
overlap_annot
##        genes module_66 module_57 IntraModCon_66 IntraModCon_57 GS.DWVa_66
## 1  111243784   magenta     black      11.223440      22.198350 -0.2925204
## 2  111243925   magenta     black       4.977129      22.088913 -0.2427469
## 5  111243999   magenta     black       4.241030      11.075776 -0.2982548
## 7  111244168   magenta     black      17.163039      49.723289 -0.4469089
## 8  111244366   magenta     black       8.195112      22.937088 -0.2901975
## 9  111244889   magenta     black       9.047380      12.616443 -0.2406085
## 10 111244965   magenta     black      11.223471      52.272521 -0.2927762
## 11 111245094   magenta     black       5.241102       8.915815 -0.3232085
## 18 111245189   magenta     black       6.223219      28.195801 -0.1443773
## 19 111245224   magenta     black      19.225611      29.806858 -0.5257100
## 20 111245582   magenta     black      10.819486      27.375348 -0.3930408
## 21 111245627   magenta     black      13.826894      30.693962 -0.5259656
## 22 111246014   magenta     black      15.741042      33.400666 -0.3590890
## 23 111246302   magenta     black       8.552619      24.511668 -0.3738306
## 24 111246841   magenta     black      13.968961      54.124280 -0.1939304
## 25 111247393   magenta     black       3.646495      11.589818 -0.4529772
## 29 111248051   magenta     black       5.443256      32.074934 -0.1430254
## 30 111248663   magenta     black      13.455119      19.074242 -0.6526831
## 31 111249529   magenta     black      18.248457      34.749502 -0.5461694
## 32 111249640   magenta     black      10.505546      56.341325 -0.3610908
## 34 111250285   magenta     black       5.554644      29.566964 -0.2247173
## 35 111250955   magenta     black       4.535455      14.494932 -0.2948846
## 36 111251058   magenta     black      18.325534      27.844484 -0.5047920
## 37 111251111   magenta     black      13.781119      39.694638 -0.3695021
## 38 111251804   magenta     black      15.157361      17.486192 -0.5437127
## 39 111252023   magenta     black      13.973837      25.692861 -0.5672668
## 40 111252053   magenta     black      14.862509      15.371700 -0.4178445
## 41 111252649   magenta     black      12.697701      32.744145 -0.4561971
## 43 111252854   magenta     black      17.943261      41.119880 -0.4752507
## 44 111253379   magenta     black       3.682578       9.704401 -0.3074540
## 45 111253800   magenta     black      16.094312      34.594783 -0.4544488
## 47 111253808   magenta     black      13.508291      15.657505 -0.6047886
## 49 111253948   magenta     black       5.039276      21.436117 -0.3471731
## 50 111254122   magenta     black      11.418235      31.362879 -0.3206842
## 51 111254141   magenta     black      13.238670      51.516648 -0.3209055
## 52 111254601   magenta     black       8.248668      55.251005 -0.2432382
## 54 111254776   magenta     black      13.196680      44.403272 -0.4034354
## 55 111255374   magenta     black      14.757598      42.451929 -0.3964158
## 56 111255470   magenta     black      16.037453      32.857336 -0.4818122
## 57 111255627   magenta     black       6.632640      15.041197 -0.2709482
##    GS.DWVa_57 GS.VDV2_66 GS.VDV2_57  GS.ARV_2_66 GS.ARV_2_57 Name
## 1  -0.1943919  0.6398958  0.6597310 -0.129847510  -0.4165116   Un
## 2  -0.2090687  0.4471420  0.5748613 -0.391770250  -0.2430201   Un
## 5  -0.1522141  0.4398575  0.4569898 -0.112730602  -0.1764775   Un
## 7  -0.3877705  0.7614299  0.8136362 -0.171302433  -0.3362780   Un
## 8  -0.1417271  0.5408519  0.6444956 -0.358470771  -0.4394230   Un
## 9  -0.1229824  0.4918116  0.5257225 -0.240698081  -0.4722398   Un
## 10 -0.2032580  0.6688896  0.7670656 -0.324538421  -0.3949422   Un
## 11 -0.2762196  0.6049363  0.5807265  0.134047618  -0.4222172   Un
## 18 -0.1371829  0.7684324  0.8240359 -0.212014499  -0.4360924   Un
## 19 -0.4297188  0.6266771  0.7010731 -0.224120281  -0.2661796   Un
## 20 -0.2685444  0.5766143  0.6611281 -0.302416626  -0.3216513   Un
## 21 -0.4369329  0.4969625  0.6151987 -0.276748922  -0.1085196   Un
## 22 -0.3258962  0.6036798  0.7015680 -0.214597145  -0.2846728   Un
## 23 -0.3946526  0.5160128  0.6608939 -0.163662362  -0.2563243   Un
## 24 -0.1341113  0.7451658  0.8185060 -0.236442918  -0.4523176   Un
## 25 -0.4482936  0.6247344  0.6491722 -0.046751586  -0.1961815   Un
## 29 -0.1266740  0.7403198  0.7410321  0.148530942  -0.4208976   Un
## 30 -0.5747656  0.5182510  0.5810407 -0.194953621  -0.1336256   Un
## 31 -0.4706368  0.5990873  0.7192397 -0.329921444  -0.2633597   Un
## 32 -0.2882585  0.6917785  0.7901045 -0.258344046  -0.2238572   Un
## 34 -0.1039504  0.6877988  0.7123644  0.018579016  -0.4346871   Un
## 35 -0.2837554  0.6458510  0.6675542  0.041280877  -0.2533139   Un
## 36 -0.4479580  0.5369363  0.6478006 -0.288503815  -0.2802167   Un
## 37 -0.3193897  0.6502168  0.7651151 -0.247056774  -0.2908267   Un
## 38 -0.4825198  0.5160739  0.6164134 -0.337826325  -0.3081682   Un
## 39 -0.5140609  0.6133908  0.7157492 -0.309702151  -0.2723798   Un
## 40 -0.3593588  0.5145422  0.5857436 -0.267409457  -0.3800227   Un
## 41 -0.3623834  0.5753213  0.6194092 -0.064013137  -0.1398686   Un
## 43 -0.4351661  0.6964539  0.8064760 -0.282119472  -0.2810398   Un
## 44 -0.2413451  0.5421018  0.5273003  0.260606048  -0.2036610   Un
## 45 -0.3511759  0.5971160  0.6996857 -0.299018590  -0.2702058   Un
## 47 -0.5229291  0.5006907  0.5900728 -0.235716934  -0.1969170   Un
## 49 -0.3130022  0.6011234  0.7144338 -0.369352756  -0.4263867   Un
## 50 -0.2610105  0.6280394  0.6896842 -0.240210917  -0.2594001   Un
## 51 -0.2592884  0.7659278  0.8677597 -0.321845412  -0.4086162   Un
## 52 -0.2240337  0.7774221  0.7831164  0.026391573  -0.2423346   Un
## 54 -0.3374515  0.6133320  0.6571393 -0.009339968  -0.1090063   Un
## 55 -0.3530532  0.6671085  0.7453012 -0.258446908  -0.3177539   Un
## 56 -0.4449958  0.6461752  0.7108208 -0.134350234  -0.2549213   Un
## 57 -0.2142499  0.4003038  0.5115095 -0.301184133  -0.3069202   Un
##         Accession Protein product Length
## 1  NW_019211455.1  XP_022645599.1     97
## 2  NW_019211455.1  XP_022646010.1    275
## 5  NW_019211455.1  XP_022646231.1    825
## 7  NW_019211455.1  XP_022646682.1    121
## 8  NW_019211455.1  XP_022647130.1    198
## 9  NW_019211455.1  XP_022648164.1    123
## 10 NW_019211455.1  XP_022648335.1     81
## 11 NW_019211454.1  XP_022648662.1    180
## 18 NW_019211454.1  XP_022648917.1    132
## 19 NW_019211455.1  XP_022649014.1    115
## 20 NW_019211455.1  XP_022649852.1     92
## 21 NW_019211455.1  XP_022649973.1    115
## 22 NW_019211455.1  XP_022650905.1    211
## 23 NW_019211456.1  XP_022651395.1    165
## 24 NW_019211456.1  XP_022652845.1    141
## 25 NW_019211456.1  XP_022653963.1    194
## 29 NW_019211456.1  XP_022655498.1    139
## 30 NW_019211457.1  XP_022657111.1    108
## 31 NW_019211457.1  XP_022659256.1     86
## 32 NW_019211457.1  XP_022659492.1    102
## 34 NW_019211457.1  XP_022661021.1    103
## 35 NW_019211458.1  XP_022662723.1    230
## 36 NW_019211458.1  XP_022662996.1    149
## 37 NW_019211458.1  XP_022663149.1    142
## 38 NW_019211458.1  XP_022664567.1     93
## 39 NW_019211458.1  XP_022665066.1     88
## 40 NW_019211458.1  XP_022665140.1    175
## 41 NW_019211459.1  XP_022666611.1    186
## 43 NW_019211459.1  XP_022667135.1    107
## 44 NW_019211459.1  XP_022668409.1    116
## 45 NW_019211460.1  XP_022669529.1     82
## 47 NW_019211460.1  XP_022669567.1    157
## 49 NW_019211460.1  XP_022669964.1    234
## 50 NW_019211460.1  XP_022670391.1    131
## 51 NW_019211460.1  XP_022670438.1     75
## 52 NW_019211460.1  XP_022671339.1    120
## 54 NW_019211460.1  XP_022671703.1    152
## 55 NW_019211454.1  XP_022673017.1    147
## 56 NW_019211454.1  XP_022673201.1    178
## 57 NW_019211454.1  XP_022673516.1    437
##                                                                     Protein Name
## 1                                                                cystatin-B-like
## 2                                uncharacterized protein LOC111243925 isoform X3
## 5                                            chondroitin sulfate synthase 3-like
## 7                                                             NADH dehydrogenase
## 8                                                  alpha-crystallin A chain-like
## 9                                           uncharacterized protein LOC111244889
## 10                         cytochrome b-c1 complex subunit 6, mitochondrial-like
## 11                               uncharacterized protein LOC111245094 isoform X1
## 18                                          uncharacterized protein LOC111245189
## 19                                          ATPase inhibitor, mitochondrial-like
## 20                                                            NADH dehydrogenase
## 21                                                            NADH dehydrogenase
## 22                                    ATP synthase subunit O, mitochondrial-like
## 23                                ATP synthase subunit delta, mitochondrial-like
## 24          coiled-coil-helix-coiled-coil-helix domain-containing protein 2-like
## 25                         high affinity copper uptake protein 1-like isoform X2
## 29                                          uncharacterized protein LOC111248051
## 30                                        cytochrome b-c1 complex subunit 7-like
## 31                                      cytochrome c oxidase subunit NDUFA4-like
## 32                               uncharacterized protein LOC111249640 isoform X2
## 34                                          uncharacterized protein LOC111250285
## 35                                          uncharacterized protein LOC111250955
## 36                           cytochrome c oxidase subunit 5A, mitochondrial-like
## 37                        ATP synthase lipid-binding protein, mitochondrial-like
## 38                                    ATP synthase subunit e, mitochondrial-like
## 39                      putative cytochrome c oxidase subunit 7A3, mitochondrial
## 40                                                            NADH dehydrogenase
## 41                               uncharacterized protein LOC111252649 isoform X2
## 43                                putative ATP synthase subunit f, mitochondrial
## 44         lipopolysaccharide-induced tumor necrosis factor-alpha factor homolog
## 45                                              MICOS complex subunit Mic10-like
## 47                                                       succinate dehydrogenase
## 49                                          uncharacterized protein LOC111253948
## 50                                          uncharacterized protein LOC111254122
## 51                           cytochrome c oxidase subunit 7C, mitochondrial-like
## 52 mitochondrial import inner membrane translocase subunit TIM14-like isoform X1
## 54                                 39S ribosomal protein L23, mitochondrial-like
## 55                                                            NADH dehydrogenase
## 56                                    ATP synthase subunit d, mitochondrial-like
## 57                                         tachykinin-like peptides receptor 99D
write_csv(x = as.data.frame(overlap_annot), "results/overlap_annot.csv")

check if the old hubgenes overlap in the new ones

#load the former hub-genes:
hub_old <- read_csv("/Users/nuriteliash/Documents/GitHub/varroa-virus-networks/data/hub_annot_old.csv", col_names = TRUE, ) 
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   genes = col_double(),
##   virus.x = col_character(),
##   `Protein Name` = col_character()
## )
hub_old$genes <- as.character(hub_old$genes)

#make a data.frame of all genes with modules:
all.genes.66 <- data.frame(
  module = moduleColors,
  geneTraitSignificance_66,
  geneModuleMembership_66,
  IntraModCon = Alldegrees1_66$kWithin) %>%
  dplyr::select(c(module, IntraModCon, MMmagenta, GS.DWVa, GS.VDV2, GS.ARV_2)) %>%
  rownames_to_column("genes")

# how many of the hub_old genes exist in the magenta module?
#return all rows from x, and all columns from x and y. 
f <- left_join(geneInfoMagenta_66, hub_old, by = "genes")
f
##        genes  module IntraModCon MMmagenta     GS.DWVa   GS.VDV2     GS.ARV_2
## 1  111242876 magenta    6.304724 0.7781005 -0.55860975 0.3865490 -0.095821062
## 2  111242941 magenta    3.358378 0.6740230 -0.03559228 0.4985539 -0.373804028
## 3  111243035 magenta    7.128138 0.7715768 -0.54448573 0.2902412 -0.277404593
## 4  111243305 magenta    4.285400 0.6966181 -0.36694122 0.3647269  0.011610041
## 5  111243700 magenta    6.890664 0.7797593 -0.50750752 0.1999109 -0.380266319
## 6  111243784 magenta   11.223440 0.8695517 -0.29252038 0.6398958 -0.129847510
## 7  111243925 magenta    4.977129 0.7149557 -0.24274692 0.4471420 -0.391770250
## 8  111243999 magenta    4.241030 0.7307336 -0.29825475 0.4398575 -0.112730602
## 9  111244078 magenta    3.374151 0.6919971 -0.33533175 0.3611966 -0.208142504
## 10 111244149 magenta   16.988361 0.9304244 -0.48439634 0.4236942 -0.304095303
## 11 111244168 magenta   17.163039 0.9124374 -0.44690886 0.7614299 -0.171302433
## 12 111244366 magenta    8.195112 0.8114501 -0.29019746 0.5408519 -0.358470771
## 13 111244889 magenta    9.047380 0.8363032 -0.24060850 0.4918116 -0.240698081
## 14 111244895 magenta    2.068979 0.6492903 -0.28659303 0.3932824 -0.141030907
## 15 111244965 magenta   11.223471 0.8127270 -0.29277621 0.6688896 -0.324538421
## 16 111245018 magenta   10.260275 0.8132027 -0.41876209 0.4578334 -0.226893844
## 17 111245094 magenta    5.241102 0.7606702 -0.32320849 0.6049363  0.134047618
## 18 111245189 magenta    6.223219 0.7316771 -0.14437728 0.7684324 -0.212014499
## 19 111245224 magenta   19.225611 0.9438103 -0.52570997 0.6266771 -0.224120281
## 20 111245319 magenta    7.817929 0.8013402 -0.24848118 0.6531090 -0.067417949
## 21 111245376 magenta    4.876569 0.7354068 -0.19736208 0.2936822 -0.379812078
## 22 111245582 magenta   10.819486 0.8437882 -0.39304075 0.5766143 -0.302416626
## 23 111245627 magenta   13.826894 0.8747785 -0.52596560 0.4969625 -0.276748922
## 24 111245837 magenta   16.026146 0.9163486 -0.58327073 0.4521852 -0.127271585
## 25 111246014 magenta   15.741042 0.9034515 -0.35908905 0.6036798 -0.214597145
## 26 111246302 magenta    8.552619 0.7739854 -0.37383063 0.5160128 -0.163662362
## 27 111246491 magenta    4.731972 0.7243380 -0.27915085 0.3901429 -0.072605013
## 28 111246841 magenta   13.968961 0.8861245 -0.19393037 0.7451658 -0.236442918
## 29 111246969 magenta   17.838370 0.9346302 -0.58194475 0.4790201 -0.212437048
## 30 111247339 magenta    4.523613 0.7229202 -0.34663930 0.4761560 -0.151848387
## 31 111247393 magenta    3.646495 0.7145910 -0.45297715 0.6247344 -0.046751586
## 32 111247862 magenta    6.542614 0.7758697 -0.33731582 0.5054671  0.109744742
## 33 111248051 magenta    5.443256 0.7283844 -0.14302545 0.7403198  0.148530942
## 34 111248124 magenta    3.901441 0.6893971 -0.42204025 0.3537784  0.283866463
## 35 111248148 magenta    6.149397 0.7606247 -0.57545123 0.4151146 -0.041018485
## 36 111248568 magenta    1.829990 0.5807608 -0.26411587 0.4060202 -0.306289459
## 37 111248663 magenta   13.455119 0.8688504 -0.65268311 0.5182510 -0.194953621
## 38 111248915 magenta    4.459002 0.7267045 -0.29229990 0.3312422 -0.038655649
## 39 111249021 magenta    8.141350 0.8077766 -0.44375069 0.3634997 -0.091720769
## 40 111249201 magenta   11.098487 0.8507984 -0.50830265 0.2503012 -0.247125145
## 41 111249253 magenta    8.251518 0.8020107 -0.40969162 0.6600876 -0.324010195
## 42 111249484 magenta    4.464690 0.7055220 -0.42598659 0.3450115 -0.203629418
## 43 111249529 magenta   18.248457 0.9232903 -0.54616945 0.5990873 -0.329921444
## 44 111249604 magenta    4.735817 0.7003771 -0.45218043 0.1925725 -0.085875225
## 45 111249640 magenta   10.505546 0.8062042 -0.36109078 0.6917785 -0.258344046
## 46 111249853 magenta   12.252758 0.8805647 -0.43067943 0.3819218 -0.112479806
## 47 111250109 magenta    8.528234 0.8164129 -0.47870266 0.3976912 -0.011172649
## 48 111250180 magenta    4.102724 0.6885171 -0.23015673 0.5069783  0.097909207
## 49 111250285 magenta    5.554644 0.7489627 -0.22471728 0.6877988  0.018579016
## 50 111250305 magenta    4.684375 0.7219795 -0.32741370 0.4934716 -0.293294652
## 51 111250595 magenta    4.709594 0.7414470 -0.45882561 0.3259767 -0.080592986
## 52 111250955 magenta    4.535455 0.7238696 -0.29488456 0.6458510  0.041280877
## 53 111250993 magenta    4.629426 0.6872982 -0.23804344 0.5113298  0.248894530
## 54 111251058 magenta   18.325534 0.9211589 -0.50479197 0.5369363 -0.288503815
## 55 111251111 magenta   13.781119 0.8587504 -0.36950213 0.6502168 -0.247056774
## 56 111251195 magenta    6.102890 0.7458169 -0.23543342 0.5127819 -0.071340245
## 57 111251417 magenta    4.786996 0.7257890 -0.28697745 0.2185357 -0.421669075
## 58 111251520 magenta    5.255670 0.7425263 -0.25489980 0.3141708 -0.244275808
## 59 111251804 magenta   15.157361 0.8791005 -0.54371268 0.5160739 -0.337826325
## 60 111252023 magenta   13.973837 0.8661814 -0.56726682 0.6133908 -0.309702151
## 61 111252053 magenta   14.862509 0.8963405 -0.41784453 0.5145422 -0.267409457
## 62 111252065 magenta    7.885429 0.8012434 -0.39036880 0.5699691  0.045579925
## 63 111252397 magenta    5.193537 0.7380677 -0.55890989 0.5028148  0.319286128
## 64 111252565 magenta    8.306397 0.7789317 -0.43534521 0.2731924 -0.307079182
## 65 111252592 magenta    5.891810 0.7337840 -0.32871356 0.1819197 -0.385443756
## 66 111252595 magenta    9.411344 0.8314912 -0.49628367 0.3365239 -0.226382522
## 67 111252649 magenta   12.697701 0.8870761 -0.45619707 0.5753213 -0.064013137
## 68 111252854 magenta   17.943261 0.9222455 -0.47525067 0.6964539 -0.282119472
## 69 111253109 magenta   12.628946 0.8589323 -0.51295405 0.3590835 -0.274514767
## 70 111253281 magenta    6.835902 0.7420314 -0.35210159 0.2102720 -0.445180599
## 71 111253379 magenta    3.682578 0.6949258 -0.30745403 0.5421018  0.260606048
## 72 111253800 magenta   16.094312 0.9034662 -0.45444879 0.5971160 -0.299018590
## 73 111253808 magenta   13.508291 0.8650949 -0.60478863 0.5006907 -0.235716934
## 74 111253948 magenta    5.039276 0.7178141 -0.34717309 0.6011234 -0.369352756
## 75 111254070 magenta    7.548068 0.7705447 -0.58683486 0.1324167 -0.342197236
## 76 111254122 magenta   11.418235 0.8774034 -0.32068423 0.6280394 -0.240210917
## 77 111254126 magenta   11.503014 0.8601873 -0.64867282 0.3551917 -0.090396930
## 78 111254141 magenta   13.238670 0.8526678 -0.32090553 0.7659278 -0.321845412
## 79 111254343 magenta    2.212959 0.6291470 -0.22748056 0.3686377 -0.146417132
## 80 111254601 magenta    8.248668 0.7797701 -0.24323823 0.7774221  0.026391573
## 81 111254622 magenta    3.673205 0.6552071 -0.54754374 0.2970110  0.226340414
## 82 111254776 magenta   13.196680 0.8765098 -0.40343539 0.6133320 -0.009339968
## 83 111255263 magenta    6.030624 0.7449968 -0.56202488 0.2294823 -0.175801033
## 84 111255374 magenta   14.757598 0.8823629 -0.39641578 0.6671085 -0.258446908
## 85 111255470 magenta   16.037453 0.9044367 -0.48181219 0.6461752 -0.134350234
## 86 111255627 magenta    6.632640 0.8014901 -0.27094816 0.4003038 -0.301184133
##    virus.x               Protein Name
## 1     <NA>                       <NA>
## 2     <NA>                       <NA>
## 3     <NA>                       <NA>
## 4     <NA>                       <NA>
## 5     <NA>                       <NA>
## 6     <NA>                       <NA>
## 7     <NA>                       <NA>
## 8     <NA>                       <NA>
## 9     <NA>                       <NA>
## 10    <NA>                       <NA>
## 11    <NA>                       <NA>
## 12    <NA>                       <NA>
## 13    <NA>                       <NA>
## 14    <NA>                       <NA>
## 15    <NA>                       <NA>
## 16    <NA>                       <NA>
## 17    <NA>                       <NA>
## 18    <NA>                       <NA>
## 19    <NA>                       <NA>
## 20    <NA>                       <NA>
## 21    <NA>                       <NA>
## 22    <NA>                       <NA>
## 23    <NA>                       <NA>
## 24    <NA>                       <NA>
## 25    <NA>                       <NA>
## 26    <NA>                       <NA>
## 27    <NA>                       <NA>
## 28    <NA>                       <NA>
## 29    <NA>                       <NA>
## 30    <NA>                       <NA>
## 31    <NA>                       <NA>
## 32    <NA>                       <NA>
## 33    <NA>                       <NA>
## 34    <NA>                       <NA>
## 35    <NA>                       <NA>
## 36    <NA>                       <NA>
## 37    <NA>                       <NA>
## 38    <NA>                       <NA>
## 39    <NA>                       <NA>
## 40    <NA>                       <NA>
## 41    <NA>                       <NA>
## 42    <NA>                       <NA>
## 43    <NA>                       <NA>
## 44    <NA>                       <NA>
## 45    <NA>                       <NA>
## 46    <NA>                       <NA>
## 47    <NA>                       <NA>
## 48    <NA>                       <NA>
## 49    <NA>                       <NA>
## 50    <NA>                       <NA>
## 51    <NA>                       <NA>
## 52    <NA>                       <NA>
## 53    <NA>                       <NA>
## 54    <NA>                       <NA>
## 55    <NA>                       <NA>
## 56    <NA>                       <NA>
## 57    <NA>                       <NA>
## 58    <NA>                       <NA>
## 59    <NA>                       <NA>
## 60    <NA>                       <NA>
## 61    <NA>                       <NA>
## 62    <NA>                       <NA>
## 63    <NA>                       <NA>
## 64    DWVa                 troponin C
## 65   ARV_2  muscle LIM protein 1-like
## 66    <NA>                       <NA>
## 67    <NA>                       <NA>
## 68    <NA>                       <NA>
## 69    <NA>                       <NA>
## 70   ARV_2 troponin I-like isoform X1
## 71    <NA>                       <NA>
## 72    <NA>                       <NA>
## 73    <NA>                       <NA>
## 74    <NA>                       <NA>
## 75    <NA>                       <NA>
## 76    <NA>                       <NA>
## 77    <NA>                       <NA>
## 78    <NA>                       <NA>
## 79    <NA>                       <NA>
## 80    <NA>                       <NA>
## 81    <NA>                       <NA>
## 82    <NA>                       <NA>
## 83    <NA>                       <NA>
## 84    <NA>                       <NA>
## 85    <NA>                       <NA>
## 86    <NA>                       <NA>
# only 3 genes of magenta module appear in the former hubgene. analysis
# so to what module these 53-hubgenes belong to?

e <- left_join(hub_old, all.genes.66, by = "genes")
e
## # A tibble: 53 x 9
##    genes virus.x `Protein Name` module IntraModCon MMmagenta GS.DWVa  GS.VDV2
##    <chr> <chr>   <chr>          <fct>        <dbl>     <dbl>   <dbl>    <dbl>
##  1 1112… DWVa    sarcoplasmic … purple        16.3     0.331  -0.420 -0.115  
##  2 1112… DWVa    LOW QUALITY P… purple        16.5     0.372  -0.390 -0.136  
##  3 1112… DWVa    myosin heavy … purple        15.7     0.299  -0.323 -0.222  
##  4 1112… DWVa    LOW QUALITY P… purple        15.8     0.241  -0.416 -0.184  
##  5 1112… DWVa    paramyosin-li… purple        15.2     0.394  -0.471 -0.0357 
##  6 1112… DWVa    glutamate rec… purple        14.2     0.356  -0.347 -0.141  
##  7 1112… DWVa    protein phosp… purple        13.3     0.398  -0.376 -0.0163 
##  8 1112… DWVa    LOW QUALITY P… purple        13.9     0.389  -0.454 -0.183  
##  9 1112… DWVa    glutamate rec… purple        14.0     0.196  -0.440 -0.312  
## 10 1112… DWVa    solute carrie… purple        11.1     0.442  -0.347 -0.00790
## # … with 43 more rows, and 1 more variable: GS.ARV_2 <dbl>
# in the 66 libs, most of them belong to the purple module 

all.genes.57 <- data.frame(
  module = moduleColors_57,
  geneTraitSignificance_57,
  geneModuleMembership_57,
  IntraModCon = Alldegrees1_57$kWithin) %>%
  dplyr::select(c(module, IntraModCon, MMmagenta, GS.DWVa, GS.VDV2, GS.ARV_2)) %>%
  rownames_to_column("genes")

g <- left_join(hub_old, all.genes.57, by = "genes")
g
## # A tibble: 53 x 9
##    genes virus.x `Protein Name` module IntraModCon MMmagenta GS.DWVa GS.VDV2
##    <chr> <chr>   <chr>          <fct>        <dbl>     <dbl>   <dbl>   <dbl>
##  1 1112… DWVa    sarcoplasmic … salmon       15.8   -0.0494   -0.303 -0.190 
##  2 1112… DWVa    LOW QUALITY P… salmon       13.6   -0.00292  -0.281 -0.151 
##  3 1112… DWVa    myosin heavy … salmon       15.1   -0.104    -0.203 -0.261 
##  4 1112… DWVa    LOW QUALITY P… salmon       15.3   -0.0104   -0.343 -0.236 
##  5 1112… DWVa    paramyosin-li… salmon       12.9   -0.108    -0.367 -0.136 
##  6 1112… DWVa    glutamate rec… salmon       13.8   -0.107    -0.223 -0.203 
##  7 1112… DWVa    protein phosp… salmon       13.0   -0.00668  -0.272 -0.0683
##  8 1112… DWVa    LOW QUALITY P… purple       14.4   -0.0892   -0.349 -0.205 
##  9 1112… DWVa    glutamate rec… salmon       11.0   -0.0396   -0.353 -0.341 
## 10 1112… DWVa    solute carrie… salmon        9.64   0.145    -0.285  0.0203
## # … with 43 more rows, and 1 more variable: GS.ARV_2 <dbl>
# in the 57 libs, most belong to the salmon module.

# and what about the silenced genes? to which module they belong to?
# prepare a table describing each gene number, short-name and full annotation, of the silenced genes:
genes <- as.factor(c("111250594", "111244103","111244832", "111248360", "111245345", "111248674", "111251059", "111245371", "111244631", "111252566", "111249664"))
annot <- as.factor(c("Sarcalumenin", "glycerol-3-phosphate dehydrogenase", "Calmodulin", "Cuticle-protein8","Cuticle-protein-14", "Glutamate-receptor-3", "Glutamate-gated-chloride-channel-subunit-beta", "Organic-cation-transporter-protein", "Twitchin", "Annulin", "Defense-protein-Hdd11"))
ShortName <- as.factor(c("Sar", "Gly","clmd", "CuP8", "CuP14", "Glut", "Chl", "Trans", "Twitch", "Anl", "HDD"))
silenced.genes <- data.frame(genes, ShortName, annot)

# to what module the silenced genes belong to?
silenced_overlap.66 <- left_join(silenced.genes, all.genes.66, by = "genes")

# of the 11 genes, 8 belong to purple module, 2 to pink and 1 to green. 
# all have negative interaction with DWVa. 

check correaltion between the overlapping genes connectivity of the two analyses:

the intramodular connectivity of the genes in magenta module is correlated to that of its matching module (black), in the 57 libraries, but not to the purple module.

check correaltion between the overlapping genes geneTraitSignificance of the two analyses, for DWVa virus

check correaltion between the overlapping genes geneTraitSignificance of the two analyses, for VDV2 virus

for both DWVa and VDV2 there is high correlation between the matching modules