<jupyter_start><jupyter_text>CSX46 - Class Session 5 - ComponentsIn this class session we are going to find the number of proteins that are in the giant component of the (undirected) protein-protein interaction network, using igraph.<jupyter_code>suppressPackageStartupMessages(library(igraph))<jupyter_output><empty_output><jupyter_text>Step 1:  load in the SIF file as a data frame `sif_data`, using the `read.table` function<jupyter_code>sif_data <-<jupyter_output><empty_output><jupyter_text>Step 2:  restrict the interactions to protein-protein undirected ("in-complex-with", "interacts-with"), using the `%in%` operator and using array indexing `[`, and include only the two species columns. The restricted data frame should be called `interac_ppi`.<jupyter_code>interac_ppi <-<jupyter_output><empty_output><jupyter_text>Step 3: restrict the data frame to only the unique interaction pairs of proteins (ignoring the interaction type), using the `unique` function.  Make an igraph `Graph` object from the data frame, using `graph_from_data_frame`.<jupyter_code>interac_ppi_unique <- 
ppi_igraph <-<jupyter_output><empty_output><jupyter_text>Map the components of the graph `ppi_igraph` using the `igraph` function `components`.  That will return a list which you should assign to object name `component_res_list`.  Get the `csize` member of the list, which will be a vector of the sizes of the components of the graph.  Call `max` on that vector to get the size of the giant component of the PPI.<jupyter_code>## call the igraph function `components` on the `ppi_igraph` object; name
## resulting object `component_res_list`
component_res_list <-
## obtain the list item in the slot named `csize`, and name the
## resulting object `component_sizes_vec`
component_sizes_vec <-
## use the `max` function to find the size of the giant component<jupyter_output><empty_output><jupyter_text>Let's print out all the component sizes, in reverse-sorted order Let's get the vertex indices of the vertices that are in the giant component. Use the `membership` slot of the list `component_res_list`, and use `which.max(component_sizes_vec)`.<jupyter_code>inds_giant_component <-<jupyter_output><empty_output><jupyter_text>Let's compute the vertex degrees, for all the vertices in the giant component. Use the `degree` function and pass the indices of the giant component vertices as the function argument `v`.<jupyter_code>ppi_degrees_gc <-<jupyter_output><empty_output><jupyter_text>What is the highest degree vertex in the giant component, and what is its degree? Use `which.max` on `ppi_degrees_gc`.<jupyter_code>ind_max <-<jupyter_output>[1] "Vertex number 6854 has maximum degree: 3600"<jupyter_text>Let's compute the shortest paths distance between highest-degree vertex of the giant component, and all the other vertices in the giant component, by calling the `distances` function on the `ppi_igraph` object. In that function call, you will want to specify as argument `v`the vertex index of the highest-degree vertex in the giant component, and as argument `to` the vertex indices of vertices in the giant component.<jupyter_code>apsp_dists <-<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07655954631379962, 'fraction_numerical': 0.004725897920604915, 'mean_word_length': 6.366589327146172, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 36, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '245760', 'license': 'Apache-2.0', 'n_tokens_mistral': 956, 'n_tokens_neox': 915, 'n_words': 375, 'path': 'class05_components_R_template.ipynb', 'repo_name': 'curiositymap/Networks-in-Computational-Biology', 'size': '3174'}