I am trying to make a co-occurrence network graph for my presence/absence data of genes per genomes but am unsure how to go about with it. I'm hoping to end up with something like the first image below,

Where each gene is linked to another gene , considering if they are both present in the same genomes, where possibly a larger circle being used to describe a higher frequency gene. I originally tried using *widyr* and *tidygraph* packages but I am unsure that my data is not compatible (see second image), as it has the BGCs as rows and the individual genomes as columns. I am examining the presence/absence pattern of the gene pair to determine if they represent a coincident relationship; basically if gene *i* and gene *j* are observed together or apart in the input genomes more often than would be expected by chance. 

1) Are there any suggestions on what packages/code I could use that would work with my data set, or how I could adapt my data set to work with these packages? 

2) Are there any statistical tests that would be also recommended specifically to assure that there is a coincident or not type relationship?

<a href="https://ibb.co/RHcrqLS"><img src="https://i.ibb.co/s3qxZLP/co-occurrence-network-example.png" alt="co-occurrence-network-example" border="0"></a><br /><a target='_blank' href='https://imgbb.com/'>Network Layout</a><br />

    # Example of data set
    # rows = genes
    # cols = genomes
    set.seed(2222)
    df <- matrix(sample(c(TRUE, FALSE), 50, replace = TRUE), 5)
    colnames(df) <- letters[1:10]


Thanks in advanced

To address question 1, I would suggest to use the R [igraph package][1]. There's an [excellent tutorial here][2].
Starting from a binary matrix A that can be considered as the adjacency matrix of the graph, you can do something like:

    library(igraph)
    G <- graph_from_adjacency_matrix(A)
    plot(G)

Here you have a bipartite graph and your matrix is not square so it is not an adjacency matrix but can be considered an incidence matrix. You can expand it to a full adjacency matrix and use the above or you can do:

    G <- graph_from_incidence_matrix(A)
Then you just need to style the graph to your liking.


EDIT: Re-reading the question, I see you mean co-occurrence in question 2. There are a number of R packages from different fields that can do co-occurrence analysis from binary matrices such as:
[EcoSimR][3] from ecology (see the [co-occurrence analysis vignette][4]) or [quanteda][5] from text analysis ([tutorial][6]).


  [1]: https://igraph.org/r/
  [2]: https://kateto.net/network-visualization
  [3]: https://CRAN.R-project.org/package=EcoSimR
  [4]: https://cran.r-project.org/web/packages/EcoSimR/vignettes/CoOccurrenceVignette.html
  [5]: https://CRAN.R-project.org/package=quanteda
  [6]: https://tm4ss.github.io/docs/Tutorial_5_Co-occurrence.html