In Step 1, we loaded the libraries we needed and then prepared the dataframe from the file of edges. The input file is basically an edge list. Each row describes a connection with one of the target nodes in the first column and one in the second. The third column contains a value representing the strength of the interaction between those two nodes, which we'll think of as an edge weight. The fields are separated by a single space and the file has no header with column names. As such, we set the values of the delim and col_names arguments appropriately. We pipe the dataframe to the dplyr::mutate() function to add an extra column called edge_type. In this column, we randomly assign either "A" or "B" to each row using the sample() ...
How it works...
Get R Bioinformatics Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.